inspector: Small reshuffling

Move the scrolled window into GtkInspectorWidgetTree.
This commit is contained in:
Matthias Clasen 2014-10-10 20:51:54 -04:00
parent bee90aa8c8
commit e8f9e7d472
5 changed files with 306 additions and 300 deletions

View File

@ -30,6 +30,7 @@
#include "widget-tree.h"
#include "gtkcelllayout.h"
#include "gtktreeview.h"
#include "gtkpopover.h"
enum

View File

@ -39,6 +39,7 @@
#include "gtkmenuitem.h"
#include "gtksettings.h"
#include "gtktextview.h"
#include "gtktreeview.h"
#include "gtktreeselection.h"
#include "gtktreestore.h"
#include "gtktreemodelsort.h"
@ -65,6 +66,7 @@ enum
struct _GtkInspectorWidgetTreePrivate
{
GtkTreeView *tree;
GtkTreeStore *model;
GHashTable *iters;
gulong map_hook;
@ -73,7 +75,7 @@ struct _GtkInspectorWidgetTreePrivate
static guint widget_tree_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorWidgetTree, gtk_inspector_widget_tree, GTK_TYPE_TREE_VIEW)
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorWidgetTree, gtk_inspector_widget_tree, GTK_TYPE_BOX)
static void
on_widget_selected (GtkTreeSelection *selection,
@ -198,6 +200,7 @@ gtk_inspector_widget_tree_class_init (GtkInspectorWidgetTreeClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/widget-tree.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, model);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorWidgetTree, tree);
gtk_widget_class_bind_template_callback (widget_class, on_widget_selected);
}
@ -208,7 +211,7 @@ gtk_inspector_widget_tree_get_selected_object (GtkInspectorWidgetTree *wt)
GtkTreeSelection *sel;
GtkTreeModel *model;
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt));
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree));
if (gtk_tree_selection_get_selected (sel, &model, &iter))
{
@ -339,20 +342,6 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
g_free (address);
if (GTK_IS_TREE_MODEL_SORT (object))
{
GObject *child = G_OBJECT (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (object)));
if (child)
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
}
if (GTK_IS_TREE_MODEL_FILTER (object))
{
GObject *child = G_OBJECT (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (object)));
if (child)
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
}
if (GTK_IS_CONTAINER (object))
{
FindAllData data;
@ -368,6 +357,20 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
* children in the GtkContainer sense, but which we still want
* to show in the tree right away.
*/
if (GTK_IS_TREE_MODEL_SORT (object))
{
GObject *child = G_OBJECT (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (object)));
if (child)
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
}
if (GTK_IS_TREE_MODEL_FILTER (object))
{
GObject *child = G_OBJECT (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (object)));
if (child)
gtk_inspector_widget_tree_append_object (wt, child, &iter, "model");
}
if (GTK_IS_MENU_ITEM (object))
{
GtkWidget *submenu;
@ -524,7 +527,7 @@ gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt,
}
g_list_free (toplevels);
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt));
gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt->priv->tree));
}
gboolean
@ -558,9 +561,9 @@ gtk_inspector_widget_tree_select_object (GtkInspectorWidgetTree *wt,
if (gtk_inspector_widget_tree_find_object (wt, object, &iter))
{
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter);
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (wt), path);
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (wt)), &iter);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (wt), path, NULL, FALSE, 0, 0);
gtk_tree_view_expand_to_path (GTK_TREE_VIEW (wt->priv->tree), path);
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree)), &iter);
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (wt->priv->tree), path, NULL, FALSE, 0, 0);
}
}

View File

@ -23,7 +23,8 @@
#ifndef _GTK_INSPECTOR_WIDGET_TREE_H_
#define _GTK_INSPECTOR_WIDGET_TREE_H_
#include <gtk/gtktreeview.h>
#include <gtk/gtkbox.h>
#include <gtk/gtktreemodel.h>
#define GTK_TYPE_INSPECTOR_WIDGET_TREE (gtk_inspector_widget_tree_get_type())
#define GTK_INSPECTOR_WIDGET_TREE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_WIDGET_TREE, GtkInspectorWidgetTree))
@ -37,13 +38,13 @@ typedef struct _GtkInspectorWidgetTreePrivate GtkInspectorWidgetTreePrivate;
typedef struct _GtkInspectorWidgetTree
{
GtkTreeView parent;
GtkBox parent;
GtkInspectorWidgetTreePrivate *priv;
} GtkInspectorWidgetTree;
typedef struct _GtkInspectorWidgetTreeClass
{
GtkTreeViewClass parent;
GtkBoxClass parent;
void (*widget_changed) (GtkInspectorWidgetTree *tree);
} GtkInspectorWidgetTreeClass;

View File

@ -10,73 +10,90 @@
<column type="gboolean"/>
</columns>
</object>
<template class="GtkInspectorWidgetTree" parent="GtkTreeView">
<property name="model">model</property>
<property name="enable-search">True</property>
<property name="search-column">2</property>
<child internal-child="selection">
<object class="GtkTreeSelection">
<signal name="changed" handler="on_widget_selected"/>
</object>
</child>
<template class="GtkInspectorWidgetTree" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Object</property>
<property name="resizable">True</property>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">always</property>
<property name="shadow-type">in</property>
<property name="width-request">250</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
<object class="GtkTreeView" id="tree">
<property name="visible">True</property>
<property name="model">model</property>
<property name="enable-search">True</property>
<property name="search-column">2</property>
<child internal-child="selection">
<object class="GtkTreeSelection">
<signal name="changed" handler="on_widget_selected"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Object</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">1</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Name</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">2</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Label</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">3</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Address</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
<property name="family">monospace</property>
</object>
<attributes>
<attribute name="text">4</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
</object>
<attributes>
<attribute name="text">1</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Name</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">2</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Label</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">3</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Address</property>
<property name="resizable">True</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
<property name="family">monospace</property>
</object>
<attributes>
<attribute name="text">4</attribute>
<attribute name="sensitive">5</attribute>
</attributes>
</child>
</object>
</child>

View File

@ -44,234 +44,218 @@
<object class="GtkStack" id="top_stack">
<property name="visible">True</property>
<child>
<object class="GtkBox">
<object class="GtkPaned">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkPaned">
<object class="GtkInspectorWidgetTree" id="widget_tree">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkNotebook">
<property name="visible">True</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<child>
<object class="GtkScrolledWindow">
<object class="GtkInspectorMiscInfo" id="misc_info">
<property name="visible">True</property>
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">always</property>
<property name="shadow-type">in</property>
<property name="width-request">250</property>
<property name="expand">True</property>
<child>
<object class="GtkInspectorWidgetTree" id="widget_tree">
<property name="visible">True</property>
<signal name="widget-changed" handler="on_widget_tree_selection_changed"/>
</object>
</child>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<object class="GtkNotebook">
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<child>
<object class="GtkInspectorMiscInfo" id="misc_info">
<property name="visible">True</property>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Miscellaneous</property>
</object>
</child>
<child>
<object class="GtkInspectorPropList" id="prop_list">
<property name="visible">True</property>
<property name="child-properties">False</property>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorSignalsList" id="signals_list">
<property name="visible">True</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Signals</property>
</object>
</child>
<child>
<object class="GtkInspectorObjectHierarchy" id="object_hierarchy">
<property name="visible">True</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Hierarchy</property>
</object>
</child>
<child>
<object class="GtkInspectorPropList" id="child_prop_list">
<property name="child-properties">True</property>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Child Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorClassesList" id="classes_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">CSS Classes</property>
</object>
</child>
<child>
<object class="GtkInspectorStylePropList" id="style_prop_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Style Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorCssEditor" id="widget_css_editor">
<property name="global">False</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Custom CSS</property>
</object>
</child>
<child>
<object class="GtkInspectorSizeGroups" id="size_groups">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Size Groups</property>
</object>
</child>
<child>
<object class="GtkInspectorDataList" id="data_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Data</property>
</object>
</child>
<child>
<object class="GtkInspectorActions" id="actions">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Actions</property>
</object>
</child>
<child>
<object class="GtkInspectorMenu" id="menu">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Menu</property>
</object>
</child>
<child>
<object class="GtkInspectorGestures" id="gestures">
<property name="widget-tree">widget_tree</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Gestures</property>
</object>
</child>
<property name="label" translatable="yes">Miscellaneous</property>
</object>
</child>
<child>
<object class="GtkInspectorPropList" id="prop_list">
<property name="visible">True</property>
<property name="child-properties">False</property>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorSignalsList" id="signals_list">
<property name="visible">True</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Signals</property>
</object>
</child>
<child>
<object class="GtkInspectorObjectHierarchy" id="object_hierarchy">
<property name="visible">True</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Hierarchy</property>
</object>
</child>
<child>
<object class="GtkInspectorPropList" id="child_prop_list">
<property name="child-properties">True</property>
<property name="widget-tree">widget_tree</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Child Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorClassesList" id="classes_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">CSS Classes</property>
</object>
</child>
<child>
<object class="GtkInspectorStylePropList" id="style_prop_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Style Properties</property>
</object>
</child>
<child>
<object class="GtkInspectorCssEditor" id="widget_css_editor">
<property name="global">False</property>
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Custom CSS</property>
</object>
</child>
<child>
<object class="GtkInspectorSizeGroups" id="size_groups">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Size Groups</property>
</object>
</child>
<child>
<object class="GtkInspectorDataList" id="data_list">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Data</property>
</object>
</child>
<child>
<object class="GtkInspectorActions" id="actions">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Actions</property>
</object>
</child>
<child>
<object class="GtkInspectorMenu" id="menu">
</object>
<packing>
<property name="tab_expand">True</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Menu</property>
</object>
</child>
<child>
<object class="GtkInspectorGestures" id="gestures">
<property name="widget-tree">widget_tree</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Gestures</property>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
<packing>