diff --git a/data/org.gnome.shell.extensions.weather.gschema.xml.in b/data/org.gnome.shell.extensions.weather.gschema.xml.in index 92a6b27..7713410 100644 --- a/data/org.gnome.shell.extensions.weather.gschema.xml.in +++ b/data/org.gnome.shell.extensions.weather.gschema.xml.in @@ -88,6 +88,10 @@ 300 <_summary>Refresh interval + + false + <_summary>Center forecastbox. + 2 <_summary>Number of days in forecast diff --git a/data/stylesheet.css b/data/stylesheet.css index 0f59b06..3945479 100644 --- a/data/stylesheet.css +++ b/data/stylesheet.css @@ -39,9 +39,12 @@ padding-right: 15px; .weather-forecasts { -st-hfade-offset: 60px; } + +.weather-forecast-box { +} + .weather-forecast-databox { -min-width: 120px; -padding-right: 30px; +min-width: 140px; } .weather-forecast-day { @@ -49,6 +52,9 @@ color: #999999; font-size: 90%; } +.weather-forecast-iconbox { +} + .weather-sunrise-icon { padding-right: 5px; } diff --git a/src/extension.js b/src/extension.js index 79a254a..648ef18 100644 --- a/src/extension.js +++ b/src/extension.js @@ -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_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const WEATHER_REFRESH_INTERVAL = 'refresh-interval'; +const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; const WEATHER_DAYS_FORECAST = 'days-forecast'; // Keep enums in sync with GSettings schemas @@ -499,13 +500,27 @@ const WeatherMenuButton = new Lang.Class({ 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() { - if (!this._settings) this.loadConfig(); + if (!this._settings) + this.loadConfig(); return this._settings.get_int(WEATHER_DAYS_FORECAST); }, set _days_forecast(v) { - if (!this._settings) this.loadConfig(); + if (!this._settings) + this.loadConfig(); this._settings.set_int(WEATHER_DAYS_FORECAST, v); }, @@ -1610,7 +1625,10 @@ const WeatherMenuButton = new Lang.Class({ this.destroyFutureWeather(); 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({ style_class: 'weather-forecasts' @@ -1650,7 +1668,7 @@ const WeatherMenuButton = new Lang.Class({ by.add_actor(forecastWeather.Temperature); let bb = new St.BoxLayout({ - style_class: 'weather-forecast-box' + style_class: 'weather-forecast-iconbox' }); bb.add_actor(forecastWeather.Icon); bb.add_actor(by); diff --git a/src/prefs.js b/src/prefs.js index 7c872c8..f7e7fdf 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -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_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const WEATHER_REFRESH_INTERVAL = 'refresh-interval'; +const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; const WEATHER_DAYS_FORECAST = 'days-forecast'; // 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.addLabel(_("Conditions in Panel")); this.addSwitch("comment_in_panel"); + this.addLabel(_("Center forecast")); + this.addSwitch("center_forecast"); this.addLabel(_("Number of days in 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); }, + 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() { if (!this.Settings) this.loadConfig();