mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 08:40:08 +00:00
inspector: Show widget allocation
https://bugzilla.gnome.org/show_bug.cgi?id=736191
This commit is contained in:
parent
7633118e7d
commit
a4d9eccbc6
@ -43,6 +43,8 @@ struct _GtkInspectorMiscInfoPrivate {
|
|||||||
GtkWidget *focus_widget_row;
|
GtkWidget *focus_widget_row;
|
||||||
GtkWidget *focus_widget;
|
GtkWidget *focus_widget;
|
||||||
GtkWidget *focus_widget_button;
|
GtkWidget *focus_widget_button;
|
||||||
|
GtkWidget *allocated_size_row;
|
||||||
|
GtkWidget *allocated_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -50,8 +52,8 @@ enum
|
|||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_WIDGET_TREE
|
PROP_WIDGET_TREE
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorMiscInfo, gtk_inspector_misc_info, GTK_TYPE_BOX)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorMiscInfo, gtk_inspector_misc_info, GTK_TYPE_SCROLLED_WINDOW)
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
format_state_flags (GtkStateFlags state)
|
format_state_flags (GtkStateFlags state)
|
||||||
@ -92,6 +94,17 @@ state_flags_changed (GtkWidget *w, GtkStateFlags old_flags, GtkInspectorMiscInfo
|
|||||||
g_free (s);
|
g_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
gtk_label_set_label (GTK_LABEL (sl->priv->allocated_size), size_label);
|
||||||
|
g_free (size_label);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_each_other (gpointer still_alive,
|
disconnect_each_other (gpointer still_alive,
|
||||||
GObject *for_science)
|
GObject *for_science)
|
||||||
@ -209,6 +222,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
|
|||||||
{
|
{
|
||||||
g_signal_handlers_disconnect_by_func (sl->priv->object, state_flags_changed, sl);
|
g_signal_handlers_disconnect_by_func (sl->priv->object, state_flags_changed, sl);
|
||||||
g_signal_handlers_disconnect_by_func (sl->priv->object, set_focus_cb, sl);
|
g_signal_handlers_disconnect_by_func (sl->priv->object, set_focus_cb, sl);
|
||||||
|
g_signal_handlers_disconnect_by_func (sl->priv->object, allocation_changed, sl);
|
||||||
disconnect_each_other (sl->priv->object, G_OBJECT (sl));
|
disconnect_each_other (sl->priv->object, G_OBJECT (sl));
|
||||||
disconnect_each_other (sl, sl->priv->object);
|
disconnect_each_other (sl, sl->priv->object);
|
||||||
sl->priv->object = NULL;
|
sl->priv->object = NULL;
|
||||||
@ -231,10 +245,15 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
|
|||||||
gtk_widget_show (sl->priv->state_row);
|
gtk_widget_show (sl->priv->state_row);
|
||||||
g_signal_connect_object (object, "state-flags-changed", G_CALLBACK (state_flags_changed), sl, 0);
|
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);
|
state_flags_changed (GTK_WIDGET (sl->priv->object), 0, sl);
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_widget_hide (sl->priv->state_row);
|
gtk_widget_hide (sl->priv->state_row);
|
||||||
|
gtk_widget_hide (sl->priv->allocated_size_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GTK_IS_BUILDABLE (object))
|
if (GTK_IS_BUILDABLE (object))
|
||||||
@ -336,6 +355,8 @@ 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_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);
|
||||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_button);
|
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, focus_widget_button);
|
||||||
|
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_callback (widget_class, show_default_widget);
|
gtk_widget_class_bind_template_callback (widget_class, show_default_widget);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, show_focus_widget);
|
gtk_widget_class_bind_template_callback (widget_class, show_focus_widget);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#ifndef _GTK_INSPECTOR_MISC_INFO_H_
|
#ifndef _GTK_INSPECTOR_MISC_INFO_H_
|
||||||
#define _GTK_INSPECTOR_MISC_INFO_H_
|
#define _GTK_INSPECTOR_MISC_INFO_H_
|
||||||
|
|
||||||
#include <gtk/gtkbox.h>
|
#include "gtkscrolledwindow.h"
|
||||||
|
|
||||||
#define GTK_TYPE_INSPECTOR_MISC_INFO (gtk_inspector_misc_info_get_type())
|
#define GTK_TYPE_INSPECTOR_MISC_INFO (gtk_inspector_misc_info_get_type())
|
||||||
#define GTK_INSPECTOR_MISC_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_MISC_INFO, GtkInspectorMiscInfo))
|
#define GTK_INSPECTOR_MISC_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_MISC_INFO, GtkInspectorMiscInfo))
|
||||||
@ -32,13 +32,13 @@ typedef struct _GtkInspectorMiscInfoPrivate GtkInspectorMiscInfoPrivate;
|
|||||||
|
|
||||||
typedef struct _GtkInspectorMiscInfo
|
typedef struct _GtkInspectorMiscInfo
|
||||||
{
|
{
|
||||||
GtkBox parent;
|
GtkScrolledWindow parent;
|
||||||
GtkInspectorMiscInfoPrivate *priv;
|
GtkInspectorMiscInfoPrivate *priv;
|
||||||
} GtkInspectorMiscInfo;
|
} GtkInspectorMiscInfo;
|
||||||
|
|
||||||
typedef struct _GtkInspectorMiscInfoClass
|
typedef struct _GtkInspectorMiscInfoClass
|
||||||
{
|
{
|
||||||
GtkBoxClass parent;
|
GtkScrolledWindowClass parent;
|
||||||
} GtkInspectorMiscInfoClass;
|
} GtkInspectorMiscInfoClass;
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -1,168 +1,210 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface domain="gtk30">
|
<interface domain="gtk30">
|
||||||
<template class="GtkInspectorMiscInfo" parent="GtkBox">
|
<template class="GtkInspectorMiscInfo" parent="GtkScrolledWindow">
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="margin">60</property>
|
|
||||||
<property name="spacing">10</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkFrame">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">true</property>
|
||||||
<property name="halign">center</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="margin">60</property>
|
||||||
|
<property name="spacing">10</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBox">
|
<object class="GtkFrame">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="selection-mode">none</property>
|
<property name="halign">center</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkListBoxRow" id="state_row">
|
<object class="GtkListBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="activatable">False</property>
|
<property name="selection-mode">none</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkListBoxRow" id="state_row">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="activatable">False</property>
|
||||||
<property name="margin">10</property>
|
|
||||||
<property name="spacing">40</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="state_label">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">State</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="halign">start</property>
|
<property name="margin">10</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">40</property>
|
||||||
<property name="xalign">0.0</property>
|
<child>
|
||||||
</object>
|
<object class="GtkLabel" id="state_label">
|
||||||
<packing>
|
<property name="visible">True</property>
|
||||||
<property name="expand">True</property>
|
<property name="label" translatable="yes">State</property>
|
||||||
</packing>
|
<property name="halign">start</property>
|
||||||
</child>
|
<property name="valign">baseline</property>
|
||||||
<child>
|
<property name="xalign">0.0</property>
|
||||||
<object class="GtkLabel" id="state">
|
</object>
|
||||||
<property name="visible">True</property>
|
<packing>
|
||||||
<property name="selectable">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="halign">end</property>
|
</packing>
|
||||||
<property name="valign">baseline</property>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="state">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="selectable">True</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBoxRow" id="buildable_id_row">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="activatable">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkListBoxRow" id="buildable_id_row">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="activatable">False</property>
|
||||||
<property name="margin">10</property>
|
|
||||||
<property name="spacing">40</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="buildable_id_label">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Buildable ID</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="halign">start</property>
|
<property name="margin">10</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">40</property>
|
||||||
<property name="xalign">0.0</property>
|
<child>
|
||||||
</object>
|
<object class="GtkLabel" id="buildable_id_label">
|
||||||
<packing>
|
<property name="visible">True</property>
|
||||||
<property name="expand">True</property>
|
<property name="label" translatable="yes">Buildable ID</property>
|
||||||
</packing>
|
<property name="halign">start</property>
|
||||||
</child>
|
<property name="valign">baseline</property>
|
||||||
<child>
|
<property name="xalign">0.0</property>
|
||||||
<object class="GtkLabel" id="buildable_id">
|
</object>
|
||||||
<property name="visible">True</property>
|
<packing>
|
||||||
<property name="selectable">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="halign">end</property>
|
</packing>
|
||||||
<property name="valign">baseline</property>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBoxRow" id="default_widget_row">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="activatable">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkListBoxRow" id="default_widget_row">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="activatable">False</property>
|
||||||
<property name="margin">10</property>
|
|
||||||
<property name="spacing">40</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="default_widget_label">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Default Widget</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="halign">start</property>
|
<property name="margin">10</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">40</property>
|
||||||
<property name="xalign">0.0</property>
|
<child>
|
||||||
</object>
|
<object class="GtkLabel" id="default_widget_label">
|
||||||
<packing>
|
<property name="visible">True</property>
|
||||||
<property name="expand">True</property>
|
<property name="label" translatable="yes">Default Widget</property>
|
||||||
</packing>
|
<property name="halign">start</property>
|
||||||
</child>
|
<property name="valign">baseline</property>
|
||||||
<child>
|
<property name="xalign">0.0</property>
|
||||||
<object class="GtkLabel" id="default_widget">
|
</object>
|
||||||
<property name="visible">True</property>
|
<packing>
|
||||||
<property name="halign">end</property>
|
<property name="expand">True</property>
|
||||||
<property name="valign">baseline</property>
|
</packing>
|
||||||
</object>
|
</child>
|
||||||
</child>
|
<child>
|
||||||
<child>
|
<object class="GtkLabel" id="default_widget">
|
||||||
<object class="GtkButton" id="default_widget_button">
|
<property name="visible">True</property>
|
||||||
<property name="visible">True</property>
|
<property name="halign">end</property>
|
||||||
<property name="halign">end</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="valign">baseline</property>
|
</object>
|
||||||
<property name="label" translatable="yes">Properties</property>
|
</child>
|
||||||
<signal name="clicked" handler="show_default_widget"/>
|
<child>
|
||||||
|
<object class="GtkButton" id="default_widget_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
<property name="label" translatable="yes">Properties</property>
|
||||||
|
<signal name="clicked" handler="show_default_widget"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListBoxRow" id="focus_widget_row">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="activatable">False</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkListBoxRow" id="focus_widget_row">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="activatable">False</property>
|
||||||
<property name="margin">10</property>
|
|
||||||
<property name="spacing">40</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="focus_widget_label">
|
<object class="GtkBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Focus Widget</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="halign">start</property>
|
<property name="margin">10</property>
|
||||||
<property name="valign">baseline</property>
|
<property name="spacing">40</property>
|
||||||
<property name="xalign">0.0</property>
|
<child>
|
||||||
</object>
|
<object class="GtkLabel" id="focus_widget_label">
|
||||||
<packing>
|
<property name="visible">True</property>
|
||||||
<property name="expand">True</property>
|
<property name="label" translatable="yes">Focus Widget</property>
|
||||||
</packing>
|
<property name="halign">start</property>
|
||||||
</child>
|
<property name="valign">baseline</property>
|
||||||
<child>
|
<property name="xalign">0.0</property>
|
||||||
<object class="GtkLabel" id="focus_widget">
|
</object>
|
||||||
<property name="visible">True</property>
|
<packing>
|
||||||
<property name="halign">end</property>
|
<property name="expand">True</property>
|
||||||
<property name="valign">baseline</property>
|
</packing>
|
||||||
<property name="ellipsize">end</property>
|
</child>
|
||||||
</object>
|
<child>
|
||||||
</child>
|
<object class="GtkLabel" id="focus_widget">
|
||||||
<child>
|
<property name="visible">True</property>
|
||||||
<object class="GtkButton" id="focus_widget_button">
|
<property name="halign">end</property>
|
||||||
<property name="visible">True</property>
|
<property name="valign">baseline</property>
|
||||||
<property name="halign">end</property>
|
<property name="ellipsize">end</property>
|
||||||
<property name="valign">baseline</property>
|
</object>
|
||||||
<property name="label" translatable="yes">Properties</property>
|
</child>
|
||||||
<signal name="clicked" handler="show_focus_widget"/>
|
<child>
|
||||||
|
<object class="GtkButton" id="focus_widget_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
<property name="label" translatable="yes">Properties</property>
|
||||||
|
<signal name="clicked" handler="show_focus_widget"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<object class="GtkListBoxRow" id="allocated_size_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">Allocated size</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="allocated_size">
|
||||||
|
<property name="visible">true</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">baseline</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -4,3 +4,4 @@ N_("Default Widget");
|
|||||||
N_("Properties");
|
N_("Properties");
|
||||||
N_("Focus Widget");
|
N_("Focus Widget");
|
||||||
N_("Properties");
|
N_("Properties");
|
||||||
|
N_("Allocated size");
|
||||||
|
Loading…
Reference in New Issue
Block a user