Add option to center forecast, closes #1

yahoo_weather
Jens Lody 11 years ago
parent 5504a73a7f
commit 1bf555c6aa
  1. 4
      data/org.gnome.shell.extensions.weather.gschema.xml.in
  2. 10
      data/stylesheet.css
  3. 26
      src/extension.js
  4. 15
      src/prefs.js

@ -88,6 +88,10 @@
<default>300</default> <default>300</default>
<_summary>Refresh interval</_summary> <_summary>Refresh interval</_summary>
</key> </key>
<key name="center-forecast" type="b">
<default>false</default>
<_summary>Center forecastbox.</_summary>
</key>
<key name="days-forecast" type="i"> <key name="days-forecast" type="i">
<default>2</default> <default>2</default>
<_summary>Number of days in forecast</_summary> <_summary>Number of days in forecast</_summary>

@ -39,9 +39,12 @@ padding-right: 15px;
.weather-forecasts { .weather-forecasts {
-st-hfade-offset: 60px; -st-hfade-offset: 60px;
} }
.weather-forecast-box {
}
.weather-forecast-databox { .weather-forecast-databox {
min-width: 120px; min-width: 140px;
padding-right: 30px;
} }
.weather-forecast-day { .weather-forecast-day {
@ -49,6 +52,9 @@ color: #999999;
font-size: 90%; font-size: 90%;
} }
.weather-forecast-iconbox {
}
.weather-sunrise-icon { .weather-sunrise-icon {
padding-right: 5px; padding-right: 5px;
} }

@ -68,6 +68,7 @@ const WEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel';
const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel';
const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel';
const WEATHER_REFRESH_INTERVAL = 'refresh-interval'; const WEATHER_REFRESH_INTERVAL = 'refresh-interval';
const WEATHER_CENTER_FORECAST_KEY = 'center-forecast';
const WEATHER_DAYS_FORECAST = 'days-forecast'; const WEATHER_DAYS_FORECAST = 'days-forecast';
// Keep enums in sync with GSettings schemas // Keep enums in sync with GSettings schemas
@ -499,13 +500,27 @@ const WeatherMenuButton = new Lang.Class({
this._settings.set_int(WEATHER_REFRESH_INTERVAL, v); this._settings.set_int(WEATHER_REFRESH_INTERVAL, v);
}, },
get _center_forecast() {
if (!this._settings)
this.loadConfig();
return this._settings.get_boolean(WEATHER_CENTER_FORECAST_KEY);
},
set _center_forecast(v) {
if (!this._settings)
this.loadConfig();
this._settings.set_boolean(WEATHER_CENTER_FORECAST_KEY, v);
},
get _days_forecast() { get _days_forecast() {
if (!this._settings) this.loadConfig(); if (!this._settings)
this.loadConfig();
return this._settings.get_int(WEATHER_DAYS_FORECAST); return this._settings.get_int(WEATHER_DAYS_FORECAST);
}, },
set _days_forecast(v) { set _days_forecast(v) {
if (!this._settings) this.loadConfig(); if (!this._settings)
this.loadConfig();
this._settings.set_int(WEATHER_DAYS_FORECAST, v); this._settings.set_int(WEATHER_DAYS_FORECAST, v);
}, },
@ -1610,7 +1625,10 @@ const WeatherMenuButton = new Lang.Class({
this.destroyFutureWeather(); this.destroyFutureWeather();
this._forecast = []; this._forecast = [];
this._forecastBox = new St.BoxLayout(); this._forecastBox = new St.BoxLayout({
x_align: this._center_forecast ? St.Align.END : St.Align.START,
style_class: 'weather-forecast-box'
});
this._forecastScrollBox = new St.ScrollView({ this._forecastScrollBox = new St.ScrollView({
style_class: 'weather-forecasts' style_class: 'weather-forecasts'
@ -1650,7 +1668,7 @@ const WeatherMenuButton = new Lang.Class({
by.add_actor(forecastWeather.Temperature); by.add_actor(forecastWeather.Temperature);
let bb = new St.BoxLayout({ let bb = new St.BoxLayout({
style_class: 'weather-forecast-box' style_class: 'weather-forecast-iconbox'
}); });
bb.add_actor(forecastWeather.Icon); bb.add_actor(forecastWeather.Icon);
bb.add_actor(by); bb.add_actor(by);

@ -54,6 +54,7 @@ const WEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel';
const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; const WEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel';
const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const WEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel';
const WEATHER_REFRESH_INTERVAL = 'refresh-interval'; const WEATHER_REFRESH_INTERVAL = 'refresh-interval';
const WEATHER_CENTER_FORECAST_KEY = 'center-forecast';
const WEATHER_DAYS_FORECAST = 'days-forecast'; const WEATHER_DAYS_FORECAST = 'days-forecast';
// Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner) // Soup session (see https://bugzilla.gnome.org/show_bug.cgi?id=661323#c64) (Simon Legner)
@ -133,6 +134,8 @@ const WeatherPrefsWidget = new GObject.Class({
this.addSwitch("text_in_panel"); this.addSwitch("text_in_panel");
this.addLabel(_("Conditions in Panel")); this.addLabel(_("Conditions in Panel"));
this.addSwitch("comment_in_panel"); this.addSwitch("comment_in_panel");
this.addLabel(_("Center forecast"));
this.addSwitch("center_forecast");
this.addLabel(_("Number of days in forecast")); this.addLabel(_("Number of days in forecast"));
this.addComboBox(["2", "3", "4", "5"], "days_forecast"); this.addComboBox(["2", "3", "4", "5"], "days_forecast");
}, },
@ -701,6 +704,18 @@ const WeatherPrefsWidget = new GObject.Class({
this.Settings.set_int(WEATHER_REFRESH_INTERVAL, v); this.Settings.set_int(WEATHER_REFRESH_INTERVAL, v);
}, },
get center_forecast() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_boolean(WEATHER_CENTER_FORECAST_KEY);
},
set center_forecast(v) {
if (!this.Settings)
this.loadConfig();
this.Settings.set_boolean(WEATHER_CENTER_FORECAST_KEY, v);
},
get days_forecast() { get days_forecast() {
if (!this.Settings) if (!this.Settings)
this.loadConfig(); this.loadConfig();

Loading…
Cancel
Save