Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to define a location #56

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion data/com.github.danrabbit.nimbus.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
<summary>Most recent y position of Nimbus</summary>
<description>Most recent y position of Nimbus</description>
</key>
<key name="latitude" type="d">
<default>-1</default>
<summary>Location Latitude</summary>
<description>The latitiude nimbus uses for weather location</description>
</key>
<key name="longitude" type="d">
<default>-1</default>
<summary>Location Longitude</summary>
<description>The longitude nimbus uses for weather location</description>
</key>
</schema>
</schemalist>

13 changes: 11 additions & 2 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
}