From a97c92661bc73d121e1ccddb0396caa2d86ed836 Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Sat, 10 Oct 2015 10:06:00 +0200 Subject: [PATCH] Add options to configure the refresh-timeouts. --- data/weather-settings.ui | 93 +++++++++++++++++++++++++++++++++++++++- src/prefs.js | 31 ++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/data/weather-settings.ui b/data/weather-settings.ui index 8302d05..fa7b20a 100644 --- a/data/weather-settings.ui +++ b/data/weather-settings.ui @@ -2,6 +2,13 @@ + + 10 + 1440 + 10 + 1 + 10 + False True @@ -156,6 +163,13 @@ + + 10 + 1440 + 10 + 1 + 10 + True False @@ -462,6 +476,8 @@ True False + start + True Chose default weather provider @@ -473,6 +489,8 @@ True False + start + True Personal Api key from openweathermap.org @@ -510,7 +528,6 @@ True True - True 32 32 @@ -523,6 +540,8 @@ True False + start + True Personal Api key from forecast.io @@ -530,6 +549,78 @@ 2 + + + True + False + start + True + Refresh timeout for current weather [min] + end + + + 0 + 4 + + + + + True + False + start + True + Refresh timeout for weather forecast [min] + end + + + 0 + 5 + + + + + True + True + number + current-refresh-adjustment + 5 + True + if-valid + 10 + + + 1 + 4 + + + + + True + True + Note: the forecast-timout is not used for forecast.io, because they do not provide seperate downloads for current weather and forecasts. + 10 + number + forecast-refresh-adjustment + 5 + True + 10 + + + 1 + 5 + + + + + True + False + + + 0 + 3 + 2 + + 1 diff --git a/src/prefs.js b/src/prefs.js index f0b44b6..38cfaeb 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -36,6 +36,7 @@ const _ = Gettext.gettext; const Soup = imports.gi.Soup; const Lang = imports.lang; +const Mainloop = imports.mainloop; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); const Config = imports.misc.config; @@ -358,6 +359,36 @@ const WeatherPrefsWidget = new GObject.Class({ return 0; })); + this.current_spin = this.Window.get_object("spin-current-refresh"); + this.current_spin.set_value(this.refresh_interval_current / 60); + // prevent from continously updating the value + this.currentSpinTimeout = undefined; + this.current_spin.connect("value-changed", Lang.bind(this, function(button) { + + if (this.currentSpinTimeout !== undefined) + Mainloop.source_remove(this.currentSpinTimeout); + this.currentSpinTimeout = Mainloop.timeout_add(250, Lang.bind(this, function() { + this.refresh_interval_current = 60 * button.get_value(); + return false; + })); + + })); + + this.forecast_spin = this.Window.get_object("spin-forecast-refresh"); + this.forecast_spin.set_value(this.refresh_interval_forecast / 60); + // prevent from continously updating the value + this.forecastSpinTimeout = undefined; + this.forecast_spin.connect("value-changed", Lang.bind(this, function(button) { + + if (this.forecastSpinTimeout !== undefined) + Mainloop.source_remove(this.forecastSpinTimeout); + this.forecastSpinTimeout = Mainloop.timeout_add(250, Lang.bind(this, function() { + this.refresh_interval_forecast = 60 * button.get_value(); + return false; + })); + + })); + let column = new Gtk.TreeViewColumn(); column.set_title(_("Location")); this.treeview.append_column(column);