inspector: Add a Label column

Move the UI strings over to that column, and use the buildable
ID for the name column, where available.
This commit is contained in:
Matthias Clasen 2014-05-08 21:15:09 -04:00
parent 1a6dd9fcd2
commit e9cc859051
2 changed files with 41 additions and 13 deletions

View File

@ -31,6 +31,7 @@ enum
OBJECT,
OBJECT_TYPE,
OBJECT_NAME,
OBJECT_LABEL,
OBJECT_ADDRESS,
SENSITIVE
};
@ -75,7 +76,7 @@ object_data_free (gpointer data)
gtk_tree_iter_free (od->iter);
if (od->map_handler)
if (g_signal_handler_is_connected (od->object, od->map_handler))
{
g_signal_handler_disconnect (od->object, od->map_handler);
g_signal_handler_disconnect (od->object, od->unmap_handler);
@ -184,7 +185,9 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
gchar *address;
gboolean mapped;
ObjectData *od;
const gchar *label;
label = NULL;
mapped = FALSE;
if (GTK_IS_WIDGET (object))
@ -197,16 +200,24 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
if (name == NULL || g_strcmp0 (name, class_name) == 0)
{
if (GTK_IS_LABEL (object))
name = gtk_label_get_text (GTK_LABEL (object));
else if (GTK_IS_BUTTON (object))
name = gtk_button_get_label (GTK_BUTTON (object));
else if (GTK_IS_WINDOW (object))
name = gtk_window_get_title (GTK_WINDOW (object));
else
name = "";
if (GTK_IS_BUILDABLE (object))
name = gtk_buildable_get_name (GTK_BUILDABLE (object));
}
if (name == NULL)
name = "";
if (GTK_IS_LABEL (object))
label = gtk_label_get_text (GTK_LABEL (object));
else if (GTK_IS_BUTTON (object))
label = gtk_button_get_label (GTK_BUTTON (object));
else if (GTK_IS_WINDOW (object))
label = gtk_window_get_title (GTK_WINDOW (object));
else if (GTK_IS_TREE_VIEW_COLUMN (object))
label = gtk_tree_view_column_get_title (GTK_TREE_VIEW_COLUMN (object));
else
label = "";
address = g_strdup_printf ("%p", object);
gtk_tree_store_append (wt->priv->model, &iter, parent_iter);
@ -214,6 +225,7 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
OBJECT, object,
OBJECT_TYPE, class_name,
OBJECT_NAME, name,
OBJECT_LABEL, label,
OBJECT_ADDRESS, address,
SENSITIVE, !GTK_IS_WIDGET (object) || mapped,
-1);

View File

@ -6,6 +6,7 @@
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gchararray"/>
<column type="gboolean"/>
</columns>
</object>
@ -28,7 +29,7 @@
</object>
<attributes>
<attribute name="text">1</attribute>
<attribute name="sensitive">4</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
@ -43,7 +44,22 @@
</object>
<attributes>
<attribute name="text">2</attribute>
<attribute name="sensitive">4</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Label</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">3</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
@ -58,8 +74,8 @@
<property name="family">monospace</property>
</object>
<attributes>
<attribute name="text">3</attribute>
<attribute name="sensitive">4</attribute>
<attribute name="text">4</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>