[gnome-clocks] Show nation name as a subtitle in the header bar
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Show nation name as a subtitle in the header bar
- Date: Sat, 9 Mar 2013 10:51:43 +0000 (UTC)
commit af379c3f9a0fd07e6ab0e685cd3e55c1bb41fac1
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Mar 9 11:50:20 2013 +0100
Show nation name as a subtitle in the header bar
Split the city and nation name properties and use them in the header
bar.
src/world.vala | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
---
diff --git a/src/world.vala b/src/world.vala
index 59fd9ba..f56a5bf 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -35,18 +35,12 @@ private class Item : Object, ContentItem {
public GWeather.Location location { get; set; }
public string name {
get {
- var nation = location;
-
- while (nation != null && nation.get_level () != GWeather.LocationLevel.COUNTRY) {
- nation = nation.get_parent ();
- }
-
// We store it in a _name member even if we overwrite it every time
- // since we the abstract name property does not return an owned string
- if (nation != null) {
- _name = "%s, %s".printf (location.get_city_name (), nation.get_name ());
+ // since the abstract name property does not return an owned string
+ if (nation_name != null) {
+ _name = "%s, %s".printf (city_name, nation_name);
} else {
- _name = location.get_city_name ();
+ _name = city_name;
}
return _name;
@@ -56,6 +50,24 @@ private class Item : Object, ContentItem {
}
}
+ public string city_name {
+ owned get {
+ return location.get_city_name ();
+ }
+ }
+
+ public string? nation_name {
+ owned get {
+ var nation = location;
+
+ while (nation != null && nation.get_level () != GWeather.LocationLevel.COUNTRY) {
+ nation = nation.get_parent ();
+ }
+
+ return nation != null ? nation.get_name () : null;
+ }
+ }
+
public bool is_daytime {
get {
return weather_info.is_daytime ();
@@ -381,7 +393,8 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
content_view.update_header_bar ();
break;
case HeaderBar.Mode.STANDALONE:
- header_bar.title = GLib.Markup.escape_text (standalone.location.name);
+ header_bar.title = GLib.Markup.escape_text (standalone.location.city_name);
+ header_bar.subtitle = GLib.Markup.escape_text (standalone.location.nation_name);
back_button.show ();
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]