inspector: Show the buildable ID in the misc tab

This is useful, since you sometimes want to use it as #id in css.
This commit is contained in:
Matthias Clasen 2014-07-24 08:29:12 -04:00
parent 3e82b77d7d
commit d97fd540ac
2 changed files with 52 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include "gtktypebuiltins.h"
#include "gtktreeview.h"
#include "gtkbuildable.h"
#include "gtklabel.h"
#include "gtkframe.h"
@ -34,6 +35,8 @@ struct _GtkInspectorMiscInfoPrivate {
GtkWidget *state_row;
GtkWidget *state;
GtkWidget *buildable_id_row;
GtkWidget *buildable_id;
GtkWidget *default_widget_row;
GtkWidget *default_widget;
GtkWidget *default_widget_button;
@ -211,7 +214,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
sl->priv->object = NULL;
}
if (!GTK_IS_WIDGET (object))
if (!GTK_IS_WIDGET (object) && !GTK_IS_BUILDABLE (object))
{
gtk_widget_hide (GTK_WIDGET (sl));
return;
@ -234,6 +237,17 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
gtk_widget_hide (sl->priv->state_row);
}
if (GTK_IS_BUILDABLE (object))
{
gtk_label_set_text (GTK_LABEL (sl->priv->buildable_id),
gtk_buildable_get_name (GTK_BUILDABLE (object)));
gtk_widget_show (sl->priv->buildable_id_row);
}
else
{
gtk_widget_hide (sl->priv->buildable_id_row);
}
if (GTK_IS_WINDOW (object))
{
gtk_widget_show (sl->priv->default_widget_row);
@ -314,6 +328,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/misc-info.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_button);

View File

@ -46,6 +46,40 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="buildable_id_row">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel" id="buildable_id_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Buildable ID</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="buildable_id">
<property name="visible">True</property>
<property name="selectable">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="default_widget_row">
<property name="visible">True</property>
@ -140,6 +174,7 @@
<property name="mode">horizontal</property>
<widgets>
<widget name="state_label"/>
<widget namel="buildable_id_label"/>
<widget name="default_widget_label"/>
<widget name="focus_widget_label"/>
</widgets>