[gnome-control-center/gnome-3-30] display: Sync scale button state after update
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-30] display: Sync scale button state after update
- Date: Thu, 18 Oct 2018 15:42:12 +0000 (UTC)
commit 5c94da6757aaf4f219b4a5e278129f2d68b8370e
Author: Benjamin Berg <bberg redhat com>
Date: Tue Oct 16 18:15:37 2018 +0200
display: Sync scale button state after update
We need to re-sync the scale button scale when updating the state
dynamically. Otherwise changing the resolution will always show a scale
of 100% (first item) rather than the actual active one.
panels/display/cc-display-panel.c | 40 +++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index c58472c0f..c96086756 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -820,6 +820,23 @@ make_label_for_scale (double scale)
return gtk_label_new (text);
}
+static void
+scale_buttons_sync (GtkWidget *bbox,
+ CcDisplayMonitor *output)
+{
+ g_autoptr(GList) children;
+ GList *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (bbox));
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *button = l->data;
+ double scale = *(double*) g_object_get_data (G_OBJECT (button), "scale");
+ if (scale == cc_display_monitor_get_scale (output))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ }
+}
+
#define MAX_N_SCALES 5
static void
setup_scale_buttons (GtkWidget *bbox,
@@ -856,27 +873,12 @@ setup_scale_buttons (GtkWidget *bbox,
group = GTK_RADIO_BUTTON (button);
}
+ scale_buttons_sync (bbox, output);
+
gtk_widget_show_all (bbox);
}
#undef MAX_N_SCALES
-static void
-scale_buttons_sync (GtkWidget *bbox,
- CcDisplayMonitor *output)
-{
- g_autoptr(GList) children;
- GList *l;
-
- children = gtk_container_get_children (GTK_CONTAINER (bbox));
- for (l = children; l; l = l->next)
- {
- GtkWidget *button = l->data;
- double scale = *(double*) g_object_get_data (G_OBJECT (button), "scale");
- if (scale == cc_display_monitor_get_scale (output))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
- }
-}
-
static GtkWidget *
make_scale_row (CcDisplayPanel *panel, CcDisplayMonitor *output)
{
@@ -896,11 +898,9 @@ make_scale_row (CcDisplayPanel *panel, CcDisplayMonitor *output)
g_object_set_data (G_OBJECT (bbox), "panel", panel);
g_signal_connect_object (output, "mode", G_CALLBACK (setup_scale_buttons),
bbox, G_CONNECT_SWAPPED);
- setup_scale_buttons (bbox, output);
-
g_signal_connect_object (output, "scale", G_CALLBACK (scale_buttons_sync),
bbox, G_CONNECT_SWAPPED);
- scale_buttons_sync (bbox, output);
+ setup_scale_buttons (bbox, output);
gtk_widget_show_all (row);
gtk_widget_set_no_show_all (row, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]