[gnome-control-center/wip/carlosg/wacom-facelift: 7/7] wacom: Move tablet/stylus sections to AdwPreferencesGroup




commit 413d16d490a4d6b12f722f9e8976f2523ee696a2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Feb 1 12:39:49 2022 +0100

    wacom: Move tablet/stylus sections to AdwPreferencesGroup
    
    There is now the header-suffix property that makes it possible to add
    tablet/stylus icons besides the title/description, so we can simply
    use this widget.

 panels/wacom/cc-wacom-page.c         | 13 ++++++-------
 panels/wacom/cc-wacom-page.ui        | 34 +++-------------------------------
 panels/wacom/cc-wacom-stylus-page.c  | 14 ++++++--------
 panels/wacom/cc-wacom-stylus-page.ui | 36 +++---------------------------------
 4 files changed, 18 insertions(+), 79 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index ee293c5c9..b08d4cebc 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -60,8 +60,7 @@ struct _CcWacomPage
        CalibArea      *area;
        GSettings      *wacom_settings;
 
-       GtkWidget      *tablet_name;
-       GtkWidget      *tablet_subtitle;
+       GtkWidget      *tablet_section;
        GtkWidget      *tablet_icon;
        GtkWidget      *tablet_display;
        GtkWidget      *tablet_calibrate;
@@ -562,8 +561,7 @@ cc_wacom_page_class_init (CcWacomPageClass *klass)
 
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/wacom/cc-wacom-page.ui");
 
-       gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_name);
-       gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_subtitle);
+       gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_section);
        gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_icon);
        gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_display);
        gtk_widget_class_bind_template_child (widget_class, CcWacomPage, tablet_calibrate);
@@ -790,9 +788,10 @@ cc_wacom_page_new (CcWacomPanel  *panel,
        page->wacom_settings  = cc_wacom_device_get_settings (stylus);
 
        /* Tablet name */
-       gtk_label_set_text (GTK_LABEL (page->tablet_name), cc_wacom_device_get_name (stylus));
-       gtk_label_set_text (GTK_LABEL (page->tablet_subtitle),
-                           cc_wacom_device_get_description (stylus));
+       adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (page->tablet_section),
+                                        cc_wacom_device_get_name (stylus));
+       adw_preferences_group_set_description (ADW_PREFERENCES_GROUP (page->tablet_section),
+                                              cc_wacom_device_get_description (stylus));
 
        g_settings_bind_with_mapping (page->wacom_settings, "mapping",
                                      page->tablet_mode_switch, "active",
diff --git a/panels/wacom/cc-wacom-page.ui b/panels/wacom/cc-wacom-page.ui
index 654b2a1f7..61cb3d73a 100644
--- a/panels/wacom/cc-wacom-page.ui
+++ b/panels/wacom/cc-wacom-page.ui
@@ -4,41 +4,13 @@
     <property name="orientation">vertical</property>
     <property name="spacing">24</property>
     <child>
-      <object class="GtkBox">
-        <child>
-          <object class="GtkBox">
-            <property name="orientation">vertical</property>
-            <property name="hexpand">True</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="tablet_name">
-                <property name="halign">start</property>
-                <style>
-                  <class name="heading"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel" id="tablet_subtitle">
-                <property name="halign">start</property>
-                <property name="wrap">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
+      <object class="AdwPreferencesGroup" id="tablet_section">
+        <property name="header-suffix">
           <object class="GtkPicture" id="tablet_icon">
             <property name="halign">end</property>
             <property name="valign">start</property>
           </object>
-        </child>
-      </object>
-    </child>
-    <child>
-      <object class="AdwPreferencesGroup">
+        </property>
         <child>
           <object class="AdwActionRow" id="tablet_mode">
             <property name="title" translatable="yes">Tablet Mode</property>
diff --git a/panels/wacom/cc-wacom-stylus-page.c b/panels/wacom/cc-wacom-stylus-page.c
index 33656198a..01819ad71 100644
--- a/panels/wacom/cc-wacom-stylus-page.c
+++ b/panels/wacom/cc-wacom-stylus-page.c
@@ -33,8 +33,7 @@ struct _CcWacomStylusPage
 {
        GtkBox          parent_instance;
 
-       GtkWidget      *stylus_name;
-       GtkWidget      *stylus_subtitle;
+       GtkWidget      *stylus_section;
        GtkWidget      *stylus_icon;
        GtkWidget      *stylus_button1_action;
        GtkWidget      *stylus_button2_action;
@@ -171,8 +170,7 @@ cc_wacom_stylus_page_class_init (CcWacomStylusPageClass *klass)
 
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/wacom/cc-wacom-stylus-page.ui");
 
-       gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_name);
-       gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_subtitle);
+       gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_section);
        gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_icon);
        gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_button1_action);
        gtk_widget_class_bind_template_child (widget_class, CcWacomStylusPage, stylus_button2_action);
@@ -232,10 +230,10 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
        page->stylus = stylus;
 
        /* Stylus name */
-       gtk_label_set_text (GTK_LABEL (page->stylus_name),
-                           cc_wacom_tool_get_name (stylus));
-       gtk_label_set_text (GTK_LABEL (page->stylus_subtitle),
-                           cc_wacom_tool_get_description (stylus));
+       adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (page->stylus_section),
+                                        cc_wacom_tool_get_name (stylus));
+       adw_preferences_group_set_description (ADW_PREFERENCES_GROUP (page->stylus_section),
+                                              cc_wacom_tool_get_description (stylus));
 
        /* Icon */
        set_icon_name (page, cc_wacom_tool_get_icon_name (stylus));
diff --git a/panels/wacom/cc-wacom-stylus-page.ui b/panels/wacom/cc-wacom-stylus-page.ui
index f070785f1..63f82037b 100644
--- a/panels/wacom/cc-wacom-stylus-page.ui
+++ b/panels/wacom/cc-wacom-stylus-page.ui
@@ -4,43 +4,13 @@
     <property name="orientation">vertical</property>
     <property name="spacing">24</property>
     <child>
-      <object class="GtkBox">
-        <property name="homogeneous">True</property>
-        <child>
-          <object class="GtkBox">
-            <property name="orientation">vertical</property>
-            <property name="hexpand">True</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="stylus_name">
-                <property name="halign">start</property>
-                <style>
-                  <class name="heading"/>
-                </style>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel" id="stylus_subtitle">
-                <property name="halign">start</property>
-                <property name="wrap">True</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
+      <object class="AdwPreferencesGroup" id="stylus_section">
+        <property name="header-suffix">
           <object class="GtkPicture" id="stylus_icon">
-            <property name="hexpand">True</property>
             <property name="halign">end</property>
             <property name="valign">start</property>
           </object>
-        </child>
-      </object>
-    </child>
-    <child>
-      <object class="AdwPreferencesGroup">
+        </property>
         <child>
           <object class="AdwActionRow" id="stylus_tip_pressure">
             <property name="title" translatable="yes">Tip Pressure Feel</property>


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