[gnome-clocks] world-row: Port to ActionRow
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] world-row: Port to ActionRow
- Date: Fri, 7 Jan 2022 17:23:44 +0000 (UTC)
commit d3e0155c92ae1c02629d64af107efc848483f369
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Mon Dec 13 10:56:23 2021 +0100
world-row: Port to ActionRow
data/css/gnome-clocks.css | 8 ----
data/ui/world-row.ui | 114 ++++++++++------------------------------------
src/world-row.vala | 24 ++++------
3 files changed, 33 insertions(+), 113 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index 35ecd71d..ac971726 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -186,18 +186,10 @@ spinbutton.clocks-timer-label button {
/* World */
-.clock-title {
- font-size: 1.1em;
-}
-
.clock-location {
font-weight: bolder;
}
-.clock-desc {
- font-size: 0.9em;
-}
-
.clock-time {
font-size: 2em;
padding: 0.2em 0.5em;
diff --git a/data/ui/world-row.ui b/data/ui/world-row.ui
index 182d41ce..af8c49e1 100644
--- a/data/ui/world-row.ui
+++ b/data/ui/world-row.ui
@@ -1,95 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <template class="ClocksWorldRow" parent="GtkListBoxRow">
+ <template class="ClocksWorldRow" parent="AdwActionRow">
+ <property name="activatable">True</property>
<child>
- <object class="GtkGrid">
- <property name="valign">start</property>
- <property name="margin_start">12</property>
- <property name="margin_end">12</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
- <property name="hexpand">True</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel" id="name_label">
- <property name="hexpand">True</property>
- <property name="label">label</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="yalign">1</property>
- <style>
- <class name="clock-title"/>
- </style>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="desc">
- <property name="hexpand">True</property>
- <property name="label">label</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <style>
- <class name="dim-label"/>
- <class name="clock-desc"/>
- </style>
- <layout>
- <property name="column">0</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="time_label">
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="label">12:34</property>
- <property name="use_markup">True</property>
- <property name="ellipsize">end</property>
- <attributes>
- <attribute name="font-features" value="tnum=1"/>
- </attributes>
- <style>
- <class name="clock-time"/>
- </style>
- <layout>
- <property name="column">1</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="GtkStack" id="delete_stack">
- <child>
- <object class="GtkButton" id="delete_button">
- <property name="width_request">34</property>
- <property name="receives_default">True</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="tooltip_text" translatable="yes">Delete</property>
- <property name="icon_name">edit-delete-symbolic</property>
- <signal name="clicked" handler="delete" object="ClocksWorldRow" swapped="no"/>
- <style>
- <class name="circular"/>
- <class name="flat"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="delete_empty">
- </object>
- </child>
- <layout>
- <property name="column">2</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
+ <object class="GtkLabel" id="time_label">
+ <property name="valign">center</property>
+ <property name="label">12:34</property>
+ <property name="use_markup">True</property>
+ <property name="ellipsize">end</property>
+ <property name="margin-bottom">12</property>
+ <property name="margin-top">12</property>
+ <style>
+ <class name="clock-time"/>
+ <class name="numeric"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="delete_button">
+ <property name="valign">center</property>
+ <property name="tooltip_text" translatable="yes">Delete</property>
+ <property name="icon_name">edit-delete-symbolic</property>
+ <signal name="clicked" handler="delete" object="ClocksWorldRow" swapped="no"/>
+ <style>
+ <class name="circular"/>
+ <class name="flat"/>
+ </style>
</object>
</child>
<style>
diff --git a/src/world-row.vala b/src/world-row.vala
index 59947025..8cf5d195 100644
--- a/src/world-row.vala
+++ b/src/world-row.vala
@@ -20,28 +20,20 @@ namespace Clocks {
namespace World {
[GtkTemplate (ui = "/org/gnome/clocks/ui/world-row.ui")]
-private class Row : Gtk.ListBoxRow {
+private class Row : Adw.ActionRow {
public Item location { get; construct set; }
[GtkChild]
private unowned Gtk.Label time_label;
[GtkChild]
- private unowned Gtk.Widget name_label;
- [GtkChild]
- private unowned Gtk.Label desc;
- [GtkChild]
- private unowned Gtk.Stack delete_stack;
- [GtkChild]
private unowned Gtk.Widget delete_button;
- [GtkChild]
- private unowned Gtk.Widget delete_empty;
internal signal void remove_clock ();
public Row (Item location) {
Object (location: location);
- location.bind_property ("city-name", name_label, "label", BindingFlags.DEFAULT |
BindingFlags.SYNC_CREATE);
+ location.bind_property ("city-name", this, "title", BindingFlags.DEFAULT | BindingFlags.SYNC_CREATE);
location.tick.connect (update);
update ();
@@ -59,15 +51,15 @@ private class Row : Gtk.ListBoxRow {
var message = Utils.get_time_difference_message ((double) location.local_offset);
if (location.day_label != null && location.day_label != "") {
- desc.label = "%s • %s".printf ((string) location.day_label, message);
- delete_stack.visible_child = delete_button;
+ subtitle = "%s • %s".printf ((string) location.day_label, message);
+ delete_button.show ();
} else if (location.automatic) {
// Translators: This clock represents the local time
- desc.label = _("Current location");
- delete_stack.visible_child = delete_empty;
+ subtitle = _("Current location");
+ delete_button.hide ();
} else {
- desc.label = "%s".printf (message);
- delete_stack.visible_child = delete_button;
+ subtitle = "%s".printf (message);
+ delete_button.show ();
}
time_label.label = location.time_label;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]