Skip to content

Commit 5b52d31

Browse files
committed
Catch the error if GTop is not installed to let this extension be loaded normally and log the error logs for it. I assume other dependencies () are installed from the first place.
Fixes: #79 Missing GTop when installed from flatpak under EndlessOS
1 parent 4e5ab14 commit 5b52d31

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

ui/autoclose.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
'use strict';
33

4-
const { Clutter, Gio, GLib, GObject, Meta, Shell, St, Atk, Pango, GTop } = imports.gi;
4+
const { Clutter, Gio, GLib, GObject, Meta, Shell, St, Atk, Pango } = imports.gi;
55

66
const ExtensionUtils = imports.misc.extensionUtils;
77
const Me = ExtensionUtils.getCurrentExtension();
@@ -20,6 +20,13 @@ const Main = imports.ui.main;
2020

2121
const Log = Me.imports.utils.log;
2222

23+
let GTop = null;
24+
try {
25+
GTop = imports.gi.GTop;
26+
} catch (e) {
27+
Log.Log.getDefault().error(e, `GTop is not installed, I highly recommend to install it, so that a process can be closed safely. How to install it? Please visit: https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager#dependencies .`);
28+
}
29+
2330
const PrefsUtils = Me.imports.utils.prefsUtils;
2431
const FileUtils = Me.imports.utils.fileUtils;
2532
const SubprocessUtils = Me.imports.utils.subprocessUtils;
@@ -552,6 +559,13 @@ var RunningApplicationListWindow = GObject.registerClass({
552559
}
553560

554561
_prepareToConfirm() {
562+
if (!GTop) {
563+
// Since the gtop is not installed, we close the system directly (if there are no apps running).
564+
// The process of apps may be still running to save data to disk, etc.
565+
this._confirm();
566+
return;
567+
}
568+
555569
if (this._checkProcessStateId) return;
556570

557571
this._applicationSection.title = `Waiting below processes to exit, this may take a while…`;

0 commit comments

Comments
 (0)