Skip to content

Commit

Permalink
Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
qwreey committed Apr 29, 2023
1 parent fe771a6 commit 0717c9a
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 168 deletions.
10 changes: 4 additions & 6 deletions features/buttonRemover.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ var buttonRemoverFeature = class {
this.settings.set_string("list-buttons",JSON.stringify(listButtons))
}

let items; {
items = this.settings.get_strv("user-removed-buttons")
if (!items) {
items = []
this.settings.set_strv("user-removed-buttons",items)
}
let items = this.settings.get_strv("user-removed-buttons")
if (!items) {
items = []
this.settings.set_strv("user-removed-buttons",items)
}

this._apply(items)
Expand Down
50 changes: 25 additions & 25 deletions features/dndQuickToggle.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()

const { featureReloader, addQuickSettingsItems } = Me.imports.libs.utility
const { QuickSettings, DateMenu, QuickSettingsGrid } = Me.imports.libs.gnome;
const { Indicator } = Me.imports.libs.dndQuickToggleHandler;
const { Gio, GObject } = imports.gi;
const { QuickSettings, DateMenu, QuickSettingsGrid } = Me.imports.libs.gnome
const { Indicator } = Me.imports.libs.dndQuickToggleHandler
const { Gio, GObject } = imports.gi

var dndQuickToggleFeature = class {
load() {
// setup reloader
featureReloader.enableWithSettingKeys(this, [
"add-dnd-quick-toggle-enabled",
]);
])

this.datemenu_dnd = null;
this.datemenu_dnd = null
// check is feature enabled
if (!this.settings.get_boolean("add-dnd-quick-toggle-enabled")) return;
if (!this.settings.get_boolean("add-dnd-quick-toggle-enabled")) return

// Add DND Quick Toggle
this.dndToggle = new Indicator();
this.dndToggle = new Indicator()
QuickSettings._indicators.add_child(this.dndToggle)
// QuickSettings._addItems(this.dndToggle.quickSettingsItems)
addQuickSettingsItems(this.dndToggle.quickSettingsItems)

//remove DND button from datemenu
this.datemenu_dnd = DateMenu.last_child.last_child;
this.datemenu_dnd.hide();
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();
});
this.datemenu_dnd.hide()
})
}

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

if (this.datemenu_dnd == null) return;
if (this.datemenu_dnd == null) return

//put back the button to the datemenu
this.datemenu_dnd.disconnect(this.datemenu_dnd_connection);
this.datemenu_dnd_connection = null;
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();
this.datemenu_dnd.show()
}
// Remove DND Quick Toggle
if (this.dndToggle) {
const dndQSItems = this.dndToggle.quickSettingsItems[0];
dndQSItems.get_parent().remove_child(dndQSItems);
this.dndToggle.get_parent().remove_child(this.dndToggle);
this.dndToggle.destroy();
this.dndToggle = null;
const dndQSItems = this.dndToggle.quickSettingsItems[0]
dndQSItems.get_parent().remove_child(dndQSItems)
this.dndToggle.get_parent().remove_child(this.dndToggle)
this.dndToggle.destroy()
this.dndToggle = null
}
}
};
}
6 changes: 3 additions & 3 deletions features/inputOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { featureReloader } = Me.imports.libs.utility
const { QuickSettingsGrid } = Me.imports.libs.gnome
const { Label } = imports.gi.St
const Volume = imports.ui.status.volume
const PopupMenu = imports.ui.popupMenu;
const PopupMenu = imports.ui.popupMenu

var inputOutputFeature = class {
load() {
Expand Down Expand Up @@ -184,7 +184,7 @@ var inputOutputFeature = class {
if (!device)
return

const {description, origin} = device;
const {description, origin} = device
const name = origin
? `${description}${origin}`
: description
Expand All @@ -195,4 +195,4 @@ var inputOutputFeature = class {
_spanTwoColumns(object) {
QuickSettingsGrid.layout_manager.child_set_property(QuickSettingsGrid, object, 'column-span', 2)
}
};
}
20 changes: 7 additions & 13 deletions features/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var notificationsFeature = class {
hideWhenNoNotifications: this.settings.get_boolean("notifications-hide-when-no-notifications")
})

let notificationStyle = this.notificationHandler.style_class =
this.notificationHandler.style_class =
// If separated, style as popup menu
(isIntegrated ? "" : "popup-menu-content quick-settings ")
// Integrated or separated
Expand All @@ -57,10 +57,10 @@ var notificationsFeature = class {

// Max height
this.notificationHandler.style
= `max-height: ${this.settings.get_int("notifications-max-height")}px;`
= `max-height: ${this.settings.get_int("notifications-max-height")}px`
this.maxHeigthListen = this.settings.connect("changed::notifications-max-height",()=>{
this.notificationHandler.style
= `max-height: ${this.settings.get_int("notifications-max-height")}px;`
= `max-height: ${this.settings.get_int("notifications-max-height")}px`
})

// Insert media control
Expand Down Expand Up @@ -100,16 +100,10 @@ var notificationsFeature = class {
// Insert notification modal
switch (this.settings.get_string("notifications-position")) {
case "top":
// get system item index
let gridChildren = QuickSettingsGrid.get_children()
let systemItemIndex = null
for (let index = 0; index<gridChildren.length; index++) {
if (gridChildren[index]?.constructor?.name == "SystemItem") {
systemItemIndex = index
break
}
}
QuickSettingsGrid.insert_child_at_index(this.notificationHandler,systemItemIndex)
QuickSettingsGrid.insert_child_at_index(this.notificationHandler,
// get system item index
QuickSettingsGrid.get_children().findIndex((child)=>child.constructor?.name == "SystemItem")+1
)
break
case "bottom":
QuickSettingsGrid.add_child(this.notificationHandler)
Expand Down
14 changes: 4 additions & 10 deletions features/volumeMixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@ var volumeMixerFeature = class {
'volume-mixer-use-regex': settings.get_boolean("volume-mixer-use-regex")
})

// Find Input slider index
let inputSliderIndex
let gridChildren = QuickSettingsGrid.get_children()
for (let index = 0; index<gridChildren.length; index++) {
if (gridChildren[index]?.constructor?.name == "InputStreamSlider") {
inputSliderIndex = index
}
}

// Insert volume mixer into Quick Settings
let position = settings.get_string("volume-mixer-position")
switch (position) {
case "top":
QuickSettingsGrid.insert_child_at_index(this.volumeMixer.actor,inputSliderIndex)
QuickSettingsGrid.insert_child_at_index(this.volumeMixer.actor,
// Find Input slider index
QuickSettingsGrid.get_children().findIndex((child)=>child.constructor?.name == "InputStreamSlider")+1
)
break
case "bottom":
QuickSettingsGrid.add_child(this.volumeMixer.actor)
Expand Down
22 changes: 11 additions & 11 deletions libs/dndQuickToggleHandler.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const { Gio, GObject } = imports.gi;
const { QuickToggle, SystemIndicator } = imports.ui.quickSettings;
const { St } = imports.gi;
const { Gio, GObject } = imports.gi
const { QuickToggle, SystemIndicator } = imports.ui.quickSettings
const { St } = imports.gi

const DndQuickToggle = GObject.registerClass(
class DndQuickToggle extends QuickToggle {
_init() {
super._init({
label: _('Do Not Disturb'),
iconName: "notifications-disabled-symbolic",
});
})

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

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

this.connectObject(
// Destroy event
Expand All @@ -24,10 +24,10 @@ const DndQuickToggle = GObject.registerClass(
"clicked", this._toggleMode.bind(this),

this
);
)

// Fetch DND status once
this._sync();
this._sync()
}

// Toggle DND
Expand All @@ -44,7 +44,7 @@ const DndQuickToggle = GObject.registerClass(
if (this.checked !== checked) this.set({ checked })
}
}
);
)

var Indicator = GObject.registerClass(
class Indicator extends SystemIndicator {
Expand All @@ -62,7 +62,7 @@ var Indicator = GObject.registerClass(

// sync
this._changedId = this._settings.connect("changed::show-banners", this._sync.bind(this))
this._sync();
this._sync()
}

_sync() {
Expand All @@ -74,4 +74,4 @@ var Indicator = GObject.registerClass(
}
}
}
);
)
3 changes: 3 additions & 0 deletions libs/notificationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const { GObject, St, Clutter } = imports.gi
const Main = imports.ui.main
const Calendar = imports.ui.calendar
const ExtensionUtils = imports.misc.extensionUtils

const Me = ExtensionUtils.getCurrentExtension()
const { fixStScrollViewScrollbarOverflow } = Me.imports.libs.utility

const NoNotifPlaceholder = GObject.registerClass(
class NoNotifPlaceholder extends St.BoxLayout {
Expand Down Expand Up @@ -77,6 +79,7 @@ class Notifications extends St.BoxLayout{
this.list = messageList._scrollView
this.list.get_parent().remove_child(this.list)
this.add_child(this.list) // mount
fixStScrollViewScrollbarOverflow(this.list) // fix fade effect
}

// Create 'Notifications' text and ClearButton
Expand Down
Loading

0 comments on commit 0717c9a

Please sign in to comment.