From 80969e34bc9078255e803d630f434f48b0ade3ae Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 9 Jan 2015 00:07:01 -0500 Subject: [PATCH] inspector: Show object address This is useful information when running the application in a debugger. https://bugzilla.gnome.org/show_bug.cgi?id=742518 --- gtk/inspector/misc-info.c | 10 ++++++++-- gtk/inspector/misc-info.ui | 38 ++++++++++++++++++++++++++++++++++++ gtk/inspector/misc-info.ui.h | 1 + 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c index 450269513e..d390c16abd 100644 --- a/gtk/inspector/misc-info.c +++ b/gtk/inspector/misc-info.c @@ -36,6 +36,7 @@ struct _GtkInspectorMiscInfoPrivate { GObject *object; + GtkWidget *address; GtkWidget *refcount_row; GtkWidget *refcount; GtkWidget *state_row; @@ -258,7 +259,7 @@ show_focus_widget (GtkWidget *button, GtkInspectorMiscInfo *sl) widget = gtk_window_get_focus (GTK_WINDOW (sl->priv->object)); if (widget) - show_object (sl, G_OBJECT (widget), "properties"); + show_object (sl, G_OBJECT (widget), "properties"); } static void @@ -277,13 +278,17 @@ update_info (gpointer data) GtkInspectorMiscInfo *sl = data; gchar *tmp; + tmp = g_strdup_printf ("%p", sl->priv->object); + gtk_label_set_text (GTK_LABEL (sl->priv->address), tmp); + g_free (tmp); + if (G_IS_OBJECT (sl->priv->object)) { tmp = g_strdup_printf ("%d", sl->priv->object->ref_count); gtk_label_set_text (GTK_LABEL (sl->priv->refcount), tmp); g_free (tmp); } - + if (GTK_IS_WIDGET (sl->priv->object)) { AtkObject *accessible; @@ -549,6 +554,7 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass) GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/misc-info.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, address); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, refcount_row); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, refcount); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state_row); diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui index c8c75bc4a7..c51814d5a5 100644 --- a/gtk/inspector/misc-info.ui +++ b/gtk/inspector/misc-info.ui @@ -26,6 +26,40 @@ True none + + + True + False + + + True + horizontal + 10 + 40 + + + True + Address + start + baseline + 0.0 + + + True + + + + + True + True + end + baseline + + + + + + True @@ -153,6 +187,7 @@ True + True end baseline @@ -195,6 +230,7 @@ True + True end baseline end @@ -609,6 +645,8 @@ horizontal + + diff --git a/gtk/inspector/misc-info.ui.h b/gtk/inspector/misc-info.ui.h index a09a285e51..d843c0902d 100644 --- a/gtk/inspector/misc-info.ui.h +++ b/gtk/inspector/misc-info.ui.h @@ -1,3 +1,4 @@ +N_("Address"); N_("Reference count"); N_("State"); N_("Buildable ID");