diff options
| author | Matthias Clasen <mclasen@redhat.com> | 2014-05-07 06:34:23 -0400 |
|---|---|---|
| committer | Matthias Clasen <mclasen@redhat.com> | 2014-05-07 06:34:23 -0400 |
| commit | 5dbea42c3265999139443b12c6a89a2dc22538b5 (patch) | |
| tree | 2d8244df4ddbd7fce45c0924f08758eb70fd1b7f | |
| parent | eeecd4b64b037b407bace4badba1284ca68d7533 (diff) | |
| download | gtk+-5dbea42c3265999139443b12c6a89a2dc22538b5.tar.gz | |
inspector: Select a window initially
There is no reason not to do this.
| -rw-r--r-- | modules/inspector/window.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/modules/inspector/window.c b/modules/inspector/window.c index db420befe8..5abf4efc93 100644 --- a/modules/inspector/window.c +++ b/modules/inspector/window.c @@ -105,8 +105,8 @@ on_send_widget_to_shell_activate (GtkWidget *menuitem, str = g_strdup_printf ("gtk_inspector.gobj(%p)", object); gtk_inspector_python_shell_append_text (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell), - str, - NULL); + str, + NULL); g_free (str); gtk_inspector_python_shell_focus (GTK_INSPECTOR_PYTHON_SHELL (iw->python_shell)); @@ -134,10 +134,44 @@ gtk_inspector_window_init (GtkInspectorWindow *iw) } static void +gtk_inspector_window_select_initially (GtkInspectorWindow *iw) +{ + GList *toplevels, *l; + GtkWidget *widget; + + toplevels = gtk_window_list_toplevels (); + widget = NULL; + for (l = toplevels; l; l = l->next) + { + if (l->data != iw) + { + widget = l->data; + break; + } + } + g_list_free (toplevels); + + if (widget) + { + gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), widget); + gtk_inspector_widget_tree_select_object (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), G_OBJECT (widget)); + } +} + +static void +gtk_inspector_window_constructed (GObject *object) +{ + gtk_inspector_window_select_initially (GTK_INSPECTOR_WINDOW (object)); +} + +static void gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + object_class->constructed = gtk_inspector_window_constructed; + gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/window.ui"); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_tree); |
