-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefs.js
More file actions
executable file
·52 lines (45 loc) · 1.9 KB
/
prefs.js
File metadata and controls
executable file
·52 lines (45 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Adw from 'gi://Adw';
import Gtk from 'gi://Gtk';
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
export default class LayoutFixerPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings('org.gnome.shell.extensions.layout-fixer');
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup({ title: 'Keyboard Shortcut' });
const row = new Adw.ActionRow({
title: 'Action Shortcut',
subtitle: settings.get_strv('shortcut-key')[0] || 'Alt+A'
});
const shortcutLabel = new Gtk.ShortcutLabel({
accelerator: settings.get_strv('shortcut-key')[0] || '<Alt>a',
valign: Gtk.Align.CENTER
});
const editBtn = new Gtk.Button({
label: 'Record',
valign: Gtk.Align.CENTER,
css_classes: ['suggested-action']
});
const keyController = new Gtk.EventControllerKey();
window.add_controller(keyController);
editBtn.connect('clicked', () => {
editBtn.label = 'Press keys...';
let conn = keyController.connect('key-pressed', (controller, keyval, keycode, state) => {
let mask = state & Gtk.accelerator_get_default_mod_mask();
let accel = Gtk.accelerator_name(keyval, mask);
if (accel) {
settings.set_strv('shortcut-key', [accel]);
shortcutLabel.accelerator = accel;
row.subtitle = accel;
editBtn.label = 'Record';
keyController.disconnect(conn);
}
return true;
});
});
row.add_suffix(shortcutLabel);
row.add_suffix(editBtn);
group.add(row);
page.add(group);
window.add(page);
}
}