[gnome-control-center/gbsneto/minor-cleanups-pt1: 3/10] notifications: Use AdwActionRow in the dialog




commit 4e5541db8469ce7ff6bdea2a86c90824ec700c5e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jan 21 12:10:48 2022 -0300

    notifications: Use AdwActionRow in the dialog
    
    Reduces code and makes it more consistent with other panels.

 panels/notifications/cc-app-notifications-dialog.c |   2 -
 .../notifications/cc-app-notifications-dialog.ui   | 252 +++++----------------
 2 files changed, 53 insertions(+), 201 deletions(-)
---
diff --git a/panels/notifications/cc-app-notifications-dialog.c 
b/panels/notifications/cc-app-notifications-dialog.c
index 7a3db6578..851ddc481 100644
--- a/panels/notifications/cc-app-notifications-dialog.c
+++ b/panels/notifications/cc-app-notifications-dialog.c
@@ -55,7 +55,6 @@ struct _CcAppNotificationsDialog {
   gchar               *app_id;
   GDBusProxy          *perm_store;
 
-  GtkWidget           *main_listbox;
   GtkWidget           *notifications_switch;
   GtkWidget           *sound_alerts_switch;
   GtkWidget           *notification_banners_switch;
@@ -354,7 +353,6 @@ cc_app_notifications_dialog_class_init (CcAppNotificationsDialogClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/notifications/cc-app-notifications-dialog.ui");
 
-  gtk_widget_class_bind_template_child (widget_class, CcAppNotificationsDialog, main_listbox);
   gtk_widget_class_bind_template_child (widget_class, CcAppNotificationsDialog, notifications_switch);
   gtk_widget_class_bind_template_child (widget_class, CcAppNotificationsDialog, sound_alerts_switch);
   gtk_widget_class_bind_template_child (widget_class, CcAppNotificationsDialog, notification_banners_switch);
diff --git a/panels/notifications/cc-app-notifications-dialog.ui 
b/panels/notifications/cc-app-notifications-dialog.ui
index 9f6217f5b..dfc7d4a26 100644
--- a/panels/notifications/cc-app-notifications-dialog.ui
+++ b/panels/notifications/cc-app-notifications-dialog.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcAppNotificationsDialog" parent="GtkDialog">
-    <property name="width_request">350</property>
+    <property name="default-width">550</property>
     <property name="resizable">False</property>
     <property name="modal">True</property>
     <child type="titlebar">
@@ -13,237 +13,91 @@
       </object>
     </child>
     <child>
-      <object class="GtkBox">
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="margin-top">12</property>
-        <property name="margin-bottom">36</property>
-        <property name="margin-start">36</property>
-        <property name="margin-end">36</property>
+      <object class="AdwPreferencesPage">
         <child>
-          <object class="GtkListBox" id="main_listbox">
-            <property name="selection_mode">none</property>
-            <property name="show-separators">True</property>
-            <property name="activate_on_single_click">False</property>
-            <style>
-              <class name="boxed-list" />
-            </style>
+          <object class="AdwPreferencesGroup">
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications" comments="This is the per 
application switch for message tray usage.">_Notifications</property>
+                <property name="activatable-widget">notifications_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes" context="notifications" comments="This is 
the per application switch for message tray usage.">_Notifications</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">notifications_switch</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="notifications_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <property name="active">True</property>
-                        <signal name="notify::active" handler="notifications_switch_state_set_cb" 
swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="notifications_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <property name="active">True</property>
+                    <signal name="notify::active" handler="notifications_switch_state_set_cb" swapped="no"/>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications" comments="This is the 
setting to configure sounds associated with notifications.">Sound _Alerts</property>
+                <property name="activatable-widget">sound_alerts_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="margin_end">15</property>
-                        <property name="label" translatable="yes" context="notifications" comments="This is 
the setting to configure sounds associated with notifications.">Sound _Alerts</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">sound_alerts_switch</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="sound_alerts_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <signal name="notify::active" handler="sound_alerts_switch_state_set_cb" 
swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="sound_alerts_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="sound_alerts_switch_state_set_cb" swapped="no"/>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications">Notification 
_Popups</property>
+                <property name="subtitle" translatable="yes">Notifications will continue to appear in the 
notification list when popups are disabled.</property>
+                <property name="activatable-widget">notification_banners_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="orientation">vertical</property>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="hexpand">True</property>
-                            <property name="vexpand">True</property>
-                            <property name="xalign">0</property>
-                            <property name="margin_end">15</property>
-                            <property name="label" translatable="yes" context="notifications">Notification 
_Popups</property>
-                            <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">notification_banners_switch</property>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkLabel">
-                            <property name="max-width-chars">42</property>
-                            <property name="wrap-mode">word</property>
-                            <property name="label" translatable="yes">Notifications will continue to appear 
in the notification list when popups are disabled.</property>
-                            <property name="wrap">True</property>
-                            <property name="lines">-1</property>
-                            <property name="xalign">0</property>
-                            <style>
-                              <class name="dim-label"/>
-                            </style>
-                            <attributes>
-                              <attribute name="scale" value="0.83"/>
-                            </attributes>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="notification_banners_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <signal name="notify::active" handler="notification_banners_switch_state_set_cb" 
swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="notification_banners_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="notification_banners_switch_state_set_cb" 
swapped="no"/>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications" comments="Popups here 
refers to message tray notifications in the middle of the screen.">Show Message _Content in Popups</property>
+                <property name="activatable-widget">notification_banners_content_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">True</property>
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="margin_end">15</property>
-                        <property name="label" translatable="yes" context="notifications" comments="Popups 
here refers to message tray notifications in the middle of the screen.">Show Message _Content in 
Popups</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">notification_banners_content_switch</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="notification_banners_content_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <signal name="notify::active" 
handler="notification_banners_content_switch_state_set_cb" swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="notification_banners_content_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="notification_banners_content_switch_state_set_cb" 
swapped="no"/>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications">_Lock Screen 
Notifications</property>
+                <property name="activatable-widget">lock_screen_notifications_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="margin_end">15</property>
-                        <property name="label" translatable="yes" context="notifications">_Lock Screen 
Notifications</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">lock_screen_notifications_switch</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="lock_screen_notifications_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <signal name="notify::active" 
handler="lock_screen_notifications_switch_state_set_cb" swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="lock_screen_notifications_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="lock_screen_notifications_switch_state_set_cb" 
swapped="no"/>
                   </object>
                 </child>
               </object>
             </child>
             <child>
-              <object class="GtkListBoxRow">
-                <property name="width_request">100</property>
-                <property name="activatable">False</property>
-                <property name="selectable">False</property>
+              <object class="AdwActionRow">
+                <property name="use-underline">True</property>
+                <property name="title" translatable="yes" context="notifications">Show Message C_ontent on 
Lock Screen</property>
+                <property name="activatable-widget">lock_screen_content_switch</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="margin_start">15</property>
-                    <property name="margin_end">15</property>
-                    <property name="margin_top">12</property>
-                    <property name="margin_bottom">12</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="margin_end">15</property>
-                        <property name="label" translatable="yes" context="notifications">Show Message 
C_ontent on Lock Screen</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">lock_screen_content_switch</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkSwitch" id="lock_screen_content_switch">
-                        <property name="halign">end</property>
-                        <property name="valign">center</property>
-                        <signal name="notify::active" handler="lock_screen_content_switch_state_set_cb" 
swapped="no"/>
-                      </object>
-                    </child>
+                  <object class="GtkSwitch" id="lock_screen_content_switch">
+                    <property name="halign">end</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="lock_screen_content_switch_state_set_cb" 
swapped="no"/>
                   </object>
                 </child>
               </object>


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