Skip to content

Commit

Permalink
Use addExternalIndicator to add quick settings entries
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Aug 16, 2023
1 parent fb70449 commit f42a26b
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions extension/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,34 +249,17 @@ class QuickSettingsManager {
];

//Create a quick setting toggle for each privacy setting
quickSettingsInfo.forEach((quickSettingInfo) => {
quickSettingsInfo.forEach((quickSettingInfo, i) => {
this._quickSettingToggles.push(
new PrivacyQuickToggle(
quickSettingInfo[0],
quickSettingInfo[1],
quickSettingInfo[2],
quickSettingInfo[3],
quickSettingInfo[0], quickSettingInfo[1],
quickSettingInfo[2], quickSettingInfo[3],
quickSettingInfo[4]
)
);
});

//Add the toggles to the system menu
QuickSettingsMenu._addItems(this._quickSettingToggles);

/* TODO:
- This is a bad idea
- When the shell provides a better way to add above background apps, it should be used instead
- This is a temporary hacky fix
- GLib import should also be dropped when the fix is removed
*/

//Place the toggles above the background apps entry
GLib.idle_add(GLib.PRIORITY_LOW, () => {
this._quickSettingToggles.forEach((item) => {
QuickSettingsMenu.menu._grid.set_child_below_sibling(item,
QuickSettingsMenu._backgroundApps.quickSettingsItems[0]);
});
//Add the toggle to the system menu
QuickSettingsMenu.addExternalIndicator(this._quickSettingToggles[i]);
});
}

Expand All @@ -293,14 +276,9 @@ class QuickSettingsManager {

class QuickGroupManager {
constructor(useQuickSubtitle) {
//Create quick settings group and add to the system menu
this._quickSettingsGroup = new PrivacyQuickGroup(useQuickSubtitle);

//Add the toggles to the system menu
QuickSettingsMenu._addItems([this._quickSettingsGroup]);

//Place the toggles above the background apps entry
QuickSettingsMenu.menu._grid.set_child_below_sibling(this._quickSettingsGroup,
QuickSettingsMenu._backgroundApps.quickSettingsItems[0]);
QuickSettingsMenu.addExternalIndicator(this._quickSettingsGroup);
}

clean() {
Expand Down

0 comments on commit f42a26b

Please sign in to comment.