inspector: Avoid a split pane for objects

Like for the resources page, use a separate page for details
to gain more room for both the tree and the details.
This commit is contained in:
Matthias Clasen 2014-10-10 22:34:32 -04:00
parent a8dc098699
commit dffceb1a17
6 changed files with 261 additions and 224 deletions

View File

@ -59,7 +59,8 @@ enum
enum
{
OBJECT_CHANGED,
OBJECT_SELECTED,
OBJECT_ACTIVATED,
LAST_SIGNAL
};
@ -78,25 +79,46 @@ static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorObjectTree, gtk_inspector_object_tree, GTK_TYPE_BOX)
static void
on_widget_selected (GtkTreeSelection *selection,
GtkInspectorObjectTree *wt)
on_row_activated (GtkTreeView *tree,
GtkTreePath *path,
GtkTreeViewColumn *col,
GtkInspectorObjectTree *wt)
{
GtkTreeIter iter;
GObject *object;
gchar *name;
gtk_tree_model_get_iter (GTK_TREE_MODEL (wt->priv->model), &iter, path);
gtk_tree_model_get (GTK_TREE_MODEL (wt->priv->model), &iter,
OBJECT, &object,
OBJECT_NAME, &name,
-1);
g_signal_emit (wt, signals[OBJECT_ACTIVATED], 0, object, name);
g_free (name);
}
static void
on_selection_changed (GtkTreeSelection *selection,
GtkInspectorObjectTree *wt)
{
GObject *object;
GtkTreeIter iter;
GtkTreeSelection *sel;
GtkTreeModel *model;
object = NULL;
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree));
if (gtk_tree_selection_get_selected (sel, &model, &iter))
gtk_tree_model_get (model, &iter,
OBJECT, &object,
-1);
else
object = NULL;
g_signal_emit (wt, signals[OBJECT_CHANGED], 0, object);
if (object)
g_signal_emit (wt, signals[OBJECT_SELECTED], 0, object);
}
typedef struct
{
GtkInspectorObjectTree *wt;
@ -200,19 +222,29 @@ gtk_inspector_object_tree_class_init (GtkInspectorObjectTreeClass *klass)
object_class->finalize = gtk_inspector_object_tree_finalize;
signals[OBJECT_CHANGED] =
g_signal_new ("object-changed",
signals[OBJECT_ACTIVATED] =
g_signal_new ("object-activated",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
G_STRUCT_OFFSET (GtkInspectorObjectTreeClass, object_changed),
G_STRUCT_OFFSET (GtkInspectorObjectTreeClass, object_activated),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
NULL,
G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_STRING);
signals[OBJECT_SELECTED] =
g_signal_new ("object-selected",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
G_STRUCT_OFFSET (GtkInspectorObjectTreeClass, object_selected),
NULL, NULL,
NULL,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/object-tree.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectTree, model);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorObjectTree, tree);
gtk_widget_class_bind_template_callback (widget_class, on_widget_selected);
gtk_widget_class_bind_template_callback (widget_class, on_selection_changed);
gtk_widget_class_bind_template_callback (widget_class, on_row_activated);
}
typedef struct
@ -486,7 +518,6 @@ gtk_inspector_object_tree_append_object (GtkInspectorObjectTree *wt,
g_list_free (list);
}
}
}
void
@ -550,10 +581,14 @@ gtk_inspector_object_tree_select_object (GtkInspectorObjectTree *wt,
if (gtk_inspector_object_tree_find_object (wt, object, &iter))
{
GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter);
GtkTreePath *path;
path = gtk_tree_model_get_path (GTK_TREE_MODEL (wt->priv->model), &iter);
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);
gtk_tree_view_row_activated (GTK_TREE_VIEW (wt->priv->tree), path, NULL);
gtk_tree_path_free (path);
}
}

View File

@ -46,8 +46,10 @@ typedef struct _GtkInspectorObjectTreeClass
{
GtkBoxClass parent;
void (*object_changed) (GtkInspectorObjectTree *wt,
GObject *object);
void (*object_selected) (GtkInspectorObjectTree *wt,
GObject *object);
void (*object_activated) (GtkInspectorObjectTree *wt,
GObject *object);
} GtkInspectorObjectTreeClass;

View File

@ -27,9 +27,12 @@
<property name="model">model</property>
<property name="enable-search">True</property>
<property name="search-column">2</property>
<property name="activate-on-single-click">True</property>
<signal name="row-activated" handler="on_row_activated"/>
<child internal-child="selection">
<object class="GtkTreeSelection">
<signal name="changed" handler="on_widget_selected"/>
<property name="mode">single</property>
<signal name="changed" handler="on_selection_changed"/>
</object>
</child>
<child>

View File

@ -42,23 +42,31 @@
#include "misc-info.h"
#include "gestures.h"
#include "gtknotebook.h"
#include "gtklabel.h"
#include "gtkbutton.h"
#include "gtkstack.h"
#include "gtktreeviewcolumn.h"
#include "gtkwindow.h"
#include "gtkwindowgroup.h"
G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
static void
on_object_tree_selection_changed (GtkInspectorObjectTree *wt,
GObject *selected,
GtkInspectorWindow *iw)
on_object_activated (GtkInspectorObjectTree *wt,
GObject *selected,
const gchar *name,
GtkInspectorWindow *iw)
{
GtkWidget *notebook;
const gchar *tab;
gint page_num;
gchar *id;
if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected))
return;
id = g_strconcat (g_type_name_from_instance ((GTypeInstance*)selected), name[0] ? " : " : NULL, name, NULL);
gtk_label_set_label (GTK_LABEL (iw->object_id), id);
g_free (id);
gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
gtk_inspector_style_prop_list_set_object (GTK_INSPECTOR_STYLE_PROP_LIST (iw->style_prop_list), selected);
gtk_inspector_signals_list_set_object (GTK_INSPECTOR_SIGNALS_LIST (iw->signals_list), selected);
@ -72,28 +80,28 @@ on_object_tree_selection_changed (GtkInspectorObjectTree *wt,
gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected);
gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected);
notebook = gtk_widget_get_parent (iw->prop_list);
tab = g_object_get_data (G_OBJECT (wt), "next-tab");
if (g_strcmp0 (tab, "properties") == 0)
{
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->prop_list);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
}
else if (g_strcmp0 (tab, "data") == 0)
{
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->data_list);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
}
else if (g_strcmp0 (tab, "actions") == 0)
{
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), iw->actions);
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
}
if (tab)
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_details), tab);
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details");
}
static void
on_object_selected (GtkInspectorObjectTree *wt,
GObject *selected,
GtkInspectorWindow *iw)
{
if (GTK_IS_WIDGET (selected))
gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
}
static void
close_details (GtkWidget *button, GtkInspectorWindow *iw)
{
gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-tree");
}
static void
gtk_inspector_window_init (GtkInspectorWindow *iw)
{
@ -123,7 +131,10 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/window.ui");
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, top_stack);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_stack);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_tree);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_id);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, signals_list);
@ -139,7 +150,9 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, gestures);
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_object_tree_selection_changed);
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
gtk_widget_class_bind_template_callback (widget_class, on_object_selected);
gtk_widget_class_bind_template_callback (widget_class, close_details);
}
GtkWidget *

View File

@ -42,7 +42,10 @@ typedef struct
GtkWindow parent;
GtkWidget *top_stack;
GtkWidget *object_stack;
GtkWidget *object_tree;
GtkWidget *object_id;
GtkWidget *object_details;
GtkWidget *prop_list;
GtkWidget *child_prop_list;
GtkWidget *signals_list;

View File

@ -44,217 +44,198 @@
<object class="GtkStack" id="top_stack">
<property name="visible">True</property>
<child>
<object class="GtkPaned">
<object class="GtkStack" id="object_stack">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkInspectorObjectTree" id="object_tree">
<property name="visible">True</property>
<signal name="object-changed" handler="on_object_tree_selection_changed"/>
<signal name="object-activated" handler="on_object_activated"/>
<signal name="object-selected" handler="on_object_selected"/>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
<property name="name">object-tree</property>
</packing>
</child>
<child>
<object class="GtkNotebook">
<object class="GtkBox">
<property name="visible">True</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkInspectorMiscInfo" id="misc_info">
<object class="GtkBox">
<property name="visible">True</property>
<property name="object-tree">object_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="object-tree">object_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="object-tree">object_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">
<property name="orientation">horizontal</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin">6</property>
<signal name="clicked" handler="close_details"/>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">window-close-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</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">
</child>
<child>
<object class="GtkLabel" id="object_id">
<property name="visible">True</property>
<property name="halign">center</property>
<property name="valign">center</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">Style Properties</property>
<packing>
<property name="expand">True</property>
</packing>
</child>
</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">
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="label" translatable="yes">Custom CSS</property>
<property name="orientation">horizontal</property>
</object>
</child>
<child>
<object class="GtkInspectorSizeGroups" id="size_groups">
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkSidebar">
<property name="visible">True</property>
<property name="stack">object_details</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">Size Groups</property>
</child>
<child>
<object class="GtkStack" id="object_details">
<property name="visible">True</property>
<child>
<object class="GtkInspectorMiscInfo" id="misc_info">
<property name="visible">True</property>
<property name="object-tree">object_tree</property>
</object>
<packing>
<property name="name">misc</property>
<property name="title" translatable="yes">Miscellaneous</property>
</packing>
</child>
<child>
<object class="GtkInspectorPropList" id="prop_list">
<property name="visible">True</property>
<property name="child-properties">False</property>
<property name="object-tree">object_tree</property>
</object>
<packing>
<property name="name">properties</property>
<property name="title" translatable="yes">Properties</property>
</packing>
</child>
<child>
<object class="GtkInspectorSignalsList" id="signals_list">
<property name="visible">True</property>
</object>
<packing>
<property name="name">signals</property>
<property name="title" translatable="yes">Signals</property>
</packing>
</child>
<child>
<object class="GtkInspectorObjectHierarchy" id="object_hierarchy">
<property name="visible">True</property>
</object>
<packing>
<property name="name">hierarchy</property>
<property name="title" translatable="yes">Hierarchy</property>
</packing>
</child>
<child>
<object class="GtkInspectorPropList" id="child_prop_list">
<property name="child-properties">True</property>
<property name="object-tree">object_tree</property>
</object>
<packing>
<property name="name">child-properties</property>
<property name="title" translatable="yes">Child Properties</property>
</packing>
</child>
<child>
<object class="GtkInspectorClassesList" id="classes_list">
</object>
</child>
<child>
<object class="GtkInspectorDataList" id="data_list">
<packing>
<property name="name">css-classes</property>
<property name="title" translatable="yes">CSS Classes</property>
</packing>
</child>
<child>
<object class="GtkInspectorStylePropList" id="style_prop_list">
</object>
<packing>
<property name="name">style-properties</property>
<property name="title" translatable="yes">Style Properties</property>
</packing>
</child>
<child>
<object class="GtkInspectorCssEditor" id="widget_css_editor">
<property name="global">False</property>
</object>
<packing>
<property name="name">css</property>
<property name="title" translatable="yes">Custom CSS</property>
</packing>
</child>
<child>
<object class="GtkInspectorSizeGroups" id="size_groups">
</object>
<packing>
<property name="name">size-groups</property>
<property name="title" translatable="yes">Size Groups</property>
</packing>
</child>
<child>
<object class="GtkInspectorDataList" id="data_list">
</object>
<packing>
<property name="name">data</property>
<property name="title" translatable="yes">Data</property>
</packing>
</child>
<child>
<object class="GtkInspectorActions" id="actions">
</object>
<packing>
<property name="name">actions</property>
<property name="title" translatable="yes">Actions</property>
</packing>
</child>
<child>
<object class="GtkInspectorMenu" id="menu">
</object>
<packing>
<property name="name">menu</property>
<property name="title" translatable="yes">Menu</property>
</packing>
</child>
<child>
<object class="GtkInspectorGestures" id="gestures">
<property name="object-tree">object_tree</property>
</object>
<packing>
<property name="name">gestures</property>
<property name="title" translatable="yes">Gestures</property>
</packing>
</child>
</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="object-tree">object_tree</property>
</object>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Gestures</property>
</child>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
<property name="name">object-details</property>
</packing>
</child>
</object>