diff --git a/data/com.github.danrabbit.nimbus.gschema.xml b/data/com.github.danrabbit.nimbus.gschema.xml index fcd1f60..5eea039 100644 --- a/data/com.github.danrabbit.nimbus.gschema.xml +++ b/data/com.github.danrabbit.nimbus.gschema.xml @@ -13,6 +13,15 @@ Most recent y position of Nimbus Most recent y position of Nimbus + + -1 + Location Latitude + The latitiude nimbus uses for weather location + + + -1 + Location Longitude + The longitude nimbus uses for weather location + - diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 4129c81..faff4ef 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -174,11 +174,20 @@ public class MainWindow : Gtk.Dialog { public void on_location_updated (double latitude, double longitude) { location = GWeather.Location.get_world (); - location = location.find_nearest_city (latitude, longitude); + var settings = new Settings ("com.github.danrabbit.nimbus"); + var user_latitude = settings.get_double ("latitude"); + var user_longitude = settings.get_double ("longitude"); + //Checking for default values + if ((user_latitude == -1) && (user_longitude == -1)){ + location = location.find_nearest_city (latitude, longitude); + } else { + location = location.find_nearest_city (user_latitude, user_longitude); + } + if (location != null) { weather_info.location = location; weather_info.update (); stack.visible_child_name = "weather"; } + } } -}