-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathprefs4.js
125 lines (101 loc) · 5.01 KB
/
prefs4.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
var TimezoneExtensionPrefsWidget4 = new GObject.Class({
Name: 'TimezoneExtension.Prefs4.Widget',
GTypeName: 'TimezoneExtensionPrefsWidget4',
_init: function(params) {
this.box = new Gtk.Box(params);
this.box.orientation = Gtk.Orientation.VERTICAL;
this.box.margin_start = 12;
this.box.margin_end = 12;
this.box.margin_top = 12;
this.box.margin_bottom = 12;
this._settings = Convenience.getSettings();
this.box.append(new Gtk.Label({ label: '<b>Location for the <i>people.json</i> file</b>',
use_markup: true, margin_bottom: 6,
hexpand: true, halign: Gtk.Align.START }));
this.box.append(this._createEntry());
this.box.append(new Gtk.Label({ label: '<small>Remote files, e.g., starting with <i>http://</i> are also valid. <a href="https://github.com/jwendell/gnome-shell-extension-timezone/blob/master/editing-people.md">Need help with JSON?</a></small>',
use_markup: true, margin_bottom: 6,
hexpand: true, halign: Gtk.Align.START}));
this.box.append(this._createHighlightBox());
this.box.append(this._createPanelConfiguration());
},
_createEntry: function() {
this._entry = new Gtk.Entry({
hexpand: true,
text: this._settings.get_string("path-to-people-json"),
activates_default: true,
secondary_icon_name: "document-open",
secondary_icon_activatable: true,
secondary_icon_tooltip_text: "Pick a file using a file chooser"
});
this._entry.connect("icon-release", Lang.bind(this, function() {
this._chooser.transient_for = this.box.get_root()
this._chooser.show();
}));
this._chooser = new Gtk.FileChooserNative({
modal: true,
title: "Choose a people.json file"
});
this._chooser.connect("response", Lang.bind(this, function(_, response) {
if (response !== Gtk.ResponseType.ACCEPT) {
return;
}
let fileURI = this._chooser.get_file().get_uri();
this._entry.set_text(fileURI);
this._settings.set_string("path-to-people-json", this._entry.text);
}));
return this._entry;
},
_createHighlightBox: function() {
let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL,
margin_bottom: 20, margin_top: 20});
let box1 = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 5});
box.append(box1);
let label = new Gtk.Label({label: '<b>Highlight working hours</b>',
use_markup: true, hexpand: true,
halign: Gtk.Align.START, margin_bottom: 5});
box1.append(label);
let sb = new Gtk.Switch();
this._settings.bind('enable-working-hours', sb, 'active', Gio.SettingsBindFlags.DEFAULT);
box1.append(sb);
let box2 = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL,
spacing: 5});
box.append(box2);
sb.bind_property('active', box2, 'sensitive', GObject.BindingFlags.SYNC_CREATE);
box2.append(new Gtk.Label({label: 'From'}));
let from = Gtk.SpinButton.new_with_range (0, 23, 1);
box2.append(from);
this._settings.bind('working-hours-start', from, 'value', Gio.SettingsBindFlags.DEFAULT);
box2.append(new Gtk.Label({label: 'to'}));
let to = Gtk.SpinButton.new_with_range (0, 23, 1);
box2.append(to);
this._settings.bind('working-hours-end', to, 'value', Gio.SettingsBindFlags.DEFAULT);
return box;
},
_createPanelConfiguration: function() {
let box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL});
let box1 = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 5});
box.append(box1);
let label = new Gtk.Label({label: '<b>Panel configuration</b>',
use_markup: true, hexpand: true,
halign: Gtk.Align.START, margin_bottom: 5});
box1.append(label);
let box2 = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 5});
box.append(box2);
box2.append(new Gtk.Label({label: 'Position in panel'}));
let combo = new Gtk.ComboBoxText({ active_id: this._settings.get_string('panel-position') });
combo.append('left', "Left");
combo.append('center', "Center");
combo.append('right', "Right");
this._settings.bind('panel-position', combo, 'active-id', Gio.SettingsBindFlags.DEFAULT);
box2.append(combo);
return box;
}
});