[gtk+] inspector: Bring the selector back
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Bring the selector back
- Date: Sun, 12 Oct 2014 11:57:52 +0000 (UTC)
commit 3a19c760178a7f3d12170983affe9bc9111b3621
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 11 22:04:57 2014 -0400
inspector: Bring the selector back
Make it a separate page instead of the old button path.
gtk/inspector/Makefile.am | 3 +
gtk/inspector/init.c | 2 +
gtk/inspector/inspector.gresource.xml | 1 +
gtk/inspector/selector.c | 91 +++++++++++++++++++++++++++++++++
gtk/inspector/selector.h | 59 +++++++++++++++++++++
gtk/inspector/selector.ui | 38 ++++++++++++++
gtk/inspector/selector.ui.h | 1 +
gtk/inspector/window.c | 3 +
gtk/inspector/window.h | 1 +
gtk/inspector/window.ui | 19 +++++--
gtk/inspector/window.ui.h | 3 +-
11 files changed, 215 insertions(+), 6 deletions(-)
---
diff --git a/gtk/inspector/Makefile.am b/gtk/inspector/Makefile.am
index 4371d4c..bceeed1 100644
--- a/gtk/inspector/Makefile.am
+++ b/gtk/inspector/Makefile.am
@@ -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 \
diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c
index ce26a19..1daa6ec 100644
--- a/gtk/inspector/init.c
+++ b/gtk/inspector/init.c
@@ -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);
diff --git a/gtk/inspector/inspector.gresource.xml b/gtk/inspector/inspector.gresource.xml
index 0b9f552..931be2d 100644
--- a/gtk/inspector/inspector.gresource.xml
+++ b/gtk/inspector/inspector.gresource.xml
@@ -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>
diff --git a/gtk/inspector/selector.c b/gtk/inspector/selector.c
new file mode 100644
index 0000000..2919dd2
--- /dev/null
+++ b/gtk/inspector/selector.c
@@ -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:
diff --git a/gtk/inspector/selector.h b/gtk/inspector/selector.h
new file mode 100644
index 0000000..60fb4d3
--- /dev/null
+++ b/gtk/inspector/selector.h
@@ -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:
diff --git a/gtk/inspector/selector.ui b/gtk/inspector/selector.ui
new file mode 100644
index 0000000..ce82384
--- /dev/null
+++ b/gtk/inspector/selector.ui
@@ -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>
diff --git a/gtk/inspector/selector.ui.h b/gtk/inspector/selector.ui.h
new file mode 100644
index 0000000..7e5eae6
--- /dev/null
+++ b/gtk/inspector/selector.ui.h
@@ -0,0 +1 @@
+N_("Selector");
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index d853938..0b307fa 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -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);
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index f3ad51b..ff9fe58 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -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;
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 582c03a..d8bafb4 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -152,6 +152,16 @@
</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>
</object>
@@ -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>
diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h
index be9b3cc..e04749c 100644
--- a/gtk/inspector/window.ui.h
+++ b/gtk/inspector/window.ui.h
@@ -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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]