Skip to content

Commit

Permalink
Merge pull request #52 from andia89/master
Browse files Browse the repository at this point in the history
Moves DND button to the quickSettingsMenu if DND toggle is enabled
  • Loading branch information
qwreey authored Dec 1, 2022
2 parents e7eab27 + 46ffc02 commit 0f8a281
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
19 changes: 18 additions & 1 deletion features/dndQuickToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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
const { Gio, GObject } = imports.gi;


var dndQuickToggleFeature = class {
load() {
Expand All @@ -19,12 +22,26 @@ 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
this.datemenu_dnd.hide()
this.datemenu_dnd_connection = this.datemenu_dnd.connect("show", () => { this.datemenu_dnd.hide() })

}

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

//put back the button to the datemenu
this.datemenu_dnd.disconnect(this.datemenu_dnd_connection)
this.datemenu_dnd_connection = null;
const _settings = new Gio.Settings({
schema_id: 'org.gnome.desktop.notifications',
});
if (!_settings.get_boolean('show-banners')){
this.datemenu_dnd.show();
}
// 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 0f8a281

Please sign in to comment.