Add options to configure the refresh-timeouts.

merge-requests/218/head
Jens Lody 9 years ago
parent c8097eb621
commit a97c92661b
  1. 93
      data/weather-settings.ui
  2. 31
      src/prefs.js

@ -2,6 +2,13 @@
<!-- Generated with glade 3.18.3 -->
<interface domain="gnome-shell-extension-openweather">
<requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="current-refresh-adjustment">
<property name="lower">10</property>
<property name="upper">1440</property>
<property name="value">10</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkWindow" id="edit-widget">
<property name="can_focus">False</property>
<property name="modal">True</property>
@ -156,6 +163,13 @@
</object>
</child>
</object>
<object class="GtkAdjustment" id="forecast-refresh-adjustment">
<property name="lower">10</property>
<property name="upper">1440</property>
<property name="value">10</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkMenu" id="search-menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -462,6 +476,8 @@
<object class="GtkLabel" id="label-weather-provider">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Chose default weather provider</property>
</object>
<packing>
@ -473,6 +489,8 @@
<object class="GtkLabel" id="label-appid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Personal Api key from openweathermap.org</property>
</object>
<packing>
@ -510,7 +528,6 @@
<object class="GtkEntry" id="appid_fc">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_tooltip">True</property>
<property name="max_length">32</property>
<property name="width_chars">32</property>
</object>
@ -523,6 +540,8 @@
<object class="GtkLabel" id="label-appid-fc">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Personal Api key from forecast.io</property>
</object>
<packing>
@ -530,6 +549,78 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-current-refresh">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Refresh timeout for current weather [min]</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-forecast-refresh">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Refresh timeout for weather forecast [min]</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin-current-refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="input_purpose">number</property>
<property name="adjustment">current-refresh-adjustment</property>
<property name="climb_rate">5</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
<property name="value">10</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin-forecast-refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Note: the forecast-timout is not used for forecast.io, because they do not provide seperate downloads for current weather and forecasts.</property>
<property name="text" translatable="yes">10</property>
<property name="input_purpose">number</property>
<property name="adjustment">forecast-refresh-adjustment</property>
<property name="climb_rate">5</property>
<property name="numeric">True</property>
<property name="value">10</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkSeparator" id="separator3">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>

@ -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);

Loading…
Cancel
Save