From 4cdda9a19b9541cddc795253dfd727257495d2f5 Mon Sep 17 00:00:00 2001 From: simon04 Date: Sun, 6 Nov 2011 13:48:34 +0100 Subject: [PATCH] UI: display preferences as icon in the top right corner --- src/extension.js | 32 ++++++++++++++++++++++---------- src/stylesheet.css | 3 +++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/extension.js b/src/extension.js index 651c6f0..86203e6 100644 --- a/src/extension.js +++ b/src/extension.js @@ -173,16 +173,6 @@ WeatherMenuButton.prototype = { this.menu.addActor(mainBox); - /* TODO install script via Makefile - this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - - let item = new PopupMenu.PopupMenuItem(_("Preferences...")); - item.connect('activate', function() { - Util.spawn(["weather-extension-configurator"]); - }); - this.menu.addMenuItem(item); - */ - // Items this.showLoadingUi(); @@ -196,6 +186,27 @@ WeatherMenuButton.prototype = { }, + getPreferencesIcon: function() { + let prefIcon = new St.Icon ({ + icon_type: this._icon_type, + icon_size: 16, + icon_name: 'system-run' + }); + let prefButton = new St.Button({ + style_class: 'panel-button' + }); + prefButton.connect('clicked', function() { + Util.spawn(["weather-extension-configurator"]); + }); + let prefBox = new St.BoxLayout({ + style_class: 'weather-config', + vertical: true + }); + prefButton.add_actor(prefIcon); + prefBox.add_actor(prefButton); + return prefBox; + }, + unit_to_url: function() { return this._units == WeatherUnits.FAHRENHEIT ? 'f' : 'c'; }, @@ -625,6 +636,7 @@ WeatherMenuButton.prototype = { let xb = new St.BoxLayout(); xb.add_actor(bb); xb.add_actor(rb); + xb.add_actor(this.getPreferencesIcon()); let box = new St.BoxLayout({ style_class: 'weather-current-iconbox' diff --git a/src/stylesheet.css b/src/stylesheet.css index cfddcaa..c79ffa6 100644 --- a/src/stylesheet.css +++ b/src/stylesheet.css @@ -46,3 +46,6 @@ font-size: 90%; } +.weather-config { + padding-right: 10px; +}