mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
window: update zoom reset label to display current zoom
This commit is contained in:
@ -215,6 +215,7 @@
|
|||||||
<property name="visible">true</property>
|
<property name="visible">true</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
|
<property name="hexpand">true</property>
|
||||||
<property name="orientation">horizontal</property>
|
<property name="orientation">horizontal</property>
|
||||||
<property name="margin-bottom">12</property>
|
<property name="margin-bottom">12</property>
|
||||||
<property name="visible">true</property>
|
<property name="visible">true</property>
|
||||||
@ -240,8 +241,13 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="action-name">zoom.zoom-one</property>
|
<property name="action-name">zoom.zoom-one</property>
|
||||||
<property name="label" translatable="yes">100%</property>
|
|
||||||
<property name="visible">true</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <math.h>
|
||||||
#include <sysprof.h>
|
#include <sysprof.h>
|
||||||
#include <sysprof-ui.h>
|
#include <sysprof-ui.h>
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ struct _SpWindow
|
|||||||
GtkStack *view_stack;
|
GtkStack *view_stack;
|
||||||
SpVisualizerView *visualizers;
|
SpVisualizerView *visualizers;
|
||||||
SpZoomManager *zoom_manager;
|
SpZoomManager *zoom_manager;
|
||||||
|
GtkLabel *zoom_one_label;
|
||||||
|
|
||||||
guint stats_handler;
|
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)));
|
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
|
static void
|
||||||
sp_window_destroy (GtkWidget *widget)
|
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, title);
|
||||||
gtk_widget_class_bind_template_child (widget_class, SpWindow, view_stack);
|
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, 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
|
static void
|
||||||
@ -834,6 +849,10 @@ sp_window_init (SpWindow *self)
|
|||||||
self,
|
self,
|
||||||
G_CONNECT_SWAPPED);
|
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.
|
* Setup actions for the window.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user