[gnome-control-center/thunderbolt-fixups: 5/6] thunderbolt: Wrap "Direct access" UI into a AdwActionRow




commit 12b940d411a6bb3a11063f2239fd50b934fca1f4
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Feb 1 16:35:44 2022 +0100

    thunderbolt: Wrap "Direct access" UI into a AdwActionRow
    
    This allows for simplifying the logic of the states of this row
    too.

 panels/thunderbolt/cc-bolt-panel.c  |  11 ++--
 panels/thunderbolt/cc-bolt-panel.ui | 107 ++++++++----------------------------
 2 files changed, 29 insertions(+), 89 deletions(-)
---
diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c
index 0ec005b68..67a7b431d 100644
--- a/panels/thunderbolt/cc-bolt-panel.c
+++ b/panels/thunderbolt/cc-bolt-panel.c
@@ -58,7 +58,7 @@ struct _CcBoltPanel
   /* authmode */
   GtkSwitch          *authmode_switch;
   GtkSpinner         *authmode_spinner;
-  GtkStack           *authmode_mode;
+  GtkStack           *direct_access_row;
 
   /* device list */
   GHashTable         *devices;
@@ -411,7 +411,6 @@ cc_bolt_panel_authmode_sync (CcBoltPanel *panel)
   BoltClient *client = panel->client;
   BoltAuthMode mode;
   gboolean enabled;
-  const char *name;
 
   mode = bolt_client_get_authmode (client);
   enabled = (mode & BOLT_AUTH_ENABLED) != 0;
@@ -422,8 +421,10 @@ cc_bolt_panel_authmode_sync (CcBoltPanel *panel)
 
   g_signal_handlers_unblock_by_func (panel->authmode_switch, on_authmode_state_set_cb, panel);
 
-  name = enabled ? "enabled" : "disabled";
-  gtk_stack_set_visible_child_name (panel->authmode_mode, name);
+  adw_preferences_row_set_title (ADW_PREFERENCES_ROW (panel->direct_access_row),
+                                 enabled ?
+                                 _("Allow direct access to devices such as docks and external GPUs.") :
+                                 _("Only USB and Display Port devices can attach."));
 }
 
 static void
@@ -908,13 +909,13 @@ cc_bolt_panel_class_init (CcBoltPanelClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/thunderbolt/cc-bolt-panel.ui");
 
-  gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, authmode_mode);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, authmode_spinner);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, authmode_switch);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, container);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, devices_list);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, devices_box);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, devices_stack);
+  gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, direct_access_row);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, headerbar_box);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, lock_button);
   gtk_widget_class_bind_template_child (widget_class, CcBoltPanel, notb_caption);
diff --git a/panels/thunderbolt/cc-bolt-panel.ui b/panels/thunderbolt/cc-bolt-panel.ui
index a0aee01f0..802c800ff 100644
--- a/panels/thunderbolt/cc-bolt-panel.ui
+++ b/panels/thunderbolt/cc-bolt-panel.ui
@@ -216,101 +216,40 @@
                                     <property name="orientation">horizontal</property>
                                     <property name="spacing">12</property>
                                     <child>
-                                      <object class="GtkBox">
-                                        <property name="hexpand">True</property>
-                                        <property name="vexpand">True</property>
-                                        <property name="orientation">vertical</property>
-                                        <property name="spacing">6</property>
-                                        <child>
-                                          <object class="GtkLabel">
-                                            <property name="hexpand">False</property>
-                                            <property name="halign">start</property>
-                                            <property name="xalign">0.0</property>
-                                            <property name="label" translatable="yes">Direct 
Access</property>
-                                            <property name="mnemonic_widget">authmode_switch</property>
-                                            <attributes>
-                                              <attribute name="weight" value="bold" />
-                                            </attributes>
-                                          </object>
-                                        </child>
+                                      <object class="AdwPreferencesGroup">
+                                        <property name="title" translatable="yes">Direct Access</property>
 
                                         <child>
-                                          <object class="GtkStack" id="authmode_mode">
-                                            <property name="transition-type">crossfade</property>
-                                            <property name="hhomogeneous">False</property>
-                                            <property name="vhomogeneous">False</property>
+                                          <object class="AdwActionRow" id="direct_access_row">
+                                            <property name="title" translatable="yes" >Allow direct access 
to devices such as docks and external GPUs.</property>
+                                            <child type="suffix">
+                                              <object class="GtkBox">
+                                                <property name="orientation">horizontal</property>
+                                                <property name="spacing">6</property>
+                                                <property name="halign">end</property>
+                                                <property name="valign">center</property>
 
-                                            <child>
-                                              <object class="GtkStackPage">
-                                                <property name="name">enabled</property>
-                                                <property name="child">
-                                                  <object class="GtkLabel">
-                                                    <property name="halign">start</property>
-                                                    <property name="margin-start">0</property>
-                                                    <property name="hexpand">False</property>
-                                                    <property name="vexpand">False</property>
-                                                    <property name="label" translatable="yes" >Allow direct 
access to devices such as docks and external GPUs.</property>
-                                                    <property name="use_markup">True</property>
-                                                    <property name="wrap">True</property>
-                                                    <property name="xalign">0.0</property>
-                                                    <property name="yalign">0.0</property>
-                                                    <property name="max-width-chars">45</property>
+                                                <child>
+                                                  <object class="GtkSpinner" id="authmode_spinner">
+                                                    <property name="spinning">False</property>
                                                   </object>
-                                                </property>
-                                              </object>
-                                            </child>
+                                                </child>
 
-                                            <child>
-                                              <object class="GtkStackPage">
-                                                <property name="name">disabled</property>
-                                                <property name="child">
-                                                  <object class="GtkLabel">
-                                                    <property name="halign">start</property>
-                                                    <property name="margin-start">0</property>
-                                                    <property name="hexpand">False</property>
-                                                    <property name="vexpand">False</property>
-                                                    <property name="label" translatable="yes" >Only USB and 
Display Port devices can attach.</property>
-                                                    <property name="use_markup">True</property>
-                                                    <property name="wrap">True</property>
-                                                    <property name="xalign">0.0</property>
-                                                    <property name="yalign">0.0</property>
-                                                    <property name="max-width-chars">45</property>
+                                                <child>
+                                                  <object class="GtkSwitch" id="authmode_switch">
+                                                    <property name="halign">end</property>
+                                                    <property name="active">True</property>
+                                                    <signal name="state-set"
+                                                            handler="on_authmode_state_set_cb"
+                                                            object="CcBoltPanel"
+                                                            swapped="yes" />
                                                   </object>
-                                                </property>
+                                                </child>
                                               </object>
                                             </child>
-
                                           </object>
                                         </child>
-                                      </object>
-                                    </child>
-                                    <child>
-                                      <object class="GtkBox">
-                                        <property name="hexpand">True</property>
-                                        <property name="vexpand">True</property>
-                                        <property name="orientation">horizontal</property>
-                                        <property name="spacing">6</property>
-                                        <property name="halign">center</property>
-                                        <property name="valign">start</property>
 
-                                        <child>
-                                          <object class="GtkSpinner" id="authmode_spinner">
-                                            <property name="spinning">False</property>
-                                          </object>
-                                        </child>
-
-                                        <child>
-                                          <object class="GtkSwitch" id="authmode_switch">
-                                            <property name="can_focus">True</property>
-                                            <property name="halign">end</property>
-                                            <property name="valign">start</property>
-                                            <property name="active">True</property>
-                                            <signal name="state-set"
-                                                    handler="on_authmode_state_set_cb"
-                                                    object="CcBoltPanel"
-                                                    swapped="yes" />
-                                          </object>
-                                        </child>
                                       </object>
                                     </child>
                                   </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]