Skip to content

Commit

Permalink
Enabled hiding suspend, restart, and power off buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
slaclau committed Mar 26, 2024
1 parent 0e25653 commit d56e571
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 17 additions & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ export default class HibernateButtonExtension extends Extension {

_updateDefaults() {
console.log("Update defaults");
let menuItems = this.systemMenu._systemItem.menu._getMenuItems()
for (let menuItem of menuItems) {
console.log(menuItem.label.get_text())
if ( menuItem.label.get_text() === _('Suspend') ) {
console.log(`Show suspend button: ${this._setting.get_boolean('show-suspend')}`)
menuItem.visible = this._setting.get_boolean('show-suspend');
}
if ( menuItem.label.get_text() === _('Restart…') ) {
console.log(`Show restart button: ${this._setting.get_boolean('show-restart')}`)
menuItem.visible = this._setting.get_boolean('show-restart');
}
if ( menuItem.label.get_text() === _('Power Off…') ) {
console.log(`Show shutdown button: ${this._setting.get_boolean('show-shutdown')}`)
menuItem.visible = this._setting.get_boolean('show-shutdown');
}
}
}

_onHibernateClicked() {
Expand Down Expand Up @@ -571,3 +587,4 @@ var ConfirmDialog = GObject.registerClass(
);

const _DIALOG_ICON_SIZE = 32;

3 changes: 0 additions & 3 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export default class Prefs extends ExtensionPreferences {

const suspend_row = new Adw.SwitchRow({
title: __('Suspend'),
subtitle: __('Not implemented yet'),
});
modes_group.add(suspend_row);
const hibernate_row = new Adw.SwitchRow({
Expand All @@ -118,12 +117,10 @@ export default class Prefs extends ExtensionPreferences {
modes_group.add(suspend_then_hibernate_row);
const restart_row = new Adw.SwitchRow({
title: __('Restart...'),
subtitle: __('Not implemented yet'),
});
modes_group.add(restart_row);
const shutdown_row = new Adw.SwitchRow({
title: __('Shutdown...'),
subtitle: __('Not implemented yet'),
});
modes_group.add(shutdown_row);

Expand Down

0 comments on commit d56e571

Please sign in to comment.