[gnome-clocks] world: Add state to display name, when available.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] world: Add state to display name, when available.
- Date: Sat, 22 Apr 2017 19:20:37 +0000 (UTC)
commit 3c7c5e9599b2dbeab17ebc65412d326fdd68625d
Author: Gordon P. Hemsley <me gphemsley org>
Date: Sun Apr 16 22:12:53 2017 -0400
world: Add state to display name, when available.
If the parent location is a first-level administrative division,
treat that as a state and include it in the display name.
https://bugzilla.gnome.org/show_bug.cgi?id=739021
src/world.vala | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/world.vala b/src/world.vala
index 54f7300..791f0f1 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -38,7 +38,11 @@ public class Item : Object, ContentItem {
// We store it in a _name member even if we overwrite it every time
// since the abstract name property does not return an owned string
if (country_name != null) {
- _name = "%s, %s".printf (city_name, country_name);
+ if (state_name != null) {
+ _name = "%s, %s, %s".printf (city_name, state_name, country_name);
+ } else {
+ _name = "%s, %s".printf (city_name, country_name);
+ }
} else {
_name = city_name;
}
@@ -56,6 +60,20 @@ public class Item : Object, ContentItem {
}
}
+ public string? state_name {
+ owned get {
+ GWeather.Location? parent = location.get_parent();
+
+ if (parent != null) {
+ if (parent.get_level() == GWeather.LocationLevel.ADM1) {
+ return parent.get_name();
+ }
+ }
+
+ return null;
+ }
+ }
+
public string? country_name {
owned get {
return location.get_country_name ();
@@ -461,7 +479,11 @@ public class Face : Gtk.Stack, Clocks.Clock {
content_view.update_header_bar ();
break;
case HeaderBar.Mode.STANDALONE:
- header_bar.title = standalone_location.city_name;
+ if (standalone_location.state_name != null) {
+ header_bar.title = "%s, %s".printf(standalone_location.city_name,
standalone_location.state_name);
+ } else {
+ header_bar.title = standalone_location.city_name;
+ }
header_bar.subtitle = standalone_location.country_name;
back_button.show ();
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]