Skip to content

Commit

Permalink
extension: check if disabled only temporarily
Browse files Browse the repository at this point in the history
Don't terminate the app and don't uninstall desktop entry and D-Bus
service.

Fixes #1087
  • Loading branch information
amezin committed Oct 29, 2024
1 parent 375d549 commit de0b824
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions ddterm/shell/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Shell from 'gi://Shell';

import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
import { ExtensionState } from 'resource:///org/gnome/shell/misc/extensionUtils.js';

import { Animation, ReverseAnimation } from './animation.js';
import { AppControl } from './appcontrol.js';
Expand Down Expand Up @@ -169,8 +170,9 @@ function create_panel_icon(settings, window_matcher, app_control, gettext_contex
return panel_icon;
}

function install(src_dir, launcher, rollback) {
const installer = new Installer(src_dir, launcher);
function install(extension, rollback) {
const { install_src_dir, launcher_path } = extension;
const installer = new Installer(install_src_dir, launcher_path);
installer.install();

if (GObject.signal_lookup('shutdown', Shell.Global)) {
Expand All @@ -186,8 +188,15 @@ function install(src_dir, launcher, rollback) {
rollback.push(() => {
// Don't uninstall desktop/service files because of screen locking
// GNOME Shell picks up newly installed desktop files with a noticeable delay
if (!Main.sessionMode.isLocked)
installer.uninstall();
if (Main.sessionMode.isLocked)
return;

// Also don't uninstall if ddterm is being disabled only temporarily
// (because some other extension is being disabled).
if (extension.is_state_active())
return;

installer.uninstall();
});
}

Expand Down Expand Up @@ -337,6 +346,11 @@ class EnabledExtension {
if (Main.sessionMode.isLocked)
return;

// Also don't terminate the app if ddterm is being disabled only temporarily
// (because some other extension is being disabled).
if (this.extension.is_state_active())
return;

if (!this.app_control.quit())
this.service.terminate();
});
Expand Down Expand Up @@ -386,11 +400,7 @@ class EnabledExtension {
rollback
);

install(
this.extension.install_src_dir,
this.extension.launcher_path,
rollback
);
install(this.extension, rollback);
}

_set_skip_taskbar() {
Expand Down Expand Up @@ -528,4 +538,13 @@ export default class DDTermExtension extends Extension {
this.enabled_state?.disable();
this.enabled_state = null;
}

is_state_active() {
const info = Main.extensionManager.lookup(this.uuid);

return [
ExtensionState.ACTIVE ?? ExtensionState.ENABLED,
ExtensionState.ACTIVATING ?? ExtensionState.ENABLING,
].includes(info?.state ?? ExtensionState.ERROR);
}
}

0 comments on commit de0b824

Please sign in to comment.