[gnome-clocks] Show the nation name



commit 5158c85a5c553a72a26f68cba6e26f97e7499f5c
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Dec 2 12:51:40 2012 +0100

    Show the nation name

 gnomeclocks/world.py |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index 23f7c31..c643cca 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -125,6 +125,7 @@ class NewWorldClockDialog(Gtk.Dialog):
 class ClockItem:
     def __init__(self, location):
         self.location = location
+        self.nation = self._get_nation()
         self.sunrise = None
         self.sunset = None
         self._update_sunrise_sunset()
@@ -140,6 +141,19 @@ class ClockItem:
 
         self.offset = location_offset - here_offset
 
+    def _get_nation(self):
+        nation = self.location
+        while nation and nation.get_level() != GWeather.LocationLevel.COUNTRY:
+            nation = nation.get_parent()
+        if nation != self.location:
+            return nation
+
+    def get_location_name(self):
+        if self.nation:
+            return self.location.get_city_name() + ', ' + self.nation.get_name()
+        else:
+            return self.location.get_city_name()
+
     def get_location_time(self, secs=None):
         if not secs:
             secs = time.time()
@@ -271,7 +285,7 @@ class ClockStandalone(Gtk.EventBox):
                 self.sunbox.hide()
 
     def get_name(self):
-        return GLib.markup_escape_text(self.clock.location.get_city_name())
+        return GLib.markup_escape_text(self.clock.get_location_name())
 
     def update(self):
         if self.clock:
@@ -387,8 +401,7 @@ class World(Clock):
         self.show_all()
 
     def _add_clock_item(self, clock):
-        name = clock.location.get_city_name()
-        label = GLib.markup_escape_text(name)
+        label = GLib.markup_escape_text(clock.get_location_name())
         view_iter = self.liststore.append([False,
                                            "<b>%s</b>" % label,
                                            clock])



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