-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialogwidgets.js
70 lines (64 loc) · 2.1 KB
/
dialogwidgets.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
const {GObject, Gtk} = imports.gi;
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();
const Gettext = imports.gettext.domain(Extension.uuid);
const _ = Gettext.gettext;
var KeyValueDialog = GObject.registerClass(
{
GTypeName: (Extension.uuid + '.KeyValueDialog').replace(/[\W_]+/g,'_')
},
class EntryDialog extends Gtk.Dialog{
_init(parent, title, keyLabel, valueLabel, key="", value=""){
super._init({
title: title,
transientFor: parent.get_root(),
modal: true,
use_header_bar: true
});
let grid = new Gtk.Grid({
marginTop: 10,
marginBottom: 10,
marginStart: 10,
marginEnd:10,
columnSpacing: 20,
rowSpacing: 20,
hexpand: true,
vexpand: true,
halign: Gtk.Align.CENTER
});
grid.insert_after(this.get_content_area(), null);
let label1 = new Gtk.Label({
halign: Gtk.Align.START,
label: keyLabel
});
grid.attach(label1, 0, 0, 1, 1);
this._entry1 = new Gtk.Entry({
text: key
});
grid.attach(this._entry1, 1, 0, 1, 1);
let label2 = new Gtk.Label({
halign: Gtk.Align.START,
label: valueLabel
});
grid.attach(label2, 0, 1, 1, 1);
this._entry2 = new Gtk.Entry({
text: value
});
grid.attach(this._entry2, 1, 1, 1, 1);
this.add_button(_('Cancel'), Gtk.ResponseType.CANCEL);
this.add_button(_('Ok'), Gtk.ResponseType.OK);
}
getKey(){
return this._entry1.get_text();
}
setKey(key){
this._entry1.set_text(key);
}
getValue(){
return this._entry2.get_text();
}
setValue(value){
this._entry2.set_text(value);
}
}
);