diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-10-24 21:14:16 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-10-24 21:14:16 -0400 |
commit | 70c3241bd3a4fe15c7cf9bd86a21d753f4ef1b35 (patch) | |
tree | 6863f4e333176fb936ed979adbbc4b79e681e7d9 | |
parent | 32326f826ffacd525d62a8a11d66f017a7d8ebe2 (diff) | |
download | gtk+-70c3241bd3a4fe15c7cf9bd86a21d753f4ef1b35.tar.gz |
inspector: Improve tab switching
Switch the object and resource trees away from activate-on-single-click
and add a 'view details' button.
-rw-r--r-- | gtk/inspector/object-tree.c | 18 | ||||
-rw-r--r-- | gtk/inspector/object-tree.h | 2 | ||||
-rw-r--r-- | gtk/inspector/object-tree.ui | 1 | ||||
-rw-r--r-- | gtk/inspector/prop-list.c | 5 | ||||
-rw-r--r-- | gtk/inspector/resource-list.c | 56 | ||||
-rw-r--r-- | gtk/inspector/resource-list.ui | 3 | ||||
-rw-r--r-- | gtk/inspector/window.c | 54 | ||||
-rw-r--r-- | gtk/inspector/window.h | 2 | ||||
-rw-r--r-- | gtk/inspector/window.ui | 105 | ||||
-rw-r--r-- | gtk/inspector/window.ui.h | 2 |
10 files changed, 188 insertions, 60 deletions
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c index aaa3674ed8..4bd5f9b769 100644 --- a/gtk/inspector/object-tree.c +++ b/gtk/inspector/object-tree.c @@ -99,21 +99,31 @@ on_row_activated (GtkTreeView *tree, g_free (name); } -static void -on_selection_changed (GtkTreeSelection *selection, - GtkInspectorObjectTree *wt) +GObject * +gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt) { GObject *object; GtkTreeIter iter; GtkTreeSelection *sel; GtkTreeModel *model; - + object = NULL; sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (wt->priv->tree)); if (gtk_tree_selection_get_selected (sel, &model, &iter)) gtk_tree_model_get (model, &iter, OBJECT, &object, -1); + + return object; +} + +static void +on_selection_changed (GtkTreeSelection *selection, + GtkInspectorObjectTree *wt) +{ + GObject *object; + + object = gtk_inspector_object_tree_get_selected (wt); if (object) g_signal_emit (wt, signals[OBJECT_SELECTED], 0, object); } diff --git a/gtk/inspector/object-tree.h b/gtk/inspector/object-tree.h index 33482305a5..02101375a2 100644 --- a/gtk/inspector/object-tree.h +++ b/gtk/inspector/object-tree.h @@ -70,6 +70,8 @@ gboolean gtk_inspector_object_tree_find_object (GtkInspectorObjectTree GObject *object, GtkTreeIter *iter); +GObject *gtk_inspector_object_tree_get_selected (GtkInspectorObjectTree *wt); + G_END_DECLS diff --git a/gtk/inspector/object-tree.ui b/gtk/inspector/object-tree.ui index c4d6032039..a5c8ffe9ba 100644 --- a/gtk/inspector/object-tree.ui +++ b/gtk/inspector/object-tree.ui @@ -25,7 +25,6 @@ <property name="model">model</property> <property name="enable-search">True</property> <property name="search-column">2</property> - <property name="activate-on-single-click">True</property> <signal name="row-activated" handler="on_row_activated"/> <child internal-child="selection"> <object class="GtkTreeSelection"> diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c index 341bdb8c6d..39511233c6 100644 --- a/gtk/inspector/prop-list.c +++ b/gtk/inspector/prop-list.c @@ -335,9 +335,12 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl, guint num_properties; guint i; - if (pl->priv->object == object || !object) + if (!object) return FALSE; + if (pl->priv->object == object) + return TRUE; + cleanup_object (pl); if (!object) diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c index 59ecdd6285..5a14448ca2 100644 --- a/gtk/inspector/resource-list.c +++ b/gtk/inspector/resource-list.c @@ -29,7 +29,7 @@ enum { PROP_0, - PROP_CLOSE_DETAILS_BUTTON + PROP_BUTTONS }; enum @@ -53,6 +53,8 @@ struct _GtkInspectorResourceListPrivate GtkWidget *info_grid; GtkWidget *stack; GtkWidget *tree; + GtkWidget *buttons; + GtkWidget *open_details_button; GtkWidget *close_details_button; GtkTreeViewColumn *count_column; GtkCellRenderer *count_renderer; @@ -215,8 +217,34 @@ row_activated (GtkTreeView *treeview, GtkTreeViewColumn *column, GtkInspectorResourceList *sl) { - if (populate_details (sl, path)) - gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "details"); + if (!populate_details (sl, path)) + return; + + gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "details"); + gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "details"); +} + +static void +open_details (GtkWidget *button, + GtkInspectorResourceList *sl) +{ + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sl->priv->tree)); + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + path = gtk_tree_model_get_path (model, &iter); + if (populate_details (sl, path)) + { + gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "details"); + gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "details"); + } + + gtk_tree_path_free (path); } static void @@ -224,6 +252,7 @@ close_details (GtkWidget *button, GtkInspectorResourceList *sl) { gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "list"); + gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->buttons), "list"); } static void @@ -231,14 +260,11 @@ visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorResourc { const gchar *child; gboolean resources_visible; - gboolean resource_details_visible; child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl)))); resources_visible = g_strcmp0 (child, "resources") == 0; - child = gtk_stack_get_visible_child_name (GTK_STACK (sl->priv->stack)); - resource_details_visible = g_strcmp0 (child, "details") == 0; - gtk_widget_set_visible (sl->priv->close_details_button, resources_visible && resource_details_visible); + gtk_widget_set_visible (sl->priv->buttons, resources_visible); } static void @@ -329,6 +355,8 @@ constructed (GObject *object) { GtkInspectorResourceList *rl = GTK_INSPECTOR_RESOURCE_LIST (object); + g_signal_connect (rl->priv->open_details_button, "clicked", + G_CALLBACK (open_details), rl); g_signal_connect (rl->priv->close_details_button, "clicked", G_CALLBACK (close_details), rl); @@ -345,8 +373,8 @@ get_property (GObject *object, switch (param_id) { - case PROP_CLOSE_DETAILS_BUTTON: - g_value_take_object (value, rl->priv->close_details_button); + case PROP_BUTTONS: + g_value_take_object (value, rl->priv->buttons); break; default: @@ -365,8 +393,10 @@ set_property (GObject *object, switch (param_id) { - case PROP_CLOSE_DETAILS_BUTTON: - rl->priv->close_details_button = g_value_get_object (value); + case PROP_BUTTONS: + rl->priv->buttons = g_value_get_object (value); + rl->priv->open_details_button = gtk_stack_get_child_by_name (GTK_STACK (rl->priv->buttons), "list"); + rl->priv->close_details_button = gtk_stack_get_child_by_name (GTK_STACK (rl->priv->buttons), "details"); break; default: @@ -387,8 +417,8 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass) widget_class->parent_set = parent_set; - g_object_class_install_property (object_class, PROP_CLOSE_DETAILS_BUTTON, - g_param_spec_object ("close-details-button", NULL, NULL, + g_object_class_install_property (object_class, PROP_BUTTONS, + g_param_spec_object ("buttons", NULL, NULL, GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/resource-list.ui"); diff --git a/gtk/inspector/resource-list.ui b/gtk/inspector/resource-list.ui index 6211ce7d8f..56d5a098c5 100644 --- a/gtk/inspector/resource-list.ui +++ b/gtk/inspector/resource-list.ui @@ -27,11 +27,10 @@ <object class="GtkTreeView" id="tree"> <property name="visible">True</property> <property name="model">model</property> - <property name="activate-on-single-click">True</property> <signal name="row-activated" handler="row_activated"/> <child internal-child="selection"> <object class="GtkTreeSelection"> - <property name="mode">none</property> + <property name="mode">single</property> </object> </child> <child> diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index f196e97602..0cd597bfda 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -52,16 +52,12 @@ G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW) -static void -on_object_activated (GtkInspectorObjectTree *wt, - GObject *selected, - const gchar *name, - GtkInspectorWindow *iw) +static gboolean +set_selected_object (GtkInspectorWindow *iw, + GObject *selected) { - const gchar *tab; - if (!gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->prop_list), selected)) - return; + 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); @@ -77,11 +73,26 @@ on_object_activated (GtkInspectorObjectTree *wt, gtk_inspector_menu_set_object (GTK_INSPECTOR_MENU (iw->menu), selected); gtk_inspector_gestures_set_object (GTK_INSPECTOR_GESTURES (iw->gestures), selected); + return TRUE; +} + +static void +on_object_activated (GtkInspectorObjectTree *wt, + GObject *selected, + const gchar *name, + GtkInspectorWindow *iw) +{ + const gchar *tab; + + if (!set_selected_object (iw, selected)) + return; + tab = g_object_get_data (G_OBJECT (wt), "next-tab"); if (tab) gtk_stack_set_visible_child_name (GTK_STACK (iw->object_details), tab); gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details"); + gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details"); } static void @@ -94,9 +105,24 @@ on_object_selected (GtkInspectorObjectTree *wt, } static void -close_details (GtkWidget *button, GtkInspectorWindow *iw) +close_object_details (GtkWidget *button, GtkInspectorWindow *iw) { gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-tree"); + gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "list"); +} + +static void +open_object_details (GtkWidget *button, GtkInspectorWindow *iw) +{ + GObject *selected; + + selected = gtk_inspector_object_tree_get_selected (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree)); + + if (!set_selected_object (iw, selected)) + return; + + gtk_stack_set_visible_child_name (GTK_STACK (iw->object_stack), "object-details"); + gtk_stack_set_visible_child_name (GTK_STACK (iw->object_buttons), "details"); } static void @@ -104,15 +130,12 @@ visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow { const gchar *child; gboolean objects_visible; - gboolean object_details_visible; child = gtk_stack_get_visible_child_name (GTK_STACK (iw->top_stack)); objects_visible = g_strcmp0 (child, "objects") == 0; - child = gtk_stack_get_visible_child_name (GTK_STACK (iw->object_stack)); - object_details_visible = g_strcmp0 (child, "object-details") == 0; gtk_widget_set_visible (iw->select_object, objects_visible); - gtk_widget_set_visible (iw->close_object_details, objects_visible && object_details_visible); + gtk_widget_set_visible (iw->object_buttons, objects_visible); } static void @@ -152,7 +175,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_stack); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_tree); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_details); - gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, close_object_details); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, object_buttons); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, select_object); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, prop_list); gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, child_prop_list); @@ -172,7 +195,8 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass) gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect); gtk_widget_class_bind_template_callback (widget_class, on_object_activated); gtk_widget_class_bind_template_callback (widget_class, on_object_selected); - gtk_widget_class_bind_template_callback (widget_class, close_details); + gtk_widget_class_bind_template_callback (widget_class, open_object_details); + gtk_widget_class_bind_template_callback (widget_class, close_object_details); } static GdkScreen * diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h index b973d84017..06863d3087 100644 --- a/gtk/inspector/window.h +++ b/gtk/inspector/window.h @@ -46,7 +46,7 @@ typedef struct GtkWidget *object_tree; GtkWidget *object_id; GtkWidget *object_details; - GtkWidget *close_object_details; + GtkWidget *object_buttons; GtkWidget *select_object; GtkWidget *prop_list; GtkWidget *child_prop_list; diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui index d8bafb4e90..d6c8a69a25 100644 --- a/gtk/inspector/window.ui +++ b/gtk/inspector/window.ui @@ -31,20 +31,51 @@ </packing> </child> <child> - <object class="GtkButton" id="close_object_details"> - <property name="tooltip-text" translatable="yes">Show all Objects</property> - <property name="halign">center</property> - <property name="valign">center</property> - <signal name="clicked" handler="close_details"/> - <style> - <class name="image-button"/> - </style> + <object class="GtkStack" id="object_buttons"> + <property name="visible">True</property> <child> - <object class="GtkImage"> + <object class="GtkButton"> <property name="visible">True</property> - <property name="icon-name">view-list-symbolic</property> - <property name="icon-size">1</property> + <property name="tooltip-text" translatable="yes">Show Details</property> + <property name="halign">center</property> + <property name="valign">center</property> + <signal name="clicked" handler="open_object_details"/> + <style> + <class name="image-button"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">dialog-information-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> </object> + <packing> + <property name="name">list</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="tooltip-text" translatable="yes">Show all Objects</property> + <property name="halign">center</property> + <property name="valign">center</property> + <signal name="clicked" handler="close_object_details"/> + <style> + <class name="image-button"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">view-list-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + </object> + <packing> + <property name="name">details</property> + </packing> </child> </object> <packing> @@ -52,20 +83,48 @@ </packing> </child> <child> - <object class="GtkButton" id="close_resource_details"> - <property name="tooltip-text" translatable="yes">Show all Resources</property> - <property name="halign">center</property> - <property name="valign">center</property> - <signal name="clicked" handler="close_details"/> - <style> - <class name="image-button"/> - </style> + <object class="GtkStack" id="resource_buttons"> <child> - <object class="GtkImage"> + <object class="GtkButton"> <property name="visible">True</property> - <property name="icon-name">view-list-symbolic</property> - <property name="icon-size">1</property> + <property name="tooltip-text" translatable="yes">Show Details</property> + <property name="halign">center</property> + <property name="valign">center</property> + <style> + <class name="image-button"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">dialog-information-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> </object> + <packing> + <property name="name">list</property> + </packing> + </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="tooltip-text" translatable="yes">Show all Resources</property> + <property name="halign">center</property> + <property name="valign">center</property> + <style> + <class name="image-button"/> + </style> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">view-list-symbolic</property> + <property name="icon-size">1</property> + </object> + </child> + </object> + <packing> + <property name="name">details</property> + </packing> </child> </object> <packing> @@ -266,7 +325,7 @@ <child> <object class="GtkInspectorResourceList"> <property name="visible">True</property> - <property name="close-details-button">close_resource_details</property> + <property name="buttons">resource_buttons</property> </object> <packing> <property name="name">resources</property> diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h index e04749ca68..5d1ad7b047 100644 --- a/gtk/inspector/window.ui.h +++ b/gtk/inspector/window.ui.h @@ -1,5 +1,7 @@ N_("Select an Object"); +N_("Show Details"); N_("Show all Objects"); +N_("Show Details"); N_("Show all Resources"); N_("Miscellaneous"); N_("Properties"); |