From 4cdda9a19b9541cddc795253dfd727257495d2f5 Mon Sep 17 00:00:00 2001 From: simon04 Date: Sun, 6 Nov 2011 13:48:34 +0100 Subject: [PATCH 1/7] 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; +} From 5403ce76aa2d6b5dca3323707dabf916d7d14709 Mon Sep 17 00:00:00 2001 From: simon04 Date: Thu, 10 Nov 2011 08:45:29 +0100 Subject: [PATCH 2/7] configurator: remove unneeded .desktop file (see #30) --- weather-extension-configurator.desktop | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 weather-extension-configurator.desktop diff --git a/weather-extension-configurator.desktop b/weather-extension-configurator.desktop deleted file mode 100755 index 1e8f4d2..0000000 --- a/weather-extension-configurator.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Name=Gnome Shell: Weather Configurator -GenericName=Configurator for the Weather extension of Gnome Shell -Exec=weather-extension-configurator.py -Terminal=false -Type=Application -Icon=utilities-system-monitor -Categories=GNOME;System; From 425ec2ba376cad12c1b0cd5028c637d3cf14596c Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 18:01:38 +0100 Subject: [PATCH 3/7] configurator: set text after loosing focus (see #29) --- weather-extension-configurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/weather-extension-configurator.py b/weather-extension-configurator.py index 2cbb5d6..342782d 100755 --- a/weather-extension-configurator.py +++ b/weather-extension-configurator.py @@ -59,6 +59,7 @@ class WeatherConfigurator: entry = Gtk.Entry() entry.set_text(self.schema.get_string(key)) entry.connect('activate', set) + entry.connect('focus-out-event', lambda x, y: set(x)) self.add_tooltip(entry, tooltip) self.add_label(label, tooltip) self.elements.append(entry) From d687884bda15dba3117222d29ddb13c9d7979411 Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 18:02:25 +0100 Subject: [PATCH 4/7] configurator: fix order of "Position in Panel" (see #29) --- weather-extension-configurator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/weather-extension-configurator.py b/weather-extension-configurator.py index 342782d..44eafdc 100755 --- a/weather-extension-configurator.py +++ b/weather-extension-configurator.py @@ -67,11 +67,12 @@ class WeatherConfigurator: def add_radio(self, key, label, items, tooltip=None): def set(rb): if rb.get_active(): - self.schema.set_enum(key, items.index(rb.get_label())) + val = [item[0] for item in items if item[1] == rb.get_label()][0] + self.schema.set_enum(key, val) vbox = Gtk.VBox() buttonFirst = None active = self.schema.get_enum(key) - for (idx,item) in enumerate(items): + for (idx,item) in items: button = Gtk.RadioButton(group=buttonFirst, label=item) if not(buttonFirst): buttonFirst = button button.set_active(active == idx) @@ -103,9 +104,9 @@ class WeatherConfigurator: self.elements = [] self.add_text('woeid', 'WOEID', 'The Where On Earth ID determinees the location/city') - self.add_radio('unit', 'Temperature Unit', ['celsius', 'fahrenheit']) + self.add_radio('unit', 'Temperature Unit', [(0, 'celsius'), (1, 'fahrenheit')]) self.add_text('city', 'Label', "Sometimes your WOEID location isn't quite right (it's the next major city around)") - self.add_radio('position-in-panel', 'Position in Panel*', ['center', 'right', 'left'], "The position of this GNOME Shell extension in the panel (requires restart of GNOME Shell).") + self.add_radio('position-in-panel', 'Position in Panel*', [(2, 'left'), (0, 'center'), (1, 'right')], "The position of this GNOME Shell extension in the panel (requires restart of GNOME Shell).") self.add_check('translate-condition', 'Translate Weather Conditions', "If enabled, the condition is translated based on the weather code. If disabled, the condition string from Yahoo is taken. Note: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") self.add_check('use-symbolic-icons', 'Symbolic Icons', "Display symbolic icons instead of full-colored icons") self.add_check('show-text-in-panel', 'Show Text in Panel*', "Whether to show the weather condition text (aka. comment) together with the temperature in the panel (requires restart of GNOME Shell).") From e86117a3aef3ac8ce130af7ad85e82d759a5f063 Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 18:22:39 +0100 Subject: [PATCH 5/7] configurator: rework texts, add dependency (see #29, thanks to ferdnyc) --- weather-extension-configurator.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/weather-extension-configurator.py b/weather-extension-configurator.py index 44eafdc..629bf6b 100755 --- a/weather-extension-configurator.py +++ b/weather-extension-configurator.py @@ -52,6 +52,7 @@ class WeatherConfigurator: label.set_alignment(1, 0.5) self.add_tooltip(label, tooltip) self.elements.append(label) + return label def add_text(self, key, label, tooltip=None): def set(tb): @@ -61,8 +62,9 @@ class WeatherConfigurator: entry.connect('activate', set) entry.connect('focus-out-event', lambda x, y: set(x)) self.add_tooltip(entry, tooltip) - self.add_label(label, tooltip) + label = self.add_label(label, tooltip) self.elements.append(entry) + return (entry, label) def add_radio(self, key, label, items, tooltip=None): def set(rb): @@ -72,6 +74,7 @@ class WeatherConfigurator: vbox = Gtk.VBox() buttonFirst = None active = self.schema.get_enum(key) + buttons = [] for (idx,item) in items: button = Gtk.RadioButton(group=buttonFirst, label=item) if not(buttonFirst): buttonFirst = button @@ -79,8 +82,10 @@ class WeatherConfigurator: button.connect('toggled', set) self.add_tooltip(button, tooltip) vbox.add(button) - self.add_label(label, tooltip) + buttons.append(button) + label = self.add_label(label, tooltip) self.elements.append(vbox) + return (buttons, label) def add_check(self, key, label, tooltip=None): def set(cb): @@ -90,8 +95,9 @@ class WeatherConfigurator: button.set_active(active) button.connect('toggled', set) self.add_tooltip(button, tooltip) - self.add_label(label, tooltip) + label = self.add_label(label, tooltip) self.elements.append(button) + return (button, label) def __init__(self): self.schema = Gio.Settings('org.gnome.shell.extensions.weather') @@ -106,11 +112,18 @@ class WeatherConfigurator: self.add_text('woeid', 'WOEID', 'The Where On Earth ID determinees the location/city') self.add_radio('unit', 'Temperature Unit', [(0, 'celsius'), (1, 'fahrenheit')]) self.add_text('city', 'Label', "Sometimes your WOEID location isn't quite right (it's the next major city around)") - self.add_radio('position-in-panel', 'Position in Panel*', [(2, 'left'), (0, 'center'), (1, 'right')], "The position of this GNOME Shell extension in the panel (requires restart of GNOME Shell).") - self.add_check('translate-condition', 'Translate Weather Conditions', "If enabled, the condition is translated based on the weather code. If disabled, the condition string from Yahoo is taken. Note: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") + self.add_radio('position-in-panel', 'Position in Panel*', [(2, 'left'), (0, 'center'), (1, 'right')], "The position of this GNOME Shell extension in the panel. (Requires restart of GNOME Shell.)") + self.add_check('translate-condition', 'Translate Weather Conditions', "If enabled, the condition is translated based on the weather code.\nIf disabled, the condition string from Yahoo is taken.\nNote: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") self.add_check('use-symbolic-icons', 'Symbolic Icons', "Display symbolic icons instead of full-colored icons") - self.add_check('show-text-in-panel', 'Show Text in Panel*', "Whether to show the weather condition text (aka. comment) together with the temperature in the panel (requires restart of GNOME Shell).") - self.add_check('show-comment-in-panel', 'Show Comment in Panel', "Whether to show the comment (aka. weather condition text, e.g. 'Windy', 'Clear') in the panel.") + (b_text, _) = self.add_check('show-text-in-panel', 'Show Text in Panel*', "Display current temperature in panel. If disabled, only the current condition icon is shown. (Requires restart of GNOME Shell.)") + (b_cond, l_cond) = self.add_check('show-comment-in-panel', ' Include Condition', "Whether to show the weather condition (e.g. 'Windy', 'Clear') in the panel.") + + # add dependency between text-in-panel and comment-in-panel + def depend(rb): + b_cond.set_sensitive(rb.get_active()) + l_cond.set_sensitive(rb.get_active()) + b_text.connect('toggled', depend) + depend(b_text) table = Gtk.Table(rows=len(self.elements)/2, columns=2, homogeneous=False) for (idx,el) in enumerate(self.elements): From 14a83d5b82bd15391e19924eb8042e29cf32e398 Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 18:25:04 +0100 Subject: [PATCH 6/7] configurator: code formatting --- weather-extension-configurator.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/weather-extension-configurator.py b/weather-extension-configurator.py index 629bf6b..9241668 100755 --- a/weather-extension-configurator.py +++ b/weather-extension-configurator.py @@ -109,14 +109,23 @@ class WeatherConfigurator: self.elements = [] - self.add_text('woeid', 'WOEID', 'The Where On Earth ID determinees the location/city') - self.add_radio('unit', 'Temperature Unit', [(0, 'celsius'), (1, 'fahrenheit')]) - self.add_text('city', 'Label', "Sometimes your WOEID location isn't quite right (it's the next major city around)") - self.add_radio('position-in-panel', 'Position in Panel*', [(2, 'left'), (0, 'center'), (1, 'right')], "The position of this GNOME Shell extension in the panel. (Requires restart of GNOME Shell.)") - self.add_check('translate-condition', 'Translate Weather Conditions', "If enabled, the condition is translated based on the weather code.\nIf disabled, the condition string from Yahoo is taken.\nNote: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") - self.add_check('use-symbolic-icons', 'Symbolic Icons', "Display symbolic icons instead of full-colored icons") - (b_text, _) = self.add_check('show-text-in-panel', 'Show Text in Panel*', "Display current temperature in panel. If disabled, only the current condition icon is shown. (Requires restart of GNOME Shell.)") - (b_cond, l_cond) = self.add_check('show-comment-in-panel', ' Include Condition', "Whether to show the weather condition (e.g. 'Windy', 'Clear') in the panel.") + self.add_text('woeid', 'WOEID', + "The Where On Earth ID determinees the location/city") + self.add_radio('unit', 'Temperature Unit', + [(0, 'celsius'), (1, 'fahrenheit')]) + self.add_text('city', 'Label', + "Sometimes your WOEID location isn't quite right (it's the next major city around)") + self.add_radio('position-in-panel', 'Position in Panel*', + [(2, 'left'), (0, 'center'), (1, 'right')], + "The position of this GNOME Shell extension in the panel. (Requires restart of GNOME Shell.)") + self.add_check('translate-condition', 'Translate Weather Conditions', + "If enabled, the condition is translated based on the weather code.\nIf disabled, the condition string from Yahoo is taken.\nNote: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") + self.add_check('use-symbolic-icons', 'Symbolic Icons', + "Display symbolic icons instead of full-colored icons") + (b_text, _) = self.add_check('show-text-in-panel', 'Show Text in Panel*', + "Display current temperature in panel. If disabled, only the current condition icon is shown. (Requires restart of GNOME Shell.)") + (b_cond, l_cond) = self.add_check('show-comment-in-panel', ' Include Condition', + "Whether to show the weather condition (e.g. 'Windy', 'Clear') in the panel.") # add dependency between text-in-panel and comment-in-panel def depend(rb): From b4455d03fc8b55fc0a037f6d308a14b9525928c4 Mon Sep 17 00:00:00 2001 From: simon04 Date: Wed, 23 Nov 2011 18:33:01 +0100 Subject: [PATCH 7/7] configurator: typographic/visual improvements --- weather-extension-configurator.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/weather-extension-configurator.py b/weather-extension-configurator.py index 9241668..bcbf1cb 100755 --- a/weather-extension-configurator.py +++ b/weather-extension-configurator.py @@ -49,6 +49,7 @@ class WeatherConfigurator: def add_label(self, label, tooltip): label = Gtk.Label(label + ":") + label.set_use_markup(True) label.set_alignment(1, 0.5) self.add_tooltip(label, tooltip) self.elements.append(label) @@ -109,23 +110,23 @@ class WeatherConfigurator: self.elements = [] - self.add_text('woeid', 'WOEID', + self.add_text('woeid', 'WOEID', "The Where On Earth ID determinees the location/city") self.add_radio('unit', 'Temperature Unit', [(0, 'celsius'), (1, 'fahrenheit')]) - self.add_text('city', 'Label', - "Sometimes your WOEID location isn't quite right (it's the next major city around)") - self.add_radio('position-in-panel', 'Position in Panel*', + self.add_text('city', 'Override Location Label', + "Sometimes your WOEID location isn’t quite right (it’s the next major city around). This label is used to override the location displayed.") + self.add_radio('position-in-panel', 'Position in Panel', [(2, 'left'), (0, 'center'), (1, 'right')], "The position of this GNOME Shell extension in the panel. (Requires restart of GNOME Shell.)") self.add_check('translate-condition', 'Translate Weather Conditions', - "If enabled, the condition is translated based on the weather code.\nIf disabled, the condition string from Yahoo is taken.\nNote: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string 'PM Thunderstorms' cannot be expressed in terms of weather codes.") + "If enabled, the condition is translated based on the weather code.\nIf disabled, the condition string from Yahoo is taken.\nNote: Enabling the translation sometimes results in loss of accuracy, e.g., the condition string “PM Thunderstorms” cannot be expressed in terms of weather codes.") self.add_check('use-symbolic-icons', 'Symbolic Icons', "Display symbolic icons instead of full-colored icons") - (b_text, _) = self.add_check('show-text-in-panel', 'Show Text in Panel*', + (b_text, _) = self.add_check('show-text-in-panel', 'Show Text in Panel', "Display current temperature in panel. If disabled, only the current condition icon is shown. (Requires restart of GNOME Shell.)") (b_cond, l_cond) = self.add_check('show-comment-in-panel', ' Include Condition', - "Whether to show the weather condition (e.g. 'Windy', 'Clear') in the panel.") + "Whether to show the weather condition (e.g., “Windy”, “Clear”) in the panel.") # add dependency between text-in-panel and comment-in-panel def depend(rb):