Position in panel configurable.

yahoo_weather
simon04 13 years ago
parent 5240fb693c
commit 6fa745779a
  1. 7
      README.md
  2. 19
      src/extension.js
  3. 9
      src/org.gnome.shell.extensions.weather.gschema.xml.in

@ -72,6 +72,13 @@ You can configure whether to show the weather condition text together with the t
gsettings set org.gnome.shell.extensions.weather show-text-in-panel true
gsettings set org.gnome.shell.extensions.weather show-text-in-panel false
#### Position in Panel (optional, center by default)
The position of this GNOME Shell extension in the panel can be configured to either 'center' or 'right' (requires restart of GNOME Shell).
gnome-shell-extension-weather]$ gsettings set org.gnome.shell.extensions.weather position-in-panel center
gnome-shell-extension-weather]$ gsettings set org.gnome.shell.extensions.weather position-in-panel right
#### Restart GNOME Shell
Don't forget to restart GNOME Shell:

@ -55,12 +55,17 @@ const WEATHER_WOEID_KEY = 'woeid';
const WEATHER_TRANSLATE_CONDITION_KEY = 'translate-condition';
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';
// Keep enums in sync with GSettings schemas
const WeatherUnits = {
CELSIUS: 0,
FAHRENHEIT: 1
};
}
const WeatherPosition = {
CENTER: 0,
RIGHT: 1
}
function WeatherMenuButton() {
this._init();
@ -84,6 +89,7 @@ WeatherMenuButton.prototype = {
this._translate_condition = this._settings.get_boolean(WEATHER_TRANSLATE_CONDITION_KEY);
this._icon_type = this._settings.get_boolean(WEATHER_USE_SYMBOLIC_ICONS_KEY) ? St.IconType.SYMBOLIC : St.IconType.FULLCOLOR;
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);
// Watch settings for changes
let load_settings_and_refresh_weather = Lang.bind(this, function() {
@ -130,7 +136,16 @@ WeatherMenuButton.prototype = {
if (this._text_in_panel)
topBox.add_actor(this._weatherInfo);
this.actor.set_child(topBox);
Main.panel._centerBox.add(this.actor, { y_fill: true });
switch (this._position_in_panel) {
case WeatherPosition.CENTER:
Main.panel._centerBox.add(this.actor, { y_fill: true });
break;
case WeatherPosition.RIGHT:
Main.panel._rightBox.add(this.actor, { y_fill: true });
break;
}
Main.panel._menus.addMenu(this.menu);
// Current weather

@ -3,6 +3,10 @@
<value nick="celsius" value="0" />
<value nick="fahrenheit" value="1" />
</enum>
<enum id="org.gnome.shell.extensions.weather.position">
<value nick="center" value="0" />
<value nick="right" 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>
@ -34,5 +38,10 @@
<_summary>Whether to show the text in the panel.</_summary>
<_description>Whether to show the weather condition text together with the temperature in the panel (requires restart).</_description>
</key>
<key name="position-in-panel" enum="org.gnome.shell.extensions.weather.position">
<default>'center'</default>
<_summary>Position in panel</_summary>
<_description>Set the position of this GNOME Shell extension in the panel to either 'center' or 'right' (requires restart).</_description>
</key>
</schema>
</schemalist>

Loading…
Cancel
Save