Blame glib/gmain.h

Packit ae235b
/* gmain.h - the GLib Main loop
Packit ae235b
 * Copyright (C) 1998-2000 Red Hat, Inc.
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public License
Packit ae235b
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifndef __G_MAIN_H__
Packit ae235b
#define __G_MAIN_H__
Packit ae235b
Packit ae235b
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
Packit ae235b
#error "Only <glib.h> can be included directly."
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#include <glib/gpoll.h>
Packit ae235b
#include <glib/gslist.h>
Packit ae235b
#include <glib/gthread.h>
Packit ae235b
Packit ae235b
G_BEGIN_DECLS
Packit ae235b
Packit ae235b
typedef enum /*< flags >*/
Packit ae235b
{
Packit ae235b
  G_IO_IN	GLIB_SYSDEF_POLLIN,
Packit ae235b
  G_IO_OUT	GLIB_SYSDEF_POLLOUT,
Packit ae235b
  G_IO_PRI	GLIB_SYSDEF_POLLPRI,
Packit ae235b
  G_IO_ERR	GLIB_SYSDEF_POLLERR,
Packit ae235b
  G_IO_HUP	GLIB_SYSDEF_POLLHUP,
Packit ae235b
  G_IO_NVAL	GLIB_SYSDEF_POLLNVAL
Packit ae235b
} GIOCondition;
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GMainContext:
Packit ae235b
 *
Packit ae235b
 * The `GMainContext` struct is an opaque data
Packit ae235b
 * type representing a set of sources to be handled in a main loop.
Packit ae235b
 */
Packit ae235b
typedef struct _GMainContext            GMainContext;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GMainLoop:
Packit ae235b
 *
Packit ae235b
 * The `GMainLoop` struct is an opaque data type
Packit ae235b
 * representing the main event loop of a GLib or GTK+ application.
Packit ae235b
 */
Packit ae235b
typedef struct _GMainLoop               GMainLoop;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSource:
Packit ae235b
 *
Packit ae235b
 * The `GSource` struct is an opaque data type
Packit ae235b
 * representing an event source.
Packit ae235b
 */
Packit ae235b
typedef struct _GSource                 GSource;
Packit ae235b
typedef struct _GSourcePrivate          GSourcePrivate;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSourceCallbackFuncs:
Packit ae235b
 * @ref: Called when a reference is added to the callback object
Packit ae235b
 * @unref: Called when a reference to the callback object is dropped
Packit ae235b
 * @get: Called to extract the callback function and data from the
Packit ae235b
 *     callback object.
Packit ae235b
 *
Packit ae235b
 * The `GSourceCallbackFuncs` struct contains
Packit ae235b
 * functions for managing callback objects.
Packit ae235b
 */
Packit ae235b
typedef struct _GSourceCallbackFuncs    GSourceCallbackFuncs;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSourceFuncs:
Packit ae235b
 * @prepare: Called before all the file descriptors are polled. If the
Packit ae235b
 *     source can determine that it is ready here (without waiting for the
Packit ae235b
 *     results of the poll() call) it should return %TRUE. It can also return
Packit ae235b
 *     a @timeout_ value which should be the maximum timeout (in milliseconds)
Packit ae235b
 *     which should be passed to the poll() call. The actual timeout used will
Packit ae235b
 *     be -1 if all sources returned -1, or it will be the minimum of all
Packit ae235b
 *     the @timeout_ values returned which were >= 0.  Since 2.36 this may
Packit ae235b
 *     be %NULL, in which case the effect is as if the function always returns
Packit ae235b
 *     %FALSE with a timeout of -1.  If @prepare returns a
Packit ae235b
 *     timeout and the source also has a ready time set, then the
Packit ae235b
 *     lower of the two will be used.
Packit ae235b
 * @check: Called after all the file descriptors are polled. The source
Packit ae235b
 *     should return %TRUE if it is ready to be dispatched. Note that some
Packit ae235b
 *     time may have passed since the previous prepare function was called,
Packit ae235b
 *     so the source should be checked again here.  Since 2.36 this may
Packit ae235b
 *     be %NULL, in which case the effect is as if the function always returns
Packit ae235b
 *     %FALSE.
Packit ae235b
 * @dispatch: Called to dispatch the event source, after it has returned
Packit ae235b
 *     %TRUE in either its @prepare or its @check function, or if a ready time
Packit ae235b
 *     has been reached. The @dispatch function receives a callback function and
Packit ae235b
 *     user data. The callback function may be %NULL if the source was never
Packit ae235b
 *     connected to a callback using g_source_set_callback(). The @dispatch
Packit ae235b
 *     function should call the callback function with @user_data and whatever
Packit ae235b
 *     additional parameters are needed for this type of event source. The
Packit ae235b
 *     return value of the @dispatch function should be #G_SOURCE_REMOVE if the
Packit ae235b
 *     source should be removed or #G_SOURCE_CONTINUE to keep it.
Packit ae235b
 * @finalize: Called when the source is finalized. At this point, the source
Packit ae235b
 *     will have been destroyed, had its callback cleared, and have been removed
Packit ae235b
 *     from its #GMainContext, but it will still have its final reference count,
Packit ae235b
 *     so methods can be called on it from within this function.
Packit ae235b
 *
Packit ae235b
 * The `GSourceFuncs` struct contains a table of
Packit ae235b
 * functions used to handle event sources in a generic manner.
Packit ae235b
 *
Packit ae235b
 * For idle sources, the prepare and check functions always return %TRUE
Packit ae235b
 * to indicate that the source is always ready to be processed. The prepare
Packit ae235b
 * function also returns a timeout value of 0 to ensure that the poll() call
Packit ae235b
 * doesn't block (since that would be time wasted which could have been spent
Packit ae235b
 * running the idle function).
Packit ae235b
 *
Packit ae235b
 * For timeout sources, the prepare and check functions both return %TRUE
Packit ae235b
 * if the timeout interval has expired. The prepare function also returns
Packit ae235b
 * a timeout value to ensure that the poll() call doesn't block too long
Packit ae235b
 * and miss the next timeout.
Packit ae235b
 *
Packit ae235b
 * For file descriptor sources, the prepare function typically returns %FALSE,
Packit ae235b
 * since it must wait until poll() has been called before it knows whether
Packit ae235b
 * any events need to be processed. It sets the returned timeout to -1 to
Packit ae235b
 * indicate that it doesn't mind how long the poll() call blocks. In the
Packit ae235b
 * check function, it tests the results of the poll() call to see if the
Packit ae235b
 * required condition has been met, and returns %TRUE if so.
Packit ae235b
 */
Packit ae235b
typedef struct _GSourceFuncs            GSourceFuncs;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GPid:
Packit ae235b
 *
Packit ae235b
 * A type which is used to hold a process identification.
Packit ae235b
 *
Packit ae235b
 * On UNIX, processes are identified by a process id (an integer),
Packit ae235b
 * while Windows uses process handles (which are pointers).
Packit ae235b
 *
Packit ae235b
 * GPid is used in GLib only for descendant processes spawned with
Packit ae235b
 * the g_spawn functions.
Packit ae235b
 */
Packit ae235b
/* defined in glibconfig.h */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PID_FORMAT:
Packit ae235b
 *
Packit ae235b
 * A format specifier that can be used in printf()-style format strings
Packit ae235b
 * when printing a #GPid.
Packit ae235b
 *
Packit ae235b
 * Since: 2.50
Packit ae235b
 */
Packit ae235b
/* defined in glibconfig.h */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSourceFunc:
Packit ae235b
 * @user_data: data passed to the function, set when the source was
Packit ae235b
 *     created with one of the above functions
Packit ae235b
 *
Packit ae235b
 * Specifies the type of function passed to g_timeout_add(),
Packit ae235b
 * g_timeout_add_full(), g_idle_add(), and g_idle_add_full().
Packit ae235b
 *
Packit ae235b
 * Returns: %FALSE if the source should be removed. #G_SOURCE_CONTINUE and
Packit ae235b
 * #G_SOURCE_REMOVE are more memorable names for the return value.
Packit ae235b
 */
Packit ae235b
typedef gboolean (*GSourceFunc)       (gpointer user_data);
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GChildWatchFunc:
Packit ae235b
 * @pid: the process id of the child process
Packit ae235b
 * @status: Status information about the child process, encoded
Packit ae235b
 *     in a platform-specific manner
Packit ae235b
 * @user_data: user data passed to g_child_watch_add()
Packit ae235b
 *
Packit ae235b
 * Prototype of a #GChildWatchSource callback, called when a child
Packit ae235b
 * process has exited.  To interpret @status, see the documentation
Packit ae235b
 * for g_spawn_check_exit_status().
Packit ae235b
 */
Packit ae235b
typedef void     (*GChildWatchFunc)   (GPid     pid,
Packit ae235b
                                       gint     status,
Packit ae235b
                                       gpointer user_data);
Packit ae235b
struct _GSource
Packit ae235b
{
Packit ae235b
  /*< private >*/
Packit ae235b
  gpointer callback_data;
Packit ae235b
  GSourceCallbackFuncs *callback_funcs;
Packit ae235b
Packit ae235b
  const GSourceFuncs *source_funcs;
Packit ae235b
  guint ref_count;
Packit ae235b
Packit ae235b
  GMainContext *context;
Packit ae235b
Packit ae235b
  gint priority;
Packit ae235b
  guint flags;
Packit ae235b
  guint source_id;
Packit ae235b
Packit ae235b
  GSList *poll_fds;
Packit ae235b
  
Packit ae235b
  GSource *prev;
Packit ae235b
  GSource *next;
Packit ae235b
Packit ae235b
  char    *name;
Packit ae235b
Packit ae235b
  GSourcePrivate *priv;
Packit ae235b
};
Packit ae235b
Packit ae235b
struct _GSourceCallbackFuncs
Packit ae235b
{
Packit ae235b
  void (*ref)   (gpointer     cb_data);
Packit ae235b
  void (*unref) (gpointer     cb_data);
Packit ae235b
  void (*get)   (gpointer     cb_data,
Packit ae235b
                 GSource     *source, 
Packit ae235b
                 GSourceFunc *func,
Packit ae235b
                 gpointer    *data);
Packit ae235b
};
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSourceDummyMarshal:
Packit ae235b
 *
Packit ae235b
 * This is just a placeholder for #GClosureMarshal,
Packit ae235b
 * which cannot be used here for dependency reasons.
Packit ae235b
 */
Packit ae235b
typedef void (*GSourceDummyMarshal) (void);
Packit ae235b
Packit ae235b
struct _GSourceFuncs
Packit ae235b
{
Packit ae235b
  gboolean (*prepare)  (GSource    *source,
Packit ae235b
                        gint       *timeout_);
Packit ae235b
  gboolean (*check)    (GSource    *source);
Packit ae235b
  gboolean (*dispatch) (GSource    *source,
Packit ae235b
                        GSourceFunc callback,
Packit ae235b
                        gpointer    user_data);
Packit ae235b
  void     (*finalize) (GSource    *source); /* Can be NULL */
Packit ae235b
Packit ae235b
  /*< private >*/
Packit ae235b
  /* For use by g_source_set_closure */
Packit ae235b
  GSourceFunc     closure_callback;        
Packit ae235b
  GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */
Packit ae235b
};
Packit ae235b
Packit ae235b
/* Standard priorities */
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PRIORITY_HIGH:
Packit ae235b
 *
Packit ae235b
 * Use this for high priority event sources.
Packit ae235b
 *
Packit ae235b
 * It is not used within GLib or GTK+.
Packit ae235b
 */
Packit ae235b
#define G_PRIORITY_HIGH            -100
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PRIORITY_DEFAULT:
Packit ae235b
 *
Packit ae235b
 * Use this for default priority event sources.
Packit ae235b
 *
Packit ae235b
 * In GLib this priority is used when adding timeout functions
Packit ae235b
 * with g_timeout_add(). In GDK this priority is used for events
Packit ae235b
 * from the X server.
Packit ae235b
 */
Packit ae235b
#define G_PRIORITY_DEFAULT          0
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PRIORITY_HIGH_IDLE:
Packit ae235b
 *
Packit ae235b
 * Use this for high priority idle functions.
Packit ae235b
 *
Packit ae235b
 * GTK+ uses #G_PRIORITY_HIGH_IDLE + 10 for resizing operations,
Packit ae235b
 * and #G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is
Packit ae235b
 * done to ensure that any pending resizes are processed before any
Packit ae235b
 * pending redraws, so that widgets are not redrawn twice unnecessarily.)
Packit ae235b
 */
Packit ae235b
#define G_PRIORITY_HIGH_IDLE        100
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PRIORITY_DEFAULT_IDLE:
Packit ae235b
 *
Packit ae235b
 * Use this for default priority idle functions.
Packit ae235b
 *
Packit ae235b
 * In GLib this priority is used when adding idle functions with
Packit ae235b
 * g_idle_add().
Packit ae235b
 */
Packit ae235b
#define G_PRIORITY_DEFAULT_IDLE     200
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_PRIORITY_LOW:
Packit ae235b
 *
Packit ae235b
 * Use this for very low priority background tasks.
Packit ae235b
 *
Packit ae235b
 * It is not used within GLib or GTK+.
Packit ae235b
 */
Packit ae235b
#define G_PRIORITY_LOW              300
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_SOURCE_REMOVE:
Packit ae235b
 *
Packit ae235b
 * Use this macro as the return value of a #GSourceFunc to remove
Packit ae235b
 * the #GSource from the main loop.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 */
Packit ae235b
#define G_SOURCE_REMOVE         FALSE
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_SOURCE_CONTINUE:
Packit ae235b
 *
Packit ae235b
 * Use this macro as the return value of a #GSourceFunc to leave
Packit ae235b
 * the #GSource in the main loop.
Packit ae235b
 *
Packit ae235b
 * Since: 2.32
Packit ae235b
 */
Packit ae235b
#define G_SOURCE_CONTINUE       TRUE
Packit ae235b
Packit ae235b
/* GMainContext: */
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_context_new       (void);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_context_ref       (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void          g_main_context_unref     (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_context_default   (void);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean      g_main_context_iteration (GMainContext *context,
Packit ae235b
                                        gboolean      may_block);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean      g_main_context_pending   (GMainContext *context);
Packit ae235b
Packit ae235b
/* For implementation of legacy interfaces
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource      *g_main_context_find_source_by_id              (GMainContext *context,
Packit ae235b
                                                             guint         source_id);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource      *g_main_context_find_source_by_user_data       (GMainContext *context,
Packit ae235b
                                                             gpointer      user_data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource      *g_main_context_find_source_by_funcs_user_data (GMainContext *context,
Packit ae235b
                                                             GSourceFuncs *funcs,
Packit ae235b
                                                             gpointer      user_data);
Packit ae235b
Packit ae235b
/* Low level functions for implementing custom main loops.
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_wakeup  (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_main_context_acquire (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_release (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_main_context_is_owner (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_main_context_wait    (GMainContext *context,
Packit ae235b
                                 GCond        *cond,
Packit ae235b
                                 GMutex       *mutex);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_main_context_prepare  (GMainContext *context,
Packit ae235b
                                  gint         *priority);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint     g_main_context_query    (GMainContext *context,
Packit ae235b
                                  gint          max_priority,
Packit ae235b
                                  gint         *timeout_,
Packit ae235b
                                  GPollFD      *fds,
Packit ae235b
                                  gint          n_fds);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean     g_main_context_check    (GMainContext *context,
Packit ae235b
                                      gint          max_priority,
Packit ae235b
                                      GPollFD      *fds,
Packit ae235b
                                      gint          n_fds);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_dispatch (GMainContext *context);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_set_poll_func (GMainContext *context,
Packit ae235b
                                       GPollFunc     func);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GPollFunc g_main_context_get_poll_func (GMainContext *context);
Packit ae235b
Packit ae235b
/* Low level functions for use by source implementations
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_add_poll    (GMainContext *context,
Packit ae235b
                                     GPollFD      *fd,
Packit ae235b
                                     gint          priority);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_remove_poll (GMainContext *context,
Packit ae235b
                                     GPollFD      *fd);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint     g_main_depth               (void);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_main_current_source      (void);
Packit ae235b
Packit ae235b
/* GMainContexts for other threads
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void          g_main_context_push_thread_default (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void          g_main_context_pop_thread_default  (GMainContext *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_context_get_thread_default  (void);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_context_ref_thread_default  (void);
Packit ae235b
Packit ae235b
/* GMainLoop: */
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainLoop *g_main_loop_new        (GMainContext *context,
Packit ae235b
                                   gboolean      is_running);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void       g_main_loop_run        (GMainLoop    *loop);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void       g_main_loop_quit       (GMainLoop    *loop);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainLoop *g_main_loop_ref        (GMainLoop    *loop);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void       g_main_loop_unref      (GMainLoop    *loop);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean   g_main_loop_is_running (GMainLoop    *loop);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_main_loop_get_context (GMainLoop    *loop);
Packit ae235b
Packit ae235b
/* GSource: */
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_source_new             (GSourceFuncs   *source_funcs,
Packit ae235b
                                   guint           struct_size);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_source_ref             (GSource        *source);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_unref           (GSource        *source);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_source_attach          (GSource        *source,
Packit ae235b
                                   GMainContext   *context);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_destroy         (GSource        *source);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_set_priority    (GSource        *source,
Packit ae235b
                                   gint            priority);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint     g_source_get_priority    (GSource        *source);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_set_can_recurse (GSource        *source,
Packit ae235b
                                   gboolean        can_recurse);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_source_get_can_recurse (GSource        *source);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_source_get_id          (GSource        *source);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMainContext *g_source_get_context (GSource       *source);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_set_callback    (GSource        *source,
Packit ae235b
                                   GSourceFunc     func,
Packit ae235b
                                   gpointer        data,
Packit ae235b
                                   GDestroyNotify  notify);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_set_funcs       (GSource        *source,
Packit ae235b
                                   GSourceFuncs   *funcs);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_source_is_destroyed    (GSource        *source);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void                 g_source_set_name       (GSource        *source,
Packit ae235b
                                              const char     *name);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
const char *         g_source_get_name       (GSource        *source);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void                 g_source_set_name_by_id (guint           tag,
Packit ae235b
                                              const char     *name);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
void                 g_source_set_ready_time (GSource        *source,
Packit ae235b
                                              gint64          ready_time);
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
gint64               g_source_get_ready_time (GSource        *source);
Packit ae235b
Packit ae235b
#ifdef G_OS_UNIX
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
gpointer             g_source_add_unix_fd    (GSource        *source,
Packit ae235b
                                              gint            fd,
Packit ae235b
                                              GIOCondition    events);
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
void                 g_source_modify_unix_fd (GSource        *source,
Packit ae235b
                                              gpointer        tag,
Packit ae235b
                                              GIOCondition    new_events);
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
void                 g_source_remove_unix_fd (GSource        *source,
Packit ae235b
                                              gpointer        tag);
Packit ae235b
GLIB_AVAILABLE_IN_2_36
Packit ae235b
GIOCondition         g_source_query_unix_fd  (GSource        *source,
Packit ae235b
                                              gpointer        tag);
Packit ae235b
#endif
Packit ae235b
Packit ae235b
/* Used to implement g_source_connect_closure and internally*/
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void g_source_set_callback_indirect (GSource              *source,
Packit ae235b
                                     gpointer              callback_data,
Packit ae235b
                                     GSourceCallbackFuncs *callback_funcs);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_add_poll            (GSource        *source,
Packit ae235b
				       GPollFD        *fd);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_remove_poll         (GSource        *source,
Packit ae235b
				       GPollFD        *fd);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_add_child_source    (GSource        *source,
Packit ae235b
				       GSource        *child_source);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_source_remove_child_source (GSource        *source,
Packit ae235b
				       GSource        *child_source);
Packit ae235b
Packit ae235b
GLIB_DEPRECATED_IN_2_28_FOR(g_source_get_time)
Packit ae235b
void     g_source_get_current_time (GSource        *source,
Packit ae235b
                                    GTimeVal       *timeval);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint64   g_source_get_time         (GSource        *source);
Packit ae235b
Packit ae235b
 /* void g_source_connect_closure (GSource        *source,
Packit ae235b
                                  GClosure       *closure);
Packit ae235b
 */
Packit ae235b
Packit ae235b
/* Specific source types
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_idle_source_new        (void);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_child_watch_source_new (GPid pid);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_timeout_source_new     (guint interval);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GSource *g_timeout_source_new_seconds (guint interval);
Packit ae235b
Packit ae235b
/* Miscellaneous functions
Packit ae235b
 */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void   g_get_current_time                 (GTimeVal       *result);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint64 g_get_monotonic_time               (void);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint64 g_get_real_time                    (void);
Packit ae235b
Packit ae235b
Packit ae235b
/* Source manipulation by ID */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_source_remove                     (guint          tag);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_source_remove_by_user_data        (gpointer       user_data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_source_remove_by_funcs_user_data  (GSourceFuncs  *funcs,
Packit ae235b
                                              gpointer       user_data);
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GClearHandleFunc:
Packit ae235b
 * @handle_id: the handle ID to clear
Packit ae235b
 *
Packit ae235b
 * Specifies the type of function passed to g_clear_handle_id().
Packit ae235b
 * The implementation is expected to free the resource identified
Packit ae235b
 * by @handle_id; for instance, if @handle_id is a #GSource ID,
Packit ae235b
 * g_source_remove() can be used.
Packit ae235b
 *
Packit ae235b
 * Since: 2.56
Packit ae235b
 */
Packit ae235b
typedef void (* GClearHandleFunc) (guint handle_id);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_2_56
Packit ae235b
void    g_clear_handle_id (guint           *tag_ptr,
Packit ae235b
                           GClearHandleFunc clear_func);
Packit ae235b
Packit ae235b
#define g_clear_handle_id(tag_ptr, clear_func)             \
Packit ae235b
  G_STMT_START {                                           \
Packit ae235b
    G_STATIC_ASSERT (sizeof *(tag_ptr) == sizeof (guint)); \
Packit ae235b
    guint *_tag_ptr = (guint *) (tag_ptr);                 \
Packit ae235b
    guint _handle_id;                                      \
Packit ae235b
                                                           \
Packit ae235b
    _handle_id = *_tag_ptr;                                \
Packit ae235b
    if (_handle_id > 0)                                    \
Packit ae235b
      {                                                    \
Packit ae235b
        *_tag_ptr = 0;                                     \
Packit ae235b
        if (clear_func != NULL)                            \
Packit ae235b
          clear_func (_handle_id);                         \
Packit ae235b
      }                                                    \
Packit ae235b
  } G_STMT_END
Packit ae235b
Packit ae235b
/* Idles, child watchers and timeouts */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_timeout_add_full         (gint            priority,
Packit ae235b
                                     guint           interval,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data,
Packit ae235b
                                     GDestroyNotify  notify);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_timeout_add              (guint           interval,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_timeout_add_seconds_full (gint            priority,
Packit ae235b
                                     guint           interval,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data,
Packit ae235b
                                     GDestroyNotify  notify);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_timeout_add_seconds      (guint           interval,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_child_watch_add_full     (gint            priority,
Packit ae235b
                                     GPid            pid,
Packit ae235b
                                     GChildWatchFunc function,
Packit ae235b
                                     gpointer        data,
Packit ae235b
                                     GDestroyNotify  notify);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_child_watch_add          (GPid            pid,
Packit ae235b
                                     GChildWatchFunc function,
Packit ae235b
                                     gpointer        data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_idle_add                 (GSourceFunc     function,
Packit ae235b
                                     gpointer        data);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
guint    g_idle_add_full            (gint            priority,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data,
Packit ae235b
                                     GDestroyNotify  notify);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean g_idle_remove_by_data      (gpointer        data);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_invoke_full (GMainContext   *context,
Packit ae235b
                                     gint            priority,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data,
Packit ae235b
                                     GDestroyNotify  notify);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void     g_main_context_invoke      (GMainContext   *context,
Packit ae235b
                                     GSourceFunc     function,
Packit ae235b
                                     gpointer        data);
Packit ae235b
Packit ae235b
/* Hook for GClosure / GSource integration. Don't touch */
Packit ae235b
GLIB_VAR GSourceFuncs g_timeout_funcs;
Packit ae235b
GLIB_VAR GSourceFuncs g_child_watch_funcs;
Packit ae235b
GLIB_VAR GSourceFuncs g_idle_funcs;
Packit ae235b
#ifdef G_OS_UNIX
Packit ae235b
GLIB_VAR GSourceFuncs g_unix_signal_funcs;
Packit ae235b
GLIB_VAR GSourceFuncs g_unix_fd_source_funcs;
Packit ae235b
#endif
Packit ae235b
Packit ae235b
G_END_DECLS
Packit ae235b
Packit ae235b
#endif /* __G_MAIN_H__ */