[gnome-boxes/refactor-thumbs: 5/8] list-view-row: Port to HdyActionRow




commit 0b28ea3832cab0309043661ce944f55c55265fad
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jan 4 11:49:56 2022 +0100

    list-view-row: Port to HdyActionRow

 data/ui/list-view-row.ui | 47 +++--------------------------------------------
 src/list-view-row.vala   | 25 ++++++-------------------
 2 files changed, 9 insertions(+), 63 deletions(-)
---
diff --git a/data/ui/list-view-row.ui b/data/ui/list-view-row.ui
index 4170d42f..e1ab44ba 100644
--- a/data/ui/list-view-row.ui
+++ b/data/ui/list-view-row.ui
@@ -1,16 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.9 -->
-  <template class="BoxesListViewRow" parent="GtkBox">
+  <template class="BoxesListViewRow" parent="HdyActionRow">
     <property name="visible">True</property>
-    <property name="margin-start">24</property>
-    <property name="margin-end">24</property>
-    <property name="margin-top">8</property>
-    <property name="margin-bottom">8</property>
-    <property name="orientation">horizontal</property>
-    <property name="spacing">16</property>
+    <property name="margin">8</property>
 
-    <child>
+    <child type="prefix">
       <object class="GtkStack" id="stack">
         <property name="visible">True</property>
         <child>
@@ -51,42 +46,6 @@
           </object>
         </child>
       </object>
-
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-      </packing>
-    </child>
-
-    <child>
-      <object class="GtkLabel" id="machine_name">
-        <property name="visible">True</property>
-        <property name="justify">left</property>
-        <property name="halign">start</property>
-        <property name="hexpand">True</property>
-        <property name="valign">center</property>
-        <property name="ellipsize">end</property>
-        <property name="xalign">0.0</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-      </packing>
-    </child>
-
-    <child>
-      <object class="GtkLabel" id="status_label">
-        <property name="visible">True</property>
-        <property name="justify">right</property>
-        <property name="halign">end</property>
-        <property name="valign">center</property>
-        <property name="ellipsize">end</property>
-        <property name="xalign">1.0</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-      </packing>
     </child>
   </template>
 </interface>
diff --git a/src/list-view-row.vala b/src/list-view-row.vala
index 9de0e0a9..28e15462 100644
--- a/src/list-view-row.vala
+++ b/src/list-view-row.vala
@@ -2,7 +2,7 @@
 using Gtk;
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/list-view-row.ui")]
-private class Boxes.ListViewRow: Gtk.Box {
+private class Boxes.ListViewRow: Hdy.ActionRow {
     public const int SCREENSHOT_WIDTH = 60;
     public const int SCREENSHOT_HEIGHT = 45;
 
@@ -21,10 +21,6 @@
     private unowned Gtk.EventBox spinner_box;
     [GtkChild]
     private unowned Gtk.Spinner spinner;
-    [GtkChild]
-    private unowned Gtk.Label machine_name;
-    [GtkChild]
-    private unowned Gtk.Label status_label;
 
     private Boxes.MachineThumbnailer thumbnailer;
 
@@ -47,7 +43,7 @@ public ListViewRow (CollectionItem item) {
         update_thumbnail ();
         update_status ();
 
-        machine.bind_property ("name", machine_name, "label", BindingFlags.SYNC_CREATE);
+        machine.bind_property ("name", this, "title", BindingFlags.SYNC_CREATE);
     }
 
     private void update_thumbnail () {
@@ -77,33 +73,24 @@ else if (machine.is_stopped)
     }
 
     private void update_status () {
-        update_status_label_style (!machine.is_on);
-
         if (machine.status != null) {
-            status_label.label = machine.status;
+            subtitle = machine.status;
 
             return;
         }
 
         if (machine.is_running) {
-            status_label.label = _("Running");
+            subtitle = _("Running");
 
             return;
         }
 
         if (machine.is_on) {
-            status_label.label = _("Paused");
+            subtitle = _("Paused");
 
             return;
         }
 
-        status_label.label = _("Powered Off");
-    }
-
-    private void update_status_label_style (bool dim) {
-        if (dim)
-            status_label.get_style_context ().add_class ("dim-label");
-        else
-            status_label.get_style_context ().remove_class ("dim-label");
+        subtitle = _("Powered Off");
     }
 }


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