W Wrapl, The Programming Language

Libraries:Gtk:Glib:GSource

Types

T

Constants

Nil : T

Functions

New(source_funcs @ Gtk.Glib.GSourceFuncs.T, struct_size @ Std.Integer.SmallT) : Gtk.Glib.GSource.T

Creates a new T structure. The size is specified to allow creating structures derived from T that contain additional data. The size passed in must be at least sizeof (GSource).

The source will not initially be associated with any Gtk.Glib.GMainContext.T and must be added to one with Gtk.Glib.GMain.SourceAttach before it will be executed.

source_funcs structure containing functions that implement the sources behavior.
struct_size size of the T structure to create.
Returns the newly-created T.


Remove(tag @ Std.Integer.SmallT) : Std.Symbol.T

Removes the source with the given id from the default main context. The id of a T is given by Gtk.Glib.GMain.SourceGetId, or will be returned by the functions Gtk.Glib.GMain.SourceAttach, Gtk.Glib.GMain.IdleAdd, Gtk.Glib.GMain.IdleAddFull, Gtk.Glib.GMain.TimeoutAdd, Gtk.Glib.GMain.TimeoutAddFull, Gtk.Glib.GMain.ChildWatchAdd, Gtk.Glib.GMain.ChildWatchAddFull, Gtk.Glib.GIOChannel.AddWatch, and Gtk.Glib.GIOChannel.AddWatchFull.

See also Gtk.Glib.GMain.SourceDestroy. You must use Gtk.Glib.GMain.SourceDestroy for sources added to a non-default main context.

tag the ID of the source to remove.
Returns TRUE if the source was found and removed.


RemoveByFuncsUserData(funcs @ Gtk.Glib.GSourceFuncs.T, user_data @ Std.Object.T) : Std.Symbol.T

Removes a source from the default main loop context given the source functions and user data. If multiple sources exist with the same source functions and user data, only one will be destroyed.

funcs The source_funcs passed to Gtk.Glib.GMain.SourceNew
user_data the user data for the callback
Returns TRUE if a source was found and removed.


RemoveByUserData(user_data @ Std.Object.T) : Std.Symbol.T

Removes a source from the default main loop context given the user data for the callback. If multiple sources exist with the same user data, only one will be destroyed.

user_data the user_data for the callback.
Returns TRUE if a source was found and removed.


SetNameById(tag @ Std.Integer.SmallT, name @ Std.String.T) : Std.Object.T

Sets the name of a source using its ID.

This is a convenience utility to set source names from the return value of Gtk.Glib.GMain.IdleAdd, Gtk.Glib.GMain.TimeoutAdd, etc.

tag a T ID
name debug name for the source


Methods

:"="(_ @ T, _ @ T)

:AddPoll(self @ T, fd @ Std.Object.T) : Std.Object.T

Adds a file descriptor to the set of file descriptors polled for this source. This is usually combined with Gtk.Glib.GMain.SourceNew to add an event source. The event source's check function will typically test the revents field in the GPollFD struct and return TRUE if events need to be processed.

source a T
fd a GPollFD structure holding information about a file descriptor to watch.


:Attach(self @ T, context @ Gtk.Glib.GMainContext.T) : Std.Integer.SmallT

Adds a T to a context so that it will be executed within that context. Remove it by calling Gtk.Glib.GMain.SourceDestroy.

source a T
context a Gtk.Glib.GMainContext.T (if NULL, the default context will be used)
Returns the ID (greater than 0) for the source within the Gtk.Glib.GMainContext.T.


:Destroy(self @ T) : Std.Object.T

Removes a source from its Gtk.Glib.GMainContext.T, if any, and mark it as destroyed. The source cannot be subsequently added to another context.

source a T


:GetCanRecurse(self @ T) : Std.Symbol.T

Checks whether a source is allowed to be called recursively. see Gtk.Glib.GMain.SourceSetCanRecurse.

source a T
Returns whether recursion is allowed.


:GetContext(self @ T) : Gtk.Glib.GMainContext.T

Gets the Gtk.Glib.GMainContext.T with which the source is associated. Calling this function on a destroyed source is an error.

source a T
Returns the Gtk.Glib.GMainContext.T with which the source is associated, or NULL if the context has not yet been added to a source. [transfer none]


:GetCurrentTime(self @ T, timeval @ Gtk.Glib.GTimeVal.T) : Std.Object.T

Warning

Gtk.Glib.GMain.SourceGetCurrentTime has been deprecated since version 2.28 and should not be used in newly-written code. use Gtk.Glib.GMain.SourceGetTime instead



:GetId(self @ T) : Std.Integer.SmallT

Returns the numeric ID for a particular source. The ID of a source is a positive integer which is unique within a particular main loop context. The reverse mapping from ID to source is done by Gtk.Glib.GMain.ContextFindSourceById.

source a T
Returns the ID (greater than 0) for the source


:GetName(self @ T) : Std.String.T

Gets a name for the source, used in debugging and profiling. The name may be NULL if it has never been set with Gtk.Glib.GMain.SourceSetName.

source a T
Returns the name of the source


:GetPriority(self @ T) : Std.Integer.SmallT

Gets the priority of a source.

source a T
Returns the priority of the source


:GetTime(self @ T, timespec @ Gtk.Glib.GTimeSpec.T) : Std.Object.T

Gets the time to be used when checking this source. The advantage of calling this function over calling Gtk.Glib.GMain.GetMonotonicTime directly is that when checking multiple sources, GLib can cache a single value instead of having to repeatedly get the system monotonic time.

The time here is the system monotonic time, if available, or some other reasonable alternative otherwise. See Gtk.Glib.GMain.GetMonotonicTime.

source a T
Returns the monotonic time in microseconds


:IsDestroyed(self @ T) : Std.Symbol.T

Returns whether source has been destroyed.

This is important when you operate upon your objects from within idle handlers, but may have freed the object before the dispatch of your idle handler.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
static gboolean 
idle_callback (gpointer data)
{
  SomeWidget *self = data;
   
  GDK_THREADS_ENTER ();
  /* do stuff with self */
  self->idle_id = 0;
  GDK_THREADS_LEAVE ();
   
  return FALSE;
}
 
static void 
some_widget_do_stuff_later (SomeWidget *self)
{
  self->idle_id = g_idle_add (idle_callback, self);
}
 
static void 
some_widget_finalize (GObject *object)
{
  SomeWidget *self = SOME_WIDGET (object);
   
  if (self->idle_id)
    g_source_remove (self->idle_id);
   
  G_OBJECT_CLASS (parent_class)->finalize (object);
}


:Ref(self @ T) : Gtk.Glib.GSource.T

Increases the reference count on a source by one.

source a T
Returns source


:RemovePoll(self @ T, fd @ Std.Object.T) : Std.Object.T

Removes a file descriptor from the set of file descriptors polled for this source.

source a T
fd a GPollFD structure previously passed to Gtk.Glib.GMain.SourceAddPoll.


:SetCallback(self @ T, func @ Std.Function.T, data @ Std.Address.T, notify @ Std.Function.T) : Std.Object.T

Sets the callback function for a source. The callback for a source is called from the source's dispatch function.

The exact type of func depends on the type of source; ie. you should not count on func being called with data as its first parameter.

Typically, you won't use this function. Instead use functions specific to the type of source you are using.

source the source
func a callback function
data the data to pass to callback function
notify a function to call when data is no longer in use, or NULL.


:SetCallbackIndirect(self @ T, callback_data @ Std.Address.T, callback_funcs @ Gtk.Glib.GSourceCallbackFuncs.T) : Std.Object.T

Sets the callback function storing the data as a refcounted callback "object". This is used internally. Note that calling Gtk.Glib.GMain.SourceSetCallbackIndirect assumes an initial reference count on callback_data, and thus callback_funcs->unref will eventually be called once more than callback_funcs->ref.

source the source
callback_data pointer to callback data "object"
callback_funcs functions for reference counting callback_data and getting the callback and data


:SetCanRecurse(self @ T, can_recurse @ Std.Symbol.T) : Std.Object.T

Sets whether a source can be called recursively. If can_recurse is TRUE, then while the source is being dispatched then this source will be processed normally. Otherwise, all processing of this source is blocked until the dispatch function returns.

source a T
can_recurse whether recursion is allowed for this source


:SetFuncs(self @ T, funcs @ Gtk.Glib.GSourceFuncs.T) : Std.Object.T

Sets the source functions (can be used to override default implementations) of an unattached source.

source a T
funcs the new Gtk.Glib.GSourceFuncs.T


:SetName(self @ T, name @ Std.String.T) : Std.Object.T

Sets a name for the source, used in debugging and profiling. The name defaults to NULL.

The source name should describe in a human-readable way what the source does. For example, "X11 event queue" or "GTK+ repaint idle handler" or whatever it is.

It is permitted to call this function multiple times, but is not recommended due to the potential performance impact. For example, one could change the name in the "check" function of a Gtk.Glib.GSourceFuncs.T to include details like the event type in the source name.

source a T
name debug name for the source


:SetPriority(self @ T, priority @ Std.Integer.SmallT) : Std.Object.T

Sets the priority of a source. While the main loop is being run, a source will be dispatched if it is ready to be dispatched and no sources at a higher (numerically smaller) priority are ready to be dispatched.

source a T
priority the new priority.


:Unref(self @ T) : Std.Object.T

Decreases the reference count of a source by one. If the resulting reference count is zero the source and associated memory will be destroyed.

source a T


:"~="(_ @ T, _ @ T)