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);
this.add_actor(topBox);
let dummyBox = new St.BoxLayout();
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;
}
this.checkPositionInPanel();
if (Main.panel._menus === undefined)
Main.panel.menuManager.addMenu(this.menu);
else
@ -221,8 +203,6 @@ class OpenweatherMenuButton extends PanelMenu.Button {
this._session = new GnomeSession.SessionManager();
this._old_position_in_panel = this._position_in_panel;
// Current weather
this._currentWeather = new St.Bin();
// Future weather
@ -1237,18 +1217,9 @@ class OpenweatherMenuButton extends PanelMenu.Button {
}
checkPositionInPanel() {
if (this._old_position_in_panel != this._position_in_panel) {
switch (this._old_position_in_panel) {
case WeatherPosition.LEFT:
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;
}
if (this._old_position_in_panel == undefined ||
this._old_position_in_panel != this._position_in_panel) {
this.get_parent().remove_actor(this);
let children = null;
switch (this._position_in_panel) {

Loading…
Cancel
Save