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

Nick Schermer noreply at xfce.org
Sun Oct 28 10:45:28 CET 2012


Updating branch refs/heads/master
         to 536274e8a8517c99e7be8e897f1f3b7392bf7606 (commit)
       from 2810861ee25677d8612931b48f6f6dc749bade1c (commit)

commit 536274e8a8517c99e7be8e897f1f3b7392bf7606
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