From e170f31e2a321168adbfd16bd74fb822d57dc093 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 15 May 2014 15:24:44 -0400 Subject: [PATCH] inspector: Don't show internal build ids These ___object_x___ ids just clutter up the tree. --- gtk/inspector/widget-tree.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gtk/inspector/widget-tree.c b/gtk/inspector/widget-tree.c index fcb1b52fa8..11d868f053 100644 --- a/gtk/inspector/widget-tree.c +++ b/gtk/inspector/widget-tree.c @@ -223,27 +223,33 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt, { GtkTreeIter iter; GtkTreePath *path; - const gchar *class_name = G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)); + const gchar *class_name; gchar *address; gboolean mapped; ObjectData *od; const gchar *label; - label = NULL; - mapped = FALSE; + if (GTK_IS_WIDGET (object)) + mapped = gtk_widget_get_mapped (GTK_WIDGET (object)); + else + mapped = TRUE; + + class_name = G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)); if (GTK_IS_WIDGET (object)) { - GtkWidget *widget = GTK_WIDGET (object); - if (name == NULL) - name = gtk_widget_get_name (GTK_WIDGET (object)); - mapped = gtk_widget_get_mapped (widget); + const gchar *id; + id = gtk_widget_get_name (GTK_WIDGET (object)); + if (name == NULL && id != NULL && g_strcmp0 (id, class_name) != 0) + name = id; } - if (name == NULL || g_strcmp0 (name, class_name) == 0) + if (GTK_IS_BUILDABLE (object)) { - if (GTK_IS_BUILDABLE (object)) - name = gtk_buildable_get_name (GTK_BUILDABLE (object)); + const gchar *id; + id = gtk_buildable_get_name (GTK_BUILDABLE (object)); + if (name == NULL && id != NULL && !g_str_has_prefix (id, "___object_")) + name = id; } if (name == NULL) @@ -269,7 +275,7 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt, OBJECT_NAME, name, OBJECT_LABEL, label, OBJECT_ADDRESS, address, - SENSITIVE, !GTK_IS_WIDGET (object) || mapped, + SENSITIVE, mapped, -1); od = g_new0 (ObjectData, 1);