[Xfce4-commits] [xfce/xfce4-settings] 55/67: display: Make profile buttons consistent in minimal dialog

noreply at xfce.org noreply at xfce.org
Sat Sep 22 11:23:46 CEST 2018


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

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-settings.

commit 5da47fa220fc12e3d393963ff8f8bd8af14f067d
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Sun Sep 2 00:49:41 2018 +0200

    display: Make profile buttons consistent in minimal dialog
---
 dialogs/display-settings/main.c                    |  51 ++--
 .../display-settings/minimal-display-dialog.glade  | 269 ++++++++++++---------
 2 files changed, 197 insertions(+), 123 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 4cbaec6..a7c5c7f 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -1317,7 +1317,7 @@ display_settings_minimal_profile_populate (GtkBuilder *builder)
     current = g_list_first (profiles);
     while (current)
     {
-        GtkWidget *profile_radio;
+        GtkWidget *box, *profile_radio, *label, *image;
         gchar *property;
         gchar *profile_name;
 
@@ -1325,16 +1325,26 @@ display_settings_minimal_profile_populate (GtkBuilder *builder)
         property = g_strdup_printf ("/%s", (gchar *)current->data);
         profile_name = xfconf_channel_get_string (display_channel, property, NULL);
 
-        profile_radio = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (profile_display1), profile_name);
+        label = gtk_label_new (profile_name);
+        image = gtk_image_new_from_icon_name ("gtk-about", 96);
+        gtk_image_set_pixel_size (GTK_IMAGE (image), 96);
+
+        profile_radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (profile_display1));
+        gtk_container_add (GTK_CONTAINER (profile_radio), image);
+        g_object_set_data (G_OBJECT (profile_radio), "profile", profile_name);
         gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (profile_radio), FALSE);
         gtk_widget_set_size_request (GTK_WIDGET (profile_radio), 128, 128);
-        gtk_box_pack_start (GTK_BOX (profile_box), profile_radio, FALSE, FALSE, 0);
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+        gtk_box_pack_start (GTK_BOX (box), profile_radio, FALSE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 3);
+        gtk_box_pack_start (GTK_BOX (profile_box), box, FALSE, FALSE, 0);
+
         g_signal_connect (profile_radio, "toggled", G_CALLBACK (display_settings_minimal_profile_apply),
                           builder);
 
-        current = g_list_next(current);
+        current = g_list_next (current);
         g_free (property);
-        g_free (profile_name);
     }
 
     gtk_widget_show_all (GTK_WIDGET (profile_box));
@@ -1546,10 +1556,10 @@ display_settings_profile_changed (GtkTreeSelection *selection, GtkBuilder *build
 static void
 display_settings_minimal_profile_apply (GtkToggleButton *widget, GtkBuilder *builder)
 {
-    const gchar  *profile;
-    gchar        *profile_hash;
+    gchar  *profile;
+    gchar  *profile_hash;
 
-    profile = gtk_button_get_label (GTK_BUTTON (widget));
+    profile = (gchar *) g_object_get_data (G_OBJECT (widget), "profile");
     profile_hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, profile, strlen(profile));
     xfce_randr_apply (xfce_randr, profile_hash, display_channel);
 }
@@ -3546,21 +3556,32 @@ display_settings_show_minimal_dialog (GdkDisplay *display)
         /* Auto-apply the first profile in the list */
         if (xfconf_channel_get_bool (display_channel, "/AutoEnableProfiles", TRUE))
         {
+            /* Walz down the widget hierarchy: profile-box -> gtkbox -> gtkradiobutton */
             GObject *profile_box;
             profile_box  = gtk_builder_get_object (builder, "profile-box");
             if (GTK_IS_CONTAINER (profile_box))
             {
                 GList *children = NULL;
-                GList *current;
+                GList *first_profile_box;
 
                 children = gtk_container_get_children (GTK_CONTAINER (profile_box));
-                current = g_list_first (children);
-                while (current)
+                first_profile_box = g_list_first (children);
+                if (first_profile_box)
                 {
-                    GtkWidget* widget = GTK_WIDGET (children->data);
-                    if (widget != NULL) {
-                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
-                        break;
+                    GList *grand_children = NULL;
+                    GList *current;
+                    GtkWidget *box = GTK_WIDGET (first_profile_box->data);
+
+                    grand_children = gtk_container_get_children (GTK_CONTAINER (box));
+                    current = g_list_first (grand_children);
+                    if (current)
+                    {
+                        GtkWidget* widget = GTK_WIDGET (grand_children->data);
+
+                        if (GTK_IS_TOGGLE_BUTTON (widget))
+                        {
+                            gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
+                        }
                     }
                 }
             }
diff --git a/dialogs/display-settings/minimal-display-dialog.glade b/dialogs/display-settings/minimal-display-dialog.glade
index 71f6095..1c165c2 100644
--- a/dialogs/display-settings/minimal-display-dialog.glade
+++ b/dialogs/display-settings/minimal-display-dialog.glade
@@ -26,173 +26,226 @@
             <property name="row_spacing">3</property>
             <property name="column_spacing">24</property>
             <child>
-              <object class="GtkLabel" id="label1">
-                <property name="width_request">128</property>
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Only Display 1</property>
-                <property name="ellipsize">middle</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label2">
-                <property name="width_request">128</property>
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="tooltip_text" translatable="yes">Mirror Displays</property>
-                <property name="label" translatable="yes">Mirror Displays</property>
-                <property name="ellipsize">middle</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label3">
-                <property name="width_request">128</property>
+              <object class="GtkBox" id="profile-box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="tooltip_text" translatable="yes">Extend to the right</property>
-                <property name="label" translatable="yes">Extend to the right</property>
-                <property name="ellipsize">middle</property>
+                <property name="spacing">24</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="top_attach">1</property>
+                <property name="left_attach">4</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label4">
-                <property name="width_request">128</property>
+              <object class="GtkBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Only Display 2</property>
-                <property name="ellipsize">middle</property>
-              </object>
-              <packing>
-                <property name="left_attach">3</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="mirror">
-                <property name="width_request">128</property>
-                <property name="height_request">128</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">center</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">False</property>
-                <property name="group">display1</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
                 <child>
-                  <object class="GtkImage" id="image2">
+                  <object class="GtkRadioButton" id="display1">
+                    <property name="width_request">128</property>
+                    <property name="height_request">128</property>
                     <property name="visible">True</property>
-                    <property name="can_focus">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="halign">center</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">False</property>
+                    <child>
+                      <object class="GtkImage" id="image1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
                 </child>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="extend_right">
-                <property name="width_request">128</property>
-                <property name="height_request">128</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">center</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">False</property>
-                <property name="group">display1</property>
                 <child>
-                  <object class="GtkImage" id="image3">
+                  <object class="GtkLabel" id="label1">
+                    <property name="width_request">128</property>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Only Display 1</property>
+                    <property name="ellipsize">middle</property>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">2</property>
+                <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkRadioButton" id="display2">
-                <property name="width_request">128</property>
-                <property name="height_request">128</property>
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">center</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">False</property>
-                <property name="group">display1</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
+                <child>
+                  <object class="GtkRadioButton" id="mirror">
+                    <property name="width_request">128</property>
+                    <property name="height_request">128</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="halign">center</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">False</property>
+                    <property name="group">display1</property>
+                    <child>
+                      <object class="GtkImage" id="image2">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
                 <child>
-                  <object class="GtkImage" id="image4">
+                  <object class="GtkLabel" id="label2">
+                    <property name="width_request">128</property>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Mirror Displays</property>
+                    <property name="label" translatable="yes">Mirror Displays</property>
+                    <property name="ellipsize">middle</property>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">3</property>
+                <property name="left_attach">1</property>
                 <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkRadioButton" id="display1">
-                <property name="width_request">128</property>
-                <property name="height_request">128</property>
+              <object class="GtkBox">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="halign">center</property>
-                <property name="active">True</property>
-                <property name="draw_indicator">False</property>
+                <property name="can_focus">False</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
                 <child>
-                  <object class="GtkImage" id="image1">
+                  <object class="GtkRadioButton" id="extend_right">
+                    <property name="width_request">128</property>
+                    <property name="height_request">128</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="halign">center</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">False</property>
+                    <property name="group">display1</property>
+                    <child>
+                      <object class="GtkImage" id="image3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label3">
+                    <property name="width_request">128</property>
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="tooltip_text" translatable="yes">Extend to the right</property>
+                    <property name="label" translatable="yes">Extend to the right</property>
+                    <property name="ellipsize">middle</property>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">0</property>
+                <property name="left_attach">2</property>
                 <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="profile-box">
+              <object class="GtkBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="spacing">24</property>
-                <child>
-                  <placeholder/>
-                </child>
+                <property name="orientation">vertical</property>
+                <property name="spacing">3</property>
                 <child>
-                  <placeholder/>
+                  <object class="GtkRadioButton" id="display2">
+                    <property name="width_request">128</property>
+                    <property name="height_request">128</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="halign">center</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">False</property>
+                    <property name="group">display1</property>
+                    <child>
+                      <object class="GtkImage" id="image4">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
                 </child>
                 <child>
-                  <placeholder/>
+                  <object class="GtkLabel" id="label4">
+                    <property name="width_request">128</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Only Display 2</property>
+                    <property name="ellipsize">middle</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="left_attach">4</property>
+                <property name="left_attach">3</property>
                 <property name="top_attach">0</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
           </object>
           <packing>
             <property name="expand">True</property>

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


More information about the Xfce4-commits mailing list