Add option to configure the position of the menu-box relative to the panel-text.

Fixes #143.
merge-requests/218/head
Jens Lody 8 years ago
parent 2b1d4b66d0
commit 8f2698b564
  1. 4
      data/org.gnome.shell.extensions.openweather.gschema.xml
  2. 74
      data/weather-settings.ui
  3. 16
      src/extension.js
  4. 1
      src/forecast_io.js
  5. 1
      src/openweathermap_org.js
  6. 30
      src/prefs.js

@ -111,6 +111,10 @@
<default>'center'</default>
<summary>Position in Panel</summary>
</key>
<key name="menu-alignment" type="d">
<default>75.0</default>
<summary>Horizontal position of menu-box.</summary>
</key>
<key type="i" name="refresh-interval-current">
<default>600</default>
<summary>Refresh interval (actual weather)</summary>

@ -170,6 +170,11 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="menu-alignment-adjustment">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
<property name="page_increment">2</property>
</object>
<object class="GtkMenu" id="search-menu">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -348,7 +353,7 @@
</data>
</object>
<object class="GtkScrolledWindow" id="main-widget">
<property name="width_request">720</property>
<property name="width_request">775</property>
<property name="height_request">480</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -872,6 +877,17 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-menu-alignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Position of menu-box [%] from 0 (left) to 100 (right)</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-wind-direction">
<property name="visible">True</property>
@ -880,7 +896,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
@ -891,7 +907,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
@ -902,7 +918,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -913,7 +929,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
@ -924,7 +940,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -935,7 +951,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -946,7 +962,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
@ -957,7 +973,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
@ -968,7 +984,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -979,7 +995,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
<child>
@ -997,6 +1013,22 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="menu_alignment">
<property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">menu-alignment-adjustment</property>
<property name="show_fill_level">True</property>
<property name="restrict_to_fill_level">False</property>
<property name="fill_level">100</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="wind_direction">
<property name="visible">True</property>
@ -1005,7 +1037,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
@ -1016,7 +1048,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
@ -1027,7 +1059,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -1038,7 +1070,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
@ -1049,7 +1081,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -1060,7 +1092,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -1071,7 +1103,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">7</property>
<property name="top_attach">8</property>
</packing>
</child>
<child>
@ -1082,7 +1114,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
</packing>
</child>
<child>
@ -1103,7 +1135,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
</packing>
</child>
<child>
@ -1119,7 +1151,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">10</property>
<property name="top_attach">11</property>
</packing>
</child>
</object>

@ -74,6 +74,7 @@ const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons';
const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons';
const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel';
const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel';
const OPENWEATHER_MENU_ALIGNMENT_KEY = 'menu-alignment';
const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel';
const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast';
const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current';
@ -178,7 +179,7 @@ const OpenweatherMenuButton = new Lang.Class({
});
// Panel menu item - the current class
let menuAlignment = 0.25;
let menuAlignment = 1.0 - (this._menu_alignment / 100);
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
menuAlignment = 1.0 - menuAlignment;
this.parent(menuAlignment);
@ -758,6 +759,12 @@ const OpenweatherMenuButton = new Lang.Class({
return this._settings.get_enum(OPENWEATHER_POSITION_IN_PANEL_KEY);
},
get _menu_alignment() {
if (!this._settings)
this.loadConfig();
return this._settings.get_double(OPENWEATHER_MENU_ALIGNMENT_KEY);
},
get _comment_in_panel() {
if (!this._settings)
this.loadConfig();
@ -1178,6 +1185,13 @@ const OpenweatherMenuButton = new Lang.Class({
return;
},
checkAlignment: function() {
let menuAlignment = 1.0 - (this._menu_alignment / 100);
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
menuAlignment = 1.0 - menuAlignment;
this.menu._arrowAlignment=menuAlignment;
},
checkPositionInPanel: function() {
if (this._old_position_in_panel != this._position_in_panel) {
switch (this._old_position_in_panel) {

@ -120,6 +120,7 @@ function parseWeatherCurrent() {
(this.currentWeatherCache == "in refresh"))
return;
this.checkAlignment();
this.checkPositionInPanel();
let json = this.currentWeatherCache;

@ -301,6 +301,7 @@ function parseWeatherCurrent() {
if (this.currentWeatherCache == "in refresh")
return;
this.checkAlignment();
this.checkPositionInPanel();
let json = this.currentWeatherCache;

@ -58,6 +58,7 @@ const OPENWEATHER_USE_SYMBOLIC_ICONS_KEY = 'use-symbolic-icons';
const OPENWEATHER_USE_TEXT_ON_BUTTONS_KEY = 'use-text-on-buttons';
const OPENWEATHER_SHOW_TEXT_IN_PANEL_KEY = 'show-text-in-panel';
const OPENWEATHER_POSITION_IN_PANEL_KEY = 'position-in-panel';
const OPENWEATHER_MENU_ALIGNMENT_KEY = 'menu-alignment';
const OPENWEATHER_SHOW_COMMENT_IN_PANEL_KEY = 'show-comment-in-panel';
const OPENWEATHER_SHOW_COMMENT_IN_FORECAST_KEY = 'show-comment-in-forecast';
const OPENWEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current';
@ -420,6 +421,8 @@ const WeatherPrefsWidget = new GObject.Class({
this.initComboBox(theObjects[i]);
else if (theObjects[i].class_path()[1].indexOf('GtkSwitch') != -1)
this.initSwitch(theObjects[i]);
else if (theObjects[i].class_path()[1].indexOf('GtkScale') != -1)
this.initScale(theObjects[i]);
this.configWidgets.push([theObjects[i], name]);
}
}
@ -478,6 +481,21 @@ const WeatherPrefsWidget = new GObject.Class({
}));
},
initScale: function(theScale) {
let name = theScale.get_name();
theScale.set_value(this[name]);
this[name+'Timeout'] = undefined;
theScale.connect("value-changed", Lang.bind(this, function(slider) {
if (this[name+'Timeout'] !== undefined)
Mainloop.source_remove(this[name+'Timeout']);
this[name+'Timeout'] = Mainloop.timeout_add(250, Lang.bind(this, function() {
this[name] = slider.get_value();
return false;
}));
}));
},
refreshUI: function() {
this.MainWidget = this.Window.get_object("main-widget");
this.treeview = this.Window.get_object("tree-treeview");
@ -879,6 +897,18 @@ const WeatherPrefsWidget = new GObject.Class({
this.Settings.set_enum(OPENWEATHER_POSITION_IN_PANEL_KEY, v);
},
get menu_alignment() {
if (!this.Settings)
this.loadConfig();
return this.Settings.get_double(OPENWEATHER_MENU_ALIGNMENT_KEY);
},
set menu_alignment(v) {
if (!this.Settings)
this.loadConfig();
return this.Settings.set_double(OPENWEATHER_MENU_ALIGNMENT_KEY, v);
},
get comment_in_panel() {
if (!this.Settings)
this.loadConfig();

Loading…
Cancel
Save