diff options
Diffstat (limited to 'gtk/gtkmain.c')
-rw-r--r-- | gtk/gtkmain.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 2980150e01..90ce42cc0a 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -141,11 +141,22 @@ static GdkColormap *gtk_colormap; /* The colormap to be used in creating new * widgets. */ +guint gtk_debug_flags; /* Global GTK debug flag */ + +#ifdef G_ENABLE_DEBUG +static GDebugKey gtk_debug_keys[] = { + {"objects", GTK_DEBUG_OBJECTS} +}; +#endif /* G_ENABLE_DEBUG */ void gtk_init (int *argc, char ***argv) { +#ifdef G_ENABLE_DEBUG + gboolean debug_set = FALSE; +#endif + if (0) { g_set_error_handler (gtk_error); @@ -154,11 +165,46 @@ gtk_init (int *argc, g_set_print_handler (gtk_print); } - /* Initialize "gdk". We simply pass along the 'argc' and 'argv' - * parameters as they contain information that + /* Initialize "gdk". We pass along the 'argc' and 'argv' + * parameters as they contain information that GDK uses */ gdk_init (argc, argv); +#ifdef G_ENABLE_DEBUG + if (argc && argv) + { + gint i; + + for (i = 1; i < *argc;) + { + if ((*argv[i]) && strcmp ("--gtk-debug", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gtk_debug_flags = g_parse_debug_string ((*argv)[i+1], + gtk_debug_keys, + sizeof(gtk_debug_keys) / sizeof(GDebugKey)); + debug_set = TRUE; + (*argv)[i + 1] = NULL; + i += 1; + } + } + i += 1; + } + } + + if (!debug_set) + { + gchar *debug_string = getenv("GTK_DEBUG"); + if (debug_string != NULL) + gtk_debug_flags = g_parse_debug_string (debug_string, + gtk_debug_keys, + sizeof(gtk_debug_keys) / sizeof(GDebugKey)); + } +#endif /* G_ENABLE_DEBUG */ + /* Initialize the default visual and colormap to be * used in creating widgets. (We want to use the system * defaults so as to be nice to the colormap). |