[gtk+] inspector: Reserve space for buttons
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Reserve space for buttons
- Date: Sat, 8 Nov 2014 05:10:26 +0000 (UTC)
commit 713d3834f6617bce5916ecaf07962be678d52805
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 8 00:06:54 2014 -0500
inspector: Reserve space for buttons
Make the button area in the top left a stack that is parallel
to the main page stack. This avoids size changes as we switch
between pages.
gtk/inspector/resource-list.c | 27 +-----------
gtk/inspector/statistics.c | 23 ---------
gtk/inspector/window.c | 18 -------
gtk/inspector/window.ui | 99 +++++++++++++++++++++++++++++------------
4 files changed, 71 insertions(+), 96 deletions(-)
---
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index 7331d98..5e3816f 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -304,19 +304,6 @@ close_details (GtkWidget *button,
}
static void
-visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorResourceList *sl)
-{
- const gchar *child;
- gboolean resources_visible;
-
- child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
- resources_visible = g_strcmp0 (child, "resources") == 0;
-
- gtk_widget_set_visible (sl->priv->buttons, resources_visible);
- gtk_widget_set_sensitive (sl->priv->open_details_button, can_show_details (sl));
-}
-
-static void
load_resources (GtkInspectorResourceList *sl)
{
gint count = 0;
@@ -369,15 +356,7 @@ on_map (GtkWidget *widget)
gtk_tree_view_expand_all (GTK_TREE_VIEW (sl->priv->tree));
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "list");
-}
-
-static void
-parent_set (GtkWidget *widget, GtkWidget *old_parent)
-{
- if (old_parent)
- g_signal_handlers_disconnect_by_func (old_parent, visible_child_name_changed, widget);
- g_signal_connect (gtk_widget_get_parent (widget), "notify::visible-child-name",
- G_CALLBACK (visible_child_name_changed), widget);
+ gtk_widget_set_sensitive (sl->priv->open_details_button, can_show_details (sl));
}
static void
@@ -600,8 +579,6 @@ gtk_inspector_resource_list_init (GtkInspectorResourceList *sl)
size_data_func, sl, NULL);
g_signal_connect (sl, "map", G_CALLBACK (on_map), NULL);
- g_signal_connect (sl->priv->stack, "notify::visible-child-name",
- G_CALLBACK (visible_child_name_changed), sl);
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (sl->priv->search_bar),
GTK_ENTRY (sl->priv->search_entry));
@@ -687,8 +664,6 @@ gtk_inspector_resource_list_class_init (GtkInspectorResourceListClass *klass)
object_class->constructed = constructed;
object_class->finalize = finalize;
- widget_class->parent_set = parent_set;
-
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));
diff --git a/gtk/inspector/statistics.c b/gtk/inspector/statistics.c
index 72b248f..de13e94 100644
--- a/gtk/inspector/statistics.c
+++ b/gtk/inspector/statistics.c
@@ -244,27 +244,6 @@ type_data_free (gpointer data)
g_free (type_data);
}
-static void
-visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorStatistics *sl)
-{
- const gchar *child;
- gboolean visible;
-
- child = gtk_stack_get_visible_child_name (GTK_STACK (gtk_widget_get_parent (GTK_WIDGET (sl))));
- visible = g_strcmp0 (child, "statistics") == 0;
-
- gtk_widget_set_visible (sl->priv->button, visible);
-}
-
-static void
-parent_set (GtkWidget *widget, GtkWidget *old_parent)
-{
- if (old_parent)
- g_signal_handlers_disconnect_by_func (old_parent, visible_child_name_changed, widget);
- g_signal_connect (gtk_widget_get_parent (widget), "notify::visible-child-name",
- G_CALLBACK (visible_child_name_changed), widget);
-}
-
static gboolean
key_press_event (GtkWidget *window,
GdkEvent *event,
@@ -452,8 +431,6 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
object_class->constructed = constructed;
object_class->finalize = finalize;
- widget_class->parent_set = parent_set;
-
g_object_class_install_property (object_class, PROP_BUTTON,
g_param_spec_object ("button", NULL, NULL,
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index da54753..79b1cb6 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -127,29 +127,11 @@ open_object_details (GtkWidget *button, GtkInspectorWindow *iw)
}
static void
-visible_child_name_changed (GObject *obj, GParamSpec *pspec, GtkInspectorWindow *iw)
-{
- const gchar *child;
- gboolean objects_visible;
-
- child = gtk_stack_get_visible_child_name (GTK_STACK (iw->top_stack));
- objects_visible = g_strcmp0 (child, "objects") == 0;
-
- gtk_widget_set_visible (iw->select_object, objects_visible);
- gtk_widget_set_visible (iw->object_buttons, objects_visible);
-}
-
-static void
gtk_inspector_window_init (GtkInspectorWindow *iw)
{
gtk_widget_init_template (GTK_WIDGET (iw));
gtk_window_group_add_window (gtk_window_group_new (), GTK_WINDOW (iw));
-
- g_signal_connect (iw->top_stack, "notify::visible-child-name",
- G_CALLBACK (visible_child_name_changed), iw);
- g_signal_connect (iw->object_stack, "notify::visible-child-name",
- G_CALLBACK (visible_child_name_changed), iw);
}
static void
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 349d210..9752614 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -9,34 +9,40 @@
<property name="visible">True</property>
<property name="show-close-button">True</property>
<child>
- <object class="GtkButton" id="select_object">
- <property name="visible">True</property>
- <property name="tooltip-text" translatable="yes">Select an Object</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <signal name="clicked" handler="gtk_inspector_on_inspect"/>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="icon-name">find-location-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="pack-type">start</property>
- </packing>
- </child>
- <child>
- <object class="GtkStack" id="object_buttons">
+ <object class="GtkStack" id="button_stack">
<property name="visible">True</property>
+ <property name="visible-child-name" bind-source="top_stack" bind-property="visible-child-name"/>
<child>
- <object class="GtkButton" id="object_details_button">
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="tooltip-text" translatable="yes">Show Details</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkButton" id="select_object">
+ <property name="visible">True</property>
+ <property name="tooltip-text" translatable="yes">Select an Object</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <signal name="clicked" handler="gtk_inspector_on_inspect"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">find-location-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="object_buttons">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkButton" id="object_details_button">
+ <property name="visible">True</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"/>
@@ -78,14 +84,17 @@
</packing>
</child>
</object>
+ </child>
+ </object>
<packing>
- <property name="pack-type">start</property>
+ <property name="name">objects</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="record_statistics_button">
+ <property name="visible">True</property>
<property name="tooltip-text" translatable="yes">Collect Statistics</property>
- <property name="halign">center</property>
+ <property name="halign">start</property>
<property name="valign">center</property>
<style>
<class name="image-button"/>
@@ -99,11 +108,14 @@
</child>
</object>
<packing>
- <property name="pack-type">start</property>
+ <property name="name">statistics</property>
</packing>
</child>
<child>
<object class="GtkStack" id="resource_buttons">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
@@ -148,9 +160,38 @@
</child>
</object>
<packing>
- <property name="pack-type">start</property>
+ <property name="name">resources</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">css</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">visual</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">general</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
<child type="title">
<object class="GtkStackSwitcher">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]