diff --git a/gtk/inspector/gtkstackcombo.c b/gtk/inspector/gtkstackcombo.c deleted file mode 100644 index 1be01c6732..0000000000 --- a/gtk/inspector/gtkstackcombo.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. - * - * This program 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 program 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 program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" -#include "gtkstackcombo.h" -#include "gtkbox.h" -#include "gtkstack.h" -#include "gtkcomboboxtext.h" -#include "gtkprivate.h" -#include "gtkintl.h" - -struct _GtkStackCombo -{ - GtkWidget parent_instance; - - GtkComboBox *combo; - GtkStack *stack; - GBinding *binding; -}; - -struct _GtkStackComboClass { - GtkWidgetClass parent_class; -}; - -enum { - PROP_0, - PROP_STACK -}; - -G_DEFINE_TYPE (GtkStackCombo, gtk_stack_combo, GTK_TYPE_WIDGET) - -static void -gtk_stack_combo_init (GtkStackCombo *self) -{ - gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE); - - self->stack = NULL; - self->combo = GTK_COMBO_BOX (gtk_combo_box_text_new ()); - gtk_widget_set_parent (GTK_WIDGET (self->combo), GTK_WIDGET (self)); -} - -static void gtk_stack_combo_set_stack (GtkStackCombo *self, - GtkStack *stack); - -static void -rebuild_combo (GtkStackCombo *self) -{ - gtk_stack_combo_set_stack (self, self->stack); -} - -static void -on_child_visible_changed (GtkStackCombo *self) -{ - rebuild_combo (self); -} - -static void -add_child (GtkWidget *widget, - GtkStackCombo *self) -{ - g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (on_child_visible_changed), self); - g_signal_connect_swapped (widget, "notify::visible", G_CALLBACK (on_child_visible_changed), self); - - if (gtk_widget_get_visible (widget)) - { - char *name, *title; - - g_object_get (gtk_stack_get_page (self->stack, widget), - "name", &name, - "title", &title, - NULL); - - gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (self->combo), name, title); - - g_free (name); - g_free (title); - } -} - -static void -populate_combo (GtkStackCombo *self) -{ - gtk_container_foreach (GTK_CONTAINER (self->stack), (GtkCallback)add_child, self); -} - -static void -clear_combo (GtkStackCombo *self) -{ - gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (self->combo)); -} - -static void -on_stack_child_added (GtkContainer *container, - GtkWidget *widget, - GtkStackCombo *self) -{ - rebuild_combo (self); -} - -static void -on_stack_child_removed (GtkContainer *container, - GtkWidget *widget, - GtkStackCombo *self) -{ - g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (on_child_visible_changed), self); - rebuild_combo (self); -} - -static void -disconnect_stack_signals (GtkStackCombo *self) -{ - g_binding_unbind (self->binding); - self->binding = NULL; - g_signal_handlers_disconnect_by_func (self->stack, on_stack_child_added, self); - g_signal_handlers_disconnect_by_func (self->stack, on_stack_child_removed, self); - g_signal_handlers_disconnect_by_func (self->stack, disconnect_stack_signals, self); -} - -static void -connect_stack_signals (GtkStackCombo *self) -{ - g_signal_connect_after (self->stack, "add", G_CALLBACK (on_stack_child_added), self); - g_signal_connect_after (self->stack, "remove", G_CALLBACK (on_stack_child_removed), self); - g_signal_connect_swapped (self->stack, "destroy", G_CALLBACK (disconnect_stack_signals), self); - self->binding = g_object_bind_property (self->stack, "visible-child-name", self->combo, "active-id", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); -} - -static void -gtk_stack_combo_set_stack (GtkStackCombo *self, - GtkStack *stack) -{ - if (stack) - g_object_ref (stack); - - if (self->stack) - { - disconnect_stack_signals (self); - clear_combo (self); - g_clear_object (&self->stack); - } - - if (stack) - { - self->stack = stack; - populate_combo (self); - connect_stack_signals (self); - } -} - -static void -gtk_stack_combo_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GtkStackCombo *self = GTK_STACK_COMBO (object); - - switch (prop_id) - { - case PROP_STACK: - g_value_set_object (value, self->stack); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_stack_combo_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GtkStackCombo *self = GTK_STACK_COMBO (object); - - switch (prop_id) - { - case PROP_STACK: - if (self->stack != g_value_get_object (value)) - { - gtk_stack_combo_set_stack (self, g_value_get_object (value)); - g_object_notify (G_OBJECT (self), "stack"); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gtk_stack_combo_dispose (GObject *object) -{ - GtkStackCombo *self = GTK_STACK_COMBO (object); - - gtk_stack_combo_set_stack (self, NULL); - - if (self->combo) - { - gtk_widget_unparent (GTK_WIDGET (self->combo)); - self->combo = NULL; - } - - G_OBJECT_CLASS (gtk_stack_combo_parent_class)->dispose (object); -} - -static void -gtk_stack_combo_measure (GtkWidget *widget, - GtkOrientation orientation, - int for_size, - int *minimum, - int *natural, - int *minimum_baseline, - int *natural_baseline) -{ - GtkStackCombo *self = GTK_STACK_COMBO (widget); - - gtk_widget_measure (GTK_WIDGET (self->combo), orientation, for_size, - minimum, natural, - minimum_baseline, natural_baseline); -} - -static void -gtk_stack_combo_size_allocate (GtkWidget *widget, - int width, - int height, - int baseline) -{ - GtkStackCombo *self = GTK_STACK_COMBO (widget); - - gtk_widget_size_allocate (GTK_WIDGET (self->combo), - &(GtkAllocation) { - 0, 0, - width, height - }, baseline); -} - -static void -gtk_stack_combo_class_init (GtkStackComboClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - - object_class->get_property = gtk_stack_combo_get_property; - object_class->set_property = gtk_stack_combo_set_property; - object_class->dispose = gtk_stack_combo_dispose; - - widget_class->measure = gtk_stack_combo_measure; - widget_class->size_allocate = gtk_stack_combo_size_allocate; - - g_object_class_install_property (object_class, - PROP_STACK, - g_param_spec_object ("stack", - P_("Stack"), - P_("Stack"), - GTK_TYPE_STACK, - GTK_PARAM_READWRITE | - G_PARAM_CONSTRUCT)); - - gtk_widget_class_set_css_name (widget_class, "stackcombo"); -} diff --git a/gtk/inspector/gtkstackcombo.h b/gtk/inspector/gtkstackcombo.h deleted file mode 100644 index 9b5738ed80..0000000000 --- a/gtk/inspector/gtkstackcombo.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016 Red Hat, Inc. - * - * This program 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 program 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 program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __GTK_STACK_COMBO_H__ -#define __GTK_STACK_COMBO_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -#define GTK_TYPE_STACK_COMBO (gtk_stack_combo_get_type ()) -#define GTK_STACK_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STACK_COMBO, GtkStackCombo)) -#define GTK_STACK_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STACK_COMBO, GtkStackComboClass)) -#define GTK_IS_STACK_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STACK_COMBO)) -#define GTK_IS_STACK_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STACK_COMBO)) -#define GTK_STACK_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STACK_COMBO, GtkStackComboClass)) - -typedef struct _GtkStackCombo GtkStackCombo; -typedef struct _GtkStackComboClass GtkStackComboClass; - -GType gtk_stack_combo_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __GTK_STACK_COMBO_H__ */ diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c index 51360e7c1c..6c9230fca5 100644 --- a/gtk/inspector/init.c +++ b/gtk/inspector/init.c @@ -44,7 +44,6 @@ #include "statistics.h" #include "visual.h" #include "window.h" -#include "gtkstackcombo.h" #include "gtkmagnifierprivate.h" @@ -78,7 +77,6 @@ gtk_inspector_init (void) g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS); g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL); g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW); - g_type_ensure (GTK_TYPE_STACK_COMBO); if (extension_point == NULL) { diff --git a/gtk/inspector/meson.build b/gtk/inspector/meson.build index e0b740783a..b67da21bd4 100644 --- a/gtk/inspector/meson.build +++ b/gtk/inspector/meson.build @@ -9,7 +9,6 @@ inspector_sources = files( 'fpsoverlay.c', 'general.c', 'graphdata.c', - 'gtkstackcombo.c', 'gtktreemodelcssnode.c', 'highlightoverlay.c', 'init.c', diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index 8e012a3d96..2fae04950c 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -52,6 +52,7 @@ #include "gtkstack.h" #include "gtktreeviewcolumn.h" #include "gtkwindowgroup.h" +#include "gtkrevealer.h" G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) @@ -267,6 +268,22 @@ object_details_changed (GtkWidget *combo, gtk_stack_set_visible_child_name (GTK_STACK (iw->object_center_stack), "title"); } +static void +toggle_sidebar (GtkWidget *button, + GtkInspectorWindow *iw) +{ + if (gtk_revealer_get_child_revealed (GTK_REVEALER (iw->sidebar_revealer))) + { + gtk_revealer_set_reveal_child (GTK_REVEALER (iw->sidebar_revealer), FALSE); + gtk_button_set_icon_name (GTK_BUTTON (button), "go-next-symbolic"); + } + else + { + gtk_revealer_set_reveal_child (GTK_REVEALER (iw->sidebar_revealer), TRUE); + gtk_button_set_icon_name (GTK_BUTTON (button), "go-previous-symbolic"); + } +} + static void gtk_inspector_window_realize (GtkWidget *widget) { @@ -322,6 +339,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, misc_info); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, controllers); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, magnifier); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, sidebar_revealer); gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect); gtk_widget_class_bind_template_callback (widget_class, on_object_activated); @@ -330,6 +348,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) gtk_widget_class_bind_template_callback (widget_class, close_object_details); gtk_widget_class_bind_template_callback (widget_class, object_details_changed); gtk_widget_class_bind_template_callback (widget_class, notify_node); + gtk_widget_class_bind_template_callback (widget_class, toggle_sidebar); } static GdkDisplay * diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h index 6e3c5f6647..a6dafde9e4 100644 --- a/gtk/inspector/window.h +++ b/gtk/inspector/window.h @@ -71,6 +71,7 @@ typedef struct GtkWidget *misc_info; GtkWidget *controllers; GtkWidget *magnifier; + GtkWidget *sidebar_revealer; GtkWidget *selected_widget; diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui index a63a265ed1..8f20480b97 100644 --- a/gtk/inspector/window.ui +++ b/gtk/inspector/window.ui @@ -1,3 +1,4 @@ + 1.0 @@ -207,43 +208,89 @@ object-details - vertical - - - - 10 - - - 6 - object_details + + slide-right + 1 + + + object_details + + + + + + + vertical + + + + + 10 + + + go-previous-symbolic + Toggle Sidebar + none + 6 + center + center + + + + + + + + empty + + + + + + + + magnifier + + + 150 + 0 + magnification_adjustment + + + + + + + + + + + + + - - + + + crossfade + 1 + center - empty + title - + - magnifier + prop-search - - 150 - 0 - magnification_adjustment - - - - - - - + + 6 + 40 @@ -252,127 +299,101 @@ - - - crossfade - 1 - center + + + - title + misc + Miscellaneous - - - - - - - prop-search - - - 6 - 40 + + object_tree - - - - - - - - - - misc - Miscellaneous - - - object_tree + + + properties + Properties + + + object_tree + prop_search_entry + + - - - - - - properties - Properties - - - object_tree - prop_search_entry + + + + css-nodes + CSS Nodes + + + + + - - - - - - css-nodes - CSS Nodes - - - + + + + size-groups + Size Groups + + + - - - - - - size-groups - Size Groups - - - - - - - - data - Data - - - - - - - - actions - Actions - - - - - - - - menu - Menu - - - - - - - - controllers - Controllers - - - object_tree + + + + data + Data + + + - - - - - - magnifier - Magnifier - - - magnification_adjustment + + + + actions + Actions + + + - + + + + menu + Menu + + + + + + + + controllers + Controllers + + + object_tree + + + + + + + magnifier + Magnifier + + + magnification_adjustment + + + +