[gnome-clocks] Add UTC and "Anywhere on Earth" clocks



commit d97a9654e9acba4ddd6a87dc9b0d0eebea0aeece
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Dec 1 11:43:05 2017 +0100

    Add UTC and "Anywhere on Earth" clocks
    
    Requires a newer libgweather, and some careful stepping around the fact
    that there is no weather info for timezones.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692243

 data/ui/worldlocationdialog.ui |    1 +
 meson.build                    |    2 +-
 src/world.vala                 |   21 +++++++++++++++++----
 3 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/data/ui/worldlocationdialog.ui b/data/ui/worldlocationdialog.ui
index 5d3fec0..1316da3 100644
--- a/data/ui/worldlocationdialog.ui
+++ b/data/ui/worldlocationdialog.ui
@@ -84,6 +84,7 @@
             </child>
             <child>
               <object class="GWeatherLocationEntry" id="location_entry">
+                <property name="show-named-timezones">True</property>
                 <property name="width_request">400</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
diff --git a/meson.build b/meson.build
index 7a1df45..5e38ebd 100644
--- a/meson.build
+++ b/meson.build
@@ -14,7 +14,7 @@ gio = dependency('gio-2.0', version: '>=2.44')
 gobject = dependency('gobject-2.0', version: '>=2.44')
 gtk = dependency('gtk+-3.0', version: '>=3.20')
 gsound = dependency('gsound', version: '>=0.98')
-gweather = dependency('gweather-3.0', version: '>=3.14')
+gweather = dependency('gweather-3.0', version: '>=3.27.2')
 gnomedesktop = dependency('gnome-desktop-3.0', version: '>=3.8')
 geocodeglib = dependency('geocode-glib-1.0', version: '>=1.0')
 libgeoclue = dependency('libgeoclue-2.0', version: '>=2.4')
diff --git a/src/world.vala b/src/world.vala
index 6c98312..432de2c 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -77,12 +77,19 @@ public class Item : Object, ContentItem {
 
     public bool is_daytime {
          get {
-            return weather_info.is_daytime ();
+            if (weather_info != null) {
+                return weather_info.is_daytime ();
+            }
+            return true;
         }
     }
 
     public string sunrise_label {
         owned get {
+            if (weather_info == null) {
+                return "-";
+            }
+
             ulong sunrise;
             if (!weather_info.get_value_sunrise (out sunrise)) {
                 return "-";
@@ -95,6 +102,10 @@ public class Item : Object, ContentItem {
 
     public string sunset_label {
         owned get {
+            if (weather_info == null) {
+                return "-";
+            }
+
             ulong sunset;
             if (!weather_info.get_value_sunset (out sunset)) {
                 return "-";
@@ -153,9 +164,11 @@ public class Item : Object, ContentItem {
 
         // We don't use the normal constructor since we only want static data
         // and we do not want update() to be called.
-        weather_info = (GWeather.Info) Object.new (typeof (GWeather.Info),
-                                                   location: location,
-                                                   enabled_providers: GWeather.Provider.NONE);
+        if (location.has_coords ()) {
+            weather_info = (GWeather.Info) Object.new (typeof (GWeather.Info),
+                                                       location: location,
+                                                       enabled_providers: GWeather.Provider.NONE);
+        }
     }
 
     public void serialize (GLib.VariantBuilder builder) {


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