Fix position-in-panel-logic.

It's better readable now and what's more: it works on gnome-shell > 3.34.
master
Jens Lody 5 years ago
parent 23e8a6e4f7
commit 3edd42466a
  1. 39
      src/extension.js

@ -194,26 +194,8 @@ class OpenweatherMenuButton extends PanelMenu.Button {
topBox.add_actor(this._weatherInfo); topBox.add_actor(this._weatherInfo);
this.add_actor(topBox); this.add_actor(topBox);
let dummyBox = new St.BoxLayout(); this.checkPositionInPanel();
this.reparent(dummyBox);
dummyBox.remove_actor(this);
dummyBox.destroy();
let children = null;
switch (this._position_in_panel) {
case WeatherPosition.LEFT:
children = Main.panel._leftBox.get_children();
Main.panel._leftBox.insert_child_at_index(this, children.length);
break;
case WeatherPosition.CENTER:
children = Main.panel._centerBox.get_children();
Main.panel._centerBox.insert_child_at_index(this, children.length);
break;
case WeatherPosition.RIGHT:
children = Main.panel._rightBox.get_children();
Main.panel._rightBox.insert_child_at_index(this, 0);
break;
}
if (Main.panel._menus === undefined) if (Main.panel._menus === undefined)
Main.panel.menuManager.addMenu(this.menu); Main.panel.menuManager.addMenu(this.menu);
else else
@ -221,8 +203,6 @@ class OpenweatherMenuButton extends PanelMenu.Button {
this._session = new GnomeSession.SessionManager(); this._session = new GnomeSession.SessionManager();
this._old_position_in_panel = this._position_in_panel;
// Current weather // Current weather
this._currentWeather = new St.Bin(); this._currentWeather = new St.Bin();
// Future weather // Future weather
@ -1237,18 +1217,9 @@ class OpenweatherMenuButton extends PanelMenu.Button {
} }
checkPositionInPanel() { checkPositionInPanel() {
if (this._old_position_in_panel != this._position_in_panel) { if (this._old_position_in_panel == undefined ||
switch (this._old_position_in_panel) { this._old_position_in_panel != this._position_in_panel) {
case WeatherPosition.LEFT: this.get_parent().remove_actor(this);
Main.panel._leftBox.remove_actor(this);
break;
case WeatherPosition.CENTER:
Main.panel._centerBox.remove_actor(this);
break;
case WeatherPosition.RIGHT:
Main.panel._rightBox.remove_actor(this);
break;
}
let children = null; let children = null;
switch (this._position_in_panel) { switch (this._position_in_panel) {

Loading…
Cancel
Save