[Xfce4-commits] [xfce/xfce4-settings] 01/01: Add option to set the primary display (bug #8328)

noreply at xfce.org noreply at xfce.org
Fri Feb 6 01:53:20 CET 2015


This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository xfce/xfce4-settings.

commit d9158dc3f7a51c61b6d25acdb389ed8419c975c6
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Feb 6 01:22:18 2015 +0100

    Add option to set the primary display (bug #8328)
    
    Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
---
 dialogs/display-settings/display-dialog.glade |   63 ++++++++++++---------
 dialogs/display-settings/main.c               |   73 ++++++++++++++++++++++++-
 dialogs/display-settings/xfce-randr.c         |    5 ++
 3 files changed, 113 insertions(+), 28 deletions(-)

diff --git a/dialogs/display-settings/display-dialog.glade b/dialogs/display-settings/display-dialog.glade
index 3d467ce..39e1a92 100644
--- a/dialogs/display-settings/display-dialog.glade
+++ b/dialogs/display-settings/display-dialog.glade
@@ -47,7 +47,7 @@
                   <object class="GtkTable" id="table1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">7</property>
+                    <property name="n_rows">8</property>
                     <property name="n_columns">2</property>
                     <property name="column_spacing">12</property>
                     <property name="row_spacing">6</property>
@@ -58,8 +58,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</property>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -71,8 +71,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -84,8 +84,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -97,8 +97,8 @@
                       <packing>
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
@@ -110,8 +110,8 @@
                         <property name="use_underline">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">6</property>
-                        <property name="bottom_attach">7</property>
+                        <property name="top_attach">7</property>
+                        <property name="bottom_attach">8</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
@@ -125,8 +125,8 @@
                         <property name="use_underline">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
+                        <property name="top_attach">6</property>
+                        <property name="bottom_attach">7</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
@@ -140,8 +140,8 @@
                         <property name="use_underline">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
+                        <property name="top_attach">5</property>
+                        <property name="bottom_attach">6</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
@@ -155,19 +155,18 @@
                         <property name="use_underline">True</property>
                       </object>
                       <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
+                        <property name="top_attach">4</property>
+                        <property name="bottom_attach">5</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
                     <child>
                       <object class="GtkCheckButton" id="output-on">
-                        <property name="label" translatable="yes">_Use this output</property>
+                        <property name="label" translatable="yes">_Use this display</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                       </object>
@@ -185,14 +184,13 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
                         <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
+                        <property name="top_attach">3</property>
+                        <property name="bottom_attach">4</property>
                         <property name="x_options">GTK_FILL</property>
                         <property name="y_options">GTK_FILL</property>
                       </packing>
@@ -207,6 +205,22 @@
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkCheckButton" id="primary">
+                        <property name="label" translatable="yes">_Primary display</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip_text" translatable="yes">This is a hint for panels, docks and desktop to show on this display preferably.</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="right_attach">2</property>
+                        <property name="top_attach">2</property>
+                        <property name="bottom_attach">3</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -235,7 +249,6 @@
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                       </object>
@@ -257,7 +270,6 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
-                            <property name="use_action_appearance">False</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -272,7 +284,6 @@
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
-                            <property name="use_action_appearance">False</property>
                             <property name="use_stock">True</property>
                           </object>
                           <packing>
@@ -316,7 +327,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -332,7 +342,6 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 867e000..93d7dc1 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -163,6 +163,9 @@ static void display_settings_minimal_extend_right_toggled    (GtkToggleButton *b
 static void display_settings_minimal_only_display2_toggled   (GtkToggleButton *button,
                                                               GtkBuilder      *builder);
 
+static void display_setting_primary_toggled                  (GtkToggleButton *button,
+                                                              GtkBuilder *builder);
+
 static void
 display_settings_changed (void)
 {
@@ -980,6 +983,69 @@ display_setting_mirror_displays_populate (GtkBuilder *builder)
 }
 
 static void
+display_setting_primary_toggled (GtkToggleButton *togglebutton,
+                                 GtkBuilder *builder)
+{
+    guint m;
+
+    if (!xfce_randr)
+        return;
+
+    if (gtk_toggle_button_get_active (togglebutton))
+    {
+        /* Set currently active display as primary */
+        xfce_randr->status[active_output]=XFCE_OUTPUT_STATUS_PRIMARY;
+        xfce_randr_save_output (xfce_randr, "Default", display_channel,
+                                active_output);
+        /* and all others as secondary */
+        for (m = 0; m < xfce_randr->noutput; ++m)
+        {
+            if (m != active_output)
+            {
+                xfce_randr->status[m]=XFCE_OUTPUT_STATUS_SECONDARY;
+                xfce_randr_save_output (xfce_randr, "Default", display_channel, m);
+            }
+        }
+    }
+    else
+    {
+        xfce_randr->status[active_output]=XFCE_OUTPUT_STATUS_SECONDARY;
+        xfce_randr_save_output (xfce_randr, "Default", display_channel, active_output);
+    }
+
+    /* Apply the changes */
+    xfce_randr_apply (xfce_randr, "Default", display_channel);
+}
+
+static void
+display_setting_primary_populate (GtkBuilder *builder)
+{
+    GObject *check;
+
+    if (!xfce_randr)
+        return;
+
+    check = gtk_builder_get_object (builder, "primary");
+
+    if (xfce_randr->noutput > 1)
+        gtk_widget_show (GTK_WIDGET (check));
+    else
+    {
+        gtk_widget_hide (GTK_WIDGET (check));
+        return;
+    }
+
+    /* Block the "changed" signal to avoid triggering the confirmation dialog */
+    g_signal_handlers_block_by_func (check, display_setting_primary_toggled,
+                                     builder);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
+    xfce_randr->status[active_output] != XFCE_OUTPUT_STATUS_SECONDARY);
+    /* Unblock the signal */
+    g_signal_handlers_unblock_by_func (check, display_setting_primary_toggled,
+                                       builder);
+}
+
+static void
 display_setting_output_toggled (GtkToggleButton *togglebutton,
                                 GtkBuilder      *builder)
 {
@@ -1082,6 +1148,7 @@ display_settings_combobox_selection_changed (GtkComboBox *combobox,
 
         /* Update the combo boxes */
         display_setting_output_status_populate (builder);
+        display_setting_primary_populate (builder);
         display_setting_mirror_displays_populate (builder);
         display_setting_resolutions_populate (builder);
         display_setting_refresh_rates_populate (builder);
@@ -1233,7 +1300,7 @@ display_settings_dialog_new (GtkBuilder *builder)
 {
     GObject          *combobox;
     GtkCellRenderer  *renderer;
-    GObject          *label, *check, *mirror, *identify;
+    GObject          *label, *check, *primary, *mirror, *identify;
 
     /* Get the combobox */
     combobox = gtk_builder_get_object (builder, "randr-outputs");
@@ -1255,17 +1322,21 @@ display_settings_dialog_new (GtkBuilder *builder)
 
     /* Setup the combo boxes */
     check = gtk_builder_get_object (builder, "output-on");
+    primary = gtk_builder_get_object (builder, "primary");
     mirror = gtk_builder_get_object (builder, "mirror-displays");
     g_signal_connect (G_OBJECT (check), "toggled", G_CALLBACK (display_setting_output_toggled), builder);
+    g_signal_connect (G_OBJECT (primary), "toggled", G_CALLBACK (display_setting_primary_toggled), builder);
     g_signal_connect (G_OBJECT (mirror), "toggled", G_CALLBACK (display_setting_mirror_displays_toggled), builder);
     if (xfce_randr->noutput > 1)
     {
         gtk_widget_show (GTK_WIDGET (check));
+        gtk_widget_show (GTK_WIDGET (primary));
         gtk_widget_show (GTK_WIDGET (mirror));
     }
     else
     {
         gtk_widget_hide (GTK_WIDGET (check));
+        gtk_widget_hide (GTK_WIDGET (primary));
         gtk_widget_hide (GTK_WIDGET (mirror));
     }
 
diff --git a/dialogs/display-settings/xfce-randr.c b/dialogs/display-settings/xfce-randr.c
index 60537b4..1453fdc 100644
--- a/dialogs/display-settings/xfce-randr.c
+++ b/dialogs/display-settings/xfce-randr.c
@@ -163,6 +163,8 @@ xfce_randr_populate (XfceRandr *randr,
     guint           m, connected;
     guint          *output_ids = NULL;
 
+    XfconfChannel *display_channel = xfconf_channel_new ("displays");
+
     g_return_if_fail (randr != NULL);
     g_return_if_fail (randr->priv != NULL);
     g_return_if_fail (randr->priv->resources != NULL);
@@ -244,6 +246,9 @@ xfce_randr_populate (XfceRandr *randr,
 
         /* fill in the name used by the UI */
         randr->friendly_name[m] = xfce_randr_friendly_name (randr, m, output_ids[m]);
+
+        /* Update display info, primary display may have changed. */
+        xfce_randr_save_output (randr, "Default", display_channel, m);
         
         /* Replace spaces with underscore in name for xfconf compatibility */
         g_strcanon(randr->priv->output_info[m]->name, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_<>", '_');

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list