forked from ba0f3/gnome-bluetooth-smartlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprefs.js
69 lines (56 loc) · 2.32 KB
/
prefs.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
import {domain} from 'gettext';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import * as ExtensionUtils from 'resource:///org/gnome/shell/misc/extensionUtils.js';
import Settings from './settings';
// It's common practice to keep GNOME API and JS imports in separate blocks
const Me = ExtensionUtils.getCurrentExtension();
const {gettext: _} = domain(Me.metadata['gettext-domain']);
/**
* Steps to run on initialization of preferenences dialog
*/
// eslint-disable-next-line no-unused-vars
function init() {
log(`[bluetooth-smartlock] Initializing ${Me.metadata.name} Preferences`);
ExtensionUtils.initTranslations(Me.metadata['gettext-domain']);
}
class SettingsBuilder {
constructor() {
this._settings = new Settings()._settings;
this._builder = new Gtk.Builder();
}
build() {
this._builder.add_from_file(`${Me.path}/settings.ui`);
this._container = this._builder.get_object('container');
this._builder.get_object('advanced_button').connect('clicked', () => {
let dialog = new Gtk.Dialog({
title: _('Advanced Settings'),
transient_for: this._container.get_ancestor(Gtk.Window),
use_header_bar: true,
modal: true,
});
let box = this._builder.get_object('advanced_settings');
dialog.get_content_area().append(box);
dialog.connect('response', () => {
dialog.get_content_area().remove(box);
dialog.destroy();
});
dialog.show();
});
this._settings.bind('active', this._builder.get_object('active_switch'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('indicator', this._builder.get_object('hide_indicator_switch'), 'active', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('interval', this._builder.get_object('scan_interval'), 'value', Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('duration-in-seconds', this._builder.get_object('duration'), 'value', Gio.SettingsBindFlags.DEFAULT);
return this._container;
}
}
/**
* Build prefernces widget
*/
// eslint-disable-next-line no-unused-vars
function buildPrefsWidget() {
let settings = new SettingsBuilder();
let widget = settings.build();
return widget;
}