From 14203f055a84d08ac32ab003670a99b51ba0a6c7 Mon Sep 17 00:00:00 2001 From: simon04 Date: Mon, 7 Nov 2011 20:58:26 +0100 Subject: [PATCH 1/9] see #11 - attempt to respect proxy settings (patch by popsas-lt) --- src/extension.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/extension.js b/src/extension.js index 651c6f0..46a5e9d 100644 --- a/src/extension.js +++ b/src/extension.js @@ -449,6 +449,10 @@ WeatherMenuButton.prototype = { load_json_async: function(url, fun) { let here = this; let session = new Soup.SessionAsync(); + + if (Soup.Session.prototype.add_feature != null) + Soup.Session.prototype.add_feature.call(session, new Soup.ProxyResolverDefault()); + let message = Soup.Message.new('GET', url); session.queue_message(message, function(session, message) { let jp = new Json.Parser(); From 2670aa766bee0361a456717812043dc4a869672d Mon Sep 17 00:00:00 2001 From: Ari Pollak Date: Mon, 14 Nov 2011 11:27:32 -0500 Subject: [PATCH 2/9] add info about dependencies needed to build from source --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8f67a2b..73ecc3c 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Currently, the weather report including forecast for today and tomorrow is fetch * [Ubuntu](https://launchpad.net/~webupd8team/+archive/gnome3/+packages) * Generic: For a generic installation, run the following commands: `./autogen.sh --prefix=/usr && make && sudo make install` + * Make sure you have the libglib2.0-dev package (or equivalent for your distribution) + installed, or else you'll get an error about GLIB_GSETTINGS. * *Please report further links!* That's it! From 3158d0f4f4cdd3b8868127efeabf7dedc5c761df Mon Sep 17 00:00:00 2001 From: simon04 Date: Mon, 14 Nov 2011 17:31:12 +0100 Subject: [PATCH 3/9] readme: formatting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73ecc3c..41e551f 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ Currently, the weather report including forecast for today and tomorrow is fetch * [Ubuntu](https://launchpad.net/~webupd8team/+archive/gnome3/+packages) * Generic: For a generic installation, run the following commands: `./autogen.sh --prefix=/usr && make && sudo make install` - * Make sure you have the libglib2.0-dev package (or equivalent for your distribution) - installed, or else you'll get an error about GLIB_GSETTINGS. + * Make sure you have the `libglib2.0-dev` package (or equivalent for your distribution) + installed, or else you'll get an error about `GLIB_GSETTINGS`. * *Please report further links!* That's it! From 309c2f2156d935728221b409395d3d2feff142d1 Mon Sep 17 00:00:00 2001 From: simon04 Date: Sun, 20 Nov 2011 22:35:28 +0100 Subject: [PATCH 4/9] use YQL to fetch all weather data (see #25) --- src/extension.js | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/extension.js b/src/extension.js index 46a5e9d..89fea0e 100644 --- a/src/extension.js +++ b/src/extension.js @@ -205,11 +205,7 @@ WeatherMenuButton.prototype = { }, get_weather_url: function() { - return 'http://weather.yahooapis.com/forecastjson?u=' + this.unit_to_url() + '&p=' + this._woeid; - }, - - get_forecast_url: function() { - return 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20item.forecast%20from%20weather.forecast%20where%20location%3D%22' + this._woeid + '%22%20%20and%20u="' + this.unit_to_url() + '"'; + return 'http://query.yahooapis.com/v1/public/yql?format=json&q=select location,wind,atmosphere,units,item.condition,item.forecast from weather.forecast where location="' + this._woeid + '" and u="' + this.unit_to_url() + '"'; }, get_weather_icon: function(code) { @@ -462,9 +458,13 @@ WeatherMenuButton.prototype = { }, refreshWeather: function(recurse) { - // Refresh current weather - this.load_json_async(this.get_weather_url(), function(weather) { + this.load_json_async(this.get_weather_url(), function(json) { + let weather = json.get_object_member('query').get_object_member('results').get_object_member('channel'); + let weather_c = weather.get_object_member('item').get_object_member('condition'); + let forecast = weather.get_object_member('item').get_array_member('forecast').get_elements(); + + /* TODO won't work with the new URL // Fixes wrong woeid if necessary try { // Wrong woeid specified @@ -485,33 +485,33 @@ WeatherMenuButton.prototype = { } catch(e) { global.log('A ' + e.name + ' has occured: ' + e.message); } + */ let location = weather.get_object_member('location').get_string_member('city'); if (this._city != null && this._city.length > 0) location = this._city; - let comment = weather.get_object_member('condition').get_string_member('text'); + // Refresh current weather + let comment = weather_c.get_string_member('text'); if (this._translate_condition) - comment = this.get_weather_condition(weather.get_object_member('condition').get_string_member('code')); + comment = this.get_weather_condition(weather_c.get_string_member('code')); - let temperature = weather.get_object_member('condition').get_double_member('temperature'); + let temperature = weather_c.get_string_member('temp'); let humidity = weather.get_object_member('atmosphere').get_string_member('humidity') + ' %'; - let pressure = weather.get_object_member('atmosphere').get_double_member('pressure'); + let pressure = weather.get_object_member('atmosphere').get_string_member('pressure'); let pressure_unit = weather.get_object_member('units').get_string_member('pressure'); let wind_direction = weather.get_object_member('wind').get_string_member('direction'); - let wind = weather.get_object_member('wind').get_double_member('speed'); + let wind = weather.get_object_member('wind').get_string_member('speed'); let wind_unit = weather.get_object_member('units').get_string_member('speed'); - let iconname = this.get_weather_icon_safely(weather.get_object_member('condition').get_string_member('code')); + let iconname = this.get_weather_icon_safely(weather_c.get_string_member('code')); this._currentWeatherIcon.icon_name = this._weatherIcon.icon_name = iconname; - if(this._comment_in_panel) + if (this._comment_in_panel) this._weatherInfo.text = (comment + ' ' + temperature + ' ' + this.unit_to_unicode()); else this._weatherInfo.text = (temperature + ' ' + this.unit_to_unicode()); - - this._currentWeatherSummary.text = comment; this._currentWeatherLocation.text = location; this._currentWeatherTemperature.text = temperature + ' ' + this.unit_to_unicode(); @@ -519,16 +519,11 @@ WeatherMenuButton.prototype = { this._currentWeatherPressure.text = pressure + ' ' + pressure_unit; this._currentWeatherWind.text = (wind_direction ? wind_direction + ' ' : '') + wind + ' ' + wind_unit; - }); - - // Refresh forecast - this.load_json_async(this.get_forecast_url(), function(forecast) { - + // Refresh forecast let date_string = [_('Today'), _('Tomorrow')]; - forecast = forecast.get_object_member('query').get_object_member('results').get_array_member('channel').get_elements(); for (let i = 0; i <= 1; i++) { let forecastUi = this._forecast[i]; - let forecastData = forecast[i].get_object().get_object_member('item').get_object_member('forecast'); + let forecastData = forecast[i].get_object(); let code = forecastData.get_string_member('code'); let t_low = forecastData.get_string_member('low'); From 5c6848101c32a096de4becb7f6dd1dcfbf2b1d5c Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 20:18:33 +0100 Subject: [PATCH 5/9] make interval configurable (fix #27) --- README.md | 6 ++++++ src/extension.js | 13 ++++++++++++- ...rg.gnome.shell.extensions.weather.gschema.xml.in | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41e551f..39d6646 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ The position of this GNOME Shell extension in the panel can be configured to eit gsettings set org.gnome.shell.extensions.weather position-in-panel left gsettings set org.gnome.shell.extensions.weather position-in-panel right +#### Refresh Interval (optional, 240 by default) + +The interval to refresh the weather information may be set arbitrarily and is specified in seconds. + + gsettings set org.gnome.shell.extensions.weather refresh-interval 240 + #### Restart GNOME Shell Don't forget to restart GNOME Shell: diff --git a/src/extension.js b/src/extension.js index 89fea0e..725761d 100644 --- a/src/extension.js +++ b/src/extension.js @@ -54,6 +54,7 @@ const WEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons'; 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'; // Keep enums in sync with GSettings schemas const WeatherUnits = { @@ -90,6 +91,8 @@ WeatherMenuButton.prototype = { this._text_in_panel = this._settings.get_boolean(WEATHER_SHOW_TEXT_IN_PANEL_KEY); this._position_in_panel = this._settings.get_enum(WEATHER_POSITION_IN_PANEL_KEY); this._comment_in_panel = this._settings.get_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY); + this._refresh_interval = this._settings.get_int(WEATHER_REFRESH_INTERVAL); + global.log(this._refresh_interval); // Watch settings for changes let load_settings_and_refresh_weather = Lang.bind(this, function() { @@ -114,6 +117,10 @@ WeatherMenuButton.prototype = { this._forecast[1].Icon.icon_type = this._icon_type; this.refreshWeather(false); })); + this._settings.connect('changed::' + WEATHER_REFRESH_INTERVAL, Lang.bind(this, function() { + this._refresh_interval = this._settings.get_int(WEATHER_REFRESH_INTERVAL); + global.log(this._refresh_interval); + })); // Panel icon this._weatherIcon = new St.Icon({ @@ -460,6 +467,7 @@ WeatherMenuButton.prototype = { refreshWeather: function(recurse) { this.load_json_async(this.get_weather_url(), function(json) { + try { let weather = json.get_object_member('query').get_object_member('results').get_object_member('channel'); let weather_c = weather.get_object_member('item').get_object_member('condition'); let forecast = weather.get_object_member('item').get_array_member('forecast').get_elements(); @@ -539,11 +547,14 @@ WeatherMenuButton.prototype = { forecastUi.Icon.icon_name = this.get_weather_icon_safely(code); } + } catch(e) { + global.log('A ' + e.name + ' has occured: ' + e.message); + } }); // Repeatedly refresh weather if recurse is set if (recurse) { - Mainloop.timeout_add_seconds(60 * 4, Lang.bind(this, function() { + Mainloop.timeout_add_seconds(this._refresh_interval, Lang.bind(this, function() { this.refreshWeather(true); })); } diff --git a/src/org.gnome.shell.extensions.weather.gschema.xml.in b/src/org.gnome.shell.extensions.weather.gschema.xml.in index 95e9c9f..8a7964e 100644 --- a/src/org.gnome.shell.extensions.weather.gschema.xml.in +++ b/src/org.gnome.shell.extensions.weather.gschema.xml.in @@ -49,5 +49,10 @@ <_summary>Position in panel <_description>Set the position of this GNOME Shell extension in the panel to either 'center', 'left' or 'right' (requires restart). + + 240 + <_summary>Refresh interval in seconds + <_description>The interval in seconds to refresh the weather information. + From 452bcfe50d1fc6285f60c1adbe559dcdaab21a0c Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 20:33:32 +0100 Subject: [PATCH 6/9] remove debugging output --- src/extension.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/extension.js b/src/extension.js index 725761d..6406a8c 100644 --- a/src/extension.js +++ b/src/extension.js @@ -92,7 +92,6 @@ WeatherMenuButton.prototype = { this._position_in_panel = this._settings.get_enum(WEATHER_POSITION_IN_PANEL_KEY); this._comment_in_panel = this._settings.get_boolean(WEATHER_SHOW_COMMENT_IN_PANEL_KEY); this._refresh_interval = this._settings.get_int(WEATHER_REFRESH_INTERVAL); - global.log(this._refresh_interval); // Watch settings for changes let load_settings_and_refresh_weather = Lang.bind(this, function() { @@ -119,7 +118,6 @@ WeatherMenuButton.prototype = { })); this._settings.connect('changed::' + WEATHER_REFRESH_INTERVAL, Lang.bind(this, function() { this._refresh_interval = this._settings.get_int(WEATHER_REFRESH_INTERVAL); - global.log(this._refresh_interval); })); // Panel icon From bdc7f5a1c5806b2a1f147ca9f805382bcafb1c01 Mon Sep 17 00:00:00 2001 From: simon04 Date: Mon, 5 Dec 2011 09:30:49 +0100 Subject: [PATCH 7/9] Added Chinese translation thanks to Tao Zhu. --- po/LINGUAS | 1 + po/zh_CN.po | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 263 insertions(+) create mode 100644 po/zh_CN.po diff --git a/po/LINGUAS b/po/LINGUAS index fa13c15..41a6a32 100644 --- a/po/LINGUAS +++ b/po/LINGUAS @@ -11,3 +11,4 @@ pl ro ru sv +zh_CN diff --git a/po/zh_CN.po b/po/zh_CN.po new file mode 100644 index 0000000..da911a4 --- /dev/null +++ b/po/zh_CN.po @@ -0,0 +1,262 @@ +# Chinese translation for gnome-shell-extension-weather +# simon 软件包的简体中文翻译. +# Copyright (C) 2011 +# This file is distributed under the same license as the gnome-shell-extension-weather package. +# bill , 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: simon 04-gnome-shell-extension-weather-452bcfe\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-05-27 01:22+0200\n" +"PO-Revision-Date: 2011-12-02 14:44+0800\n" +"Last-Translator: Tao Zhu \n" +"Language-Team: Chinese (simplified)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: extension.js:73 +msgid "..." +msgstr "..." + +#: extension.js:228 +msgid "Tornado" +msgstr "龙卷风" + +#: extension.js:230 +msgid "Tropical storm" +msgstr "热带风暴" + +#: extension.js:232 +msgid "Hurricane" +msgstr "飓风" + +#: extension.js:234 +msgid "Severe thunderstorms" +msgstr "雷暴" + +#: extension.js:236 +msgid "Thunderstorms" +msgstr "雷阵雨" + +#: extension.js:238 +msgid "Mixed rain and snow" +msgstr "雨夹雪" + +#: extension.js:240 +msgid "Mixed rain and sleet" +msgstr "雨夹雪" + +#: extension.js:242 +msgid "Mixed snow and sleet" +msgstr "雨夹雪" + +#: extension.js:244 +msgid "Freezing drizzle" +msgstr "冻雨" + +#: extension.js:246 +msgid "Drizzle" +msgstr "小雨" + +#: extension.js:248 +msgid "Freezing rain" +msgstr "冻雨" + +#: extension.js:250 +#: extension.js:252 +msgid "Showers" +msgstr "阵雨" + +#: extension.js:254 +msgid "Snow flurries" +msgstr "阵雪" + +#: extension.js:256 +msgid "Light snow showers" +msgstr "小雪" + +#: extension.js:258 +msgid "Blowing snow" +msgstr "暴雪" + +#: extension.js:260 +msgid "Snow" +msgstr "雪" + +#: extension.js:262 +msgid "Hail" +msgstr "冰雹" + +#: extension.js:264 +msgid "Sleet" +msgstr "雨夹雪" + +#: extension.js:266 +msgid "Dust" +msgstr "扬沙" + +#: extension.js:268 +msgid "Foggy" +msgstr "雾" + +#: extension.js:270 +msgid "Haze" +msgstr "霾" + +#: extension.js:272 +msgid "Smoky" +msgstr "烟雾" + +#: extension.js:274 +msgid "Blustery" +msgstr "大风" + +#: extension.js:276 +msgid "Windy" +msgstr "刮风" + +#: extension.js:278 +msgid "Cold" +msgstr "冷" + +#: extension.js:280 +msgid "Cloudy" +msgstr "多云" + +#: extension.js:283 +msgid "Mostly cloudy" +msgstr "多云" + +#: extension.js:286 +#: extension.js:312 +msgid "Partly cloudy" +msgstr "晴转多云 " + +#: extension.js:288 +msgid "Clear" +msgstr "晴" + +#: extension.js:290 +msgid "Sunny" +msgstr "晴" + +#: extension.js:293 +msgid "Fair" +msgstr "晴" + +#: extension.js:295 +msgid "Mixed rain and hail" +msgstr "冰雹" + +#: extension.js:297 +msgid "Hot" +msgstr "炎热" + +#: extension.js:299 +msgid "Isolated thunderstorms" +msgstr "局地雷阵雨" + +#: extension.js:302 +msgid "Scattered thunderstorms" +msgstr "零星雷阵雨" + +#: extension.js:304 +msgid "Scattered showers" +msgstr "零星小雪" + +#: extension.js:306 +#: extension.js:310 +msgid "Heavy snow" +msgstr "大雪" + +#: extension.js:308 +msgid "Scattered snow showers" +msgstr "零星阵雪" + +#: extension.js:314 +msgid "Thundershowers" +msgstr "雷阵雨" + +#: extension.js:316 +msgid "Snow showers" +msgstr "阵雪" + +#: extension.js:318 +msgid "Isolated thundershowers" +msgstr "局地雷阵雨" + +#: extension.js:321 +msgid "Not available" +msgstr "不可用" + +#: extension.js:336 +msgid "Monday" +msgstr "星期一" + +#: extension.js:336 +msgid "Tuesday" +msgstr "星期二" + +#: extension.js:336 +msgid "Wednesday" +msgstr "星期三" + +#: extension.js:336 +msgid "Thursday" +msgstr "星期四" + +#: extension.js:336 +msgid "Friday" +msgstr "星期五" + +#: extension.js:336 +msgid "Saturday" +msgstr "星期六" + +#: extension.js:336 +msgid "Sunday" +msgstr "星期日" + +#: extension.js:392 +msgid "Today" +msgstr "今天" + +#: extension.js:392 +msgid "Tomorrow" +msgstr "明天" + +#: extension.js:429 +msgid "Loading current weather ..." +msgstr "正在加载当前天气 ..." + +#: extension.js:430 +msgid "Loading future weather ..." +msgstr "正在加载预报天气 ..." + +#: extension.js:446 +msgid "Loading ..." +msgstr "正在加载 ..." + +#: extension.js:449 +msgid "Please wait" +msgstr "请等待" + +#: extension.js:467 +msgid "Temperature:" +msgstr "温度:" + +#: extension.js:469 +msgid "Humidity:" +msgstr "湿度:" + +#: extension.js:471 +msgid "Pressure:" +msgstr "气压:" + +#: extension.js:473 +msgid "Wind:" +msgstr "风力:" + From e6132f218561dd0b1be833a3315cc3f076f9fbcc Mon Sep 17 00:00:00 2001 From: simon04 Date: Mon, 5 Dec 2011 09:39:15 +0100 Subject: [PATCH 8/9] Add support for Gnome 3.3 (fix #44) --- src/metadata.json.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/metadata.json.in b/src/metadata.json.in index e5063c9..7f7fab7 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" ], +"shell-version": [ "3.1.90", "3.1.91", "3.1.92", "3.2", "3.3" ], "localedir": "@LOCALEDIR@", "url": "@url@" } From 2a8a9ebe3ed57d474784f12ca5ede6280dbafd65 Mon Sep 17 00:00:00 2001 From: simon04 Date: Mon, 5 Dec 2011 09:44:36 +0100 Subject: [PATCH 9/9] Update README to reflect correct WOEID (fix #41). --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39d6646..d33ba86 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,9 @@ gnome-shell-extension-weather uses gsettings to save your configuration. You can #### Location -See [WOEID Info](http://sigizmund.info/woeidinfo/) to determine your WOEID. You can specify your location using the following command. Perhaps you need quotation marks as in the second command. +At the moment, only WOEIDs consisting of 4 uppercase letters followed by 4 digits are supported. Determine your WOEID using [edg3.co.uk](http://edg3.co.uk/snippets/weather-location-codes/) or [xoap.weather.com](http://xoap.weather.com/search/search?where=Innsbruck). + +You can specify your location using the following command. Perhaps you need quotation marks as in the second command. gsettings set org.gnome.shell.extensions.weather woeid your_woeid gsettings set org.gnome.shell.extensions.weather woeid "'your_woeid'"