[Xfce4-commits] <xfce4-settings:xrandr-display-settings> Don't show on and off when there is only one screen.

Jérôme Guelfucci noreply at xfce.org
Fri Jun 25 19:30:02 CEST 2010


Updating branch refs/heads/xrandr-display-settings
         to 906545a1b55fe46edc1546c83e2192c9a97199d9 (commit)
       from 55d5aa18eda44206073b0a049cd1c2102f851853 (commit)

commit 906545a1b55fe46edc1546c83e2192c9a97199d9
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Fri Jun 25 19:28:25 2010 +0200

    Don't show on and off when there is only one screen.
    
    We don't want the user to disable his last remaining screen... More work
    coming on that topic.

 dialogs/display-settings/main.c |   63 ++++++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 8 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 1a3e971..3e10ff0 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -137,6 +137,29 @@ display_setting_combo_box_get_value (GtkComboBox *combobox,
 
 
 
+static gint
+display_setting_get_n_active_outputs (void)
+{
+    gint noutput;
+
+    noutput = 0;
+
+    if (xfce_randr)
+    {
+        gint i;
+
+        for (i = 0; i < xfce_randr->resources->noutput; i++)
+        {
+            if (xfce_randr->status[i] != XFCE_OUTPUT_STATUS_NONE)
+                noutput++;
+        }
+    }
+
+    return noutput;
+}
+
+
+
 #ifdef HAS_RANDR_ONE_POINT_TWO
 static void
 display_setting_reflections_changed (GtkComboBox *combobox,
@@ -500,14 +523,21 @@ static void
 display_setting_output_toggled (GtkToggleButton *togglebutton,
                                 GtkBuilder      *builder)
 {
-    GObject *radio;
-    gint     is_active;
+    gint is_active;
 
     if (!xfce_randr)
         return;
 
-    radio = gtk_builder_get_object (builder, "randr-on");
-    is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
+    if (display_setting_get_n_active_outputs () > 1)
+    {
+        GObject *radio;
+        radio = gtk_builder_get_object (builder, "randr-on");
+        is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
+    }
+    else
+    {
+        is_active = TRUE;
+    }
 
     if (is_active && XFCE_RANDR_MODE (xfce_randr) == None)
         XFCE_RANDR_MODE (xfce_randr) =
@@ -530,6 +560,9 @@ display_setting_output_status_populate (GtkBuilder *builder)
     if (!xfce_randr)
         return;
 
+    if (display_setting_get_n_active_outputs () <= 1)
+        return;
+
     radio_on = gtk_builder_get_object (builder, "randr-on");
     radio_off = gtk_builder_get_object (builder, "randr-off");
 
@@ -780,12 +813,26 @@ display_settings_dialog_new (GtkBuilder *builder)
     if (xfce_randr != NULL)
     {
         radio = gtk_builder_get_object (builder, "randr-on");
-        gtk_widget_show (GTK_WIDGET (radio));
-        g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (display_setting_output_toggled), builder);
+        if (display_setting_get_n_active_outputs () > 1)
+        {
+            gtk_widget_show (GTK_WIDGET (radio));
+            g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (display_setting_output_toggled), builder);
+        }
+        else
+        {
+            gtk_widget_hide (GTK_WIDGET (radio));
+        }
 
         radio = gtk_builder_get_object (builder, "randr-off");
-        gtk_widget_show (GTK_WIDGET (radio));
-        g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (display_setting_output_toggled), builder);
+        if (display_setting_get_n_active_outputs () > 1)
+        {
+            gtk_widget_show (GTK_WIDGET (radio));
+            g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (display_setting_output_toggled), builder);
+        }
+        else
+        {
+            gtk_widget_hide (GTK_WIDGET (radio));
+        }
 
         label = gtk_builder_get_object (builder, "label-reflection");
         gtk_widget_show (GTK_WIDGET (label));



More information about the Xfce4-commits mailing list