From 1e0529b5a61e0b7247583b44bef43ed583be8867 Mon Sep 17 00:00:00 2001 From: Neroth Date: Thu, 26 Apr 2012 21:09:22 +0200 Subject: [PATCH] Fix for GNOME Shell 3.4 compatibility --- src/extension.js | 45 ++++++++++++++++++++++++++++---------- src/metadata.json.in | 2 +- src/weather-settings.js.in | 36 ++++++++++++++++-------------- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/extension.js b/src/extension.js index c9dd6c9..eaf127b 100644 --- a/src/extension.js +++ b/src/extension.js @@ -30,6 +30,7 @@ */ const Cairo = imports.cairo; +const Clutter = imports.gi.Clutter; const Gettext = imports.gettext.domain('gnome-shell-extension-weather'); const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; @@ -83,21 +84,39 @@ WeatherMenuButton.prototype = { // Load settings this.loadConfig(); - // Panel icon - this._weatherIcon = new St.Icon({ - icon_type: this._icon_type, - icon_name: 'view-refresh-symbolic', - style_class: 'system-status-icon weather-icon' + (Main.panel.actor.get_direction() == St.TextDirection.RTL ? '-rtl' : '') - }); - // Label this._weatherInfo = new St.Label({ text: _('...') }); - // Panel menu item - the current class - let menuAlignment = 0.25; - if (St.Widget.get_default_direction() == St.TextDirection.RTL) - menuAlignment = 1.0 - menuAlignment; - PanelMenu.Button.prototype._init.call(this, menuAlignment); + if(typeof St.TextDirection == "undefined") + { + // Panel icon + this._weatherIcon = new St.Icon({ + icon_type: this._icon_type, + icon_name: 'view-refresh-symbolic', + style_class: 'system-status-icon weather-icon' + (Main.panel.actor.get_text_direction() == Clutter.TextDirection.RTL ? '-rtl' : '') + }); + + // Panel menu item - the current class + let menuAlignment = 0.25; + if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) + menuAlignment = 1.0 - menuAlignment; + PanelMenu.Button.prototype._init.call(this, menuAlignment); + } + else + { + // Panel icon + this._weatherIcon = new St.Icon({ + icon_type: this._icon_type, + icon_name: 'view-refresh-symbolic', + style_class: 'system-status-icon weather-icon' + (Main.panel.actor.get_direction() == St.TextDirection.RTL ? '-rtl' : '') + }); + + // Panel menu item - the current class + let menuAlignment = 0.25; + if (St.Widget.get_default_direction() == St.TextDirection.RTL) + menuAlignment = 1.0 - menuAlignment; + PanelMenu.Button.prototype._init.call(this, menuAlignment); + } // Putting the panel item together let topBox = new St.BoxLayout(); @@ -231,6 +250,8 @@ WeatherMenuButton.prototype = { cities = [cities]; var l = cities.length-1; +global.log(a < 0); +global.log(a); if(a < 0) a = 0; diff --git a/src/metadata.json.in b/src/metadata.json.in index 7f7fab7..c4811af 100644 --- a/src/metadata.json.in +++ b/src/metadata.json.in @@ -2,7 +2,7 @@ "uuid": "@uuid@", "name": "Weather indicator", "description": "Adds weather information menu", -"shell-version": [ "3.1.90", "3.1.91", "3.1.92", "3.2", "3.3" ], +"shell-version": [ "3.1.90", "3.1.91", "3.1.92", "3.2", "3.3", "3.4" ], "localedir": "@LOCALEDIR@", "url": "@url@" } diff --git a/src/weather-settings.js.in b/src/weather-settings.js.in index 746f4c4..4896138 100644 --- a/src/weather-settings.js.in +++ b/src/weather-settings.js.in @@ -199,7 +199,6 @@ WeatherSetting.prototype = if(!this.Settings) this.loadConfig(); var a = this.Settings.get_int(WEATHER_ACTUAL_CITY_KEY); - var b = a; var citys = this.city.split(" && "); if(citys && typeof citys == "string") @@ -216,8 +215,6 @@ WeatherSetting.prototype = if(a > l) a = l; - if(a != b) - this.actual_city = a; return a; }, @@ -333,28 +330,33 @@ WeatherSetting.prototype = { this.Window.get_object("tree-toolbutton-remove").sensitive = Boolean(this.city.length); - if(typeof this.liststore != "undefined") - this.liststore.clear(); - - if(this.city.length > 0) + if(this.mCities != this.city) { - var city = String(this.city).split(" && "); + if(typeof this.liststore != "undefined") + this.liststore.clear(); + + if(this.city.length > 0) + { + var city = String(this.city).split(" && "); - if(city && typeof city == "string") - city = [city]; + if(city && typeof city == "string") + city = [city]; - var iter = this.iter; + var iter = this.iter; - for(var i in city) - { - var a = this.liststore.append(iter); - var current = a.iter; - this.liststore.set_value(current,0,city[i]); + for(var i in city) + { + var a = this.liststore.append(iter); + var current = a.iter; + this.liststore.set_value(current,0,city[i]); + } } - this.changeSelection(); + this.mCities = this.city; } + this.changeSelection(); + var config = this.configWidgets; for(var i in config) if(config[i][0].active != this[config[i][1]])