96 lines
2.8 KiB
JavaScript
96 lines
2.8 KiB
JavaScript
import GLib from 'gi://GLib';
|
|
import St from 'gi://St';
|
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
|
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
|
|
|
|
import { SettingsWrapper } from './src/storage/settings.js';
|
|
import { SecretsStore } from './src/storage/secretsStore.js';
|
|
import { ClipboardStore } from './src/storage/clipboardStore.js';
|
|
import { SecretService } from './src/services/secretService.js';
|
|
import { ClipboardService } from './src/services/clipboardService.js';
|
|
import { PanelButton } from './src/ui/panelButton.js';
|
|
|
|
function _log(msg) {
|
|
console.log(`[ClipCoffre] ${msg}`);
|
|
}
|
|
|
|
export default class ClipCoffreExtension extends Extension {
|
|
constructor(metadata) {
|
|
super(metadata);
|
|
_log('constructor called');
|
|
this._panelButton = null;
|
|
this._settings = null;
|
|
this._clipboardService = null;
|
|
this._secretService = null;
|
|
}
|
|
|
|
enable() {
|
|
_log('enable() called');
|
|
try {
|
|
if (this._panelButton) {
|
|
_log('panelButton already exists, returning');
|
|
return;
|
|
}
|
|
|
|
_log('Creating SettingsWrapper...');
|
|
this._settings = new SettingsWrapper(this.getSettings());
|
|
_log('SettingsWrapper created');
|
|
|
|
_log('Creating SecretsStore...');
|
|
const secretsStore = new SecretsStore(this);
|
|
_log('SecretsStore created');
|
|
|
|
_log('Creating ClipboardStore...');
|
|
const clipboardStore = new ClipboardStore(this, this._settings);
|
|
_log('ClipboardStore created');
|
|
|
|
_log('Creating SecretService...');
|
|
this._secretService = new SecretService(secretsStore, this._settings);
|
|
_log('SecretService created');
|
|
|
|
_log('Creating ClipboardService...');
|
|
this._clipboardService = new ClipboardService(clipboardStore);
|
|
_log('ClipboardService created');
|
|
|
|
_log('Creating PanelButton...');
|
|
this._panelButton = new PanelButton(this._settings, {
|
|
secretService: this._secretService,
|
|
clipboardService: this._clipboardService,
|
|
});
|
|
_log('PanelButton created');
|
|
|
|
_log('Adding to status area...');
|
|
Main.panel.addToStatusArea('clipcoffre-panel', this._panelButton);
|
|
_log('Extension enabled successfully');
|
|
|
|
} catch (e) {
|
|
_log(`ERROR in enable(): ${e.message}`);
|
|
_log(`Stack: ${e.stack}`);
|
|
}
|
|
}
|
|
|
|
disable() {
|
|
_log('disable() called');
|
|
try {
|
|
if (this._panelButton) {
|
|
this._panelButton.destroy();
|
|
this._panelButton = null;
|
|
}
|
|
|
|
if (this._clipboardService) {
|
|
this._clipboardService.destroy();
|
|
this._clipboardService = null;
|
|
}
|
|
|
|
if (this._settings) {
|
|
this._settings.destroy();
|
|
this._settings = null;
|
|
}
|
|
_log('Extension disabled successfully');
|
|
} catch (e) {
|
|
_log(`ERROR in disable(): ${e.message}`);
|
|
_log(`Stack: ${e.stack}`);
|
|
}
|
|
}
|
|
}
|