import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import SamIndicator from './sam-indicator.js';
import AppearanceFeature from './gtk-theme-integration.js';
import DonationReminder from './donation-reminder.js';
import SystemExtensionMonitor from './system-extension-monitor.js';
import StartupOverviewFeature from './startup-overview.js';

export default class StillGnomeExtension extends Extension {
    enable() {
        this._samIndicator = new SamIndicator();
        this._appearanceFeature = new AppearanceFeature();
        this._donationReminder = new DonationReminder();
        this._systemExtensionMonitor = new SystemExtensionMonitor();
        this._startupOverviewFeature = new StartupOverviewFeature();

        this._startupOverviewFeature.enable(this.getSettings());
        this._samIndicator.enable(this.uuid);
        this._appearanceFeature.enable();
        this._donationReminder.enable();
        this._systemExtensionMonitor.enable(this.uuid);
    }

    disable() {
        if (this._startupOverviewFeature) {
            this._startupOverviewFeature.disable();
            this._startupOverviewFeature = null;
        }

        if (this._systemExtensionMonitor) {
            this._systemExtensionMonitor.disable();
            this._systemExtensionMonitor = null;
        }

        if (this._donationReminder) {
            this._donationReminder.disable();
            this._donationReminder = null;
        }

        if (this._appearanceFeature) {
            this._appearanceFeature.disable();
            this._appearanceFeature = null;
        }

        if (this._samIndicator) {
            this._samIndicator.disable();
            this._samIndicator = null;
        }
    }
}
