Skip to content

Commit

Permalink
Moves DND button to the quickSettingsMenu if DND toggle is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
andia89 committed Nov 22, 2022
1 parent e7eab27 commit 0f90ea4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
10 changes: 9 additions & 1 deletion features/dndQuickToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const Me = ExtensionUtils.getCurrentExtension()
const featureReloader = Me.imports.libs.featureReloader
const { QuickSettings } = Me.imports.libs.gnome
const { Indicator } = Me.imports.libs.dndQuickToogleHandler
const { DateMenu } = Me.imports.libs.gnome


var dndQuickToggleFeature = class {
load() {
Expand All @@ -19,12 +21,18 @@ var dndQuickToggleFeature = class {
this.dndToggle = new Indicator()
QuickSettings._indicators.add_child(this.dndToggle)
QuickSettings._addItems(this.dndToggle.quickSettingsItems)

//remove DND button from datemenu
this.datemenu_dnd = DateMenu.last_child.last_child
DateMenu.last_child.remove_actor(this.datemenu_dnd);

}

unload() {
// disable feature reloader
featureReloader.disable(this)

//put back the button to the datemenu
DateMenu.last_child.add_child(this.datemenu_dnd);
// Remove DND Quick Toggle
if (this.dndToggle) {
const dndQSItems = this.dndToggle.quickSettingsItems[0]
Expand Down
26 changes: 26 additions & 0 deletions libs/dndQuickToogleHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Gio, GObject } = imports.gi;
const { QuickToggle, SystemIndicator } = imports.ui.quickSettings;
const { St } = imports.gi

const DndQuickToogle = GObject.registerClass(
class DndQuickToogle extends QuickToggle {
Expand Down Expand Up @@ -41,6 +42,31 @@ class Indicator extends SystemIndicator {
_init() {
super._init();

this._indicator = this._addIndicator();

this._indicator.icon_name = 'notifications-disabled-symbolic'
this.quickSettingsItems.push(new DndQuickToogle());

this._settings = new Gio.Settings({
schema_id: 'org.gnome.desktop.notifications',
});

this._changedId = this._settings.connect('changed::show-banners',
() => this._sync());

this._sync();
}

_sync() {
const checked = !this._settings.get_boolean('show-banners');
if (checked){
this._indicator.visible = true;
}
else{
this._indicator.visible = false;
}

}


});

0 comments on commit 0f90ea4

Please sign in to comment.