[sysprof/wip/visualizers] window: update zoom reset label to display current zoom
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] window: update zoom reset label to display current zoom
- Date: Thu, 29 Sep 2016 01:07:13 +0000 (UTC)
commit 60e917a5d13e261cbf8d905296e526df82816337
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 28 18:06:33 2016 -0700
window: update zoom reset label to display current zoom
src/resources/ui/sp-window.ui | 8 +++++++-
src/sp-window.c | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/src/resources/ui/sp-window.ui b/src/resources/ui/sp-window.ui
index f95a93a..86e14e9 100644
--- a/src/resources/ui/sp-window.ui
+++ b/src/resources/ui/sp-window.ui
@@ -215,6 +215,7 @@
<property name="visible">true</property>
<child>
<object class="GtkBox">
+ <property name="hexpand">true</property>
<property name="orientation">horizontal</property>
<property name="margin-bottom">12</property>
<property name="visible">true</property>
@@ -240,8 +241,13 @@
<child>
<object class="GtkButton">
<property name="action-name">zoom.zoom-one</property>
- <property name="label" translatable="yes">100%</property>
<property name="visible">true</property>
+ <child>
+ <object class="GtkLabel" id="zoom_one_label">
+ <property name="width-chars">5</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
</object>
</child>
<child>
diff --git a/src/sp-window.c b/src/sp-window.c
index f1840a1..93e011c 100644
--- a/src/sp-window.c
+++ b/src/sp-window.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <glib/gi18n.h>
+#include <math.h>
#include <sysprof.h>
#include <sysprof-ui.h>
@@ -52,6 +53,7 @@ struct _SpWindow
GtkStack *view_stack;
SpVisualizerView *visualizers;
SpZoomManager *zoom_manager;
+ GtkLabel *zoom_one_label;
guint stats_handler;
@@ -715,6 +717,17 @@ sp_window_reset_paned (SpWindow *self)
gtk_paned_set_position (self->paned, MAX (min_height, MIN (nat_height, 300)));
}
+static gboolean
+zoom_level_to_string (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ gdouble percent = 100.0 * g_value_get_double (from_value);
+ g_value_take_string (to_value, g_strdup_printf ("%u%%", (guint)ceil (percent)));
+ return TRUE;
+}
+
static void
sp_window_destroy (GtkWidget *widget)
{
@@ -786,6 +799,8 @@ sp_window_class_init (SpWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, SpWindow, title);
gtk_widget_class_bind_template_child (widget_class, SpWindow, view_stack);
gtk_widget_class_bind_template_child (widget_class, SpWindow, visualizers);
+ gtk_widget_class_bind_template_child (widget_class, SpWindow, zoom_manager);
+ gtk_widget_class_bind_template_child (widget_class, SpWindow, zoom_one_label);
}
static void
@@ -834,6 +849,10 @@ sp_window_init (SpWindow *self)
self,
G_CONNECT_SWAPPED);
+ g_object_bind_property_full (self->zoom_manager, "zoom", self->zoom_one_label, "label",
+ G_BINDING_SYNC_CREATE,
+ zoom_level_to_string, NULL, NULL, NULL);
+
/*
* Setup actions for the window.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]