From af3789bb871eaf4d968fef8d066badd5cfb3c228 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 30 Oct 2015 06:49:57 -0400 Subject: [PATCH] inspector: Drop the style property list Style properties are now shown for each CSS node in the CSS node tab, so we don't need a separate per-widget tab for this. --- gtk/inspector/Makefile.inc | 3 - gtk/inspector/init.c | 2 - gtk/inspector/style-prop-list.c | 291 ----------------------------- gtk/inspector/style-prop-list.h | 59 ------ gtk/inspector/style-prop-list.ui | 138 -------------- gtk/inspector/style-prop-list.ui.h | 3 - gtk/inspector/window.c | 3 - gtk/inspector/window.ui | 7 - 8 files changed, 506 deletions(-) delete mode 100644 gtk/inspector/style-prop-list.c delete mode 100644 gtk/inspector/style-prop-list.h delete mode 100644 gtk/inspector/style-prop-list.ui delete mode 100644 gtk/inspector/style-prop-list.ui.h diff --git a/gtk/inspector/Makefile.inc b/gtk/inspector/Makefile.inc index d133bd4cb0..e34a805a6c 100644 --- a/gtk/inspector/Makefile.inc +++ b/gtk/inspector/Makefile.inc @@ -23,7 +23,6 @@ inspector_c_sources = \ inspector/signals-list.c \ inspector/size-groups.c \ inspector/statistics.c \ - inspector/style-prop-list.c \ inspector/strv-editor.c \ inspector/treewalk.c \ inspector/visual.c \ @@ -53,7 +52,6 @@ inspector_h_sources = \ inspector/signals-list.h \ inspector/size-groups.h \ inspector/statistics.h \ - inspector/style-prop-list.h \ inspector/strv-editor.h \ inspector/treewalk.h \ inspector/visual.h \ @@ -75,6 +73,5 @@ inspector_templates = \ inspector/selector.ui \ inspector/signals-list.ui \ inspector/statistics.ui \ - inspector/style-prop-list.ui \ inspector/visual.ui \ inspector/window.ui diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c index 040497c246..8e4c216f09 100644 --- a/gtk/inspector/init.c +++ b/gtk/inspector/init.c @@ -43,7 +43,6 @@ #include "signals-list.h" #include "size-groups.h" #include "statistics.h" -#include "style-prop-list.h" #include "visual.h" #include "window.h" @@ -76,7 +75,6 @@ gtk_inspector_init (void) g_type_ensure (GTK_TYPE_INSPECTOR_SIGNALS_LIST); g_type_ensure (GTK_TYPE_INSPECTOR_SIZE_GROUPS); g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS); - g_type_ensure (GTK_TYPE_INSPECTOR_STYLE_PROP_LIST); g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL); g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW); diff --git a/gtk/inspector/style-prop-list.c b/gtk/inspector/style-prop-list.c deleted file mode 100644 index 7cf3e98d5e..0000000000 --- a/gtk/inspector/style-prop-list.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * 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. - */ - -#include "config.h" -#include - -#include "style-prop-list.h" - -#include "gtkcssproviderprivate.h" -#include "gtkcssstylepropertyprivate.h" -#include "gtkcsssectionprivate.h" -#include "gtkcssstyleprivate.h" -#include "gtkcssvalueprivate.h" -#include "gtkliststore.h" -#include "gtksettings.h" -#include "gtktreeview.h" -#include "gtktreeselection.h" -#include "gtkstack.h" -#include "gtksearchentry.h" -#include "gtklabel.h" - -enum -{ - COLUMN_NAME, - COLUMN_VALUE, - COLUMN_LOCATION -}; - -struct _GtkInspectorStylePropListPrivate -{ - GtkListStore *model; - GtkWidget *widget; - GtkWidget *tree; - GtkWidget *search_entry; - GtkWidget *search_stack; - GtkWidget *object_title; - GHashTable *prop_iters; - GtkTreeViewColumn *name_column; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorStylePropList, gtk_inspector_style_prop_list, GTK_TYPE_BOX) - -static void -search_close_clicked (GtkWidget *button, - GtkInspectorStylePropList *pl) -{ - gtk_entry_set_text (GTK_ENTRY (pl->priv->search_entry), ""); - gtk_stack_set_visible_child_name (GTK_STACK (pl->priv->search_stack), "title"); -} - -static gboolean -key_press_event (GtkWidget *window, - GdkEvent *event, - GtkInspectorStylePropList *pl) -{ - if (!gtk_widget_get_mapped (GTK_WIDGET (pl))) - return GDK_EVENT_PROPAGATE; - - if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (pl->priv->search_entry), event)) - { - gtk_stack_set_visible_child_name (GTK_STACK (pl->priv->search_stack), "search"); - return GDK_EVENT_STOP; - } - return GDK_EVENT_PROPAGATE; -} - -static void -hierarchy_changed (GtkWidget *widget, - GtkWidget *previous_toplevel) -{ - if (previous_toplevel) - g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget); - g_signal_connect (gtk_widget_get_toplevel (widget), "key-press-event", - G_CALLBACK (key_press_event), widget); -} - -static void -gtk_inspector_style_prop_list_init (GtkInspectorStylePropList *pl) -{ - gint i; - - pl->priv = gtk_inspector_style_prop_list_get_instance_private (pl); - gtk_widget_init_template (GTK_WIDGET (pl)); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (pl->priv->model), - COLUMN_NAME, - GTK_SORT_ASCENDING); - gtk_tree_view_set_search_entry (GTK_TREE_VIEW (pl->priv->tree), - GTK_ENTRY (pl->priv->search_entry)); - - pl->priv->prop_iters = g_hash_table_new_full (g_str_hash, - g_str_equal, - NULL, - (GDestroyNotify) gtk_tree_iter_free); - - for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++) - { - GtkCssStyleProperty *prop; - GtkTreeIter iter; - const gchar *name; - - prop = _gtk_css_style_property_lookup_by_id (i); - name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)); - - gtk_list_store_append (pl->priv->model, &iter); - gtk_list_store_set (pl->priv->model, &iter, COLUMN_NAME, name, -1); - g_hash_table_insert (pl->priv->prop_iters, (gpointer)name, gtk_tree_iter_copy (&iter)); - } -} - -static void -disconnect_each_other (gpointer still_alive, - GObject *for_science) -{ - if (GTK_INSPECTOR_IS_STYLE_PROP_LIST (still_alive)) - { - GtkInspectorStylePropList *self = GTK_INSPECTOR_STYLE_PROP_LIST (still_alive); - self->priv->widget = NULL; - } - - g_signal_handlers_disconnect_matched (still_alive, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, for_science); - g_object_weak_unref (still_alive, disconnect_each_other, for_science); -} - -static void -finalize (GObject *object) -{ - GtkInspectorStylePropList *pl = GTK_INSPECTOR_STYLE_PROP_LIST (object); - - g_hash_table_unref (pl->priv->prop_iters); - - G_OBJECT_CLASS (gtk_inspector_style_prop_list_parent_class)->finalize (object); -} - -static void -ensure_css_sections (void) -{ - GtkSettings *settings; - gchar *theme_name; - - gtk_css_provider_set_keep_css_sections (); - - settings = gtk_settings_get_default (); - g_object_get (settings, "gtk-theme-name", &theme_name, NULL); - g_object_set (settings, "gtk-theme-name", theme_name, NULL); - g_free (theme_name); -} - -static void -gtk_inspector_style_prop_list_class_init (GtkInspectorStylePropListClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - ensure_css_sections (); - - object_class->finalize = finalize; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/style-prop-list.ui"); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, model); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, tree); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, search_stack); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, search_entry); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, object_title); - gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStylePropList, name_column); - gtk_widget_class_bind_template_callback (widget_class, search_close_clicked); - gtk_widget_class_bind_template_callback (widget_class, hierarchy_changed); -} - -static void -populate (GtkInspectorStylePropList *self) -{ - GtkInspectorStylePropListPrivate *priv = self->priv; - GtkStyleContext *context; - GtkCssStyle *style; - gint i; - - context = gtk_widget_get_style_context (priv->widget); - style = gtk_style_context_lookup_style (context); - - for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++) - { - GtkCssStyleProperty *prop; - const gchar *name; - GtkTreeIter *iter; - GtkCssSection *section; - gchar *location; - gchar *value; - - prop = _gtk_css_style_property_lookup_by_id (i); - name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)); - - iter = (GtkTreeIter *)g_hash_table_lookup (priv->prop_iters, name); - - value = _gtk_css_value_to_string (gtk_css_style_get_value (style, i)); - - section = gtk_css_style_get_section (style, i); - if (section) - location = _gtk_css_section_to_string (section); - else - location = NULL; - - gtk_list_store_set (priv->model, - iter, - COLUMN_VALUE, value, - COLUMN_LOCATION, location, - -1); - - g_free (location); - g_free (value); - } -} - -static void -widget_style_updated (GtkWidget *widget, - GtkInspectorStylePropList *self) -{ - populate (self); -} - -static void -widget_state_flags_changed (GtkWidget *widget, - GtkStateFlags flags, - GtkInspectorStylePropList *self) -{ - populate (self); -} - -void -gtk_inspector_style_prop_list_set_object (GtkInspectorStylePropList *self, - GObject *object) -{ - const gchar *title; - - if (self->priv->widget == (GtkWidget *)object) - { - gtk_widget_hide (GTK_WIDGET (self)); - return; - } - - if (self->priv->widget) - { - disconnect_each_other (self->priv->widget, G_OBJECT (self)); - disconnect_each_other (self, G_OBJECT (self->priv->widget)); - self->priv->widget = NULL; - } - - if (!GTK_IS_WIDGET (object)) - { - gtk_widget_hide (GTK_WIDGET (self)); - return; - } - - title = (const gchar *)g_object_get_data (object, "gtk-inspector-object-title"); - gtk_label_set_label (GTK_LABEL (self->priv->object_title), title); - - gtk_entry_set_text (GTK_ENTRY (self->priv->search_entry), ""); - gtk_stack_set_visible_child_name (GTK_STACK (self->priv->search_stack), "title"); - - self->priv->widget = (GtkWidget *)object; - g_object_weak_ref (G_OBJECT (self), disconnect_each_other, object); - g_object_weak_ref (G_OBJECT (object), disconnect_each_other, self); - - populate (self); - gtk_widget_show (GTK_WIDGET (self)); - - g_signal_connect (object, "style-updated", - G_CALLBACK (widget_style_updated), self); - g_signal_connect (object, "state-flags-changed", - G_CALLBACK (widget_state_flags_changed), self); -} - -// vim: set et sw=2 ts=2: diff --git a/gtk/inspector/style-prop-list.h b/gtk/inspector/style-prop-list.h deleted file mode 100644 index 46e604d1f4..0000000000 --- a/gtk/inspector/style-prop-list.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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_STYLE_PROP_LIST_H_ -#define _GTK_INSPECTOR_STYLE_PROP_LIST_H_ - -#include - -#define GTK_TYPE_INSPECTOR_STYLE_PROP_LIST (gtk_inspector_style_prop_list_get_type()) -#define GTK_INSPECTOR_STYLE_PROP_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_STYLE_PROP_LIST, GtkInspectorStylePropList)) -#define GTK_INSPECTOR_STYLE_PROP_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_STYLE_PROP_LIST, GtkInspectorStylePropListClass)) -#define GTK_INSPECTOR_IS_STYLE_PROP_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_STYLE_PROP_LIST)) -#define GTK_INSPECTOR_IS_STYLE_PROP_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_STYLE_PROP_LIST)) -#define GTK_INSPECTOR_STYLE_PROP_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_STYLE_PROP_LIST, GtkInspectorStylePropListClass)) - - -typedef struct _GtkInspectorStylePropListPrivate GtkInspectorStylePropListPrivate; - -typedef struct _GtkInspectorStylePropList -{ - GtkBox parent; - GtkInspectorStylePropListPrivate *priv; -} GtkInspectorStylePropList; - -typedef struct _GtkInspectorStylePropListClass -{ - GtkBoxClass parent; -} GtkInspectorStylePropListClass; - - -G_BEGIN_DECLS - -GType gtk_inspector_style_prop_list_get_type (void); -void gtk_inspector_style_prop_list_set_object (GtkInspectorStylePropList *pl, - GObject *object); - -G_END_DECLS - -#endif // _GTK_INSPECTOR_STYLE_PROP_LIST_H_ - -// vim: set et sw=2 ts=2: diff --git a/gtk/inspector/style-prop-list.ui b/gtk/inspector/style-prop-list.ui deleted file mode 100644 index 2bbe257cbe..0000000000 --- a/gtk/inspector/style-prop-list.ui +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - diff --git a/gtk/inspector/style-prop-list.ui.h b/gtk/inspector/style-prop-list.ui.h deleted file mode 100644 index d0cd964735..0000000000 --- a/gtk/inspector/style-prop-list.ui.h +++ /dev/null @@ -1,3 +0,0 @@ -N_("Property"); -N_("Value"); -N_("Location"); diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index ed0a715c20..8bc52e7cd8 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -35,7 +35,6 @@ #include "object-tree.h" #include "selector.h" #include "size-groups.h" -#include "style-prop-list.h" #include "data-list.h" #include "signals-list.h" #include "actions.h" @@ -64,7 +63,6 @@ set_selected_object (GtkInspectorWindow *iw, return FALSE; 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); 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); @@ -225,7 +223,6 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) 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); - 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, widget_css_node_tree); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_hierarchy); diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui index ef05006162..5eaafb8c18 100644 --- a/gtk/inspector/window.ui +++ b/gtk/inspector/window.ui @@ -305,13 +305,6 @@ Selector - - - - style-properties - Style Properties - - True