diff --git a/data/org.gnome.shell.extensions.openweather.gschema.xml b/data/org.gnome.shell.extensions.openweather.gschema.xml index f056fbd..eda20a2 100644 --- a/data/org.gnome.shell.extensions.openweather.gschema.xml +++ b/data/org.gnome.shell.extensions.openweather.gschema.xml @@ -111,6 +111,10 @@ 'center' Position in Panel + + 75.0 + Horizontal position of menu-box. + 600 Refresh interval (actual weather) diff --git a/data/weather-settings.ui b/data/weather-settings.ui index 5089cd5..b2bf5fc 100644 --- a/data/weather-settings.ui +++ b/data/weather-settings.ui @@ -170,6 +170,11 @@ 1 10 + + 100 + 0.10000000000000001 + 2 + True False @@ -348,7 +353,7 @@ - 720 + 775 480 True True @@ -872,6 +877,17 @@ 0 + + + True + False + Position of menu-box [%] from 0 (left) to 100 (right) + + + 0 + 1 + + True @@ -880,7 +896,7 @@ 0 - 1 + 2 @@ -891,7 +907,7 @@ 0 - 2 + 3 @@ -902,7 +918,7 @@ 0 - 3 + 4 @@ -913,7 +929,7 @@ 0 - 4 + 5 @@ -924,7 +940,7 @@ 0 - 5 + 6 @@ -935,7 +951,7 @@ 0 - 6 + 7 @@ -946,7 +962,7 @@ 0 - 7 + 8 @@ -957,7 +973,7 @@ 0 - 8 + 9 @@ -968,7 +984,7 @@ 0 - 9 + 10 @@ -979,7 +995,7 @@ 0 - 10 + 11 @@ -997,6 +1013,22 @@ 0 + + + 200 + True + True + True + menu-alignment-adjustment + True + False + 100 + + + 1 + 1 + + True @@ -1005,7 +1037,7 @@ 1 - 1 + 2 @@ -1016,7 +1048,7 @@ 1 - 2 + 3 @@ -1027,7 +1059,7 @@ 1 - 3 + 4 @@ -1038,7 +1070,7 @@ 1 - 4 + 5 @@ -1049,7 +1081,7 @@ 1 - 5 + 6 @@ -1060,7 +1092,7 @@ 1 - 6 + 7 @@ -1071,7 +1103,7 @@ 1 - 7 + 8 @@ -1082,7 +1114,7 @@ 1 - 8 + 9 @@ -1103,7 +1135,7 @@ 1 - 9 + 10 @@ -1119,7 +1151,7 @@ 1 - 10 + 11 diff --git a/src/extension.js b/src/extension.js index a03f088..50372bd 100644 --- a/src/extension.js +++ b/src/extension.js @@ -74,6 +74,7 @@ const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; +const OPENWEATHER_MENU_ALIGNMENT_KEY = 'menu-alignment'; const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; @@ -178,7 +179,7 @@ const OpenweatherMenuButton = new Lang.Class({ }); // Panel menu item - the current class - let menuAlignment = 0.25; + let menuAlignment = 1.0 - (this._menu_alignment / 100); if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) menuAlignment = 1.0 - menuAlignment; this.parent(menuAlignment); @@ -758,6 +759,12 @@ const OpenweatherMenuButton = new Lang.Class({ return this._settings.get_enum(OPENWEATHER_POSITION_IN_PANEL_KEY); }, + get _menu_alignment() { + if (!this._settings) + this.loadConfig(); + return this._settings.get_double(OPENWEATHER_MENU_ALIGNMENT_KEY); + }, + get _comment_in_panel() { if (!this._settings) this.loadConfig(); @@ -1178,6 +1185,13 @@ const OpenweatherMenuButton = new Lang.Class({ return; }, + checkAlignment: function() { + let menuAlignment = 1.0 - (this._menu_alignment / 100); + if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) + menuAlignment = 1.0 - menuAlignment; + this.menu._arrowAlignment=menuAlignment; + }, + checkPositionInPanel: function() { if (this._old_position_in_panel != this._position_in_panel) { switch (this._old_position_in_panel) { diff --git a/src/forecast_io.js b/src/forecast_io.js index 5178381..c55806a 100644 --- a/src/forecast_io.js +++ b/src/forecast_io.js @@ -120,6 +120,7 @@ function parseWeatherCurrent() { (this.currentWeatherCache == "in refresh")) return; + this.checkAlignment(); this.checkPositionInPanel(); let json = this.currentWeatherCache; diff --git a/src/openweathermap_org.js b/src/openweathermap_org.js index 3c7849d..c252100 100644 --- a/src/openweathermap_org.js +++ b/src/openweathermap_org.js @@ -301,6 +301,7 @@ function parseWeatherCurrent() { if (this.currentWeatherCache == "in refresh") return; + this.checkAlignment(); this.checkPositionInPanel(); let json = this.currentWeatherCache; diff --git a/src/prefs.js b/src/prefs.js index c894ff7..eb5ccd6 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -58,6 +58,7 @@ const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons'; const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel'; const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel'; +const OPENWEATHER_MENU_ALIGNMENT_KEY = 'menu-alignment'; const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel'; const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast'; const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; @@ -420,6 +421,8 @@ const WeatherPrefsWidget = new GObject.Class({ this.initComboBox(theObjects[i]); else if (theObjects[i].class_path()[1].indexOf('GtkSwitch') != -1) this.initSwitch(theObjects[i]); + else if (theObjects[i].class_path()[1].indexOf('GtkScale') != -1) + this.initScale(theObjects[i]); this.configWidgets.push([theObjects[i], name]); } } @@ -478,6 +481,21 @@ const WeatherPrefsWidget = new GObject.Class({ })); }, + initScale: function(theScale) { + let name = theScale.get_name(); + theScale.set_value(this[name]); + this[name+'Timeout'] = undefined; + theScale.connect("value-changed", Lang.bind(this, function(slider) { + if (this[name+'Timeout'] !== undefined) + Mainloop.source_remove(this[name+'Timeout']); + this[name+'Timeout'] = Mainloop.timeout_add(250, Lang.bind(this, function() { + this[name] = slider.get_value(); + return false; + })); + })); + + }, + refreshUI: function() { this.MainWidget = this.Window.get_object("main-widget"); this.treeview = this.Window.get_object("tree-treeview"); @@ -879,6 +897,18 @@ const WeatherPrefsWidget = new GObject.Class({ this.Settings.set_enum(OPENWEATHER_POSITION_IN_PANEL_KEY, v); }, + get menu_alignment() { + if (!this.Settings) + this.loadConfig(); + return this.Settings.get_double(OPENWEATHER_MENU_ALIGNMENT_KEY); + }, + + set menu_alignment(v) { + if (!this.Settings) + this.loadConfig(); + return this.Settings.set_double(OPENWEATHER_MENU_ALIGNMENT_KEY, v); + }, + get comment_in_panel() { if (!this.Settings) this.loadConfig();