inspector: Bring the selector back

Make it a separate page instead of the old button path.
This commit is contained in:
Matthias Clasen 2014-10-11 22:04:57 -04:00
parent 5018c7f7cb
commit 3a19c76017
11 changed files with 215 additions and 6 deletions

View File

@ -44,6 +44,8 @@ libgtkinspector_la_SOURCES = \
prop-editor.c \
prop-list.h \
prop-list.c \
selector.h \
selector.c \
style-prop-list.h \
style-prop-list.c \
resource-list.h \
@ -101,6 +103,7 @@ templates = \
object-tree.ui \
prop-list.ui \
resource-list.ui \
selector.ui \
signals-list.ui \
statistics.ui \
style-prop-list.ui \

View File

@ -37,6 +37,7 @@
#include "prop-list.h"
#include "resource-list.h"
#include "resources.h"
#include "selector.h"
#include "signals-list.h"
#include "size-groups.h"
#include "statistics.h"
@ -61,6 +62,7 @@ gtk_inspector_init (void)
g_type_ensure (GTK_TYPE_INSPECTOR_OBJECT_TREE);
g_type_ensure (GTK_TYPE_INSPECTOR_PROP_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_RESOURCE_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_SELECTOR);
g_type_ensure (GTK_TYPE_INSPECTOR_SIGNALS_LIST);
g_type_ensure (GTK_TYPE_INSPECTOR_SIZE_GROUPS);
g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS);

View File

@ -11,6 +11,7 @@
<file compressed="true">object-hierarchy.ui</file>
<file compressed="true">object-tree.ui</file>
<file compressed="true">prop-list.ui</file>
<file compressed="true">selector.ui</file>
<file compressed="true">signals-list.ui</file>
<file compressed="true">statistics.ui</file>
<file compressed="true">style-prop-list.ui</file>

91
gtk/inspector/selector.c Normal file
View File

@ -0,0 +1,91 @@
/*
* Copyright (c) 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include "selector.h"
#include "gtktreeselection.h"
#include "gtktreestore.h"
#include "gtktreeview.h"
#include "gtkwidgetpath.h"
enum
{
COLUMN_SELECTOR
};
struct _GtkInspectorSelectorPrivate
{
GtkTreeStore *model;
GtkTreeView *tree;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorSelector, gtk_inspector_selector, GTK_TYPE_BOX)
static void
gtk_inspector_selector_init (GtkInspectorSelector *oh)
{
oh->priv = gtk_inspector_selector_get_instance_private (oh);
gtk_widget_init_template (GTK_WIDGET (oh));
}
static void
gtk_inspector_selector_class_init (GtkInspectorSelectorClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/selector.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSelector, model);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorSelector, tree);
}
void
gtk_inspector_selector_set_object (GtkInspectorSelector *oh,
GObject *object)
{
GtkTreeIter iter, parent;
gint i;
GtkWidget *widget;
gchar *path, **words;
gtk_tree_store_clear (oh->priv->model);
if (!GTK_IS_WIDGET (object))
return;
widget = GTK_WIDGET (object);
path = gtk_widget_path_to_string (gtk_widget_get_path (widget));
words = g_strsplit (path, " ", 0);
for (i = 0; i < g_strv_length (words); i++)
{
gtk_tree_store_append (oh->priv->model, &iter, i ? &parent : NULL);
gtk_tree_store_set (oh->priv->model, &iter,
COLUMN_SELECTOR, words[i],
-1);
parent = iter;
}
gtk_tree_view_expand_all (oh->priv->tree);
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (oh->priv->tree), &iter);
}
// vim: set et sw=2 ts=2:

59
gtk/inspector/selector.h Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2014 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef _GTK_INSPECTOR_SELECTOR_H_
#define _GTK_INSPECTOR_SELECTOR_H_
#include <gtk/gtkbox.h>
#define GTK_TYPE_INSPECTOR_SELECTOR (gtk_inspector_selector_get_type())
#define GTK_INSPECTOR_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_SELECTOR, GtkInspectorSelector))
#define GTK_INSPECTOR_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_SELECTOR, GtkInspectorSelectorClass))
#define GTK_INSPECTOR_IS_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_SELECTOR))
#define GTK_INSPECTOR_IS_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_SELECTOR))
#define GTK_INSPECTOR_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_SELECTOR, GtkInspectorSelectorClass))
typedef struct _GtkInspectorSelectorPrivate GtkInspectorSelectorPrivate;
typedef struct _GtkInspectorSelector
{
GtkBox parent;
GtkInspectorSelectorPrivate *priv;
} GtkInspectorSelector;
typedef struct _GtkInspectorSelectorClass
{
GtkBoxClass parent;
} GtkInspectorSelectorClass;
G_BEGIN_DECLS
GType gtk_inspector_selector_get_type (void);
void gtk_inspector_selector_set_object (GtkInspectorSelector *oh,
GObject *object);
G_END_DECLS
#endif // _GTK_INSPECTOR_SELECTOR_H_
// vim: set et sw=2 ts=2:

38
gtk/inspector/selector.ui Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk30">
<object class="GtkTreeStore" id="model">
<columns>
<column type="gchararray"/>
</columns>
</object>
<template class="GtkInspectorSelector" parent="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<property name="vscrollbar-policy">automatic</property>
<property name="expand">True</property>
<child>
<object class="GtkTreeView" id="tree">
<property name="visible">True</property>
<property name="model">model</property>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Selector</property>
<child>
<object class="GtkCellRendererText">
<property name="scale">0.8</property>
</object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -0,0 +1 @@
N_("Selector");

View File

@ -33,6 +33,7 @@
#include "css-editor.h"
#include "object-hierarchy.h"
#include "object-tree.h"
#include "selector.h"
#include "size-groups.h"
#include "style-prop-list.h"
#include "data-list.h"
@ -66,6 +67,7 @@ on_object_activated (GtkInspectorObjectTree *wt,
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);
gtk_inspector_object_hierarchy_set_object (GTK_INSPECTOR_OBJECT_HIERARCHY (iw->object_hierarchy), selected);
gtk_inspector_selector_set_object (GTK_INSPECTOR_SELECTOR (iw->selector), selected);
gtk_inspector_misc_info_set_object (GTK_INSPECTOR_MISC_INFO (iw->misc_info), selected);
gtk_inspector_classes_list_set_object (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), selected);
gtk_inspector_css_editor_set_object (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), selected);
@ -159,6 +161,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, style_prop_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, widget_css_editor);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, selector);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, size_groups);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, data_list);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, actions);

View File

@ -50,6 +50,7 @@ typedef struct
GtkWidget *select_object;
GtkWidget *prop_list;
GtkWidget *child_prop_list;
GtkWidget *selector;
GtkWidget *signals_list;
GtkWidget *style_prop_list;
GtkWidget *classes_list;

View File

@ -151,6 +151,16 @@
<property name="title" translatable="yes">Signals</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="GtkInspectorObjectHierarchy" id="object_hierarchy">
<property name="visible">True</property>
@ -161,13 +171,12 @@
</packing>
</child>
<child>
<object class="GtkInspectorPropList" id="child_prop_list">
<property name="child-properties">True</property>
<property name="object-tree">object_tree</property>
<object class="GtkInspectorSelector" id="selector">
<property name="visible">True</property>
</object>
<packing>
<property name="name">child-properties</property>
<property name="title" translatable="yes">Child Properties</property>
<property name="name">selector</property>
<property name="title" translatable="yes">Selector</property>
</packing>
</child>
<child>

View File

@ -4,8 +4,9 @@ N_("Show all Resources");
N_("Miscellaneous");
N_("Properties");
N_("Signals");
N_("Hierarchy");
N_("Child Properties");
N_("Hierarchy");
N_("Selector");
N_("CSS Classes");
N_("Style Properties");
N_("Custom CSS");