[Xfce4-commits] <xfce4-settings:master> Save outputs to xfconf in two passes

Nick Schermer noreply at xfce.org
Sat Aug 28 23:04:46 CEST 2010


Updating branch refs/heads/master
         to dda7b498ad9e67bd9f402fb6ef2ebe9d82505cf0 (commit)
       from 886b52f4702b9ffc3567f4f0e1750da915a5f504 (commit)

commit dda7b498ad9e67bd9f402fb6ef2ebe9d82505cf0
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date:   Sat Jun 26 17:04:39 2010 +0200

    Save outputs to xfconf in two passes
    
    The first pass saves only active outputs, and the second one disabled outputs.
    This improves the active outputs' tracking of the previous commit.

 dialogs/display-settings/xfce-randr.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/dialogs/display-settings/xfce-randr.c b/dialogs/display-settings/xfce-randr.c
index 69d137a..25416ad 100644
--- a/dialogs/display-settings/xfce-randr.c
+++ b/dialogs/display-settings/xfce-randr.c
@@ -475,7 +475,7 @@ xfce_randr_save (XfceRandr     *randr,
                  XfconfChannel *channel)
 {
     gchar        property[512];
-    guint        n;
+    guint        n, nsaved;
 
     g_return_if_fail (XFCONF_IS_CHANNEL (channel));
 
@@ -483,13 +483,29 @@ xfce_randr_save (XfceRandr     *randr,
     g_snprintf (property, sizeof (property), "/%s/Layout", scheme);
     xfconf_channel_set_string (channel, property, "Outputs");
 
-    /* save connected outputs */
+    /* first pass: save connected and active outputs */
+    nsaved = 0;
     for (n = 0; n < randr->noutput; ++n)
     {
-        g_snprintf (property, sizeof (property), "Output%u", n);
+        if (randr->mode[n] == None)
+            continue;
+
+        g_snprintf (property, sizeof (property), "Output%u", nsaved++);
+        xfce_randr_save_device (randr, scheme, channel, n, property);
+    }
+
+    /* second pass: save connected and disabled outputs */
+    for (n = 0; n < randr->noutput; ++n)
+    {
+        if (randr->mode[n] != None)
+            continue;
+
+        g_snprintf (property, sizeof (property), "Output%u", nsaved++);
         xfce_randr_save_device (randr, scheme, channel, n, property);
     }
 
+    g_assert_cmpuint (nsaved, ==, randr->noutput);
+
     /* store the number of outputs saved */
     g_snprintf (property, sizeof (property), "/%s/NumOutputs", scheme);
     xfconf_channel_set_int (channel, property, randr->noutput);



More information about the Xfce4-commits mailing list