summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukefromdc <[email protected]>2017-10-27 00:40:50 -0400
committerraveit65 <[email protected]>2017-11-05 18:11:05 +0100
commit458315df723f211956edcbbf96e8c84acc9da06c (patch)
treee729283dabc8f7d0895ad705b5303cf5d76c0899
parentc5bce79ac7c654716cd8e1d69882a67053d469ef (diff)
downloadmate-sensors-applet-458315df723f211956edcbbf96e8c84acc9da06c.tar.bz2
mate-sensors-applet-458315df723f211956edcbbf96e8c84acc9da06c.tar.xz
Stop jumping applet as numbers change
Hold the value labels to the largest size they have been unless the units have just been shown or hidden.
-rw-r--r--sensors-applet/active-sensor.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/sensors-applet/active-sensor.c b/sensors-applet/active-sensor.c
index 78d03b6..f4097a3 100644
--- a/sensors-applet/active-sensor.c
+++ b/sensors-applet/active-sensor.c
@@ -493,8 +493,11 @@ void active_sensor_update(ActiveSensor *active_sensor,
gdouble sensor_multiplier;
gdouble sensor_offset;
gdouble sensor_value;
- GdkPixbuf *icon_pixbuf;
- gchar *graph_color;
+ GdkPixbuf *icon_pixbuf;
+ gchar *graph_color;
+ gint label_min_width;
+ gint label_width;
+ GtkRequisition req;
/* to build the list of labels as we go */
gchar *value_text = NULL;
@@ -511,6 +514,7 @@ void active_sensor_update(ActiveSensor *active_sensor,
/* hidden gsettings options */
gint font_size = 0;
gboolean hide_units = FALSE;
+ gboolean hide_units_old = FALSE;
g_assert(active_sensor);
g_assert(active_sensor->sensor_row);
@@ -565,7 +569,7 @@ void active_sensor_update(ActiveSensor *active_sensor,
sensor_value = -1;
} else {
/* use hidden gsettings key for hide_units */
-
+ hide_units_old = hide_units;
hide_units = g_settings_get_boolean(sensors_applet->settings, HIDE_UNITS);
/* scale value and set text using this
@@ -713,8 +717,22 @@ void active_sensor_update(ActiveSensor *active_sensor,
value_text = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text);
g_free(old_value_text);
}
+ /*Keep the label as large as previous size unless hide_units has changed */
+ gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value),
+ &req, NULL);
+ if (!(hide_units_old == hide_units)){
+ label_min_width = 0;
+ }
+ else{
+ label_min_width = req.width;
+ }
gtk_label_set_markup(GTK_LABEL(active_sensor->value),
value_text);
+ gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value),
+ &req, NULL);
+ label_width = MAX(req.width, label_min_width);
+ gtk_widget_set_size_request (GTK_WIDGET (active_sensor->value),
+ label_min_width, req.height);
if (tooltip) {
gtk_widget_set_tooltip_text(active_sensor->value,
tooltip);