[gnome-clocks/wip/vala] Use latest gnome-desktop api



commit 0745574b3ff4890fd0edb43a9dd7a24ccf37514d
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Feb 12 10:12:14 2013 +0100

    Use latest gnome-desktop api

 src/alarm.vala             |    2 +-
 src/gnome-desktop-3.0.vapi |    4 ++++
 src/utils.vala             |   11 +++++++----
 3 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index d491771..163c362 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -98,7 +98,7 @@ private class Item : Object {
     private void update_alarm_time () {
         var wallclock = Utils.WallClock.get_default ();
         var now = wallclock.date_time;
-        var dt = new GLib.DateTime(wallclock.time_zone,
+        var dt = new GLib.DateTime(wallclock.timezone,
                                    now.get_year (),
                                    now.get_month (),
                                    now.get_day_of_month (),
diff --git a/src/gnome-desktop-3.0.vapi b/src/gnome-desktop-3.0.vapi
index 0a8aa5c..d483d1c 100644
--- a/src/gnome-desktop-3.0.vapi
+++ b/src/gnome-desktop-3.0.vapi
@@ -8,9 +8,13 @@ namespace Gnome {
 		protected WallClock ();
 		[CCode (cname = "gnome_wall_clock_get_clock")]
 		public unowned string get_clock ();
+		[CCode (cname = "gnome_wall_clock_get_timezone")]
+		public unowned GLib.TimeZone get_timezone ();
 		[NoAccessorMethod]
 		public string clock { owned get; }
 		[NoAccessorMethod]
 		public bool time_only { get; set; }
+		[NoAccessorMethod]
+		public GLib.TimeZone timezone { owned get; }
 	}
 }
diff --git a/src/utils.vala b/src/utils.vala
index 1aa0499..7ce44e5 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -78,7 +78,7 @@ public class WallClock : Object {
     }
 
     public GLib.DateTime date_time { get; private set; }
-    public GLib.TimeZone time_zone { get; private set; }
+    public GLib.TimeZone timezone { get; private set; }
     public Format format { get; private set; }
 
     private GLib.Settings settings;
@@ -91,8 +91,11 @@ public class WallClock : Object {
             tick ();
         });
 
-        // we keep it around since it is relatively expesive to get
-        time_zone = new GLib.TimeZone.local ();
+        // mirror the wallclock's timezone property
+        timezone = wc.timezone;
+        wc.notify["timezone"].connect (() => {
+            timezone = wc.timezone;
+        });
 
         // system-wide settings about clock format
         settings = new GLib.Settings ("org.gnome.desktop.interface");
@@ -115,7 +118,7 @@ public class WallClock : Object {
     // in AlarmItem and ClockItem, so they don't need to call these
     // functions themselves all the time (they only care about minutes).
     private void update () {
-        date_time = new GLib.DateTime.now (time_zone);
+        date_time = new GLib.DateTime.now (timezone);
     }
 
     public string format_time (GLib.DateTime date_time) {


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