From 6bc7f827a3d96dce65cd5a2ad1dfa9e559b10c4b Mon Sep 17 00:00:00 2001 From: Benjamin Kahn Date: Wed, 22 Nov 2023 09:09:20 -0500 Subject: [PATCH 01/13] Switch to the new ESM import Still missing some imports line "bytearray" and "mainloop" and "lang" which will need thinking about. The extension dosn't work yet. --- extension.js | 67 ++++++++++++++++++++++++++++++++-------------------- search.js | 33 +++++++++++++++++++++----- 2 files changed, 69 insertions(+), 31 deletions(-) diff --git a/extension.js b/extension.js index a9a85f3..508e591 100644 --- a/extension.js +++ b/extension.js @@ -17,34 +17,51 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -const St = imports.gi.St; -const Gdk = imports.gi.Gdk; -const GLib = imports.gi.GLib; -const Gio = imports.gi.Gio; -const Lang = imports.lang; -const Shell = imports.gi.Shell; - -const Mainloop = imports.mainloop; -const Signals = imports.signals; - -const Main = imports.ui.main; -const PanelMenu = imports.ui.panelMenu; -const PopupMenu = imports.ui.popupMenu; -const Panel = imports.ui.panel; -const Util = imports.misc.util; -const ByteArray = imports.byteArray; -const Me = imports.misc.extensionUtils.getCurrentExtension(); - -const Gettext = imports.gettext.domain('gnome-shell-extensions'); -const _ = Gettext.gettext; - +import St from 'gi://St'; +import Gdk from 'gi://Gdk'; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; +import GObject from 'gi://GObject'; +import Shell from 'gi://Shell'; + +/* + "Lang" is no longer available. Just removing it for now. + When the replacement code goes in, I'll remove this comment. + const Lang = imports.lang; +*/ + + +import * as Signals from 'resource:///org/gnome/shell/misc/signals.js'; + +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; +import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js'; +import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; +import * as Panel from 'resource:///org/gnome/shell/ui/panel.js'; +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; + +/* + "ByteArray" does not appear to have an import in Gnome Shell 45 yet + Or I'm missing it as I hack and slash through this. + const ByteArray = imports.byteArray; +*/ + +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; let extensionPath; +let extensionObject, extensionSettings; +let CM = Extension.lookupByURL(import.meta.url); +let Me = Extension.lookupByURL(import.meta.url); + +/* + The code above should be the replacement for these two lines. + But I'm suspicious about why "CM" and "Me" need to be defined + and if the structure is still the same. Keeping these in a comment for now. + const Me = imports.misc.extensionUtils.getCurrentExtension(); + const CM = imports.misc.extensionUtils.getCurrentExtension(); +*/ // Import Command Terminal Manager and Search class -const CM = imports.misc.extensionUtils.getCurrentExtension(); -const Search = CM.imports.search; -const Terminals = CM.imports.terminals; - +import * as Search from './search.js' +import * as Terminals from './terminals.js'; const ConnectionManager = new Lang.Class({ Name: 'ConnectionManager', diff --git a/search.js b/search.js index f564551..4b18f1b 100644 --- a/search.js +++ b/search.js @@ -16,15 +16,36 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -const St = imports.gi.St; -const Gio = imports.gi.Gio; +import St from 'gi://St'; +import Gio from 'gi://Gio'; + +import Shell from 'gi://Shell'; +import * as Util from 'resource:///org/gnome/shell/misc/util.js'; + +// const Lang = imports.lang; +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; +let Me = Extension.lookupByURL(import.meta.url); + +/* + "Lang" is no longer available. Just removing it for now. + When the replacement code goes in, I'll remove this comment. + const Lang = imports.lang; +*/ -const Shell = imports.gi.Shell; -const Util = imports.misc.util; -const Lang = imports.lang; const Me = imports.misc.extensionUtils.getCurrentExtension(); -const Config = imports.misc.config; +/* + The code above should be the replacement for these two lines. + Keeping these in a comment for now. (See extension.js) + const Me = imports.misc.extensionUtils.getCurrentExtension(); +*/ + +import * as Config from 'resource:///org/gnome/shell/misc/config.js'; +/* + The above line should replace this one. + But there are now TWO config paths. I chose one, but I'm not sure I made the right choice. + const Config = imports.misc.config; +*/ // SSH / Apps Search Provider var SshSearchProvider = new Lang.Class({ From eab7b7d97872e13dbde52a364b970efb06807136 Mon Sep 17 00:00:00 2001 From: Benjamin Kahn Date: Wed, 22 Nov 2023 10:54:57 -0500 Subject: [PATCH 02/13] Replace ByteArray with TextDecoder; fix import of St.IconTheme Thanks to @justperfection:gnome.org in Matrix #extensions:gnome.org for the TextDecoder solution. The IconTheme solution was mine, so it's likely missing something --- extension.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/extension.js b/extension.js index 508e591..75d29a0 100644 --- a/extension.js +++ b/extension.js @@ -39,11 +39,7 @@ import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Panel from 'resource:///org/gnome/shell/ui/panel.js'; import * as Util from 'resource:///org/gnome/shell/misc/util.js'; -/* - "ByteArray" does not appear to have an import in Gnome Shell 45 yet - Or I'm missing it as I hack and slash through this. - const ByteArray = imports.byteArray; -*/ +let ByteArrayReplacement = new TextDecoder('utf-8'); import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; let extensionPath; @@ -127,7 +123,7 @@ const ConnectionManager = new Lang.Class({ if (GLib.file_test(this._configFile, GLib.FileTest.EXISTS) ) { let filedata = GLib.file_get_contents(this._configFile); - let jsondata = JSON.parse(ByteArray.toString(filedata[1])); + let jsondata = JSON.parse(ByteArrayReplacement.decode(filedata[1])); let root = jsondata['Root']; // Global Settings @@ -369,7 +365,7 @@ function disable() { function init(extensionMeta) { extensionPath = extensionMeta.path; - let theme = imports.gi.Gtk.IconTheme.get_default(); + let theme = St.IconTheme.new(); theme.append_search_path(extensionPath); } From 3808544c3322615d7ef57e0ae28d07a8a8f22e9d Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Tue, 17 May 2022 14:24:09 +0200 Subject: [PATCH 03/13] 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() { From e0d108c9c3dc65e475a3e12c147a8d05072dfa9c Mon Sep 17 00:00:00 2001 From: Gerd Riesselmann Date: Wed, 8 Apr 2015 17:00:02 +0200 Subject: [PATCH 04/13] Fix #51 Fixed .ssh/config parsing but replaces it by a simpler algorithm, ignoring HostName, User, Port (and IdentityFile, which is already ignored) --- extension.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extension.js b/extension.js index b2c7a71..443d03f 100644 --- a/extension.js +++ b/extension.js @@ -362,7 +362,8 @@ function init(extensionMeta) { extensionPath = extensionMeta.path; let theme = St.IconTheme.new(); - theme.append_search_path(extensionPath); + if (theme) + theme.append_search_path(extensionPath); } From f3405e3682844d910ec9c429e5fffc3544cee91a Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Mon, 3 May 2021 19:08:30 +0200 Subject: [PATCH 05/13] fixes for Fedora 32+ (see https://github.com/sciancio/connectionmanager2/issues/69) --- connmgr.py | 4 ++-- metadata.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/connmgr.py b/connmgr.py index e1874cb..7b2f193 100644 --- a/connmgr.py +++ b/connmgr.py @@ -29,7 +29,7 @@ gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk, Gio -from StringIO import StringIO +from io import StringIO import os.path import shutil @@ -702,7 +702,7 @@ def item_dialog(self, row): profileName = profile.get_string("visible-name") entry3.append_text(profileName) - if profileName.decode('utf-8') == row[3]: + if profileName == row[3]: entry3.set_active(index) else: diff --git a/metadata.json b/metadata.json index 08e9f02..0f7e810 100644 --- a/metadata.json +++ b/metadata.json @@ -14,7 +14,8 @@ "3.26", "3.28", "3.30", - "3.32" + "3.32", + "40.0" ], "sw_bin": "connmgr.py", "sw_config": ".connmgr", From ba6c5c4179e9f7a045e6fbc085069d6a82950193 Mon Sep 17 00:00:00 2001 From: Benjamin Kahn Date: Mon, 26 Feb 2024 16:36:35 -0500 Subject: [PATCH 06/13] Make ConnectionManager work in GNOME 45 Basic hack and slash approach to getting this to work. --- extension.js | 122 ++++++++++++++++++-------------------- metadata.json | 13 +---- search.js | 158 +++++++++++++++++++++++++++++++++++++++++++------- terminals.js | 2 +- 4 files changed, 196 insertions(+), 99 deletions(-) diff --git a/extension.js b/extension.js index 443d03f..18ad29b 100644 --- a/extension.js +++ b/extension.js @@ -59,52 +59,32 @@ let Me = Extension.lookupByURL(import.meta.url); import * as Search from './search.js' import * as Terminals from './terminals.js'; -const ConnectionManager = new GObject.registerClass({ - GTypeName: 'ConnectionManager', - }, class ConnectionManager extends PanelMenu.Button { +class ConnectionManager extends PanelMenu.Button { + static { + GObject.registerClass(this); + } - _init() { + constructor() { - super._init(1.0, "Connection Manager", false); + super(1.0, "Connection Manager", false); + this.CM = Extension.lookupByURL(import.meta.url); this._box = new St.BoxLayout(); - -// this._icon = new St.Icon({ -// style_class: 'system-status-icon' -// }); -// this._icon.gicon = Gio.icon_new_for_string(Me.path + '/icons/' + DisabledIcon +'.svg'); - - - this._icon = new St.Icon({ gicon: Gio.icon_new_for_string(Me.path + '/emblem-cm-symbolic.svg'), + this._icon = new St.Icon({ gicon: Gio.icon_new_for_string(this.CM.path + '/emblem-cm-symbolic.svg'), icon_size: 15 }); this._bin = new St.Bin({child: this._icon}); this._box.add(this._bin); - this.actor.add_actor(this._box); - this.actor.add_style_class_name('panel-status-button'); + this.add_actor(this._box); + this.add_style_class_name('panel-status-button'); - let CMPrefs = CM.metadata; + let CMPrefs = this.CM.metadata; this._configFile = GLib.build_filenamev([GLib.get_home_dir(), CMPrefs['sw_config']]); this._prefFile = GLib.build_filenamev([extensionPath, CMPrefs['sw_bin']]) + " " + extensionPath; - // Search provider - this._searchProvider = null; - this._sshList = []; - this._searchProvider = new Search.SshSearchProvider('CONNECTION MANAGER'); - - if( typeof Main.overview.viewSelector === "object" && - typeof Main.overview.viewSelector._searchResults === "object") { - if(typeof Main.overview.viewSelector._searchResults._registerProvider === "function") { //3.14 - Main.overview.viewSelector._searchResults._registerProvider(this._searchProvider); - } else if(typeof Main.overview.viewSelector._searchResults._searchSystem === "object" && - typeof Main.overview.viewSelector._searchResults._searchSystem.addProvider === "function") { //3.12 - Main.overview.viewSelector._searchResults._searchSystem.addProvider(this._searchProvider); - } - } - this._readConf(); } @@ -156,7 +136,7 @@ const ConnectionManager = new GObject.registerClass({ this.menu.addMenuItem(menuPref, this.menu.length+1); // Update ssh name list - this._searchProvider._update(this._sshList); + // this._searchProvider._update(this._sshList); } @@ -181,10 +161,10 @@ const ConnectionManager = new GObject.registerClass({ icon = new St.Icon({icon_name: 'terminal', style_class: 'connmgr-icon' }); - menuItem.actor.add_child(icon); + menuItem.add_child(icon); label = new St.Label({ text: ident+child.Name }); - menuItem.actor.add_child(label); + menuItem.add_child(label); // For each command ... this.TermCmd.resetEnv(); @@ -223,10 +203,10 @@ const ConnectionManager = new GObject.registerClass({ menuItem = new PopupMenu.PopupBaseMenuItem(); icon = new St.Icon({icon_name: 'gtk-execute', style_class: 'connmgr-icon' }); - menuItem.actor.add_child(icon); + menuItem.add_child(icon); label = new St.Label({ text: ident+child.Name }); - menuItem.actor.add_child(label); + menuItem.add_child(label); // For each command ... this.TermCmd.resetEnv(); @@ -285,10 +265,10 @@ const ConnectionManager = new GObject.registerClass({ menuItemAll = new PopupMenu.PopupBaseMenuItem(); iconAll = new St.Icon({icon_name: 'fileopen', style_class: 'connmgr-icon' }); - menuItemAll.actor.add_child(iconAll); + menuItemAll.add_child(iconAll); label = new St.Label({ text: ident+"Open all windows" }); - menuItemAll.actor.add_child(label); + menuItemAll.add_child(label); parent.menu.addMenuItem(menuItemAll, position); position += 1; @@ -303,10 +283,10 @@ const ConnectionManager = new GObject.registerClass({ menuItemTabs = new PopupMenu.PopupBaseMenuItem(); iconTabs = new St.Icon({icon_name: 'fileopen', style_class: 'connmgr-icon' }); - menuItemTabs.actor.add_child(iconTabs); + menuItemTabs.add_child(iconTabs); label = new St.Label({ text: ident+"Open all as tabs" }); - menuItemTabs.actor.add_child(label); + menuItemTabs.add_child(label); parent.menu.addMenuItem(menuItemTabs, position); position += 1; @@ -332,38 +312,52 @@ const ConnectionManager = new GObject.registerClass({ ident = ident_prec; } -}); +} let cm; -function enable() { - cm = new ConnectionManager(); +export default class ConnectionManagerExtension extends Extension { - let _children_length = Main.panel._rightBox.get_n_children(); - Main.panel.addToStatusArea("connectionmanager", cm, _children_length - 2, "right"); - - let file = Gio.file_new_for_path(cm._configFile); - cm.monitor = file.monitor(Gio.FileMonitorFlags.NONE, null); - cm.monitor.connect('changed', () => cm._readConf()); -} + enable() { + + // extensionPath = extensionMeta.path; + extensionObject = Extension.lookupByUUID('connectionmanager2@ciancio.net'); + // extensionSettings = extensionObject.getSettings(); + extensionPath = extensionObject.path; + + let theme = St.IconTheme.new(); + //if (theme) + // theme.append_search_path(extensionPath); + + this.cm = new ConnectionManager(); + + let _children_length = Main.panel._rightBox.get_n_children(); + Main.panel.addToStatusArea("connectionmanager", this.cm, _children_length - 2, "right"); + + let file = Gio.file_new_for_path(this.cm._configFile); + this.cm.monitor = file.monitor(Gio.FileMonitorFlags.NONE, null); + this.cm.monitor.connect('changed', () => this.cm._readConf()); -function disable() { - if(cm._searchProvider!=null) { - Main.overview.removeSearchProvider(cm._searchProvider); - cm._searchProvider = null; + this._searchProvider = new Search.SearchProvider(this); + Main.overview.searchController.addProvider(this._searchProvider); } - cm.monitor.cancel(); - cm.destroy(); -} + disable() { + Main.overview.searchController.removeProvider(this._searchProvider); + this._searchProvider = null; -function init(extensionMeta) { - extensionPath = extensionMeta.path; - - let theme = St.IconTheme.new(); - if (theme) - theme.append_search_path(extensionPath); + this.cm.monitor.cancel(); + this.cm.destroy(); + } +/* + constructor(extensionMeta) { + extensionPath = extensionMeta.path; + + let theme = St.IconTheme.new(); + if (theme) + theme.append_search_path(extensionPath); + } +*/ } - diff --git a/metadata.json b/metadata.json index 0f7e810..268d6d5 100644 --- a/metadata.json +++ b/metadata.json @@ -4,18 +4,7 @@ "name": "Connection Manager", "original-authors": "Stefano Ciancio", "shell-version": [ - "3.12", - "3.14", - "3.16", - "3.18", - "3.20", - "3.22", - "3.24", - "3.26", - "3.28", - "3.30", - "3.32", - "40.0" + "45" ], "sw_bin": "connmgr.py", "sw_config": ".connmgr", diff --git a/search.js b/search.js index 4b18f1b..2663125 100644 --- a/search.js +++ b/search.js @@ -22,9 +22,12 @@ import Gio from 'gi://Gio'; import Shell from 'gi://Shell'; import * as Util from 'resource:///org/gnome/shell/misc/util.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + // const Lang = imports.lang; import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; -let Me = Extension.lookupByURL(import.meta.url); +const Me = Extension.lookupByURL(import.meta.url); + /* "Lang" is no longer available. Just removing it for now. @@ -32,7 +35,7 @@ let Me = Extension.lookupByURL(import.meta.url); const Lang = imports.lang; */ -const Me = imports.misc.extensionUtils.getCurrentExtension(); +// const Me = imports.misc.extensionUtils.getCurrentExtension(); /* The code above should be the replacement for these two lines. @@ -48,28 +51,139 @@ import * as Config from 'resource:///org/gnome/shell/misc/config.js'; */ // SSH / Apps Search Provider -var SshSearchProvider = new Lang.Class({ - Name: 'SshSearchProvider', +export class SearchProvider { + constructor(extension) { + this._extension = extension; + } + + // The application of the provider. Extensions will usually return `null`. + get appInfo() { + return null; + } + + // Whether the provider offers detailed results. + // Extensions will usually return `false`. + get canLaunchSearch() { + return false; + } + + // The unique ID of the provider. + get id() { + return this._extension.uuid; + } + + // This method is called when a search provider result is activated. + activateResult(result, terms) { + console.debug(`activateResult(${result}, [${terms}])`); + Util.spawnCommandLine(this.sshNames[result-1].command); + } + + getResultMetas (resultIds, callback) { + let app = null; + + const {scaleFactor} = St.ThemeContext.get_for_stage(global.stage); + + return new Promise((resolve, reject) => { + const cancelledId = cancellable.connect( + () => reject(Error('Operation Cancelled'))); + + const metas = []; - _init: function(title) { - this.id = title; + for (let i=0; i Date: Mon, 26 Feb 2024 16:45:36 -0500 Subject: [PATCH 07/13] Update README.md to GNOME 45 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 15121d7..e9275cf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +Connection Manager for GNOME 45 +========================= + +Connection Manager was written by [Stefano Ciancio](https://github.com/sciancio) as a copy of [sshmenu](http://sshmenu.sourceforge.net/) from GNOME 2. Sadly, he lost interest in maintaining the extension after GNOME 3.32 on May 2019. Other maintainers have continued to provide updates to this extension over the years. + +This repository includes an update that supports GNOME 45. + What is Connection Manager ======================== From 1c0729f0ae3eda2b2ae120bbe3f8df4e262d4b76 Mon Sep 17 00:00:00 2001 From: Benjamin Kahn Date: Wed, 28 Feb 2024 10:45:49 -0500 Subject: [PATCH 08/13] Change global.logError to console.error --- extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.js b/extension.js index 18ad29b..8136673 100644 --- a/extension.js +++ b/extension.js @@ -122,7 +122,7 @@ class ConnectionManager extends PanelMenu.Button { this._readTree(root, this, ""); } else { - global.logError("CONNMGR: Error reading config file " + this._configFile); + console.error("CONNMGR: Error reading config file " + this._configFile); let filedata = null } From 14792cec5f10623aba946d7a7f6011405226142e Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Fri, 3 May 2024 17:40:33 +0200 Subject: [PATCH 09/13] updated fpr gnome-46, spaces and old code removed --- extension.js | 89 ++++++++++++++++++--------------------------------- metadata.json | 2 +- search.js | 28 +++------------- 3 files changed, 37 insertions(+), 82 deletions(-) diff --git a/extension.js b/extension.js index 8136673..77a31d9 100644 --- a/extension.js +++ b/extension.js @@ -1,5 +1,5 @@ -// ConnectionManager 3 - Simple GUI app for Gnome 3 that provides a menu -// for initiating SSH/Telnet/Custom Apps connections. +// ConnectionManager 3 - Simple GUI app for Gnome 3 that provides a menu +// for initiating SSH/Telnet/Custom Apps connections. // Copyright (C) 2011 Stefano Ciancio // // This library is free software; you can redistribute it and/or @@ -24,13 +24,6 @@ import Gio from 'gi://Gio'; import GObject from 'gi://GObject'; import Shell from 'gi://Shell'; -/* - "Lang" is no longer available. Just removing it for now. - When the replacement code goes in, I'll remove this comment. - const Lang = imports.lang; -*/ - - import * as Signals from 'resource:///org/gnome/shell/misc/signals.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; @@ -47,14 +40,6 @@ let extensionObject, extensionSettings; let CM = Extension.lookupByURL(import.meta.url); let Me = Extension.lookupByURL(import.meta.url); -/* - The code above should be the replacement for these two lines. - But I'm suspicious about why "CM" and "Me" need to be defined - and if the structure is still the same. Keeping these in a comment for now. - const Me = imports.misc.extensionUtils.getCurrentExtension(); - const CM = imports.misc.extensionUtils.getCurrentExtension(); -*/ - // Import Command Terminal Manager and Search class import * as Search from './search.js' import * as Terminals from './terminals.js'; @@ -66,18 +51,20 @@ class ConnectionManager extends PanelMenu.Button { constructor() { - super(1.0, "Connection Manager", false); + super(1, "Connection Manager", false); + this.CM = Extension.lookupByURL(import.meta.url); - this._box = new St.BoxLayout(); + let box = new St.BoxLayout(); - this._icon = new St.Icon({ gicon: Gio.icon_new_for_string(this.CM.path + '/emblem-cm-symbolic.svg'), + let icon = new St.Icon({ gicon: Gio.icon_new_for_string(this.CM.path + '/emblem-cm-symbolic.svg'), icon_size: 15 }); - this._bin = new St.Bin({child: this._icon}); + let bin = new St.Bin({child: icon}); - this._box.add(this._bin); - this.add_actor(this._box); + box.add_child(bin); + + this.add_child(box); this.add_style_class_name('panel-status-button'); let CMPrefs = this.CM.metadata; @@ -97,7 +84,7 @@ class ConnectionManager extends PanelMenu.Button { this.menu._setOpenedSubMenu = submenu => { this._openedSubMenu = submenu; } - + this._sshList = []; if (GLib.file_test(this._configFile, GLib.FileTest.EXISTS) ) { @@ -134,9 +121,6 @@ class ConnectionManager extends PanelMenu.Button { Util.trySpawnCommandLine('python ' + this._prefFile); }); this.menu.addMenuItem(menuPref, this.menu.length+1); - - // Update ssh name list - // this._searchProvider._update(this._sshList); } @@ -144,25 +128,25 @@ class ConnectionManager extends PanelMenu.Button { let child, menuItem, menuSep, menuSub, icon, label, menuItemAll, iconAll, menuSepAll, menuItemTabs, iconTabs, ident_prec; - let childHasItem = false, commandAll = new Array(), commandTab = new Array(), + let childHasItem = false, commandAll = new Array(), commandTab = new Array(), sshparamsTab = new Array(), itemnr = 0; - // For each child ... + // For each child ... for (let i = 0; i < node.length; i++) { child = node[i][0]; let command; - + if (child.hasOwnProperty('Type')) { // Simple Item if (child.Type == '__item__') { menuItem = new PopupMenu.PopupBaseMenuItem(); - + icon = new St.Icon({icon_name: 'terminal', style_class: 'connmgr-icon' }); menuItem.add_child(icon); - + label = new St.Label({ text: ident+child.Name }); menuItem.add_child(label); @@ -174,15 +158,15 @@ class ConnectionManager extends PanelMenu.Button { let [commandT, sshparamsT] = this.TermCmd.createTabCmd(); menuItem.connect('activate', function() { - Util.spawnCommandLine(command); + Util.spawnCommandLine(command); }); parent.menu.addMenuItem(menuItem, i); childHasItem = true; if (this._menu_open_windows) { commandAll[itemnr] = command; } - if (this._menu_open_tabs) { - commandTab[itemnr] = commandT; - sshparamsTab[itemnr] = sshparamsT; + if (this._menu_open_tabs) { + commandTab[itemnr] = commandT; + sshparamsTab[itemnr] = sshparamsT; } itemnr++; @@ -216,7 +200,7 @@ class ConnectionManager extends PanelMenu.Button { let [commandT, sshparamsT] = this.TermCmd.createTabCmd(); menuItem.connect('activate', function() { - Util.spawnCommandLine(command); + Util.spawnCommandLine(command); }); parent.menu.addMenuItem(menuItem, i); @@ -224,7 +208,7 @@ class ConnectionManager extends PanelMenu.Button { if (this._menu_open_windows) { commandAll[itemnr] = command; } if (this._menu_open_tabs) { commandTab[itemnr] = commandT; - sshparamsTab[itemnr] = sshparamsT; + sshparamsTab[itemnr] = sshparamsT; } itemnr++; @@ -244,13 +228,13 @@ class ConnectionManager extends PanelMenu.Button { if (child.Type == '__sep__') { parent.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem(), i); } - + // Folder if (child.Type == '__folder__') { menuSub = new PopupMenu.PopupSubMenuMenuItem(ident+child.Name); parent.menu.addMenuItem(menuSub); - + ident_prec = ident; this._readTree(child.Children, menuSub, ident+" "); @@ -269,7 +253,7 @@ class ConnectionManager extends PanelMenu.Button { label = new St.Label({ text: ident+"Open all windows" }); menuItemAll.add_child(label); - + parent.menu.addMenuItem(menuItemAll, position); position += 1; menuItemAll.connect('activate', function() { @@ -318,23 +302,21 @@ class ConnectionManager extends PanelMenu.Button { let cm; export default class ConnectionManagerExtension extends Extension { - + enable() { - + // extensionPath = extensionMeta.path; extensionObject = Extension.lookupByUUID('connectionmanager2@ciancio.net'); // extensionSettings = extensionObject.getSettings(); extensionPath = extensionObject.path; - + let theme = St.IconTheme.new(); - //if (theme) - // theme.append_search_path(extensionPath); this.cm = new ConnectionManager(); - + let _children_length = Main.panel._rightBox.get_n_children(); Main.panel.addToStatusArea("connectionmanager", this.cm, _children_length - 2, "right"); - + let file = Gio.file_new_for_path(this.cm._configFile); this.cm.monitor = file.monitor(Gio.FileMonitorFlags.NONE, null); this.cm.monitor.connect('changed', () => this.cm._readConf()); @@ -350,14 +332,5 @@ export default class ConnectionManagerExtension extends Extension { this.cm.monitor.cancel(); this.cm.destroy(); } -/* - constructor(extensionMeta) { - extensionPath = extensionMeta.path; - - let theme = St.IconTheme.new(); - if (theme) - theme.append_search_path(extensionPath); - - } -*/ } + diff --git a/metadata.json b/metadata.json index 268d6d5..62e59d9 100644 --- a/metadata.json +++ b/metadata.json @@ -4,7 +4,7 @@ "name": "Connection Manager", "original-authors": "Stefano Ciancio", "shell-version": [ - "45" + "46" ], "sw_bin": "connmgr.py", "sw_config": ".connmgr", diff --git a/search.js b/search.js index 2663125..4c719e5 100644 --- a/search.js +++ b/search.js @@ -1,5 +1,5 @@ -// ConnectionManager 3 - Simple GUI app for Gnome 3 that provides a menu -// for initiating SSH/Telnet/Custom Apps connections. +// ConnectionManager 3 - Simple GUI app for Gnome 3 that provides a menu +// for initiating SSH/Telnet/Custom Apps connections. // Copyright (C) 2011 Stefano Ciancio // // This library is free software; you can redistribute it and/or @@ -29,26 +29,7 @@ import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/ex const Me = Extension.lookupByURL(import.meta.url); -/* - "Lang" is no longer available. Just removing it for now. - When the replacement code goes in, I'll remove this comment. - const Lang = imports.lang; -*/ - -// const Me = imports.misc.extensionUtils.getCurrentExtension(); - -/* - The code above should be the replacement for these two lines. - Keeping these in a comment for now. (See extension.js) - const Me = imports.misc.extensionUtils.getCurrentExtension(); -*/ - import * as Config from 'resource:///org/gnome/shell/misc/config.js'; -/* - The above line should replace this one. - But there are now TWO config paths. I chose one, but I'm not sure I made the right choice. - const Config = imports.misc.config; -*/ // SSH / Apps Search Provider export class SearchProvider { @@ -56,7 +37,7 @@ export class SearchProvider { this._extension = extension; } - // The application of the provider. Extensions will usually return `null`. + // The application of the provider. Extensions will usually return `null`. get appInfo() { return null; } @@ -126,7 +107,7 @@ export class SearchProvider { resolve(resultMetas); }); callback(metas); - } + } } export class SshSearchProvider { constructor(extension) { @@ -248,3 +229,4 @@ export class SshSearchProvider { Util.spawnCommandLine(this.sshNames[id-1].command); } } + From f25124cf57336c10e4e198592ecb0f485cf7e6bc Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Fri, 3 May 2024 17:52:23 +0200 Subject: [PATCH 10/13] unreachable code removed --- search.js | 1 - 1 file changed, 1 deletion(-) diff --git a/search.js b/search.js index 4c719e5..66ae7ae 100644 --- a/search.js +++ b/search.js @@ -106,7 +106,6 @@ export class SearchProvider { if (!cancellable.is_cancelled()) resolve(resultMetas); }); - callback(metas); } } export class SshSearchProvider { From ca77e74a86864d3055ac67991aefb91bd8bfda83 Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Fri, 3 May 2024 17:53:16 +0200 Subject: [PATCH 11/13] test statement added --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e9275cf..69e5adb 100644 --- a/README.md +++ b/README.md @@ -66,5 +66,7 @@ You can find other info: * [License](https://github.com/sciancio/connectionmanager/wiki/License) - +Testing +======================== +$ dbus-run-session -- gnome-shell --nested --wayland From b76d7ad0d37aa6afc1e7420aed4bfc01b0c4885a Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Fri, 3 May 2024 17:53:47 +0200 Subject: [PATCH 12/13] branches for gnome versions added --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69e5adb..2f1000d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -Connection Manager for GNOME 45 +Connection Manager for GNOME 46 ========================= Connection Manager was written by [Stefano Ciancio](https://github.com/sciancio) as a copy of [sshmenu](http://sshmenu.sourceforge.net/) from GNOME 2. Sadly, he lost interest in maintaining the extension after GNOME 3.32 on May 2019. Other maintainers have continued to provide updates to this extension over the years. -This repository includes an update that supports GNOME 45. +This repository includes branches supporting GNOME pre-45, 45, 46. What is Connection Manager ======================== From a71f116f6a4340d7d4afb3e254dde6bd21bb26b9 Mon Sep 17 00:00:00 2001 From: Andreas Piesk Date: Tue, 29 Oct 2024 21:47:52 +0100 Subject: [PATCH 13/13] upgrade to fedora 41 (gnome 47.1) --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 62e59d9..051af76 100644 --- a/metadata.json +++ b/metadata.json @@ -4,7 +4,7 @@ "name": "Connection Manager", "original-authors": "Stefano Ciancio", "shell-version": [ - "46" + "47.1" ], "sw_bin": "connmgr.py", "sw_config": ".connmgr",