inspector: Add style classes to the object list
We have a lot of space here now, so show some useful information.
This commit is contained in:
@ -45,6 +45,7 @@
|
|||||||
#include "gtktreemodelsort.h"
|
#include "gtktreemodelsort.h"
|
||||||
#include "gtktreemodelfilter.h"
|
#include "gtktreemodelfilter.h"
|
||||||
#include "gtkwidgetprivate.h"
|
#include "gtkwidgetprivate.h"
|
||||||
|
#include "gtkstylecontext.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -52,7 +53,7 @@ enum
|
|||||||
OBJECT_TYPE,
|
OBJECT_TYPE,
|
||||||
OBJECT_NAME,
|
OBJECT_NAME,
|
||||||
OBJECT_LABEL,
|
OBJECT_LABEL,
|
||||||
OBJECT_ADDRESS,
|
OBJECT_CLASSES,
|
||||||
SENSITIVE
|
SENSITIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -307,7 +308,7 @@ gtk_inspector_object_tree_append_object (GtkInspectorObjectTree *wt,
|
|||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
const gchar *class_name;
|
const gchar *class_name;
|
||||||
gchar *address;
|
gchar *classes;
|
||||||
gboolean mapped;
|
gboolean mapped;
|
||||||
ObjectData *od;
|
ObjectData *od;
|
||||||
const gchar *label;
|
const gchar *label;
|
||||||
@ -322,10 +323,28 @@ gtk_inspector_object_tree_append_object (GtkInspectorObjectTree *wt,
|
|||||||
if (GTK_IS_WIDGET (object))
|
if (GTK_IS_WIDGET (object))
|
||||||
{
|
{
|
||||||
const gchar *id;
|
const gchar *id;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GList *list, *l;
|
||||||
|
GString *string;
|
||||||
|
|
||||||
id = gtk_widget_get_name (GTK_WIDGET (object));
|
id = gtk_widget_get_name (GTK_WIDGET (object));
|
||||||
if (name == NULL && id != NULL && g_strcmp0 (id, class_name) != 0)
|
if (name == NULL && id != NULL && g_strcmp0 (id, class_name) != 0)
|
||||||
name = id;
|
name = id;
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (object));
|
||||||
|
string = g_string_new ("");
|
||||||
|
list = gtk_style_context_list_classes (context);
|
||||||
|
for (l = list; l; l = l->next)
|
||||||
|
{
|
||||||
|
if (string->len > 0)
|
||||||
|
g_string_append_c (string, ' ');
|
||||||
|
g_string_append (string, (gchar *)l->data);
|
||||||
}
|
}
|
||||||
|
classes = g_string_free (string, FALSE);
|
||||||
|
g_list_free (list);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
classes = g_strdup ("");
|
||||||
|
|
||||||
if (GTK_IS_BUILDABLE (object))
|
if (GTK_IS_BUILDABLE (object))
|
||||||
{
|
{
|
||||||
@ -349,18 +368,18 @@ gtk_inspector_object_tree_append_object (GtkInspectorObjectTree *wt,
|
|||||||
else
|
else
|
||||||
label = "";
|
label = "";
|
||||||
|
|
||||||
address = g_strdup_printf ("%p", object);
|
|
||||||
|
|
||||||
gtk_tree_store_append (wt->priv->model, &iter, parent_iter);
|
gtk_tree_store_append (wt->priv->model, &iter, parent_iter);
|
||||||
gtk_tree_store_set (wt->priv->model, &iter,
|
gtk_tree_store_set (wt->priv->model, &iter,
|
||||||
OBJECT, object,
|
OBJECT, object,
|
||||||
OBJECT_TYPE, class_name,
|
OBJECT_TYPE, class_name,
|
||||||
OBJECT_NAME, name,
|
OBJECT_NAME, name,
|
||||||
OBJECT_LABEL, label,
|
OBJECT_LABEL, label,
|
||||||
OBJECT_ADDRESS, address,
|
OBJECT_CLASSES, classes,
|
||||||
SENSITIVE, mapped,
|
SENSITIVE, mapped,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
|
g_free (classes);
|
||||||
|
|
||||||
od = g_new0 (ObjectData, 1);
|
od = g_new0 (ObjectData, 1);
|
||||||
od->wt = wt;
|
od->wt = wt;
|
||||||
od->object = object;
|
od->object = object;
|
||||||
@ -371,8 +390,6 @@ gtk_inspector_object_tree_append_object (GtkInspectorObjectTree *wt,
|
|||||||
g_hash_table_insert (wt->priv->iters, object, od);
|
g_hash_table_insert (wt->priv->iters, object, od);
|
||||||
g_object_weak_ref (object, gtk_object_tree_remove_dead_object, od);
|
g_object_weak_ref (object, gtk_object_tree_remove_dead_object, od);
|
||||||
|
|
||||||
g_free (address);
|
|
||||||
|
|
||||||
if (GTK_IS_CONTAINER (object))
|
if (GTK_IS_CONTAINER (object))
|
||||||
{
|
{
|
||||||
FindAllData data;
|
FindAllData data;
|
||||||
|
@ -79,12 +79,11 @@
|
|||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTreeViewColumn">
|
<object class="GtkTreeViewColumn">
|
||||||
<property name="title" translatable="yes">Address</property>
|
<property name="title" translatable="yes">Style Classes</property>
|
||||||
<property name="resizable">True</property>
|
<property name="resizable">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCellRendererText">
|
<object class="GtkCellRendererText">
|
||||||
<property name="scale">0.8</property>
|
<property name="scale">0.8</property>
|
||||||
<property name="family">monospace</property>
|
|
||||||
</object>
|
</object>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="text">4</attribute>
|
<attribute name="text">4</attribute>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
N_("Object");
|
N_("Object");
|
||||||
N_("Name");
|
N_("Name");
|
||||||
N_("Label");
|
N_("Label");
|
||||||
N_("Address");
|
N_("Style Classes");
|
||||||
|
Reference in New Issue
Block a user