[gnome-control-center/benzea/ensure-valid-config-after-loading: 9/9] display: Ensure configuration has the expected type



commit 59221d7bb3d43139f95cc510b868bfbc81807071
Author: Benjamin Berg <bberg redhat com>
Date:   Fri Feb 22 16:17:26 2019 +0100

    display: Ensure configuration has the expected type
    
    In almost all cases, the configuration will be "valid" in the sense that
    g-c-c can represent it in the UI. However, there are cases like
    mirroring setups with three monitors that we do not allow.
    
    In case that the user has such a configuration, ensure that the
    configuration we represent is actually valid according to our
    expectations. This should not affect normal use cases, but allows users
    to recover again if the configuration is broken for some reason.
    
    Fixes #383

 panels/display/cc-display-panel.c | 40 ++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 6e12fd11d..12b29bf6b 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -169,25 +169,6 @@ cc_panel_get_selected_type (CcDisplayPanel *panel)
     g_assert_not_reached ();
 }
 
-static void
-cc_panel_set_selected_type (CcDisplayPanel *panel, CcDisplayConfigType type)
-{
-  switch (type)
-    {
-    case CC_DISPLAY_CONFIG_JOIN:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_join), TRUE);
-      break;
-    case CC_DISPLAY_CONFIG_CLONE:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_mirror), TRUE);
-      break;
-    case CC_DISPLAY_CONFIG_SINGLE:
-      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_single), TRUE);
-      break;
-    default:
-      g_assert_not_reached ();
-    }
-}
-
 static void
 config_ensure_of_type (CcDisplayPanel *panel, CcDisplayConfigType type)
 {
@@ -278,6 +259,27 @@ config_ensure_of_type (CcDisplayPanel *panel, CcDisplayConfigType type)
   rebuild_ui (panel);
 }
 
+static void
+cc_panel_set_selected_type (CcDisplayPanel *panel, CcDisplayConfigType type)
+{
+  switch (type)
+    {
+    case CC_DISPLAY_CONFIG_JOIN:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_join), TRUE);
+      break;
+    case CC_DISPLAY_CONFIG_CLONE:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_mirror), TRUE);
+      break;
+    case CC_DISPLAY_CONFIG_SINGLE:
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (panel->config_type_single), TRUE);
+      break;
+    default:
+      g_assert_not_reached ();
+    }
+
+  config_ensure_of_type (panel, type);
+}
+
 static void
 monitor_labeler_hide (CcDisplayPanel *self)
 {


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