[gnome-control-center/thunderbolt-fixups: 4/6] thunderbolt: Port CcBoltDeviceEntry to AdwActionRow




commit f3122f10b1bc4029a4a3c34fe876241b648353ad
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Feb 1 16:21:04 2022 +0100

    thunderbolt: Port CcBoltDeviceEntry to AdwActionRow

 panels/thunderbolt/cc-bolt-device-entry.c  | 12 +++----
 panels/thunderbolt/cc-bolt-device-entry.h  |  3 +-
 panels/thunderbolt/cc-bolt-device-entry.ui | 52 ++++--------------------------
 3 files changed, 12 insertions(+), 55 deletions(-)
---
diff --git a/panels/thunderbolt/cc-bolt-device-entry.c b/panels/thunderbolt/cc-bolt-device-entry.c
index cba7ac056..2bde1ac70 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.c
+++ b/panels/thunderbolt/cc-bolt-device-entry.c
@@ -31,20 +31,18 @@
 
 struct _CcBoltDeviceEntry
 {
-  GtkListBoxRow parent;
+  AdwActionRow parent;
 
   BoltDevice   *device;
 
   /* main ui */
-  GtkLabel *name_label;
-  GtkLabel *status_label;
   GtkLabel *status_warning;
   gboolean  show_warnings;
 };
 
 static const char *   device_status_to_brief_for_ui (BoltDevice *dev);
 
-G_DEFINE_TYPE (CcBoltDeviceEntry, cc_bolt_device_entry, GTK_TYPE_LIST_BOX_ROW);
+G_DEFINE_TYPE (CcBoltDeviceEntry, cc_bolt_device_entry, ADW_TYPE_ACTION_ROW);
 
 enum
 {
@@ -64,7 +62,7 @@ entry_set_name (CcBoltDeviceEntry *entry)
 
   name = bolt_device_get_display_name (dev);
 
-  gtk_label_set_label (entry->name_label, name);
+  adw_preferences_row_set_title (ADW_PREFERENCES_ROW (entry), name);
 }
 
 static void
@@ -77,7 +75,7 @@ entry_update_status (CcBoltDeviceEntry *entry)
   status = bolt_device_get_status (entry->device);
   brief = device_status_to_brief_for_ui (entry->device);
 
-  gtk_label_set_label (entry->status_label, brief);
+  adw_action_row_set_subtitle (ADW_ACTION_ROW (entry), brief);
 
   g_signal_emit (entry,
                  signals[SIGNAL_STATUS_CHANGED],
@@ -171,8 +169,6 @@ cc_bolt_device_entry_class_init (CcBoltDeviceEntryClass *klass)
   object_class->finalize = cc_bolt_device_entry_finalize;
 
   gtk_widget_class_set_template_from_resource (widget_class, RESOURCE_UI);
-  gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, name_label);
-  gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, status_label);
   gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, status_warning);
 
   signals[SIGNAL_STATUS_CHANGED] =
diff --git a/panels/thunderbolt/cc-bolt-device-entry.h b/panels/thunderbolt/cc-bolt-device-entry.h
index f6fc1f76f..e95e3d889 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.h
+++ b/panels/thunderbolt/cc-bolt-device-entry.h
@@ -19,13 +19,14 @@
 
 #pragma once
 
+#include <adwaita.h>
 #include <gtk/gtk.h>
 #include "bolt-device.h"
 
 G_BEGIN_DECLS
 
 #define CC_TYPE_BOLT_DEVICE_ENTRY cc_bolt_device_entry_get_type ()
-G_DECLARE_FINAL_TYPE (CcBoltDeviceEntry, cc_bolt_device_entry, CC, BOLT_DEVICE_ENTRY, GtkListBoxRow);
+G_DECLARE_FINAL_TYPE (CcBoltDeviceEntry, cc_bolt_device_entry, CC, BOLT_DEVICE_ENTRY, AdwActionRow);
 
 
 CcBoltDeviceEntry * cc_bolt_device_entry_new (BoltDevice *device,
diff --git a/panels/thunderbolt/cc-bolt-device-entry.ui b/panels/thunderbolt/cc-bolt-device-entry.ui
index 0b10a7009..2790f92cd 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.ui
+++ b/panels/thunderbolt/cc-bolt-device-entry.ui
@@ -1,52 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <requires lib="gtk+" version="3.20"/>
-
-  <template class="CcBoltDeviceEntry" parent="GtkListBoxRow">
+  <template class="CcBoltDeviceEntry" parent="AdwActionRow">
     <property name="activatable">True</property>
-    <child>
-      <object class="GtkBox">
-        <property name="margin-top">12</property>
-        <property name="margin-bottom">12</property>
-        <property name="margin-start">12</property>
-        <property name="margin-end">12</property>
-        <property name="column-spacing">12</property>
-        <property name="row-spacing">2</property>
-        <child>
-          <object class="GtkLabel" id="name_label">
-            <property name="ellipsize">end</property>
-            <property name="use-markup">True</property>
-            <property name="hexpand">True</property>
-            <property name="label">Device Name</property>
-            <property name="xalign">0.0</property>
-            <property name="valign">center</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkBox">
-            <property name="hexpand">False</property>
-            <property name="halign">end</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkImage" id="status_warning">
-                <property name="visible">False</property>
-                <property name="icon_name">dialog-warning-symbolic</property>
-                <property name="icon_size">1</property>
-                <property name="margin_left">0</property>
-                <property name="xalign">0.0</property>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel" id="status_label">
-                <property name="hexpand">False</property>
-                <property name="label">Status</property>
-                <property name="halign">end</property>
-                <property name="valign">center</property>
-                <property name="xalign">1.0</property>
-              </object>
-            </child>
-          </object>
-        </child>
+    <child type="suffix">
+      <object class="GtkImage" id="status_warning">
+        <property name="visible">False</property>
+        <property name="icon_name">dialog-warning-symbolic</property>
+        <property name="icon_size">1</property>
       </object>
     </child>
   </template>


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