Skip to content

Commit

Permalink
Add extension settings to quick settings menu
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Jan 7, 2025
1 parent e47bdd8 commit a98aa29
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const PrivacyQuickToggle = GObject.registerClass(
//Class for the privacy quick settings group
const PrivacyQuickGroup = GObject.registerClass(
class PrivacyQuickGroup extends QuickSettings.QuickMenuToggle {
_init(useQuickSubtitle, clickToToggle) {
_init(extension, useQuickSubtitle, clickToToggle) {
//Set up the quick setting toggle
super._init({
title: _('Privacy'),
Expand Down Expand Up @@ -204,6 +204,16 @@ const PrivacyQuickGroup = GObject.registerClass(
this._useQuickSubtitle = useQuickSubtitle;
this._updateSubtitle();

//Add extension settings entry
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
let settingsItem = this.menu.addAction(_('Settings'), () => {
extension.openPreferences();
});

//Hide the settings when the screen is locked
settingsItem.visible = Main.sessionMode.allowSettings;
this.menu._settingsActions[Me.uuid] = settingsItem;

//Set initial enabled / disabled
this._updateVisualState();
}
Expand Down Expand Up @@ -300,9 +310,9 @@ class QuickSettingsManager {
}

class QuickGroupManager {
constructor(useQuickSubtitle, clickToToggle) {
constructor(extension, useQuickSubtitle, clickToToggle) {
//Create quick settings group and add to the system menu
this._quickSettingsGroup = new PrivacyQuickGroup(useQuickSubtitle, clickToToggle);
this._quickSettingsGroup = new PrivacyQuickGroup(extension, useQuickSubtitle, clickToToggle);
let backgroundApps = QuickSettingsMenu._backgroundApps?.quickSettingsItems?.at(-1) ?? null;
QuickSettingsMenu.menu.insertItemBefore(this._quickSettingsGroup, backgroundApps);
}
Expand Down Expand Up @@ -403,7 +413,7 @@ class PrivacyExtension {
} else if (menuType == 'quick-group') {
let useQuickSubtitle = this._extensionSettings.get_boolean('use-quick-subtitle');
let clickToToggle = this._extensionSettings.get_boolean('click-to-toggle');
this._privacyManager = new QuickGroupManager(useQuickSubtitle, clickToToggle);
this._privacyManager = new QuickGroupManager(this, useQuickSubtitle, clickToToggle);
} else if (menuType == 'indicator') {
let forceIconRight = this._extensionSettings.get_boolean('move-icon-right');
this._privacyManager = new IndicatorSettingsManager(forceIconRight);
Expand Down

0 comments on commit a98aa29

Please sign in to comment.