[Xfce4-commits] <xfce4-settings:bluesabre/display-settings> Show the confirmation dialog when {en, dis}abling outputs

Simon Steinbeiss noreply at xfce.org
Thu Oct 25 11:14:03 CEST 2012


Updating branch refs/heads/bluesabre/display-settings
         to 9038d18e4b635fddd9c0a6b93781a89260e587e2 (commit)
       from a4dbaf9416a626e058683f631fc037e282f24fa7 (commit)

commit 9038d18e4b635fddd9c0a6b93781a89260e587e2
Author: Lionel Le Folgoc <lionel at lefolgoc.net>
Date:   Wed Oct 24 19:01:31 2012 +0200

    Show the confirmation dialog when {en,dis}abling outputs
    
    Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>

 dialogs/display-settings/main.c |   43 ++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index ac2d09e..069715a 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -1246,41 +1246,52 @@ static void
 display_setting_output_toggled (GtkToggleButton *togglebutton,
                                 GtkBuilder      *builder)
 {
+    RRMode old_mode;
+
     if (!xfce_randr)
         return;
 
     if (xfce_randr->noutput <= 1)
         return;
 
+    old_mode = xfce_randr->mode[active_output];
+
     if (gtk_toggle_button_get_active (togglebutton))
-    {
         xfce_randr->mode[active_output] =
             xfce_randr_preferred_mode (xfce_randr, active_output);
-        /* Apply the changes */
-        xfce_randr_save_output (xfce_randr, "Default", display_channel,
-                                active_output, FALSE);
-        xfce_randr_apply (xfce_randr, "Default", display_channel);
-    }
     else
     {
-        /* Prevents the user from disabling everything… */
-        if (display_settings_get_n_active_outputs () > 1)
-        {
-            xfce_randr->mode[active_output] = None;
-            /* Apply the changes */
-            xfce_randr_save_output (xfce_randr, "Default", display_channel,
-                                    active_output, FALSE);
-            xfce_randr_apply (xfce_randr, "Default", display_channel);
-        }
-        else
+        if (display_settings_get_n_active_outputs () == 1)
         {
             xfce_dialog_show_warning (NULL,
                                       _("The last active output must not be disabled, the system would"
                                         " be unusable."),
                                       _("Selected output not disabled"));
             /* Set it back to active */
+            g_object_disconnect (togglebutton, "any_signal::toggled",
+                                 display_setting_output_toggled,
+                                 builder, NULL);
             gtk_toggle_button_set_active (togglebutton, TRUE);
+            g_signal_connect (G_OBJECT (togglebutton), "toggled",
+                              G_CALLBACK (display_setting_output_toggled),
+                              builder);
+            return;
         }
+        xfce_randr->mode[active_output] = None;
+    }
+
+    /* Apply the changes */
+    xfce_randr_save_output (xfce_randr, "Default", display_channel,
+                            active_output, FALSE);
+    xfce_randr_apply (xfce_randr, "Default", display_channel);
+
+    /* Ask user confirmation */
+    if (!display_setting_timed_confirmation (builder))
+    {
+        xfce_randr->mode[active_output] = old_mode;
+        xfce_randr_save_output (xfce_randr, "Default", display_channel,
+                                active_output, FALSE);
+        xfce_randr_apply (xfce_randr, "Default", display_channel);
     }
 }
 


More information about the Xfce4-commits mailing list