[gtk+/gtk-3-14] Inspector: Show more misc info about widgets
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-14] Inspector: Show more misc info about widgets
- Date: Thu, 19 Mar 2015 16:35:28 +0000 (UTC)
commit baba3ff0e5565b86a6e93e7d9b4e3947001e2c61
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 24 07:49:37 2014 -0400
Inspector: Show more misc info about widgets
This adds clip area, accessible role, mapped, realize,
is-toplevel, child-visible and mnemonic labels to the displayed information.
gtk/inspector/misc-info.c | 111 ++++++++++++++++++-
gtk/inspector/misc-info.ui | 248 ++++++++++++++++++++++++++++++++++++++++++
gtk/inspector/misc-info.ui.h | 7 +
3 files changed, 363 insertions(+), 3 deletions(-)
---
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index 4b615e5..cd99658 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -27,6 +27,9 @@
#include "gtkbuildable.h"
#include "gtklabel.h"
#include "gtkframe.h"
+#include "gtkbutton.h"
+#include "gtkwidgetprivate.h"
+
struct _GtkInspectorMiscInfoPrivate {
GtkInspectorWidgetTree *widget_tree;
@@ -43,8 +46,22 @@ struct _GtkInspectorMiscInfoPrivate {
GtkWidget *focus_widget_row;
GtkWidget *focus_widget;
GtkWidget *focus_widget_button;
+ GtkWidget *mnemonic_label_row;
+ GtkWidget *mnemonic_label;
GtkWidget *allocated_size_row;
GtkWidget *allocated_size;
+ GtkWidget *clip_area_row;
+ GtkWidget *clip_area;
+ GtkWidget *accessible_role_row;
+ GtkWidget *accessible_role;
+ GtkWidget *mapped_row;
+ GtkWidget *mapped;
+ GtkWidget *realized_row;
+ GtkWidget *realized;
+ GtkWidget *is_toplevel_row;
+ GtkWidget *is_toplevel;
+ GtkWidget *child_visible_row;
+ GtkWidget *child_visible;
};
enum
@@ -97,12 +114,31 @@ state_flags_changed (GtkWidget *w, GtkStateFlags old_flags, GtkInspectorMiscInfo
static void
allocation_changed (GtkWidget *w, GdkRectangle *allocation, GtkInspectorMiscInfo *sl)
{
- gchar *size_label = g_strdup_printf ("%d × %d",
- gtk_widget_get_allocated_width (w),
- gtk_widget_get_allocated_height (w));
+ GtkAllocation clip;
+ gchar *size_label;
+
+ size_label = g_strdup_printf ("%d × %d",
+ gtk_widget_get_allocated_width (w),
+ gtk_widget_get_allocated_height (w));
gtk_label_set_label (GTK_LABEL (sl->priv->allocated_size), size_label);
g_free (size_label);
+
+ gtk_widget_get_clip (w, &clip);
+
+ if (clip.width == gtk_widget_get_allocated_width (w) &&
+ clip.height == gtk_widget_get_allocated_height (w))
+ {
+ gtk_widget_hide (sl->priv->clip_area_row);
+ }
+ else
+ {
+ gtk_widget_show (sl->priv->clip_area_row);
+
+ size_label = g_strdup_printf ("%d × %d", clip.width, clip.height);
+ gtk_label_set_label (GTK_LABEL (sl->priv->clip_area), size_label);
+ g_free (size_label);
+ }
}
static void
@@ -214,6 +250,16 @@ show_focus_widget (GtkWidget *button, GtkInspectorMiscInfo *sl)
show_object (sl, G_OBJECT (widget), NULL, "properties");
}
+static void
+show_mnemonic_label (GtkWidget *button, GtkInspectorMiscInfo *sl)
+{
+ GtkWidget *widget;
+
+ widget = g_object_get_data (G_OBJECT (button), "mnemonic-label");
+ if (widget)
+ show_object (sl, G_OBJECT (widget), NULL, "properties");
+}
+
void
gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
GObject *object)
@@ -242,18 +288,63 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
if (GTK_IS_WIDGET (object))
{
+ AtkObject *accessible;
+ AtkRole role;
+ GList *list, *l;
+
gtk_widget_show (sl->priv->state_row);
g_signal_connect_object (object, "state-flags-changed", G_CALLBACK (state_flags_changed), sl, 0);
state_flags_changed (GTK_WIDGET (sl->priv->object), 0, sl);
+ gtk_widget_show (sl->priv->mnemonic_label_row);
+ gtk_container_forall (GTK_CONTAINER (sl->priv->mnemonic_label), (GtkCallback)gtk_widget_destroy, NULL);
+ list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->priv->object));
+ for (l = list; l; l = l->next)
+ {
+ gchar *tmp;
+ GtkWidget *button;
+
+ tmp = g_strdup_printf ("%p (%s)", l->data, g_type_name_from_instance ((GTypeInstance*)l->data));
+ button = gtk_button_new_with_label (tmp);
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (sl->priv->mnemonic_label), button);
+ g_object_set_data (G_OBJECT (button), "mnemonic-label", l->data);
+ g_signal_connect (button, "clicked", G_CALLBACK (show_mnemonic_label), sl);
+ }
+ g_list_free (list);
+
allocation_changed (GTK_WIDGET (sl->priv->object), NULL, sl);
gtk_widget_show (sl->priv->allocated_size_row);
g_signal_connect_object (object, "size-allocate", G_CALLBACK (allocation_changed), sl, 0);
+
+ accessible = ATK_OBJECT (gtk_widget_get_accessible (GTK_WIDGET (sl->priv->object)));
+ role = atk_object_get_role (accessible);
+ gtk_label_set_text (GTK_LABEL (sl->priv->accessible_role), atk_role_get_name (role));
+ gtk_widget_show (sl->priv->accessible_role_row);
+
+ gtk_widget_set_visible (sl->priv->mapped, gtk_widget_get_mapped (GTK_WIDGET (sl->priv->object)));
+ gtk_widget_show (sl->priv->mapped_row);
+
+ gtk_widget_set_visible (sl->priv->realized, gtk_widget_get_realized (GTK_WIDGET (sl->priv->object)));
+ gtk_widget_show (sl->priv->realized_row);
+
+ gtk_widget_set_visible (sl->priv->is_toplevel, gtk_widget_is_toplevel (GTK_WIDGET (sl->priv->object)));
+ gtk_widget_show (sl->priv->is_toplevel_row);
+
+ gtk_widget_set_visible (sl->priv->child_visible, gtk_widget_get_child_visible (GTK_WIDGET
(sl->priv->object)));
+ gtk_widget_show (sl->priv->is_toplevel_row);
}
else
{
gtk_widget_hide (sl->priv->state_row);
+ gtk_widget_hide (sl->priv->mnemonic_label_row);
gtk_widget_hide (sl->priv->allocated_size_row);
+ gtk_widget_hide (sl->priv->clip_area_row);
+ gtk_widget_hide (sl->priv->accessible_role_row);
+ gtk_widget_hide (sl->priv->mapped_row);
+ gtk_widget_hide (sl->priv->realized_row);
+ gtk_widget_hide (sl->priv->is_toplevel_row);
+ gtk_widget_hide (sl->priv->child_visible_row);
}
if (GTK_IS_BUILDABLE (object))
@@ -355,8 +446,22 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_button);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mnemonic_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, allocated_size_row);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, allocated_size);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, clip_area_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, clip_area);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, accessible_role);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, mapped);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, realized_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, realized);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, is_toplevel_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, is_toplevel);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible_row);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, child_visible);
gtk_widget_class_bind_template_callback (widget_class, show_default_widget);
gtk_widget_class_bind_template_callback (widget_class, show_focus_widget);
diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui
index bb03b90..e357d43 100644
--- a/gtk/inspector/misc-info.ui
+++ b/gtk/inspector/misc-info.ui
@@ -172,6 +172,41 @@
</child>
<child>
+ <object class="GtkListBoxRow" id="mnemonic_label_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">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Mnemonic Label</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="GtkBox" id="mnemonic_label">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">10</property>
+ <property name="halign">end</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
<object class="GtkListBoxRow" id="allocated_size_row">
<property name="visible">true</property>
<property name="activatable">false</property>
@@ -205,6 +240,218 @@
</object>
</child>
+ <child>
+ <object class="GtkListBoxRow" id="clip_area_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Clip area</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="clip_area">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow" id="accessible_role_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Accessible role</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="accessible_role">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow" id="mapped_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Mapped</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="mapped">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow" id="realized_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Realized</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="realized">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow" id="is_toplevel_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Is Toplevel</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="is_toplevel">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow" id="child_visible_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">
+ <property name="visible">true</property>
+ <property name="label" translatable="yes">Child Visible</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">true</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="child_visible">
+ <property name="visible">true</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ <property name="icon-size">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
</object>
</child>
</object>
@@ -222,3 +469,4 @@
</widgets>
</object>
</interface>
+
diff --git a/gtk/inspector/misc-info.ui.h b/gtk/inspector/misc-info.ui.h
index b78feec..1d4dee8 100644
--- a/gtk/inspector/misc-info.ui.h
+++ b/gtk/inspector/misc-info.ui.h
@@ -4,4 +4,11 @@ N_("Default Widget");
N_("Properties");
N_("Focus Widget");
N_("Properties");
+N_("Mnemonic Label");
N_("Allocated size");
+N_("Clip area");
+N_("Accessible role");
+N_("Mapped");
+N_("Realized");
+N_("Is Toplevel");
+N_("Child Visible");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]