[gnome-control-center/benzea/hide-unsupported-resolutions: 2/3] display: Sync scale button state after update



commit ef52df9e50e833aab892bb39d3478734538d1204
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 43555a4b8..dc0d3e468 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -848,6 +848,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,
@@ -888,27 +905,12 @@ setup_scale_buttons (GtkWidget        *bbox,
       group = GTK_RADIO_BUTTON (button);
     }
 
+  scale_buttons_sync (bbox, output);
+
   gtk_widget_show (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)
 {
@@ -930,11 +932,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);
 
   g_signal_connect_object (output, "mode", G_CALLBACK (scale_row_sync_visibility),
                            row, G_CONNECT_SWAPPED);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]