diff --git a/gtk/inspector/Makefile.am b/gtk/inspector/Makefile.am index 4371d4cc99..bceeed1147 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 ce26a199fe..1daa6ecdb8 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 0b9f552c00..931be2d5fc 100644 --- a/gtk/inspector/inspector.gresource.xml +++ b/gtk/inspector/inspector.gresource.xml @@ -11,6 +11,7 @@ object-hierarchy.ui object-tree.ui prop-list.ui + selector.ui signals-list.ui statistics.ui style-prop-list.ui diff --git a/gtk/inspector/selector.c b/gtk/inspector/selector.c new file mode 100644 index 0000000000..2919dd2c6c --- /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 . + */ + +#include "config.h" +#include + +#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 0000000000..60fb4d3b1f --- /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 + +#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 0000000000..ce8238456b --- /dev/null +++ b/gtk/inspector/selector.ui @@ -0,0 +1,38 @@ + + + + + + + + + diff --git a/gtk/inspector/selector.ui.h b/gtk/inspector/selector.ui.h new file mode 100644 index 0000000000..7e5eae68d3 --- /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 d853938b5a..0b307fa8ed 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 f3ad51b8da..ff9fe5847b 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 582c03a3cc..d8bafb4e90 100644 --- a/gtk/inspector/window.ui +++ b/gtk/inspector/window.ui @@ -151,6 +151,16 @@ Signals + + + True + object_tree + + + child-properties + Child Properties + + True @@ -161,13 +171,12 @@ - - True - object_tree + + True - child-properties - Child Properties + selector + Selector diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h index be9b3cce44..e04749ca68 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");