From b26a8bdeedf845917b5b1a682e22d53062fe3f4b Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 22 Feb 2019 16:17:26 +0100 Subject: [PATCH] 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 c0a3438cb..7970e8654 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) {