From 3edd42466a2741118e4fe7b1a753913358e5bc48 Mon Sep 17 00:00:00 2001 From: Jens Lody Date: Fri, 10 Jan 2020 23:36:56 +0100 Subject: [PATCH] Fix position-in-panel-logic. It's better readable now and what's more: it works on gnome-shell > 3.34. --- src/extension.js | 39 +++++---------------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/src/extension.js b/src/extension.js index 2b894fa..a7621ed 100644 --- a/src/extension.js +++ b/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) {