Show layout children in the inspector

This commit is contained in:
Matthias Clasen 2019-04-05 19:15:16 +00:00
parent c6aa90f176
commit ef9dc43474
5 changed files with 66 additions and 2 deletions

View File

@ -38,6 +38,7 @@
#include "gtkmain.h"
#include "gtkstack.h"
#include "gtkeventcontrollerkey.h"
#include "gtklayoutmanager.h"
enum
{
@ -502,4 +503,39 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
return TRUE;
}
void
gtk_inspector_prop_list_set_layout_child (GtkInspectorPropList *pl,
GObject *object)
{
GtkWidget *stack;
GtkStackPage *page;
GtkWidget *parent;
GtkLayoutManager *layout_manager;
GtkLayoutChild *layout_child;
stack = gtk_widget_get_parent (GTK_WIDGET (pl));
page = gtk_stack_get_page (GTK_STACK (stack), GTK_WIDGET (pl));
g_object_set (page, "visible", FALSE, NULL);
if (!GTK_IS_WIDGET (object))
return;
parent = gtk_widget_get_parent (GTK_WIDGET (object));
if (!parent)
return;
layout_manager = gtk_widget_get_layout_manager (parent);
if (!layout_manager)
return;
layout_child = gtk_layout_manager_get_layout_child (layout_manager, GTK_WIDGET (object));
if (!layout_child)
return;
if (!gtk_inspector_prop_list_set_object (pl, G_OBJECT (layout_child)))
return;
g_object_set (page, "visible", TRUE, NULL);
}
// vim: set et sw=2 ts=2:

View File

@ -53,6 +53,9 @@ G_BEGIN_DECLS
GType gtk_inspector_prop_list_get_type (void);
gboolean gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
GObject *object);
void gtk_inspector_prop_list_set_layout_child (GtkInspectorPropList *pl,
GObject *object);
G_END_DECLS

View File

@ -53,6 +53,7 @@
#include "gtktreeviewcolumn.h"
#include "gtkwindowgroup.h"
#include "gtkrevealer.h"
#include "gtklayoutmanager.h"
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
@ -70,6 +71,7 @@ set_selected_object (GtkInspectorWindow *iw,
gtk_label_set_label (GTK_LABEL (iw->object_title), title);
g_free (title);
gtk_inspector_prop_list_set_layout_child (GTK_INSPECTOR_PROP_LIST (iw->layout_prop_list), selected);
gtk_inspector_misc_info_set_object (GTK_INSPECTOR_MISC_INFO (iw->misc_info), selected);
gtk_inspector_css_node_tree_set_object (GTK_INSPECTOR_CSS_NODE_TREE (iw->widget_css_node_tree), selected);
gtk_inspector_size_groups_set_object (GTK_INSPECTOR_SIZE_GROUPS (iw->size_groups), selected);
@ -329,6 +331,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details_button);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, select_object);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, layout_prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_node_tree);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_recorder);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_title);

View File

@ -56,10 +56,9 @@ typedef struct
GtkWidget *object_center_stack;
GtkWidget *object_title;
GtkWidget *prop_list;
GtkWidget *child_prop_list;
GtkWidget *layout_prop_list;
GtkWidget *selector;
GtkWidget *signals_list;
GtkWidget *style_prop_list;
GtkWidget *classes_list;
GtkWidget *widget_css_node_tree;
GtkWidget *widget_recorder;

View File

@ -295,6 +295,17 @@
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">layout-prop-search</property>
<property name="child">
<object class="GtkSearchEntry" id="layout_prop_search_entry">
<property name="margin">6</property>
<property name="max-width-chars">40</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
@ -325,6 +336,18 @@
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">layout_properties</property>
<property name="title" translatable="yes">Layout</property>
<property name="child">
<object class="GtkInspectorPropList" id="layout_prop_list">
<property name="object-tree">object_tree</property>
<property name="search-entry">layout_prop_search_entry</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">css-nodes</property>