From 3808544c3322615d7ef57e0ae28d07a8a8f22e9d Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Tue, 17 May 2022 14:24:09 +0200 Subject: [PATCH] changed to ES6, work done by didierm * (https://github.com/sciancio/connectionmanager2/issues/73#issuecomment-1128606674) * Small update by Benjamin Kahn --- extension.js | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/extension.js b/extension.js index 75d29a0..b2c7a71 100644 --- a/extension.js +++ b/extension.js @@ -59,13 +59,13 @@ let Me = Extension.lookupByURL(import.meta.url); import * as Search from './search.js' import * as Terminals from './terminals.js'; -const ConnectionManager = new Lang.Class({ - Name: 'ConnectionManager', - Extends: PanelMenu.Button, +const ConnectionManager = new GObject.registerClass({ + GTypeName: 'ConnectionManager', + }, class ConnectionManager extends PanelMenu.Button { - _init: function() { + _init() { - this.parent(1.0, "Connection Manager", false); + super._init(1.0, "Connection Manager", false); this._box = new St.BoxLayout(); @@ -106,17 +106,17 @@ const ConnectionManager = new Lang.Class({ } this._readConf(); - }, + } - _readConf: function () { + _readConf() { this.menu.removeAll(); // Rewrite _setOpenedSubMenu method to correctly open submenu - this.menu._setOpenedSubMenu = Lang.bind(this, function (submenu) { + this.menu._setOpenedSubMenu = submenu => { this._openedSubMenu = submenu; - }); + } this._sshList = []; @@ -150,21 +150,17 @@ const ConnectionManager = new Lang.Class({ this.menu.addMenuItem(menuSepPref, this.menu.length); let menuPref = new PopupMenu.PopupMenuItem("Connection Manager Settings"); - menuPref.connect('activate', Lang.bind(this, function() { - try { - Util.trySpawnCommandLine('python2 ' + this._prefFile); - } catch (e) { - Util.trySpawnCommandLine('python ' + this._prefFile); - } - })); + menuPref.connect('activate', () => { + Util.trySpawnCommandLine('python ' + this._prefFile); + }); this.menu.addMenuItem(menuPref, this.menu.length+1); // Update ssh name list this._searchProvider._update(this._sshList); - }, + } - _readTree: function(node, parent, ident) { + _readTree(node, parent, ident) { let child, menuItem, menuSep, menuSub, icon, label, menuItemAll, iconAll, menuSepAll, menuItemTabs, iconTabs, ident_prec; @@ -334,7 +330,7 @@ const ConnectionManager = new Lang.Class({ } ident = ident_prec; - }, + } }); @@ -349,7 +345,7 @@ function enable() { let file = Gio.file_new_for_path(cm._configFile); cm.monitor = file.monitor(Gio.FileMonitorFlags.NONE, null); - cm.monitor.connect('changed', Lang.bind(cm, cm._readConf)); + cm.monitor.connect('changed', () => cm._readConf()); } function disable() {