forked from SUPERCILEX/gnome-clipboard-history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirmDialog.js
76 lines (67 loc) · 1.58 KB
/
confirmDialog.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
'use strict';
const { St, GObject, Clutter } = imports.gi;
const ModalDialog = imports.ui.modalDialog;
let _openDialog;
function openConfirmDialog(
title,
message,
sub_message,
ok_label,
cancel_label,
callback,
) {
if (!_openDialog) {
_openDialog = new ConfirmDialog(
title,
message + '\n' + sub_message,
ok_label,
cancel_label,
callback,
).open();
}
}
const ConfirmDialog = GObject.registerClass(
class ConfirmDialog extends ModalDialog.ModalDialog {
_init(title, desc, ok_label, cancel_label, callback) {
super._init();
let main_box = new St.BoxLayout({
vertical: false,
});
this.contentLayout.add_child(main_box);
let message_box = new St.BoxLayout({
vertical: true,
});
main_box.add_child(message_box);
let subject_label = new St.Label({
style: 'font-weight: bold',
x_align: Clutter.ActorAlign.CENTER,
text: title,
});
message_box.add_child(subject_label);
let desc_label = new St.Label({
style: 'padding-top: 12px',
x_align: Clutter.ActorAlign.CENTER,
text: desc,
});
message_box.add_child(desc_label);
this.setButtons([
{
label: cancel_label,
action: () => {
this.close();
_openDialog = null;
},
key: Clutter.Escape,
},
{
label: ok_label,
action: () => {
this.close();
callback();
_openDialog = null;
},
},
]);
}
},
);