Details
gtk_set_locale ()
gchar* gtk_set_locale (void); |
Sets the current locale according to the program environment. This is the
same as calling the libc function setlocale(LC_ALL, "") but also takes
care of the locale specific setup of the windowing system used by GDK.
You should call this function before gtk_init to
support internationalization of your GTK+ applications.
gtk_init ()
void gtk_init (int *argc,
char ***argv); |
Call this function before using any other GTK functions in your GUI
applications. It will initialize everything needed to operate the toolkit and
parses some standard command line options. argc and
argv are adjusted accordingly so your own code will
never see those standard arguments.
Note: This function will terminate your program if it was unable to initialize
the GUI for some reason. If you want your program to fall back to a
textual interface you want to call gtk_init_check
instead.
gtk_init_check ()
gboolean gtk_init_check (int *argc,
char ***argv); |
This function does the same work as gtk_init with only
a single change: It does not terminate the program if the GUI can't be
initialized. Instead it returns FALSE on failure.
This way the application can fall back to some other means of communication
with the user - for example a curses or command line interface.
gtk_exit ()
void gtk_exit (gint error_code); |
Terminate the program and return the given exit code to the caller.
This function will shut down the GUI and free all resources allocated
for GTK.
gtk_events_pending ()
gint gtk_events_pending (void); |
Check if any events are pending. This can be used to update the GUI
and invoke timeouts etc. while doing some time intensive computation.
Example 2. Updating the GUI during a long computation
gtk_main ()
Runs the main loop until gtk_main_quit() is called. You can nest calls to
gtk_main. In that case gtk_main_quit() will make the innerst invocation
of the main loop return.
gtk_main_level ()
guint gtk_main_level (void); |
Ask for the current nesting level of the main loop. This can be useful
when calling gtk_quit_add.
gtk_main_quit ()
void gtk_main_quit (void); |
Makes the innermost invocation of the main loop return when it regains
control.
gtk_main_iteration ()
gint gtk_main_iteration (void); |
Runs a single iteration of the mainloop. If no events are waiting to be
processed GTK+ will block until the next event is noticed. If you don't
want to block look at gtk_main_iteration_do or check if any events are
pending with gtk_events_pending first.
gtk_main_iteration_do ()
Run a single iteration of the mainloop. If no events are available either
return or block dependend on the value of blocking.
gtk_main_do_event ()
void gtk_main_do_event (GdkEvent *event); |
Process a single GDK event. This is public only to allow filtering of events
between GDK and GTK. You will not usually need to call this function directly.
While you should not call this function directly, you might want to know
how exactly events are handled. So here is what this function does with
the event:
Compress enter/leave notify events. If the event passed build an
enter/leave pair together with the next event (peeked from Gdk)
both events are thrown away. This is to avoid a backlog of (de-)highlighting
widgets crossed by the pointer.
Find the widget which got the event. If the widget can't be determined
the event is thrown away unless it belongs to a INCR transaction. In that
case it is passed to gtk_selection_incr_event.
Then the event is passed on a stack so you can query the currently handled
event with gtk_get_current_event.
The event is sent to a widget. If a grab is active all events for
widgets that are not in the contained in the grab widget are sent to the
latter with a few exceptions:
Deletion and destruction events are still sent to the event widget for
obvious reasons.
Events which directly relate to the visual representation of the event
widget.
Leave events are delivered to the event widget if there was an enter
event delivered to it before without the paired leave event.
Drag events are not redirected because it is unclear what the semantics
of that would be.
Another point of interest might be that all keypresses are first passed
through the key snooper functions if there are any. Read the description
of gtk_key_snooper_install() if you need this feature. After finishing the delivery the event is popped from the event stack.
GtkModuleInitFunc ()
void (*GtkModuleInitFunc) (gint *argc,
gchar ***argv); |
Each GTK+ module must have a function gtk_module_init with this prototype.
This function is called after loading the module with the argc and argv
cleaned from any arguments that GTK+ handles itself.
gtk_true ()
All this function does it to return TRUE. This can be useful for example
if you want to inhibit the deletion of a window. Of course you should
not do this as the user expects a reaction from clicking the close
icon of the window...
Example 3. A persistent window
#include <gtk/gtk.h>
int
main (int argc, char **argv)
{
GtkWidget *win, *but;
gtk_init( &argc, &argv );
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT(win), "delete-event",
(GtkSignalFunc) gtk_true, NULL);
gtk_signal_connect (GTK_OBJECT(win), "destroy",
(GtkSignalFunc) gtk_main_quit, NULL);
but = gtk_button_new_with_label ("Close yourself. I mean it!");
gtk_signal_connect_object (
GTK_OBJECT (but), "clicked",
(GtkSignalFunc) gtk_object_destroy, (gpointer) win );
gtk_container_add (GTK_CONTAINER (win), but);
gtk_widget_show_all (win);
gtk_main();
return 0;
} |
gtk_false ()
Analogical to gtk_true this function does nothing
but always returns FALSE.
gtk_grab_add ()
Makes widget the current grabbed widget. This means that interaction with
other widgets in the same application is blocked and mouse as well as
keyboard events are delivered to this widget.
gtk_grab_get_current ()
Queries the current grab.
gtk_grab_remove ()
Remove the grab from the given widget. You have to pair calls to gtk_grab_add
and gtk_grab_remove.
gtk_init_add ()
Register a function to be called when the mainloop is started.
gtk_quit_add_destroy ()
Trigger destruction of object in case the mainloop at level main_level
is quit.
gtk_quit_add ()
Registers a function to be called when an instance of the mainloop is left.
gtk_quit_add_full ()
Registers a function to be called when an instance of the mainloop is left.
In comparison to gtk_quit_add() this function adds the possibility to
pass a marshaller and a function to be called when the quit handler is freed.
The former can be used to run interpreted code instead of a compiled function
while the latter can be used to free the information stored in data (while
you can do this in function as well)... So this function will mostly be
used by GTK+ wrappers for languages other than C.
gtk_quit_remove ()
void gtk_quit_remove (guint quit_handler_id); |
Remove a quit handler by it's identifier.
gtk_quit_remove_by_data ()
void gtk_quit_remove_by_data (gpointer data); |
Remove a quit handler identified by it's data field.
gtk_timeout_add_full ()
Registers a function to be called periodically. The function will be called
repeatedly after interval milliseconds until it returns FALSE at which
point the timeout is destroyed and will not be called again.
gtk_timeout_add ()
Registers a function to be called periodically. The function will be called
repeatedly after interval milliseconds until it returns FALSE at which
point the timeout is destroyed and will not be called again.
gtk_timeout_remove ()
void gtk_timeout_remove (guint timeout_handler_id); |
Removes the given timeout destroying all information about it.
gtk_idle_add ()
Causes the mainloop to call the given function whenever no events with
higher priority are to be processed. The default priority is
GTK_PRIORITY_DEFAULT, which is rather low.
gtk_idle_add_priority ()
Like gtk_idle_add() this function allows you to have a function called
when the event loop is idle. The difference is that you can give a
priority different from GTK_PRIORITY_DEFAULT to the idle function.
gtk_idle_remove ()
void gtk_idle_remove (guint idle_handler_id); |
Removes the idle function with the given id.
gtk_idle_remove_by_data ()
void gtk_idle_remove_by_data (gpointer data); |
Removes the idle function identified by the user data.
gtk_input_remove ()
void gtk_input_remove (guint input_handler_id); |
GTK_PRIORITY_REDRAW
#define GTK_PRIORITY_REDRAW (G_PRIORITY_HIGH_IDLE + 20) |
Use this priority for redrawing related stuff. It is used internally by
GTK+ to do pending redraws. This priority is lower than GTK_PRIORITY_RESIZE
to avoid redrawing a widget just before resizing (and therefore redrawing
it again).
GTK_PRIORITY_RESIZE
#define GTK_PRIORITY_RESIZE (G_PRIORITY_HIGH_IDLE + 10) |
Use this priority for resizing related stuff. It is used internally by
GTK+ to compute the sizes of widgets. This priority is higher than
GTK_PRIORITY_REDRAW to avoid resizing a widget which was just redrawn.
GTK_PRIORITY_HIGH
#define GTK_PRIORITY_HIGH G_PRIORITY_HIGH |
Use this for high priority timeouts. This priority is never used inside
GTK+ so everything running at this priority will be running before anything
inside the toolkit.
Note: This macro is deprecated. You should use G_PRIORITY_HIGH instead.
GTK_PRIORITY_INTERNAL
#define GTK_PRIORITY_INTERNAL GTK_PRIORITY_REDRAW |
This priority is for GTK+ internal stuff. Don't use it in your applications.
GTK_PRIORITY_DEFAULT
#define GTK_PRIORITY_DEFAULT G_PRIORITY_DEFAULT_IDLE |
Default priority for idle functions.
Note: This macro is deprecated. You should use G_PRIORITY_DEFAULT_IDLE instead.
GTK_PRIORITY_LOW
#define GTK_PRIORITY_LOW G_PRIORITY_LOW |
Priority for very unimportant background tasks.
Note: This macro is deprecated. You should use G_PRIORITY_LOW instead.
gtk_key_snooper_install ()
gtk_key_snooper_remove ()
void gtk_key_snooper_remove (guint snooper_handler_id); |