Skip to content

Commit 2834cd3

Browse files
committed
Make hibernate confirmation dialog optiona;
1 parent e1a86fc commit 2834cd3

File tree

3 files changed

+69
-28
lines changed

3 files changed

+69
-28
lines changed

extension.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -222,32 +222,36 @@ export default class MyExtension extends Extension {
222222
_onHibernateClicked() {
223223
this.systemMenu._systemItem.menu.itemActivated();
224224

225+
if (this._setting.get_boolean('show-hibernate-dialog')) {
225226
let HibernateDialogContent = {
226-
subject: C_('title', __('Hibernate')),
227-
description: __('Do you really want to hibernate the system?'),
228-
confirmButtons: [
229-
{
230-
signal: 'Cancel',
231-
label: C_('button', __('Cancel')),
232-
key: Clutter.Escape,
233-
},
234-
{
235-
signal: 'ConfirmedHibernate',
236-
label: C_('button', __('Hibernate')),
237-
default: true,
238-
},
239-
],
240-
iconName: 'document-save-symbolic',
241-
iconStyleClass: 'end-session-dialog-shutdown-icon',
242-
};
227+
subject: C_('title', __('Hibernate')),
228+
description: __('Do you really want to hibernate the system?'),
229+
confirmButtons: [
230+
{
231+
signal: 'Cancel',
232+
label: C_('button', __('Cancel')),
233+
key: Clutter.Escape,
234+
},
235+
{
236+
signal: 'ConfirmedHibernate',
237+
label: C_('button', __('Hibernate')),
238+
default: true,
239+
},
240+
],
241+
iconName: 'document-save-symbolic',
242+
iconStyleClass: 'end-session-dialog-shutdown-icon',
243+
};
243244

244-
this._dialog = new ConfirmDialog(
245-
HibernateDialogContent
246-
);
247-
this._dialog.connect('ConfirmedHibernate', () =>
245+
this._dialog = new ConfirmDialog(
246+
HibernateDialogContent
247+
);
248+
this._dialog.connect('ConfirmedHibernate', () =>
249+
this._loginManagerHibernate()
250+
);
251+
this._dialog.open();
252+
} else {
248253
this._loginManagerHibernate()
249-
);
250-
this._dialog.open();
254+
}
251255
}
252256

253257
_onHybridSleepClicked() {

prefs.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,47 @@ export default class Prefs extends ExtensionPreferences {
9393
});
9494
window.add(page);
9595

96-
const group = new Adw.PreferencesGroup({
96+
const modes_group = new Adw.PreferencesGroup({
9797
title: __('Modes'),
9898
description: __('Which buttons should be enabled'),
9999
});
100-
page.add(group);
100+
page.add(modes_group);
101101

102102
// Create a new preferences row
103103
const hibernate_row = new Adw.SwitchRow({
104104
title: __('Hibernate'),
105105
});
106-
group.add(hibernate_row);
106+
modes_group.add(hibernate_row);
107107
const hybrid_row = new Adw.SwitchRow({
108108
title: __('Hybrid sleep'),
109109
});
110-
group.add(hybrid_row);
110+
modes_group.add(hybrid_row);
111111
const suspend_then_hibernate_row = new Adw.SwitchRow({
112112
title: __('Suspend then hibernate'),
113113
});
114-
group.add(suspend_then_hibernate_row);
114+
modes_group.add(suspend_then_hibernate_row);
115+
116+
const dialog_group = new Adw.PreferencesGroup({
117+
title: __('Dialogs'),
118+
description: __('Which dialogs should be enabled'),
119+
});
120+
page.add(dialog_group);
121+
122+
// Create a new preferences row
123+
const hibernate_dialog_row = new Adw.SwitchRow({
124+
title: __('Hibernate'),
125+
});
126+
dialog_group.add(hibernate_dialog_row);
127+
const hybrid_dialog_row = new Adw.SwitchRow({
128+
title: __('Hybrid sleep'),
129+
subtitle: __('Not implemented yet'),
130+
});
131+
dialog_group.add(hybrid_dialog_row);
132+
const suspend_then_hibernate_dialog_row = new Adw.SwitchRow({
133+
title: __('Suspend then hibernate'),
134+
subtitle: __('Not implemented yet'),
135+
});
136+
dialog_group.add(suspend_then_hibernate_dialog_row);
115137

116138
window._settings = this.getSettings();
117139
window._settings.bind('show-hibernate', hibernate_row, 'active',
@@ -120,5 +142,11 @@ export default class Prefs extends ExtensionPreferences {
120142
Gio.SettingsBindFlags.DEFAULT);
121143
window._settings.bind('show-suspend-then-hibernate', suspend_then_hibernate_row, 'active',
122144
Gio.SettingsBindFlags.DEFAULT);
145+
window._settings.bind('show-hibernate-dialog', hibernate_dialog_row, 'active',
146+
Gio.SettingsBindFlags.DEFAULT);
147+
window._settings.bind('show-hybrid-sleep-dialog', hybrid_dialog_row, 'active',
148+
Gio.SettingsBindFlags.DEFAULT);
149+
window._settings.bind('show-suspend-then-hibernate-dialog', suspend_then_hibernate_dialog_row, 'active',
150+
Gio.SettingsBindFlags.DEFAULT);
123151
}
124152
}

schemas/org.gnome.shell.extensions.hibernate-status-button.gschema.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@
1313
<key type="b" name="show-suspend-then-hibernate">
1414
<default>true</default>
1515
</key>
16+
<key type="b" name="show-hibernate-dialog">
17+
<default>true</default>
18+
</key>
19+
<key type="b" name="show-hybrid-sleep-dialog">
20+
<default>false</default>
21+
</key>
22+
<key type="b" name="show-suspend-then-hibernate-dialog">
23+
<default>false</default>
24+
</key>
1625
</schema>
1726
</schemalist>

0 commit comments

Comments
 (0)