[gtk+] inspector: Move the record button up
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Move the record button up
- Date: Sat, 8 Nov 2014 05:10:11 +0000 (UTC)
commit 5f701cf4c953b1d3c076a38eb99ae38c00113763
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Nov 7 23:19:28 2014 -0500
inspector: Move the record button up
Give all the page space to the content.
gtk/inspector/statistics.c | 98 ++++++++++++++++++++++++++++++++++++++--
gtk/inspector/statistics.ui | 15 ------
gtk/inspector/statistics.ui.h | 3 -
gtk/inspector/window.ui | 21 +++++++++
gtk/inspector/window.ui.h | 1 +
5 files changed, 115 insertions(+), 23 deletions(-)
---
diff --git a/gtk/inspector/statistics.c b/gtk/inspector/statistics.c
index 69c4bc8..21fe86b 100644
--- a/gtk/inspector/statistics.c
+++ b/gtk/inspector/statistics.c
@@ -26,6 +26,12 @@
#include "gtkcellrenderertext.h"
#include "gtkcelllayout.h"
+enum
+{
+ PROP_0,
+ PROP_BUTTON
+};
+
struct _GtkInspectorStatisticsPrivate
{
GtkWidget *stack;
@@ -137,13 +143,13 @@ update_type_counts (gpointer data)
}
static void
-toggle_record (GtkToggleToolButton *button,
+toggle_record (GtkToggleButton *button,
GtkInspectorStatistics *sl)
{
- if (gtk_toggle_tool_button_get_active (button) == (sl->priv->update_source_id != 0))
+ if (gtk_toggle_button_get_active (button) == (sl->priv->update_source_id != 0))
return;
- if (gtk_toggle_tool_button_get_active (button))
+ if (gtk_toggle_button_get_active (button))
{
sl->priv->update_source_id = gdk_threads_add_timeout_seconds (1,
update_type_counts,
@@ -236,6 +242,27 @@ type_data_free (gpointer 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 void
gtk_inspector_statistics_init (GtkInspectorStatistics *sl)
{
sl->priv = gtk_inspector_statistics_get_instance_private (sl);
@@ -265,6 +292,20 @@ gtk_inspector_statistics_init (GtkInspectorStatistics *sl)
}
static void
+constructed (GObject *object)
+{
+ GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
+
+ g_signal_connect (sl->priv->button, "toggled",
+ G_CALLBACK (toggle_record), sl);
+
+ if (has_instance_counts ())
+ update_type_counts (sl);
+ else
+ gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse");
+}
+
+static void
finalize (GObject *object)
{
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
@@ -278,13 +319,62 @@ finalize (GObject *object)
}
static void
+get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
+
+ switch (param_id)
+ {
+ case PROP_BUTTON:
+ g_value_take_object (value, sl->priv->button);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
+
+ switch (param_id)
+ {
+ case PROP_BUTTON:
+ sl->priv->button = g_value_get_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->get_property = get_property;
+ object_class->set_property = set_property;
+ 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));
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/statistics.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, view);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, stack);
@@ -297,8 +387,6 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_self2);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, column_cumulative2);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2);
- gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, button);
- gtk_widget_class_bind_template_callback (widget_class, toggle_record);
}
// vim: set et sw=2 ts=2:
diff --git a/gtk/inspector/statistics.ui b/gtk/inspector/statistics.ui
index 9e72d45..6549fe5 100644
--- a/gtk/inspector/statistics.ui
+++ b/gtk/inspector/statistics.ui
@@ -23,26 +23,11 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkToolbar" id="toolbar">
- <property name="visible">True</property>
- <property name="icon-size">small-toolbar</property>
- <child>
- <object class="GtkToggleToolButton" id="button">
- <property name="visible">True</property>
- <property name="icon-name">media-record-symbolic</property>
- <property name="tooltip-text" translatable="yes">Collect Statistics</property>
- <signal name="toggled" handler="toggle_record"/>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="expand">True</property>
<property name="hscrollbar-policy">automatic</property>
<property name="vscrollbar-policy">always</property>
- <property name="shadow-type">in</property>
<child>
<object class="GtkTreeView" id="view">
<property name="visible">True</property>
diff --git a/gtk/inspector/statistics.ui.h b/gtk/inspector/statistics.ui.h
index c937346..583f018 100644
--- a/gtk/inspector/statistics.ui.h
+++ b/gtk/inspector/statistics.ui.h
@@ -1,4 +1,3 @@
-N_("Collect Statistics");
N_("Type");
N_("Self 1");
N_("Cumulative 1");
@@ -6,6 +5,4 @@ N_("Self 2");
N_("Cumulative 2");
N_("Self");
N_("Cumulative");
-N_("Self");
-N_("Cumulative");
N_("Enable statistics with GOBJECT_DEBUG=instance-count");
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 6162ff6..349d210 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -83,6 +83,26 @@
</packing>
</child>
<child>
+ <object class="GtkToggleButton" id="record_statistics_button">
+ <property name="tooltip-text" translatable="yes">Collect Statistics</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">media-record-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="resource_buttons">
<child>
<object class="GtkButton">
@@ -316,6 +336,7 @@
<child>
<object class="GtkInspectorStatistics">
<property name="visible">True</property>
+ <property name="button">record_statistics_button</property>
</object>
<packing>
<property name="name">statistics</property>
diff --git a/gtk/inspector/window.ui.h b/gtk/inspector/window.ui.h
index e1de5c1..498011c 100644
--- a/gtk/inspector/window.ui.h
+++ b/gtk/inspector/window.ui.h
@@ -1,6 +1,7 @@
N_("Select an Object");
N_("Show Details");
N_("Show all Objects");
+N_("Collect Statistics");
N_("Show Details");
N_("Show all Resources");
N_("Miscellaneous");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]