forked from awamper/gpaste-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpaste_buttons.js
115 lines (100 loc) · 3.64 KB
/
gpaste_buttons.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
const St = imports.gi.St;
const Lang = imports.lang;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const ButtonsBar = Me.imports.buttons_bar;
const GPasteClient = Me.imports.gpaste_client;
const GPasteButtons = new Lang.Class({
Name: "GPasteButtons",
_init: function(gpaste_integration) {
this._gpaste_integration = gpaste_integration;
this._statusbar = this._gpaste_integration._statusbar;
GPasteClient.get_client().connect('tracking',
Lang.bind(this, function(c, state) {
this.track_changes_btn.set_checked(state);
})
);
this._buttons_bar = new ButtonsBar.ButtonsBar();
this._init_track_changes_button();
this._init_switch_history_button();
this._init_clear_button();
this._init_prefs_button();
this._buttons_bar.add_button(this._track_changes_btn);
this._buttons_bar.add_button(this._histories_btn);
this._buttons_bar.add_button(this._clear_btn);
this._buttons_bar.add_button(this._prefs_btn);
},
_init_track_changes_button: function() {
let button_params = {
icon_name: Utils.ICONS.toggle,
label_text: '',
tip_text: 'Track changes',
button_style_class: 'gpaste-toggle-button',
toggle_mode: true,
statusbar: this._statusbar,
action: Lang.bind(this, function() {
let checked = this.track_changes_btn.get_checked();
GPasteClient.get_client().track(checked);
})
};
this._track_changes_btn = new ButtonsBar.ButtonsBarButton(button_params);
},
_init_switch_history_button: function() {
let button_params = {
icon_name: Utils.ICONS.switch_history,
label_text: '',
tip_text: 'Switch history',
button_style_class: 'gpaste-button',
statusbar: this._statusbar,
action: Lang.bind(this, function() {
this._gpaste_integration.history_switcher.toggle();
})
};
this._histories_btn = new ButtonsBar.ButtonsBarButton(button_params);
},
_init_clear_button: function() {
let button_params = {
icon_name: Utils.ICONS.clear,
label_text: '',
tip_text: 'Clear history',
button_style_class: 'gpaste-button',
statusbar: this._statusbar,
confirmation_dialog: true,
action: Lang.bind(this, Lang.bind(this, function() {
this._gpaste_integration.hide(true);
GPasteClient.get_client().empty();
}))
};
this._clear_btn = new ButtonsBar.ButtonsBarButton(button_params);
},
_init_prefs_button: function() {
let button_params = {
icon_name: Utils.ICONS.preferences,
label_text: '',
tip_text: 'Preferences',
button_style_class: 'gpaste-button',
statusbar: this._statusbar,
action: Lang.bind(this, function() {
Utils.launch_extension_prefs(Me.uuid);
this._gpaste_integration.hide(false);
})
};
this._prefs_btn = new ButtonsBar.ButtonsBarButton(button_params);
},
destroy: function() {
this._buttons_bar.destroy();
},
get actor() {
return this._buttons_bar.actor;
},
get clear_btn() {
return this._clear_btn;
},
get prefs_btn() {
return this._prefs_btn;
},
get track_changes_btn() {
return this._track_changes_btn;
}
});