------------------ G_Main_Context -- ------------------
function Acquire (Context : G_Main_Context) return Boolean
Tries to become the owner of the specified context. If some other thread is the owner of the context, returns FALSE immediately. Ownership is properly recursive: the owner can require ownership again and will release ownership when Release() is called as many times as Acquire(). You must be the owner of a context before you can call Prepare(), Query(), Check(), Dispatch().
procedure Activate_Application
Under Mac OS X, calling this is the equivalent of activating the application: the frontmost window gains the input focus and active decorations. Under other platform, this has no effects.
procedure Add_Poll
(Source : G_Source;
Fd : Glib.Poll.GPoll_FD)
Adds a file descriptor to the set of file descriptors polled for this source.
function Attach
(Source : G_Source;
Context : G_Main_Context := null) return G_Source_Id
Add Source to Context. The Source will be executed within that context. If context is null, the source is added to the default context. Returns the Id of the source within Context.
function Default_Dispatch
(Source : G_Source; Cb : G_Source_Func_User_Data; Data : System.Address)
return Gboolean
Default implementation for the dispatch callback for sources. This simply calls Cb and pass it Data.
function Depth return Integer
The main loop recursion level in the current thread. It returns 0 when called from the toplevel.
procedure Dispatch (Context : G_Main_Context)
Dispatches all pending sources.
function Find_Source_By_Id
(Id : G_Source_Id; Context : G_Main_Context := null) return G_Source
Find a source given a context and its Id.
type G_Main_Context is new Glib.C_Proxy;
This type represents a set of sources to handled in the main loop. Basically, this represents a main loop. There might be several main loops running at the same time, although gtk+ itself has only one, identified as the default main context.
type G_Priority is new Gint;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
type G_Source is new Glib.C_Proxy;
This type represents an event source that can be monitored by the main loop. There are various internal types of such sources, that can be configured by setting appropriate callbacks (this is not yet doable in GtkAda). See Idle_Source_New and Timeout_Source_New.
type G_Source_Func is access function return Boolean;
type G_Source_Func_User_Data is access
function (User_Data : System.Address) return Gboolean;
A callback for a G_Source. If it returns False, the source will be removed and no longer executed. User_Data is the data passed to Set_Callback.
type G_Source_Id is new Guint;
The ID of a source within the context to which it is attached.
type G_Source_Type is private;
Create a new type of sources. This function is specific to GtkAda. The returned value is never freed. Most of the time, you do not need to create a new source type, or even call Source_New. Most things can be implemented through the careful use of Idle and Timeout callbacks. However, creating a new source type allows for cleaner code, by sharing the common part of the handling.
For idle sources, the prepare and check functions always return TRUE to indicate that the source is always ready to be processed. The prepare function also returns a timeout value of 0 to ensure that the poll() call doesn't block (since that would be time wasted which could have been spent running the idle function).
For timeout sources, the prepare and check functions both return TRUE if the timeout interval has expired. The prepare function also returns a timeout value to ensure that the poll() call doesn't block too long and miss the next timeout.
For file descriptor sources, the prepare function typically returns FALSE, since it must wait until poll() has been called before it knows whether any events need to be processed. It sets the returned timeout to -1 to indicate that it doesn't mind how long the poll() call blocks. In the check function, it tests the results of the poll() call to see if the required condition has been met, and returns TRUE if so.
function G_Source_Type_New
(Prepare : Source_Prepare_Func;
Check : Source_Check_Func;
Dispatch : Source_Dispatch_Func := Default_Dispatch'Access;
Finalize : Source_Finalize_Func := null) return G_Source_Type
Create a new type of sources. This function is specific to GtkAda. The returned value is never freed. Most of the time, you do not need to create a new source type, or even call Source_New. Most things can be implemented through the careful use of Idle and Timeout callbacks. However, creating a new source type allows for cleaner code, by sharing the common part of the handling.
For idle sources, the prepare and check functions always return TRUE to indicate that the source is always ready to be processed. The prepare function also returns a timeout value of 0 to ensure that the poll() call doesn't block (since that would be time wasted which could have been spent running the idle function).
For timeout sources, the prepare and check functions both return TRUE if the timeout interval has expired. The prepare function also returns a timeout value to ensure that the poll() call doesn't block too long and miss the next timeout.
For file descriptor sources, the prepare function typically returns FALSE, since it must wait until poll() has been called before it knows whether any events need to be processed. It sets the returned timeout to -1 to indicate that it doesn't mind how long the poll() call blocks. In the check function, it tests the results of the poll() call to see if the required condition has been met, and returns TRUE if so.
generic
type User_Data is limited private;
function Generic_Child_Add_Watch
(pid : Glib.Spawn.GPid;
callback : access procedure
(pid : Glib.Spawn.GPid;
status : Glib.Gint;
data : access User_Data);
data : access User_Data) return G_Source_Id
Sets a function to be called when the child indicated by pid exits, at a default priority, G_PRIORITY_DEFAULT.
If you obtain pid from g_spawn_async() or g_spawn_async_with_pipes() you will need to pass G_SPAWN_DO_NOT_REAP_CHILD as flag to the spawn function for the child watching to work.
Note that on platforms where GPid must be explicitly closed (see g_spawn_close_pid()) pid must not be closed while the source is still active. Typically, you will want to call g_spawn_close_pid() in the callback function for the source.
GLib supports only a single callback per process id. On POSIX platforms, the same restrictions mentioned for g_child_watch_source_new() apply to this function.
This internally creates a main loop source using g_child_watch_source_new() and attaches it to the main loop context using g_source_attach(). You can do these steps manually if you need greater control.
function Get_Can_Recurse (Source : G_Source) return Boolean
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.
function Get_Context (Source : G_Source) return G_Main_Context
Gets the context with which the source is associated. Calling this function on a destroyed source is an error. The returned value is Null for sources that haven't been attached yet
function Get_Id (Source : G_Source) return G_Source_Id
Returns the numeric ID for a particular source. The ID of a source is positive integer which is unique within a particular main loop context. The reverse mapping from ID to source is done by Find_Source_By_Id
function Get_Priority (Source : G_Source) return G_Priority
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.
function Get_User_Data (Source : G_Source) return System.Address
Return the user data passed to Source_New. This only applies to sources created through that function, and returns undefined results (or even segfaults) otherwise
function Idle_Add (Func : G_Source_Func) return G_Source_Id
Adds a function to be called whenever there are no higher priority events pending in the default main loop. This function is given the priority Priority_Default_Idle. If the function returns False, it is automatically removed from the list of event sources and will not be called again. This function returns the Id of the event source. See Find_Source_By_Id. This is implemented by using Idle_Source_New internally.
function Idle_Source_New return G_Source
Return a newly allocated idle G_Source. Such a source is polled whenever the main loop is not processing events with a higher priority. This source must be attached to a main context before it will be executed.
function Is_Owner (Context : G_Main_Context) return Boolean
Determines whether this thread holds the (recursive) ownership of this context. This is useful to know before waiting on another thread that may be blocking to get ownership of context.
function Main_Context_Default return G_Main_Context
Returns the default main context. This is the main context used for main loop functions when a main loop is not explicitly specified.
function Main_Context_New return G_Main_Context
Create a new context
procedure Main_Context_Ref (Context : G_Main_Context)
Increase or decreate the reference counting for Context. When this reaches 0, the memory is freed.
procedure Main_Context_Unref (Context : G_Main_Context)
Increase or decreate the reference counting for Context. When this reaches 0, the memory is freed.
No_Source_Id : constant G_Source_Id;
Null_Source_Type : constant G_Source_Type;
Create a new type of sources. This function is specific to GtkAda. The returned value is never freed. Most of the time, you do not need to create a new source type, or even call Source_New. Most things can be implemented through the careful use of Idle and Timeout callbacks. However, creating a new source type allows for cleaner code, by sharing the common part of the handling.
For idle sources, the prepare and check functions always return TRUE to indicate that the source is always ready to be processed. The prepare function also returns a timeout value of 0 to ensure that the poll() call doesn't block (since that would be time wasted which could have been spent running the idle function).
For timeout sources, the prepare and check functions both return TRUE if the timeout interval has expired. The prepare function also returns a timeout value to ensure that the poll() call doesn't block too long and miss the next timeout.
For file descriptor sources, the prepare function typically returns FALSE, since it must wait until poll() has been called before it knows whether any events need to be processed. It sets the returned timeout to -1 to indicate that it doesn't mind how long the poll() call blocks. In the check function, it tests the results of the poll() call to see if the required condition has been met, and returns TRUE if so.
Priority_Default : constant G_Priority := 0;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
Priority_Default_Idle : constant G_Priority := 200;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
Priority_High : constant G_Priority := -100;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
Priority_High_Idle : constant G_Priority := 100;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
Priority_Low : constant G_Priority := 300;
Priority_High and Priority_Low are not used within glib or gtk+. The priority for all graphical events is Priority_Default. gtk+ uses Priority_High_Idle+10 for resizing operations, and Priority_High_Idle+20 for redrawing operations, to ensure that resizing occurs before redrawing and avoid redrawing twice.
procedure Release (Context : G_Main_Context)
Releases ownership of a context previously acquired by this thread with Acquire(). If the context was acquired multiple times, the only release ownership when Release() is called as many times as it was acquired.
function Remove (Id : G_Source_Id) return Boolean
Removes the source with the given id from the default main context. The id of. Return True if the source was found and removed
procedure Remove (Id : G_Source_Id)
Removes the source with the given id from the default main context. The id of. Return True if the source was found and removed
procedure Remove_Poll
(Source : G_Source;
Fd : Glib.Poll.GPoll_FD)
Removes a file descriptor from the set of file descriptors polled for this source.
procedure Set_Can_Recurse (Source : G_Source; Can_Recurse : Boolean)
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.
procedure Set_Priority (Source : G_Source; Priority : G_Priority)
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.
type Source_Check_Func is access
function (Source : G_Source) return Gboolean;
Called after all the file descriptors are polled. The source should return TRUE if it is ready to be dispatched. Note that some time may have passed since the previous prepare function was called, so the source should be checked again here.
procedure Source_Destroy (Source : G_Source)
Removes the source from its context, and mark it as destroyed (the memory is not reclaimed while the reference counting doesn't reach 0). Source cannot be added to another context.
type Source_Dispatch_Func is access
function (Source : G_Source;
Callback : G_Source_Func_User_Data;
Data : System.Address) return Gboolean;
Called to dispatch the event source, after it has returned TRUE in either its prepare or its check function. The dispatch function is passed in a callback function and data. The callback function may be NULL if the source was never connected to a callback using Set_Callback(). In C, the exact profile of Callback depends on the type of Source. This is not possible in Ada, which expects a precise profile.
type Source_Finalize_Func is access procedure (Source : G_Source);
Called when the source is finalized.
function Source_New
(Source_Type : G_Source_Type; User_Data : System.Address) return G_Source
Creates a new GSource structure.
The source will not initially be associated with any GMainContext and must be added to one with Attach() before it will be executed.
type Source_Prepare_Func is access
function (Source : G_Source; Timeout : access Gint) return Gboolean;
Called before all the file descriptors are polled. If the source can determine that it is ready here (without waiting for the results of the poll() call) it should return TRUE. It can also return a timeout value which should be the maximum timeout (in milliseconds) which should be passed to the poll() call. The actual timeout used will be -1 if all sources returned -1, or it will be the minimum of all the timeout_ values returned which were >= 0.
procedure Source_Ref (Source : G_Source)
Increase or decrease the reference counting for Source. When this reaches 0, the Source is destroyed
procedure Source_Unref (Source : G_Source)
Increase or decrease the reference counting for Source. When this reaches 0, the Source is destroyed
function Timeout_Add
(Interval : Guint;
Func : G_Source_Func) return G_Source_Id
Create a new function to be called periodically until it returns False.
Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays).
function Timeout_Source_New (Interval : Guint) return G_Source
Return a newly allocated idle G_Source. Such a source is called at regular intervals. Internval is in milliseconds.
procedure Wakeup (Context : G_Main_Context)
If context is currently waiting in a poll(), interrupt the poll(), and continue the iteration process.