forked from AuroraMiddleware/gtk
Merge branch 'master' into 'master'
gtk: Add gtk_is_initialized() and gtk_get_main_thread() See merge request GNOME/gtk!186
This commit is contained in:
commit
c047e97cfa
@ -140,6 +140,7 @@ static guint gtk_main_loop_level = 0;
|
||||
static gint pre_initialized = FALSE;
|
||||
static gint gtk_initialized = FALSE;
|
||||
static GList *current_events = NULL;
|
||||
static GThread *initialized_thread = NULL;
|
||||
|
||||
static GSList *main_loops = NULL; /* stack of currently executing main loops */
|
||||
|
||||
@ -774,6 +775,8 @@ gtk_init_check (void)
|
||||
do_pre_parse_initialization ();
|
||||
do_post_parse_initialization ();
|
||||
|
||||
initialized_thread = g_thread_self ();
|
||||
|
||||
ret = gdk_display_open_default () != NULL;
|
||||
|
||||
if (ret && (gtk_get_debug_flags () & GTK_DEBUG_INTERACTIVE))
|
||||
@ -884,6 +887,34 @@ gtk_init_check_abi_check (int num_checks, size_t sizeof_GtkWindow, size_t sizeof
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* gtk_is_initialized:
|
||||
*
|
||||
* Use this function to check if GTK+ has been initialized with gtk_init()
|
||||
* or gtk_init_check().
|
||||
*
|
||||
* Returns: the initialization status
|
||||
*/
|
||||
gboolean
|
||||
gtk_is_initialized (void)
|
||||
{
|
||||
return gtk_initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_get_main_thread:
|
||||
*
|
||||
* Get the thread from which GTK+ was initialized.
|
||||
*
|
||||
* Returns: (transfer none): The #GThread initialized for GTK+, must not be freed
|
||||
*/
|
||||
GThread *
|
||||
gtk_get_main_thread (void)
|
||||
{
|
||||
return initialized_thread;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_get_locale_direction:
|
||||
*
|
||||
|
@ -78,6 +78,12 @@ void gtk_init (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_init_check (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_is_initialized (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GThread * gtk_get_main_thread (void);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
/* Variants that are used to check for correct struct packing
|
||||
|
30
testsuite/gtk/main.c
Normal file
30
testsuite/gtk/main.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <locale.h>
|
||||
|
||||
static void
|
||||
test_init (void)
|
||||
{
|
||||
GThread *self = g_thread_self ();
|
||||
|
||||
g_assert (gtk_is_initialized () == FALSE);
|
||||
g_assert (gtk_get_main_thread () == NULL);
|
||||
|
||||
g_assert (gtk_init_check ());
|
||||
g_assert (gtk_is_initialized () == TRUE);
|
||||
|
||||
g_assert (gtk_get_main_thread () == self);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
/* Don't use gtk_test_init here because it implicitely initializes GTK+. */
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
gtk_disable_setlocale();
|
||||
setlocale (LC_ALL, "C");
|
||||
g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s");
|
||||
|
||||
g_test_add_func ("/main/init", test_init);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
@ -27,6 +27,7 @@ tests = [
|
||||
['icontheme'],
|
||||
['keyhash', ['../../gtk/gtkkeyhash.c', gtkresources, '../../gtk/gtkprivate.c'], gtk_cargs],
|
||||
['listbox'],
|
||||
['main'],
|
||||
['notify'],
|
||||
['no-gtk-init'],
|
||||
['object'],
|
||||
|
Loading…
Reference in New Issue
Block a user