Merge branch 'master' into prefs

yahoo_weather
simon04 13 years ago
commit ef17385d95
  1. 12
      README.md
  2. 1
      po/LINGUAS
  3. 262
      po/zh_CN.po
  4. 54
      src/extension.js
  5. 2
      src/metadata.json.in
  6. 5
      src/org.gnome.shell.extensions.weather.gschema.xml.in

@ -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!
@ -38,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'"
@ -92,6 +96,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:

@ -11,3 +11,4 @@ pl
ro
ru
sv
zh_CN

@ -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 <bill_zt@sina.com>, 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 <bill_zt@sina.com>\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 "风力:"

@ -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,7 @@ 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);
// Watch settings for changes
let load_settings_and_refresh_weather = Lang.bind(this, function() {
@ -114,6 +116,9 @@ 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);
}));
// Panel icon
this._weatherIcon = new St.Icon({
@ -216,11 +221,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) {
@ -460,6 +461,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();
@ -469,9 +474,14 @@ 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) {
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();
/* TODO won't work with the new URL
// Fixes wrong woeid if necessary
try {
// Wrong woeid specified
@ -492,33 +502,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();
@ -526,16 +536,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) {
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');
@ -551,11 +556,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);
}));
}

@ -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@"
}

@ -49,5 +49,10 @@
<_summary>Position in panel</_summary>
<_description>Set the position of this GNOME Shell extension in the panel to either 'center', 'left' or 'right' (requires restart).</_description>
</key>
<key name="refresh-interval" type="i">
<default>240</default>
<_summary>Refresh interval in seconds</_summary>
<_description>The interval in seconds to refresh the weather information.</_description>
</key>
</schema>
</schemalist>

Loading…
Cancel
Save