Merge pull request #3 from ecyrbe/master

improves translation, packagin and settings
yahoo_weather
simon04 14 years ago
commit 48f6bdc0d8
  1. 17
      .gitignore
  2. 4
      Makefile.am
  3. 16
      NEWS
  4. 61
      README
  5. 59
      README.md
  6. 20
      autogen.sh
  7. 3
      config/.gitignore
  8. 28
      configure.ac
  9. 0
      data/screenshot.png
  10. BIN
      data/screenshot2.png
  11. 1
      m4/.gitignore
  12. 2
      po/LINGUAS
  13. 2
      po/POTFILES.in
  14. 260
      po/fr.po
  15. 258
      po/gnome-shell-extension-weather.pot
  16. 32
      src/Makefile.am
  17. 203
      src/extension.js
  18. 8
      src/metadata.json.in
  19. 23
      src/org.gnome.shell.extensions.weather.gschema.xml.in
  20. 0
      src/stylesheet.css
  21. 1
      weather@venemo.net/metadata.json

17
.gitignore vendored

@ -0,0 +1,17 @@
Makefile
Makefile.in
Makefile.in.in
configure
config.log
config.status
aclocal.m4
autom4te.cache/
po/POTFILES
po/stamp-it
staging/
*~
*.gmo
metadata.json
*.gschema.xml
*.gschema.valid

@ -0,0 +1,4 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = src po

16
NEWS

@ -0,0 +1,16 @@
0.4
===
- add autotools support
0.3
===
- add translation support
0.2
===
- add yahoo backend
- add symbolic icons
0.1 (
===
first skeleton implementation

@ -0,0 +1,61 @@
## gnome-shell-extension-weather
gnome-shell-extension-weather is a simple extension for displaying weather notifications in Gnome Shell.
Currently, the weather report including forecast for today and tomorrow is fetched from [Yahoo](http://weather.yahoo.com/).
### Screenshot
![Screenshot](https://github.com/ecyrbe/gnome-shell-extension-weather/raw/master/data/screenshot.png)
### Installation
From the command line
1. ./autogen.sh --prefix="/usr"
2. make
3. sudo make install
that's it!
### Configuration
Gnome extension weather use gsettings to save your configuration
You can modify the temperature unit with the following command
. gsettings set org.gnome.shell.extensions.weather unit 'celsius'
or
. gsettings set org.gnome.shell.extensions.weather unit 'fahrenheit'
You can specify your location buy using this command, (cf. [WOEID](http://developer.yahoo.com/geo/geoplanet/guide/concepts.html))
. gsettings set org.gnome.shell.extensions.weather woeid 'your location'
Sometimes your woeid location isn't quite right. it's the next major city around. to customise the displayed city you can type :
. gsettings set org.gnome.shell.extensions.weather city 'your city'
### Restart Gnome-Shell
Don't forget to restart Gnome-Shell
1. Restart Gnome Shell (`[Alt]+[F2]`, `r`)
2. Fork this project as you like
### Licence
Copyright (C) 2011
Ecyrbe <ecyrbe+spam@gmail.com>,
Timur Kristóf <venemo@msn.com>,
Elad Alfassa <elad@fedoraproject.org>,
Simon Legner <Simon.Legner@gmail.com>
This file is part of gnome-shell-extension-weather.
gnome-shell-extension-weather is free software: you can redistribute it and/or modify it under the terms of the **GNU General Public License as published by the Free Software Foundation, either version 3** of the License, or (at your option) any later version.
gnome-shell-extension-weather is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with gnome-shell-extension-weather. If not, see <http://www.gnu.org/licenses/>.

@ -4,20 +4,67 @@ gnome-shell-extension-weather is a simple extension for displaying weather notif
Currently, the weather report including forecast for today and tomorrow is fetched from [Yahoo](http://weather.yahoo.com/).
### Screenshot
### Screenshots
![Screenshot](https://github.com/simon04/gnome-shell-extension-weather/raw/master/screenshot.png)
![Screenshot](https://github.com/ecyrbe/gnome-shell-extension-weather/raw/master/data/screenshot.png)
And with french translation:
![Screenshot](https://github.com/ecyrbe/gnome-shell-extension-weather/raw/master/data/screenshot2.png)
### Installation
1. Change `YAHOO_ID` to your location in extension.js (cf. [WOEID](http://developer.yahoo.com/geo/geoplanet/guide/concepts.html))
2. Put directory `weather@venemo.com/` in `~/.local/share/gnome-shell/extensions/`
3. Restart Gnome Shell (`[Alt]+[F2]`, `r`)
4. Enjoy, contribute, ...
From the command line
1. ./autogen.sh --prefix="/usr"
2. make
3. sudo make install
That's it!
### Configuration
Gnome extension weather use gsettings to save your configuration. you can use dconf-editor or gsettings from the command line to modify some parameters
#### Location (cf [WOEID](http://developer.yahoo.com/geo/geoplanet/guide/concepts.html))
You can specify your location buy using this command:
```bash
gsettings set org.gnome.shell.extensions.weather woeid 'your location'
```
#### Temperature units (optional, celsius by default)
You can modify the temperature unit with the following command
```bash
gsettings set org.gnome.shell.extensions.weather unit 'celsius'
```
or
```bash
gsettings set org.gnome.shell.extensions.weather unit 'fahrenheit'
```
#### Displayed location (optional)
Sometimes your woeid location isn't quite right. it's the next major city around. to customise the displayed city you can type :
```bash
gsettings set org.gnome.shell.extensions.weather city 'your city'
```
### Restart Gnome-Shell
Don't forget to restart Gnome-Shell
1. Restart Gnome Shell (`[Alt]+[F2]`, `r`)
2. Fork this project as you like
### Licence
Copyright (C) 2011
Ecyrbe <ecyrbe+spam@gmail.com>,
Timur Kristóf <venemo@msn.com>,
Elad Alfassa <elad@fedoraproject.org>,
Simon Legner <Simon.Legner@gmail.com>

@ -0,0 +1,20 @@
#!/bin/bash
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
PKG_NAME="gnome-shell-extension-weather"
test -f $srcdir/configure.ac || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level gnome-shell-extensions directory"
exit 1
}
which gnome-autogen.sh || {
echo "You need to install gnome-common from GNOME Git (or from"
echo "your OS vendor's package manager)."
exit 1
}
. gnome-autogen.sh

3
config/.gitignore vendored

@ -0,0 +1,3 @@
install-sh
mkinstalldirs
missing

@ -0,0 +1,28 @@
AC_PREREQ(2.63)
dnl be carefull, the version needs to be in sync with your gnome shell version
AC_INIT([gnome-shell-extension-weather],[3.0],[https://github.com/ecyrbe/gnome-shell-extension-weather/issues])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([1.10 dist-bzip2 no-dist-gzip foreign tar-ustar])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
GETTEXT_PACKAGE=gnome-shell-extension-weather
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
[The prefix for our gettext translation domains.])
IT_PROG_INTLTOOL(0.26)
PKG_PROG_PKG_CONFIG([0.22])
GLIB_GSETTINGS
dnl Please keep this sorted alphabetically
AC_CONFIG_FILES([
Makefile
po/Makefile.in
src/Makefile
])
AC_OUTPUT

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

1
m4/.gitignore vendored

@ -0,0 +1 @@
intltool.m4

@ -0,0 +1,2 @@
fr

@ -0,0 +1,2 @@
src/extension.js

@ -0,0 +1,260 @@
# French translations for PACKAGE package
# Traductions françaises du paquet PACKAGE.
# Copyright (C) 2011 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Simon Claessens <gagalago@gmail.com>, 2011.
# ecyrbe <ecyrbe@gmail.com>, 2011.
#
msgid ""
msgstr ""
"Project-Id-Version: 3.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-05-27 01:22+0200\n"
"PO-Revision-Date: 2011-05-27 09:44+0200\n"
"Last-Translator: ecyrbe <ecyrbe@gmail.com>\n"
"Language-Team: Français <ecyrbe@gmail.com>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bits\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: extension.js:73
msgid "..."
msgstr "..."
#: extension.js:228
msgid "Tornado"
msgstr "Tornade"
#: extension.js:230
msgid "Tropical storm"
msgstr "Tempête tropicale"
#: extension.js:232
msgid "Hurricane"
msgstr "Ouragan"
#: extension.js:234
msgid "Severe thunderstorms"
msgstr "Orage sévère"
#: extension.js:236
msgid "Thunderstorms"
msgstr "Orage"
#: extension.js:238
msgid "Mixed rain and snow"
msgstr "Neige et pluie"
#: extension.js:240
msgid "Mixed rain and sleet"
msgstr "Grêle et pluie"
#: extension.js:242
msgid "Mixed snow and sleet"
msgstr "Neige et Grêle"
#: extension.js:244
msgid "Freezing drizzle"
msgstr "Pluie verglaçante"
#: extension.js:246
msgid "Drizzle"
msgstr "Pluie fine"
#: extension.js:248
msgid "Freezing rain"
msgstr "Pluie verglaçante"
#: extension.js:250 extension.js:252
msgid "Showers"
msgstr "Averses"
#: extension.js:254
msgid "Snow flurries"
msgstr "Neige"
#: extension.js:256
msgid "Light snow showers"
msgstr "Neige"
#: extension.js:258
msgid "Blowing snow"
msgstr "Neige"
#: extension.js:260
msgid "Snow"
msgstr "Neige"
#: extension.js:262
msgid "Hail"
msgstr "Grêle"
#: extension.js:264
msgid "Sleet"
msgstr "Grêlons"
#: extension.js:266
msgid "Dust"
msgstr "Brouillard"
#: extension.js:268
msgid "Foggy"
msgstr "Brouillard"
#: extension.js:270
msgid "Haze"
msgstr "Brume"
#: extension.js:272
msgid "Smoky"
msgstr "Brouillard"
#: extension.js:274
msgid "Blustery"
msgstr "Bourrasques de vent"
#: extension.js:276
msgid "Windy"
msgstr "Venteux"
#: extension.js:278
msgid "Cold"
msgstr "Froid"
#: extension.js:280
msgid "Cloudy"
msgstr "Nuageux"
#: extension.js:283
msgid "Mostly cloudy"
msgstr "Nuageux"
#: extension.js:286 extension.js:312
msgid "Partly cloudy"
msgstr "Éclaircies"
#: extension.js:288
msgid "Clear"
msgstr "Beau"
#: extension.js:290
msgid "Sunny"
msgstr "Ensoleillé"
#: extension.js:293
msgid "Fair"
msgstr "Beau"
#: extension.js:295
msgid "Mixed rain and hail"
msgstr "Pluie et Grêle"
#: extension.js:297
msgid "Hot"
msgstr "Chaud"
#: extension.js:299
msgid "Isolated thunderstorms"
msgstr "Orageux"
#: extension.js:302
msgid "Scattered thunderstorms"
msgstr "Orageux"
#: extension.js:304
msgid "Scattered showers"
msgstr "Grosses averses"
#: extension.js:306 extension.js:310
msgid "Heavy snow"
msgstr "Tempête de neige"
#: extension.js:308
msgid "Scattered snow showers"
msgstr "Tempête de neige"
#: extension.js:314
msgid "Thundershowers"
msgstr "Orages"
#: extension.js:316
msgid "Snow showers"
msgstr "Tempête de neige"
#: extension.js:318
msgid "Isolated thundershowers"
msgstr "Orageux"
#: extension.js:321
msgid "Not available"
msgstr "Non disponible"
#: extension.js:336
msgid "Monday"
msgstr "Lundi"
#: extension.js:336
msgid "Tuesday"
msgstr "Mardi"
#: extension.js:336
msgid "Wednesday"
msgstr "Mercredi"
#: extension.js:336
msgid "Thursday"
msgstr "Jeudi"
#: extension.js:336
msgid "Friday"
msgstr "Vendredi"
#: extension.js:336
msgid "Saturday"
msgstr "Samedi"
#: extension.js:336
msgid "Sunday"
msgstr "Dimanche"
#: extension.js:392
msgid "Today"
msgstr "Aujourd'hui"
#: extension.js:392
msgid "Tomorrow"
msgstr "Demain"
#: extension.js:429
msgid "Loading current weather ..."
msgstr "Chargement de la météo ..."
#: extension.js:430
msgid "Loading future weather ..."
msgstr "Chargement des prévisions ..."
#: extension.js:446
msgid "Loading ..."
msgstr "Chargement ..."
#: extension.js:449
msgid "Please wait"
msgstr "Patientez s'il vous plaît"
#: extension.js:467
msgid "Temperature:"
msgstr "Température :"
#: extension.js:469
msgid "Humidity:"
msgstr "Humidité :"
#: extension.js:471
msgid "Pressure:"
msgstr "Pression :"
#: extension.js:473
msgid "Wind:"
msgstr "Vent :"

@ -0,0 +1,258 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-05-27 01:22+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\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 ""

@ -0,0 +1,32 @@
extensionurl = https://github.com/ecyrbe/gnome-shell-extension-weather
# Change these to modify how installation is performed
topextensiondir = $(datadir)/gnome-shell/extensions
uuid = weather@gnome-shell-extensions.gnome.org
extensiondir = $(topextensiondir)/$(uuid)
dist_extension_DATA = extension.js stylesheet.css
nodist_extension_DATA = metadata.json $(EXTRA_EXTENSION)
EXTRA_DIST = metadata.json.in
metadata.json: metadata.json.in $(top_builddir)/config.status
$(AM_V_GEN) sed -e "s|[@]LOCALEDIR@|$(datadir)/locale|" \
-e "s|[@]uuid@|$(uuid)|" \
-e "s|[@]shell_current@|$(PACKAGE_VERSION)|" \
-e "s|[@]url@|$(extensionurl)|" $< > $@
CLEANFILES = metadata.json
gschemas_in = org.gnome.shell.extensions.weather.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml)
@GSETTINGS_RULES@
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)
EXTRA_DIST += $(gschemas_in)

@ -5,7 +5,8 @@
* - On click, gives a popup with details about the weather
Copyright (C) 2011
Timur Kristóf <venemo@msn.com>,
ecyrbe <ecyrbe+spam@gmail.com>,
Timur Kristof <venemo@msn.com>,
Elad Alfassa <elad@fedoraproject.org>,
Simon Legner <Simon.Legner@gmail.com>
@ -34,7 +35,7 @@ const Cairo = imports.cairo;
const Clutter = imports.gi.Clutter;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Gettext = imports.gettext.domain('gnome-shell');
const Gettext = imports.gettext.domain('gnome-shell-extension-weather');
const _ = Gettext.gettext;
const Json = imports.gi.Json;
@ -44,25 +45,42 @@ const PopupMenu = imports.ui.popupMenu;
const Soup = imports.gi.Soup;
const Util = imports.misc.util;
const UNITS = 'c'; // Units for temperature (case sensitive). f: Fahrenheit. c: Celsius
const YAHOO_ID = 'AUXX0010';
const WEATHER_URL = 'http://weather.yahooapis.com/forecastjson?u=' + UNITS + '&p=' + YAHOO_ID;
const FORECAST_URL = 'http://query.yahooapis.com/v1/public/yql?format=json&q=select%20item.forecast%20from%20weather.forecast%20where%20location%3D%22' + YAHOO_ID + '%22%20%20and%20u="' + UNITS + '"';
// Settings
const WEATHER_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.weather';
const WEATHER_UNIT_KEY = 'unit';
const WEATHER_CITY_KEY = 'city';
const WEATHER_WOEID_KEY = 'woeid';
// Keep enums in sync with GSettings schemas
const WeatherUnits = {
CELSIUS: 0,
FAHRENHEIT: 1
};
function WeatherMenuButton() {
this._init();
}
function getSettings(schema) {
if (Gio.Settings.list_schemas().indexOf(schema) == -1)
throw _("Schema \"%s\" not found.").format(schema);
return new Gio.Settings({ schema: schema });
}
WeatherMenuButton.prototype = {
__proto__: PanelMenu.Button.prototype,
_init: function() {
// Load Settings
this._settings = getSettings(WEATHER_SETTINGS_SCHEMA);
this._units = this._settings.get_enum(WEATHER_UNIT_KEY);
this._city = this._settings.get_string(WEATHER_CITY_KEY);
this._woeid = this._settings.get_string(WEATHER_WOEID_KEY);
// Panel icon
this._weatherIcon = new St.Icon({
icon_type: St.IconType.FULLCOLOR,
icon_size: Main.panel.button.get_child().height - 4,
icon_type: St.IconType.SYMBOLIC,
icon_size: Main.panel.button.get_child().height,
icon_name: 'view-refresh-symbolic',
style_class: 'weather-icon' + (Main.panel.actor.get_direction() == St.TextDirection.RTL ? '-rtl' : '')
});
@ -90,7 +108,7 @@ WeatherMenuButton.prototype = {
this._futureWeather = new St.Bin({style_class: 'forecast'/*, x_align: St.Align.START*/});
// Separator (copied from Gnome shell's popupMenu.js)
this._separatorArea = new St.DrawingArea({ style_class: 'popup-separator-menu-item' });
this._separatorArea = new St.DrawingArea({ style_class: 'popup-separator-menu-item' });
this._separatorArea.width = 200;
this._separatorArea.connect('repaint', Lang.bind(this, this._onSeparatorAreaRepaint));
@ -115,6 +133,32 @@ WeatherMenuButton.prototype = {
});
},
has_schema: function(schema){
let schemas = Gio.Settings.list_schemas();
for(let i=0;i<schemas.length;i++){
if(schemas[i]==schema){
return true;
}
}
return false;
},
unit_to_string: function(unit) {
if(unit == WeatherUnits.FAHRENHEIT){
return 'f';
}else {
return 'c';
}
},
get_weather_url: function() {
return 'http://weather.yahooapis.com/forecastjson?u=' + this.unit_to_string(this._units) + '&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_string(this._units) + '"';
},
get_weather_icon: function(code) {
switch (parseInt(code, 10)){
@ -196,7 +240,6 @@ WeatherMenuButton.prototype = {
case 37:/* isolated thunderstorms */
return 'weather-storm';
case 38:/* scattered thunderstorms */
return 'weather-storm';
case 39:/* scattered thunderstorms */
return 'weather-storm';
case 40:/* scattered showers */
@ -216,11 +259,125 @@ WeatherMenuButton.prototype = {
case 47:/* isolated thundershowers */
return 'weather-storm';
case 3200:/* not available */
return 'weather-severe-alert';
default:
return 'weather-severe-alert';
}
},
get_weather_condition: function(code) {
switch (parseInt(code, 10)){
case 0:/* tornado */
return _('Tornado');
case 1:/* tropical storm */
return _('Tropical storm');
case 2:/* hurricane */
return _('Hurricane');
case 3:/* severe thunderstorms */
return _('Severe thunderstorms');
case 4:/* thunderstorms */
return _('Thunderstorms');
case 5:/* mixed rain and snow */
return _('Mixed rain and snow');
case 6:/* mixed rain and sleet */
return _('Mixed rain and sleet');
case 7:/* mixed snow and sleet */
return _('Mixed snow and sleet');
case 8:/* freezing drizzle */
return _('Freezing drizzle');
case 9:/* drizzle */
return _('Drizzle');
case 10:/* freezing rain */
return _('Freezing rain');
case 11:/* showers */
return _('Showers');
case 12:/* showers */
return _('Showers');
case 13:/* snow flurries */
return _('Snow flurries');
case 14:/* light snow showers */
return _('Light snow showers');
case 15:/* blowing snow */
return _('Blowing snow');
case 16:/* snow */
return _('Snow');
case 17:/* hail */
return _('Hail');
case 18:/* sleet */
return _('Sleet');
case 19:/* dust */
return _('Dust');
case 20:/* foggy */
return _('Foggy');
case 21:/* haze */
return _('Haze');
case 22:/* smoky */
return _('Smoky');
case 23:/* blustery */
return _('Blustery');
case 24:/* windy */
return _('Windy');
case 25:/* cold */
return _('Cold');
case 26:/* cloudy */
return _('Cloudy');
case 27:/* mostly cloudy (night) */
case 28:/* mostly cloudy (day) */
return _('Mostly cloudy');
case 29:/* partly cloudy (night) */
case 30:/* partly cloudy (day) */
return _('Partly cloudy');
case 31:/* clear (night) */
return _('Clear');
case 32:/* sunny */
return _('Sunny');
case 33:/* fair (night) */
case 34:/* fair (day) */
return _('Fair');
case 35:/* mixed rain and hail */
return _('Mixed rain and hail');
case 36:/* hot */
return _('Hot');
case 37:/* isolated thunderstorms */
return _('Isolated thunderstorms');
case 38:/* scattered thunderstorms */
case 39:/* scattered thunderstorms */
return _('Scattered thunderstorms');
case 40:/* scattered showers */
return _('Scattered showers');
case 41:/* heavy snow */
return _('Heavy snow');
case 42:/* scattered snow showers */
return _('Scattered snow showers');
case 43:/* heavy snow */
return _('Heavy snow');
case 44:/* partly cloudy */
return _('Partly cloudy');
case 45:/* thundershowers */
return _('Thundershowers');
case 46:/* snow showers */
return _('Snow showers');
case 47:/* isolated thundershowers */
return _('Isolated thundershowers');
case 3200:/* not available */
default:
return _('Not available');
}
},
parse_day: function(abr) {
let yahoo_days = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
for(var i =0;i<yahoo_days.length;i++){
if( yahoo_days[i].substr(0,abr.length) == abr.toLowerCase()){
return i;
}
}
return 0;
},
get_locale_day: function(abr) {
let days = [_('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday'), _('Sunday')];
return days[this.parse_day(abr)].substr(0,abr.length);
},
load_json: function(url) {
var session = new Soup.SessionSync();
@ -243,12 +400,14 @@ WeatherMenuButton.prototype = {
},
refreshWeather: function() {
// Refresh current weather
this.load_json_async(WEATHER_URL, function(weather) {
this.load_json_async(this.get_weather_url(), function(weather) {
let location = weather.get_object_member('location').get_string_member('city');
let comment = weather.get_object_member('condition').get_string_member('text');
if(this._city!=null && this._city.length>0) {
location = this._city;
}
let comment = this.get_weather_condition(weather.get_object_member('condition').get_string_member('code'));
let temperature = weather.get_object_member('condition').get_double_member('temperature');
let temperature_unit = '\u00b0' + weather.get_object_member('units').get_string_member('temperature');
let humidity = weather.get_object_member('atmosphere').get_string_member('humidity') + ' %';
@ -272,21 +431,21 @@ WeatherMenuButton.prototype = {
});
// Refresh forecast
this.load_json_async(FORECAST_URL, function(forecast) {
this.load_json_async(this.get_forecast_url(), function(forecast) {
date_string = ['Today', 'Tomorrow'];
date_string = [_('Today'), _('Tomorrow')];
forecast2 = 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 = forecast2[i].get_object().get_object_member('item').get_object_member('forecast');
let code = forecastData.get_string_member('code');
let comment = forecastData.get_string_member('text');
let comment = this.get_weather_condition(code);
let t_low = forecastData.get_string_member('low');
let t_high = forecastData.get_string_member('high');
forecastUi.Day.text = date_string[i] + ' (' + forecastData.get_string_member('day') + ')';
forecastUi.Temperature.text = t_low + '\u2013' + t_high + ' ' + UNITS.toUpperCase();
forecastUi.Day.text = date_string[i] + ' (' + this.get_locale_day(forecastData.get_string_member('day')) + ')';
forecastUi.Temperature.text = t_low + '\u2013' + t_high + ' \u00b0' + this.unit_to_string(this._units).toUpperCase();
forecastUi.Summary.text = comment;
forecastUi.Icon.icon_name = this.get_weather_icon(code);
}
@ -320,7 +479,7 @@ WeatherMenuButton.prototype = {
// This will hold the icon for the current weather
this._currentWeatherIcon = new St.Icon({
icon_type: St.IconType.FULLCOLOR, //TODO SYMBOLIC not available in 64x64!?
icon_type: St.IconType.SYMBOLIC,
icon_size: 64,
icon_name: 'view-refresh-symbolic',
style_class: 'weather-current-icon'
@ -406,7 +565,7 @@ WeatherMenuButton.prototype = {
},
// Copied from Gnome shell's popupMenu.js
_onSeparatorAreaRepaint: function(area) {
_onSeparatorAreaRepaint: function(area){
let cr = area.get_context();
let themeNode = area.get_theme_node();
let [width, height] = area.get_surface_size();

@ -0,0 +1,8 @@
{
"uuid": "@uuid@",
"name": "Weather indicator",
"description": "Adds weather information menu",
"shell-version": [ "@shell_current@" ],
"localedir": "@LOCALEDIR@",
"url": "@url@"
}

@ -0,0 +1,23 @@
<schemalist gettext-domain="gnome-shell-extension-weather">
<enum id="org.gnome.shell.extensions.weather.unit">
<value nick="celsius" value="0" />
<value nick="fahrenheit" value="1" />
</enum>
<schema id="org.gnome.shell.extensions.weather" path="/org/gnome/shell/extensions/weather/">
<key name="unit" enum="org.gnome.shell.extensions.weather.unit">
<default>'celsius'</default>
<_summary>display units</_summary>
<_description>Choose the units you want the temperatures. Allowed values are 'celsius' or 'fahrenheit'</_description>
</key>
<key name="woeid" type="s">
<default>'FRXX6724'</default>
<_summary>Forecast Yahoo WOEID</_summary>
<_description>Set Yahoo id location to retrieve the corresponding forecast informations</_description>
</key>
<key name="city" type="s">
<default>''</default>
<_summary>City to be displayed</_summary>
<_description>Optional, you can override the displayed city provided by the woeid location</_description>
</key>
</schema>
</schemalist>

@ -1 +0,0 @@
{"shell-version": ["3.0"], "uuid": "weather@venemo.net", "name": "Weather", "description": "Adds weather information next to the clock."}
Loading…
Cancel
Save