Commit e7bd73f2 authored by Matthias Clasen's avatar Matthias Clasen

inspector: Simplify populating the tree

No need to loop toplevels in two places.
parent 2cb31edf
......@@ -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));
}
......
......@@ -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));
}
......
......@@ -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
......
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