General

General

Includes

#include <gtk/gtk.h>

Description

Functions

gtk_set_locale ()

gchar *
gtk_set_locale (void);

gtk_set_locale has been deprecated since version 2.24 and should not be used in newly-written code.

Use setlocale() directly

Initializes internationalization support for GTK+. gtk_init() automatically does this, so there is typically no point in calling this function.

If you are calling this function because you changed the locale after GTK+ is was initialized, then calling this function may help a bit. (Note, however, that changing the locale after GTK+ is initialized may produce inconsistent results and is not really supported.)

In detail - sets the current locale according to the program environment. This is the same as calling the C library function setlocale (LC_ALL, "") but also takes care of the locale specific setup of the windowing system used by GDK.

Returns

a string corresponding to the locale set, typically in the form lang_COUNTRY, where lang is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. On Unix, this form matches the result of the setlocale(); it is also used on other machines, such as Windows, where the C library returns a different result. The string is owned by GTK+ and should not be modified or freed.


gtk_disable_setlocale ()

void
gtk_disable_setlocale (void);

Prevents gtk_init(), gtk_init_check(), gtk_init_with_args() and gtk_parse_args() from automatically calling setlocale (LC_ALL, ""). You would want to use this function if you wanted to set the locale for your program to something other than the user's locale, or if you wanted to set different values for different locale categories.

Most programs should not need to call this function.


gtk_get_default_language ()

PangoLanguage *
gtk_get_default_language (void);

Returns the PangoLanguage for the default language currently in effect. (Note that this can change over the life of an application.) The default language is derived from the current locale. It determines, for example, whether GTK+ uses the right-to-left or left-to-right text direction.

This function is equivalent to pango_language_get_default(). See that function for details.

Returns

the default language as a PangoLanguage, must not be freed


gtk_parse_args ()

gboolean
gtk_parse_args (int *argc,
                char ***argv);

Parses command line arguments, and initializes global attributes of GTK+, but does not actually open a connection to a display. (See gdk_display_open(), gdk_get_display_arg_name())

Any arguments used by GTK+ or GDK are removed from the array and argc and argv are updated accordingly.

There is no need to call this function explicitely if you are using gtk_init(), or gtk_init_check().

Parameters

argc

a pointer to the number of command line arguments.

[inout]

argv

a pointer to the array of command line arguments.

[array length=argc][inout]

Returns

TRUE if initialization succeeded, otherwise FALSE.


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 that there are some alternative ways to initialize GTK+: if you are calling gtk_parse_args(), gtk_init_check(), gtk_init_with_args() or g_option_context_parse() with the option group returned by gtk_get_option_group(), you don't have to call gtk_init().

This function will terminate your program if it was unable to initialize the windowing system for some reason. If you want your program to fall back to a textual interface you want to call gtk_init_check() instead.

Since 2.18, GTK+ calls signal (SIGPIPE, SIG_IGN) during initialization, to ignore SIGPIPE signals, since these are almost never wanted in graphical applications. If you do need to handle SIGPIPE for some reason, reset the handler after gtk_init(), but notice that other libraries (e.g. libdbus or gvfs) might do similar things.

Parameters

argc

Address of the argc parameter of your main() function. Changed if any arguments were handled.

[inout]

argv

Address of the

argv parameter of main(). Any options

understood by GTK+ are stripped before return.

[array length=argc][inout][allow-none]

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.

Parameters

argc

Address of the argc parameter of your main() function. Changed if any arguments were handled.

[inout]

argv

Address of the argv parameter of main(). Any parameters understood by gtk_init() are stripped before return.

[array length=argc][inout][allow-none]

Returns

TRUE if the GUI has been successfully initialized, FALSE otherwise.


gtk_init_with_args ()

gboolean
gtk_init_with_args (int *argc,
                    char ***argv,
                    const char *parameter_string,
                    GOptionEntry *entries,
                    const char *translation_domain,
                    GError **error);

This function does the same work as gtk_init_check(). Additionally, it allows you to add your own commandline options, and it automatically generates nicely formatted --help output. Note that your program will be terminated after writing out the help output.

Parameters

argc

a pointer to the number of command line arguments.

 

argv

a pointer to the array of command line arguments.

[inout][array length=argc]

parameter_string

a string which is displayed in the first line of --help output, after programname [OPTION...]

 

entries

a NULL-terminated array of GOptionEntrys describing the options of your program.

[array zero-terminated=1]

translation_domain

a translation domain to use for translating the --help output for the options in entries and the parameter_string with gettext(), or NULL

 

error

a return location for errors

 

Returns

TRUE if the GUI has been successfully initialized, FALSE otherwise.

Since: 2.6


gtk_get_option_group ()

GOptionGroup *
gtk_get_option_group (gboolean open_default_display);

Returns a GOptionGroup for the commandline arguments recognized by GTK+ and GDK. You should add this group to your GOptionContext with g_option_context_add_group(), if you are using g_option_context_parse() to parse your commandline arguments.

Parameters

open_default_display

whether to open the default display when parsing the commandline arguments

 

Returns

a GOptionGroup for the commandline arguments recognized by GTK+

Since: 2.6


gtk_exit ()

void
gtk_exit (gint error_code);

gtk_exit is deprecated and should not be used in newly-written code.


gtk_events_pending ()

gboolean
gtk_events_pending (void);

gtk_main ()

void
gtk_main (void);

gtk_main_level ()

guint
gtk_main_level (void);

gtk_main_quit ()

void
gtk_main_quit (void);

gtk_main_iteration ()

gboolean
gtk_main_iteration (void);

gtk_main_iteration_do ()

gboolean
gtk_main_iteration_do (gboolean blocking);

gtk_main_do_event ()

void
gtk_main_do_event (GdkEvent *event);

GtkModuleInitFunc ()

void
(*GtkModuleInitFunc) (gint *argc,
                      gchar ***argv);

GtkModuleDisplayInitFunc ()

void
(*GtkModuleDisplayInitFunc) (GdkDisplay *display);

gtk_true ()

gboolean
gtk_true (void);

gtk_false ()

gboolean
gtk_false (void);

gtk_grab_add ()

void
gtk_grab_add (GtkWidget *widget);

gtk_grab_get_current ()

GtkWidget *
gtk_grab_get_current (void);

Queries the current grab of the default window group.

Returns

The widget which currently has the grab or NULL if no grab is active.

[transfer none]


gtk_grab_remove ()

void
gtk_grab_remove (GtkWidget *widget);

gtk_init_add ()

void
gtk_init_add (GtkFunction function,
              gpointer data);

gtk_init_add is deprecated and should not be used in newly-written code.


gtk_quit_add_destroy ()

void
gtk_quit_add_destroy (guint main_level,
                      GtkObject *object);

gtk_quit_add_destroy is deprecated and should not be used in newly-written code.


gtk_quit_add ()

guint
gtk_quit_add (guint main_level,
              GtkFunction function,
              gpointer data);

gtk_quit_add is deprecated and should not be used in newly-written code.


gtk_quit_add_full ()

guint
gtk_quit_add_full (guint main_level,
                   GtkFunction function,
                   GtkCallbackMarshal marshal,
                   gpointer data,
                   GDestroyNotify destroy);

gtk_quit_add_full is deprecated and should not be used in newly-written code.


gtk_quit_remove ()

void
gtk_quit_remove (guint quit_handler_id);

gtk_quit_remove is deprecated and should not be used in newly-written code.


gtk_quit_remove_by_data ()

void
gtk_quit_remove_by_data (gpointer data);

gtk_quit_remove_by_data is deprecated and should not be used in newly-written code.


gtk_timeout_add_full ()

guint
gtk_timeout_add_full (guint32 interval,
                      GtkFunction function,
                      GtkCallbackMarshal marshal,
                      gpointer data,
                      GDestroyNotify destroy);

gtk_timeout_add_full is deprecated and should not be used in newly-written code.


gtk_timeout_add ()

guint
gtk_timeout_add (guint32 interval,
                 GtkFunction function,
                 gpointer data);

gtk_timeout_add is deprecated and should not be used in newly-written code.


gtk_timeout_remove ()

void
gtk_timeout_remove (guint timeout_handler_id);

gtk_timeout_remove is deprecated and should not be used in newly-written code.


gtk_idle_add ()

guint
gtk_idle_add (GtkFunction function,
              gpointer data);

gtk_idle_add is deprecated and should not be used in newly-written code.


gtk_idle_add_priority ()

guint
gtk_idle_add_priority (gint priority,
                       GtkFunction function,
                       gpointer data);

gtk_idle_add_priority is deprecated and should not be used in newly-written code.


gtk_idle_add_full ()

guint
gtk_idle_add_full (gint priority,
                   GtkFunction function,
                   GtkCallbackMarshal marshal,
                   gpointer data,
                   GDestroyNotify destroy);

gtk_idle_add_full is deprecated and should not be used in newly-written code.


gtk_idle_remove ()

void
gtk_idle_remove (guint idle_handler_id);

gtk_idle_remove is deprecated and should not be used in newly-written code.


gtk_idle_remove_by_data ()

void
gtk_idle_remove_by_data (gpointer data);

gtk_idle_remove_by_data is deprecated and should not be used in newly-written code.


gtk_input_add_full ()

guint
gtk_input_add_full (gint source,
                    GdkInputCondition condition,
                    GdkInputFunction function,
                    GtkCallbackMarshal marshal,
                    gpointer data,
                    GDestroyNotify destroy);

gtk_input_add_full is deprecated and should not be used in newly-written code.


gtk_input_remove ()

void
gtk_input_remove (guint input_handler_id);

gtk_input_remove is deprecated and should not be used in newly-written code.


gtk_key_snooper_install ()

guint
gtk_key_snooper_install (GtkKeySnoopFunc snooper,
                         gpointer func_data);

GtkKeySnoopFunc ()

gint
(*GtkKeySnoopFunc) (GtkWidget *grab_widget,
                    GdkEventKey *event,
                    gpointer func_data);

gtk_key_snooper_remove ()

void
gtk_key_snooper_remove (guint snooper_handler_id);

gtk_get_current_event ()

GdkEvent *
gtk_get_current_event (void);

Obtains a copy of the event currently being processed by GTK+. For example, if you get a "clicked" signal from GtkButton, the current event will be the GdkEventButton that triggered the "clicked" signal. The returned event must be freed with gdk_event_free(). If there is no current event, the function returns NULL.

Returns

a copy of the current event, or NULL if no current event.

[transfer full]


gtk_get_current_event_time ()

guint32
gtk_get_current_event_time (void);

If there is a current event and it has a timestamp, return that timestamp, otherwise return GDK_CURRENT_TIME.

Returns

the timestamp from the current event, or GDK_CURRENT_TIME.


gtk_get_current_event_state ()

gboolean
gtk_get_current_event_state (GdkModifierType *state);

If there is a current event and it has a state field, place that state field in state and return TRUE, otherwise return FALSE.

Parameters

state

a location to store the state of the current event.

[out]

Returns

TRUE if there was a current event and it had a state field


gtk_get_event_widget ()

GtkWidget *
gtk_get_event_widget (GdkEvent *event);

If event is NULL or the event was not associated with any widget, returns NULL, otherwise returns the widget that received the event originally.

Parameters

event

a GdkEvent

 

Returns

the widget that originally received event , or NULL.

[transfer none]


gtk_propagate_event ()

void
gtk_propagate_event (GtkWidget *widget,
                     GdkEvent *event);

Sends an event to a widget, propagating the event to parent widgets if the event remains unhandled. Events received by GTK+ from GDK normally begin in gtk_main_do_event(). Depending on the type of event, existence of modal dialogs, grabs, etc., the event may be propagated; if so, this function is used. gtk_propagate_event() calls gtk_widget_event() on each widget it decides to send the event to. So gtk_widget_event() is the lowest-level function; it simply emits the "event" and possibly an event-specific signal on a widget. gtk_propagate_event() is a bit higher-level, and gtk_main_do_event() is the highest level.

All that said, you most likely don't want to use any of these functions; synthesizing events is rarely needed. Consider asking on the mailing list for better ways to achieve your goals. For example, use gdk_window_invalidate_rect() or gtk_widget_queue_draw() instead of making up expose events.

Parameters

widget

a GtkWidget

 

event

an event

 

Types and Values

GTK_PRIORITY_REDRAW

#define GTK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)

GTK_PRIORITY_REDRAW is deprecated and should not be used in newly-written code.


GTK_PRIORITY_RESIZE

#define GTK_PRIORITY_RESIZE     (G_PRIORITY_HIGH_IDLE + 10)

GTK_PRIORITY_HIGH

#define GTK_PRIORITY_HIGH       G_PRIORITY_HIGH

GTK_PRIORITY_HIGH is deprecated and should not be used in newly-written code.


GTK_PRIORITY_INTERNAL

#define GTK_PRIORITY_INTERNAL   GTK_PRIORITY_REDRAW

GTK_PRIORITY_INTERNAL is deprecated and should not be used in newly-written code.


GTK_PRIORITY_DEFAULT

#define GTK_PRIORITY_DEFAULT G_PRIORITY_DEFAULT_IDLE

GTK_PRIORITY_DEFAULT is deprecated and should not be used in newly-written code.


GTK_PRIORITY_LOW

#define GTK_PRIORITY_LOW G_PRIORITY_LOW

GTK_PRIORITY_LOW is deprecated and should not be used in newly-written code.