[Xfce4-commits] <xfce4-settings:bluesabre/display-settings> Changed to switch statement and static variables.

Sean Davis noreply at xfce.org
Wed Sep 26 21:46:01 CEST 2012


Updating branch refs/heads/bluesabre/display-settings
         to 82b0324a5c4dbfa62e87d991f22ef9d54b0769de (commit)
       from 46f17f9d57fe52af6c1c2af5c7b7fa4d041eff1d (commit)

commit 82b0324a5c4dbfa62e87d991f22ef9d54b0769de
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Wed Sep 26 15:43:56 2012 -0400

    Changed to switch statement and static variables.

 dialogs/display-settings/main.c       |   76 ++++++++++++++++-----------------
 dialogs/display-settings/xfce-randr.h |    4 ++
 2 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 350f3bb..2147c68 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -247,9 +247,6 @@ static void
 display_setting_positions_changed (GtkComboBox *combobox,
                                      GtkBuilder  *builder)
 {
-    /* This part is incomplete.  We should check if the display combobox is 
-       also already selected, then move on with working with the specific 
-       displays. */
     gint value, current_display, selected_display, n;
     GObject *display_combobox;
     XfceRRMode   *modes;
@@ -267,44 +264,45 @@ display_setting_positions_changed (GtkComboBox *combobox,
     /* Store the Current Display */
     current_display = xfce_randr->active_output;
     
-    /* FIXME: Extend Left (Move primary screen right/make secondary primary) */
-    if (value == 0)
-    {
-        /* Walk all supported modes of current display */
-        modes = XFCE_RANDR_SUPPORTED_MODES (xfce_randr);
-        for (n = 0; n < XFCE_RANDR_OUTPUT_INFO (xfce_randr)->nmode; ++n)
-        {
-            /* Find the current mode. */
-            if (modes[n].id == XFCE_RANDR_MODE (xfce_randr))
+    switch (value) {
+        case XFCE_RANDR_PLACEMENT_LEFT: // Extend Left FIXME
+            /* Walk all supported modes of current display */
+            modes = XFCE_RANDR_SUPPORTED_MODES (xfce_randr);
+            for (n = 0; n < XFCE_RANDR_OUTPUT_INFO (xfce_randr)->nmode; ++n)
             {
-                /* Change active output to secondary display. */
-                xfce_randr->active_output = selected_display;
-                /* Move the secondary display to the right of the primary display. */
-                XFCE_RANDR_POS_X (xfce_randr) = modes[n].width;
-                break;
+                /* Find the current mode. */
+                if (modes[n].id == XFCE_RANDR_MODE (xfce_randr))
+                {
+                    /* Change active output to secondary display. */
+                    xfce_randr->active_output = selected_display;
+                    /* Move the secondary display to the right of the primary display. */
+                    XFCE_RANDR_POS_X (xfce_randr) = modes[n].width;
+                    break;
+                }
             }
-        }
-    }
-    
-    /* Extend Right */
-    if (value == 1)
-    {
-        /* Change active output to secondary display. */
-        xfce_randr->active_output = selected_display;
-        
-        /* Find the current mode. */
-        modes = XFCE_RANDR_SUPPORTED_MODES (xfce_randr);
-        for (n = 0; n < XFCE_RANDR_OUTPUT_INFO (xfce_randr)->nmode; ++n)
-        {
-            if (modes[n].id == XFCE_RANDR_MODE (xfce_randr))
+            break;
+        case XFCE_RANDR_PLACEMENT_RIGHT: // Extend Right
+            /* Change active output to secondary display. */
+            xfce_randr->active_output = selected_display;
+            
+            /* Find the current mode. */
+            modes = XFCE_RANDR_SUPPORTED_MODES (xfce_randr);
+            for (n = 0; n < XFCE_RANDR_OUTPUT_INFO (xfce_randr)->nmode; ++n)
             {
-                /* Change active output to primary display. */
-                xfce_randr->active_output = current_display;
-                /* Move the primary display to the right of the secondary display. */
-                XFCE_RANDR_POS_X (xfce_randr) = modes[n].width;
-                break;
+                if (modes[n].id == XFCE_RANDR_MODE (xfce_randr))
+                {
+                    /* Change active output to primary display. */
+                    xfce_randr->active_output = current_display;
+                    /* Move the primary display to the right of the secondary display. */
+                    XFCE_RANDR_POS_X (xfce_randr) = modes[n].width;
+                    break;
+                }
             }
-        }
+            break;
+        case XFCE_RANDR_PLACEMENT_UP:
+        case XFCE_RANDR_PLACEMENT_DOWN:
+        default:
+            break;
     }
     
     /* Restore the current display to the primary display. */
@@ -347,13 +345,13 @@ display_setting_positions_populate (GtkBuilder *builder)
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
     gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                         COLUMN_COMBO_NAME, _("left of"),
-                        COLUMN_COMBO_VALUE, 0, -1);
+                        COLUMN_COMBO_VALUE, XFCE_RANDR_PLACEMENT_LEFT, -1);
 
     /* Insert right-of */
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
     gtk_list_store_set (GTK_LIST_STORE (model), &iter,
                         COLUMN_COMBO_NAME, _("right of"),
-                        COLUMN_COMBO_VALUE, 1, -1);
+                        COLUMN_COMBO_VALUE, XFCE_RANDR_PLACEMENT_RIGHT, -1);
 
     
     /* Reconnect the signal */
diff --git a/dialogs/display-settings/xfce-randr.h b/dialogs/display-settings/xfce-randr.h
index 93bbdbb..9aed8de 100644
--- a/dialogs/display-settings/xfce-randr.h
+++ b/dialogs/display-settings/xfce-randr.h
@@ -34,6 +34,10 @@
 #define XFCE_RANDR_POS_Y(randr)           (randr->position[randr->active_output].y)
 #define XFCE_RANDR_ROTATIONS_MASK         (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
 #define XFCE_RANDR_REFLECTIONS_MASK       (RR_Reflect_X|RR_Reflect_Y)
+#define XFCE_RANDR_PLACEMENT_UP           0
+#define XFCE_RANDR_PLACEMENT_RIGHT        1
+#define XFCE_RANDR_PLACEMENT_DOWN         2
+#define XFCE_RANDR_PLACEMENT_LEFT         3
 
 /* check for randr 1.3 or better */
 #if RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3)


More information about the Xfce4-commits mailing list