inspector: Simplify populating the tree

No need to loop toplevels in two places.
This commit is contained in:
Matthias Clasen 2014-09-26 09:49:47 -04:00
parent 2cb31edf6f
commit e7bd73f2b0
3 changed files with 6 additions and 30 deletions

View File

@ -212,9 +212,6 @@ select_widget (GtkInspectorWindow *iw,
gtk_notebook_set_current_page (GTK_NOTEBOOK (iw->top_notebook), 0);
gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree),
gtk_widget_get_toplevel (widget));
gtk_inspector_widget_tree_select_object (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree),
G_OBJECT (widget));
}

View File

@ -497,6 +497,9 @@ gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt,
if (g_application_get_default ())
gtk_inspector_widget_tree_append_object (wt, G_OBJECT (g_application_get_default ()), NULL, NULL);
if (window)
gtk_inspector_widget_tree_append_object (wt, G_OBJECT (window), NULL, NULL);
inspector_win = gtk_widget_get_toplevel (GTK_WIDGET (wt));
toplevels = gtk_window_list_toplevels ();
for (l = toplevels; l; l = l->next)
@ -509,8 +512,6 @@ gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt,
}
g_list_free (toplevels);
gtk_inspector_widget_tree_append_object (wt, G_OBJECT (window), NULL, NULL);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt));
}

View File

@ -152,36 +152,14 @@ 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 (gtk_widget_get_mapped (GTK_WIDGET (l->data)) &&
GTK_IS_WINDOW (l->data) &&
!GTK_INSPECTOR_IS_WINDOW (l->data))
{
widget = l->data;
break;
}
}
g_list_free (toplevels);
if (widget)
gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), widget);
}
static void
gtk_inspector_window_constructed (GObject *object)
{
gtk_inspector_window_select_initially (GTK_INSPECTOR_WINDOW (object));
GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (object);
G_OBJECT_CLASS (gtk_inspector_window_parent_class)->constructed (object);
gtk_inspector_widget_tree_scan (GTK_INSPECTOR_WIDGET_TREE (iw->widget_tree), NULL);
}
static void