[gnome-clocks/zbrown/list-alarms: 17/24] alarms: Use HdyActionRow in the list



commit b75d4ea6069ce89215f1a2b370b46a6cf935ebeb
Author: Zander Brown <zbrown gnome org>
Date:   Sun Jul 28 21:13:10 2019 +0100

    alarms: Use HdyActionRow in the list

 data/ui/alarm.ui     |  6 ++++++
 data/ui/alarmtile.ui | 57 ++++++++++++++++++++++------------------------------
 src/alarm.vala       | 18 +++++++----------
 3 files changed, 37 insertions(+), 44 deletions(-)
---
diff --git a/data/ui/alarm.ui b/data/ui/alarm.ui
index 0e5eac2..6c90e88 100644
--- a/data/ui/alarm.ui
+++ b/data/ui/alarm.ui
@@ -53,7 +53,13 @@
             <child>
               <object class="GtkListBox" id="listbox">
                 <property name="visible">True</property>
+                <property name="selection-mode">none</property>
+                <property name="valign">start</property>
+                <property name="margin">24</property>
                 <!--<signal name="row-activated" handler="item_activated" swapped="no"/>-->
+                <style>
+                  <class name="frame"/>
+                </style>
               </object>
             </child>
           </object>
diff --git a/data/ui/alarmtile.ui b/data/ui/alarmtile.ui
index 10184ec..15d1730 100644
--- a/data/ui/alarmtile.ui
+++ b/data/ui/alarmtile.ui
@@ -1,47 +1,38 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="ClocksAlarmTile" parent="GtkGrid">
+  <template class="ClocksAlarmRow" parent="HdyActionRow">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="halign">start</property>
-    <property name="valign">start</property>
-    <child>
-      <object class="GtkLabel" id="time_label">
-        <property name="width_request">256</property>
-        <property name="height_request">256</property>
+    <property name="activatable-widget">toggle</property>
+    <child type="action">
+      <object class="GtkButton">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="valign">center</property>
         <property name="halign">center</property>
-        <property name="valign">end</property>
-        <property name="use-markup">True</property>
-        <property name="justify">center</property>
-        <property name="wrap">True</property>
-        <property name="max-width-chars">7</property>
-        <style>
-          <class name="tile-label"/>
-          <class name="alarm-tile"/>
-        </style>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">applications-system-symbolic</property>
+            <property name="icon-size">4</property>
+          </object>
+        </child>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
-      </packing>
     </child>
-    <child>
-      <object class="GtkLabel" id="name_label">
+    <child type="action">
+      <object class="GtkSeparator">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="halign">center</property>
+        <property name="margin-top">8</property>
+        <property name="margin-bottom">8</property>
+      </object>
+    </child>
+    <child type="action">
+      <object class="GtkSwitch" id="toggle">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
         <property name="halign">center</property>
-        <property name="wrap">True</property>
-        <property name="max-width-chars">30</property>
-        <style>
-          <class name="name-label"/>
-        </style>
       </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">1</property>
-      </packing>
     </child>
   </template>
 </interface>
diff --git a/src/alarm.vala b/src/alarm.vala
index 5f03f4f..7d9127d 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -275,18 +275,13 @@ private class Item : Object, ContentItem {
 }
 
 [GtkTemplate (ui = "/org/gnome/clocks/ui/alarmtile.ui")]
-private class Tile : Gtk.Grid {
+private class Row : Hdy.ActionRow {
     public Item alarm { get; construct set; }
 
-    [GtkChild]
-    private Gtk.Label time_label;
-    [GtkChild]
-    private Gtk.Widget name_label;
-
-    public Tile (Item alarm) {
+    public Row (Item alarm) {
         Object (alarm: alarm);
 
-        alarm.bind_property ("name", name_label, "label", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
+        alarm.bind_property ("name", this, "subtitle", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
 
         alarm.notify["active"].connect (update);
         alarm.notify["state"].connect (update);
@@ -316,9 +311,9 @@ private class Tile : Gtk.Grid {
         }
 
         if (sub_text != null && sub_text != "") {
-            time_label.label = "%s\n<span size='xx-small'>%s</span>".printf (text, sub_text);
+            title = "%s • %s".printf (text, sub_text);
         } else {
-            time_label.label = text;
+            title = text;
         }
     }
 }
@@ -632,8 +627,9 @@ public class Face : Gtk.Stack, Clocks.Clock {
             }
         });
 
+        listbox.set_header_func((Gtk.ListBoxUpdateHeaderFunc) Hdy.list_box_separator_header);
         listbox.bind_model (alarms, (item) => {
-            return new Tile ((Item)item);
+            return new Row ((Item)item);
         });
 
         load ();


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