Commit 7a56404e authored by Matthias Clasen's avatar Matthias Clasen

Make the inspector available via GTK_DEBUG

Change things around so GTK_DEBUG=interactive also brings
up the inspector window.
parent 97567787
......@@ -51,7 +51,8 @@ typedef enum {
GTK_DEBUG_NO_CSS_CACHE = 1 << 13,
GTK_DEBUG_BASELINES = 1 << 14,
GTK_DEBUG_PIXEL_CACHE = 1 << 15,
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16
GTK_DEBUG_NO_PIXEL_CACHE = 1 << 16,
GTK_DEBUG_INTERACTIVE = 1 << 17
} GtkDebugFlag;
#ifdef G_ENABLE_DEBUG
......
......@@ -175,7 +175,8 @@ static const GDebugKey gtk_debug_keys[] = {
{"no-css-cache", GTK_DEBUG_NO_CSS_CACHE},
{"baselines", GTK_DEBUG_BASELINES},
{"pixel-cache", GTK_DEBUG_PIXEL_CACHE},
{"no-pixel-cache", GTK_DEBUG_NO_PIXEL_CACHE}
{"no-pixel-cache", GTK_DEBUG_NO_PIXEL_CACHE},
{"interactive", GTK_DEBUG_INTERACTIVE}
};
#endif /* G_ENABLE_DEBUG */
......@@ -976,10 +977,17 @@ gboolean
gtk_init_check (int *argc,
char ***argv)
{
gboolean ret;
if (!gtk_parse_args (argc, argv))
return FALSE;
return gdk_display_open_default_libgtk_only () != NULL;
ret = gdk_display_open_default_libgtk_only () != NULL;
if (debug_flags & GTK_DEBUG_INTERACTIVE)
gtk_window_set_interactive_debugging (TRUE);
return ret;
}
#ifdef G_PLATFORM_WIN32
......
......@@ -12428,13 +12428,12 @@ _gtk_window_get_popover_position (GtkWindow *window,
*rect = data->rect;
}
static void
gtk_window_toggle_debugging (GtkWindow *window)
static GtkWidget *inspector_window = NULL;
void
gtk_window_set_interactive_debugging (gboolean enable)
{
static GType type = G_TYPE_NONE;
static GtkWidget *inspector_window = NULL;
g_debug ("toggle debugging");
if (type == G_TYPE_NONE)
{
......@@ -12449,15 +12448,22 @@ gtk_window_toggle_debugging (GtkWindow *window)
if (inspector_window == NULL)
{
g_debug ("creating a GtkInspector window");
inspector_window = GTK_WIDGET (g_object_new (type, NULL));
g_signal_connect (inspector_window, "delete-event",
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
}
if (gtk_widget_is_visible (inspector_window))
if (enable)
gtk_window_present (GTK_WINDOW (inspector_window));
else
gtk_widget_hide (inspector_window);
}
static void
gtk_window_toggle_debugging (GtkWindow *window)
{
if (GTK_IS_WIDGET (inspector_window) && gtk_widget_is_visible (inspector_window))
gtk_window_set_interactive_debugging (FALSE);
else
gtk_window_present (GTK_WINDOW (inspector_window));
gtk_window_set_interactive_debugging (TRUE);
}
......@@ -110,6 +110,8 @@ void _gtk_window_get_popover_position (GtkWindow *window,
GdkPixbuf *gtk_window_get_icon_for_size (GtkWindow *window,
gint size);
void gtk_window_set_interactive_debugging (gboolean enable);
G_END_DECLS
#endif /* __GTK_WINDOW_PRIVATE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment