[gnome-clocks/zbrown/named-timezones: 3/4] world: refine dialogue rows
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/zbrown/named-timezones: 3/4] world: refine dialogue rows
- Date: Sun, 12 Jul 2020 17:11:21 +0000 (UTC)
commit e53a6c181e6e41a7856f36b67bb56bde5065aa3d
Author: Zander Brown <zbrown gnome org>
Date: Sat Jul 11 22:36:14 2020 +0100
world: refine dialogue rows
Fix https://gitlab.gnome.org/GNOME/gnome-clocks/-/issues/125
data/css/gnome-clocks.css | 4 +++
data/ui/world-location-dialog-row.ui | 49 ++++++++++--------------------------
src/world-location-dialog-row.vala | 38 +++++++++-------------------
src/world-location-dialog.vala | 12 ++++-----
4 files changed, 35 insertions(+), 68 deletions(-)
---
diff --git a/data/css/gnome-clocks.css b/data/css/gnome-clocks.css
index f38ef4d..ea9b913 100644
--- a/data/css/gnome-clocks.css
+++ b/data/css/gnome-clocks.css
@@ -195,6 +195,10 @@ spinbutton.clocks-timer-label button {
font-size: 1.1em;
}
+.clock-location {
+ font-weight: bolder;
+}
+
.clock-desc {
font-size: 0.9em;
}
diff --git a/data/ui/world-location-dialog-row.ui b/data/ui/world-location-dialog-row.ui
index 757a30c..286e40d 100644
--- a/data/ui/world-location-dialog-row.ui
+++ b/data/ui/world-location-dialog-row.ui
@@ -1,29 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
- <template class="ClocksWorldAddClockRow" parent="GtkListBoxRow">
+ <template class="ClocksWorldLocationDialogRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selectable">False</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<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="margin">12</property>
<property name="hexpand">True</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkLabel" id="desc">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="label">label</property>
+ <property name="label" bind-source="ClocksWorldLocationDialogRow"
bind-property="clock-description" bind-flags="sync-create"/>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
@@ -43,10 +37,9 @@
<property name="can_focus">False</property>
<property name="spacing">10</property>
<child>
- <object class="GtkLabel" id="name_label">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">label</property>
+ <property name="label" bind-source="ClocksWorldLocationDialogRow" bind-property="clock-name"
bind-flags="sync-create"/>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<property name="yalign">1</property>
@@ -54,27 +47,17 @@
<class name="clock-title"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="country_label">
+ <object class="GtkLabel">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="label">label</property>
+ <property name="label" bind-source="ClocksWorldLocationDialogRow"
bind-property="clock-location" bind-flags="sync-create"/>
+ <property name="xalign">0</property>
+ <property name="yalign">1</property>
<style>
- <class name="caption-heading"/>
+ <class name="clock-location"/>
</style>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
@@ -83,8 +66,8 @@
</packing>
</child>
<child>
- <object class="GtkImage" id="checkmark">
- <property name="can_focus">False</property>
+ <object class="GtkImage">
+ <property name="visible" bind-source="ClocksWorldLocationDialogRow"
bind-property="clock-selected" bind-flags="sync-create"/>
<property name="icon_name">object-select-symbolic</property>
</object>
<packing>
@@ -93,12 +76,6 @@
<property name="height">2</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
</object>
</child>
<style>
diff --git a/src/world-location-dialog-row.vala b/src/world-location-dialog-row.vala
index 0a4cd2d..e7ea7ae 100644
--- a/src/world-location-dialog-row.vala
+++ b/src/world-location-dialog-row.vala
@@ -20,27 +20,19 @@ namespace Clocks {
namespace World {
[GtkTemplate (ui = "/org/gnome/clocks/ui/world-location-dialog-row.ui")]
-private class AddClockRow : Gtk.ListBoxRow {
+private class LocationDialogRow : Gtk.ListBoxRow {
public ClockLocation data { get; construct set; }
- [GtkChild]
- private Gtk.Label name_label;
- [GtkChild]
- private Gtk.Label country_label;
- [GtkChild]
- private Gtk.Label desc;
- [GtkChild]
- private Gtk.Widget checkmark;
+ public string? clock_name { get; set; default = null; }
+ public string? clock_location { get; set; default = null; }
+ public string? clock_description { get; set; default = null; }
+ public bool clock_selected { get; set; default = false; }
- public AddClockRow (ClockLocation data) {
+ public LocationDialogRow (ClockLocation data) {
Object (data: data);
- name_label.label = data.location.get_name ();
-
- var country_name = data.location.get_country_name ();
- if (country_name != null) {
- country_label.label = (string) country_name;
- }
+ clock_name = data.location.get_name ();
+ clock_location = data.location.get_country_name ();
var wallclock = Utils.WallClock.get_default ();
var local_time = wallclock.date_time;
@@ -53,23 +45,17 @@ private class AddClockRow : Gtk.ListBoxRow {
var time_zone_name = ((GWeather.Timezone) weather_time_zone).get_name ();
if ((string?) time_zone_name != null) {
- desc.label = "%s • %s".printf (time_zone_name, time_diff_message);
+ clock_description = "%s • %s".printf (time_zone_name, time_diff_message);
} else {
- desc.label = "%s".printf (time_diff_message);
+ clock_description = "%s".printf (time_diff_message);
}
-
-
} else {
- desc.hide ();
+ clock_description = null;
}
sensitive = !data.selected;
- data.notify["selected"].connect (on_selected_changed);
- }
-
- private void on_selected_changed () {
- checkmark.visible = data.selected;
+ data.bind_property ("selected", this, "clock-selected", SYNC_CREATE);
}
}
diff --git a/src/world-location-dialog.vala b/src/world-location-dialog.vala
index 63907ca..2cdd388 100644
--- a/src/world-location-dialog.vala
+++ b/src/world-location-dialog.vala
@@ -43,8 +43,8 @@ private class LocationDialog : Gtk.Dialog {
private Face world;
private ListStore locations;
- private AddClockRow? _selected_row = null;
- private AddClockRow? selected_row {
+ private LocationDialogRow? _selected_row = null;
+ private LocationDialogRow? selected_row {
get {
return _selected_row;
} set {
@@ -68,22 +68,22 @@ private class LocationDialog : Gtk.Dialog {
locations = new ListStore (typeof (ClockLocation));
listbox.bind_model (locations, (data) => {
- return new AddClockRow ((ClockLocation) data);
+ return new LocationDialogRow ((ClockLocation) data);
});
}
public GWeather.Location? get_selected_location () {
if (selected_row == null)
return null;
- return ((AddClockRow) selected_row).data.location;
+ return ((LocationDialogRow) selected_row).data.location;
}
[GtkCallback]
private void item_activated (Gtk.ListBoxRow listbox_row) {
- var row = (AddClockRow) listbox_row;
+ var row = (LocationDialogRow) listbox_row;
if (selected_row != null && selected_row != row) {
- ((AddClockRow) selected_row).data.selected = false;
+ ((LocationDialogRow) selected_row).data.selected = false;
}
row.data.selected = !row.data.selected;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]