From 0fa1fdb4772c442cdf7d8bb3fb293235450e33d4 Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Thu, 7 Nov 2013 07:51:15 +0100 Subject: [PATCH] Add link to openweathermap.org in menu; uses gnome-open to open forecast page of the actual city if possible, fallback is openweathermaps main page. --- data/stylesheet.css | 4 ++++ src/extension.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/data/stylesheet.css b/data/stylesheet.css index 3945479..8ea1ca1 100644 --- a/data/stylesheet.css +++ b/data/stylesheet.css @@ -1,3 +1,7 @@ +.weather-provider { +font-size: 110%; +} + .weather-current-summarybox { padding-top:5px; } diff --git a/src/extension.js b/src/extension.js index 8e9c806..267a34b 100644 --- a/src/extension.js +++ b/src/extension.js @@ -233,6 +233,26 @@ const WeatherMenuButton = new Lang.Class({ let item = new PopupMenu.PopupSeparatorMenuItem(); this.menu.addMenuItem(item); + let item = new PopupMenu.PopupMenuItem(_("Weather data provided by: ") + ("http://openweathermap.org/"), { + style_class: 'weather-provider' + }); + item.connect('activate', Lang.bind(this, function() { + let cityId = this.extractId(this._city); + if (!cityId) { + this.updateCities(); + cityId = this.extractId(this._city); + } + if (cityId) + Util.spawn(["gnome-open", "http://openweathermap.org/city/" + cityId]); + else + Util.spawn(["gnome-open", "http://openweathermap.org"]); + })); + + this.menu.addMenuItem(item); + + let item = new PopupMenu.PopupSeparatorMenuItem(); + this.menu.addMenuItem(item); + this._selectCity = new PopupMenu.PopupSubMenuMenuItem(_("Locations")); this.menu.addMenuItem(this._selectCity); this.rebuildSelectCityItem();