-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs.js
128 lines (106 loc) · 5.66 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
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
126
127
128
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import {setButtonColor, colorButton, createGtkButton} from './prefs/helperFunctions.js';
export default class AddCustomTextToWorkSpaceIndicatorsExtensionPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
window._settings = this.getSettings();
window._pillsColorButton = new Gtk.ColorButton();
window._logoColorButton = new Gtk.ColorButton();
window._labelColorButton = new Gtk.ColorButton();
window._indicatorColorButton = new Gtk.ColorButton();
setButtonColor(window._pillsColorButton, 'pills-color', window._settings);
setButtonColor(window._logoColorButton, 'logo-color', window._settings);
setButtonColor(window._labelColorButton, 'label-color', window._settings);
setButtonColor(window._indicatorColorButton, 'indicator-color', window._settings);
const page = new Adw.PreferencesPage();
window.maximize();
window.add(page);
// system indicators
const systemIndicatorsGroup = new Adw.PreferencesGroup({
title: _('System Workspace Indicators (Pills)'),
});
page.add(systemIndicatorsGroup);
const workSpaceIndicatorsRow = new Adw.SwitchRow({
title: _('Hide System Workspace Indicators (Pills)'),
});
systemIndicatorsGroup.add(workSpaceIndicatorsRow);
const systemIndicatorColorRow = new Adw.ActionRow({
title: _('Pills Color'),
});
systemIndicatorsGroup.add(colorButton(_('Reset'), window._pillsColorButton, 'pills-color', window._settings, systemIndicatorColorRow));
//
// Logo
const logoGroup = new Adw.PreferencesGroup({
title: _('Logo'),
hexpand_set: true,
hexpand: true,
});
page.add(logoGroup);
const showLogoRow = new Adw.SwitchRow({
title: _('Show Logo'),
subtitle: _('you can set the logo by placing an svg icon with the name "brand-logo-symbolic.svg" in ".icons" folder of home directory'),
});
logoGroup.add(showLogoRow);
const logoColor = new Adw.ActionRow({
title: _('Logo Color'),
});
logoGroup.add(colorButton(_('Reset'), window._logoColorButton, 'logo-color', window._settings, logoColor));
//
// custom text group
const customTextGroup = new Adw.PreferencesGroup({
title: _('Custom Text'),
});
page.add(customTextGroup);
const showCustomTextRow = new Adw.SwitchRow({
title: _('Show Custom Text'),
});
customTextGroup.add(showCustomTextRow);
const customTextColor = new Adw.ActionRow({
title: _('Custom Text Color'),
});
customTextGroup.add(colorButton(_('Reset'), window._labelColorButton, 'label-color', window._settings, customTextColor));
const entryRow = new Adw.EntryRow({
title: _('Enter your text or leave it blank for extensions default text'),
'enable-emoji-completion': true,
});
entryRow.set_text(window._settings.get_string('custom-text'));
entryRow.connect('changed', entry => {
window._settings.set_string('custom-text', entry.get_text());
});
entryRow.add_prefix(new Gtk.Label({label: _('Custom Text')}));
entryRow.add_suffix(createGtkButton(_('Clear Text'), 'custom-text', '', window._settings, entryRow));
customTextGroup.add(entryRow);
const customTextsPredefinedTitleRow = new Adw.ActionRow({
title: _('Predefined Texts'),
});
customTextGroup.add(customTextsPredefinedTitleRow);
const customTextsPredefinedRow = new Adw.ActionRow();
customTextsPredefinedRow.add_suffix(createGtkButton(_('User Name'), 'custom-text', 'username', window._settings, entryRow));
customTextsPredefinedRow.add_suffix(createGtkButton(_('Real Name'), 'custom-text', 'realname', window._settings, entryRow));
customTextsPredefinedRow.add_suffix(createGtkButton(_('Host Name'), 'custom-text', 'hostname', window._settings, entryRow));
customTextsPredefinedRow.add_suffix(createGtkButton(_('OS Name'), 'custom-text', 'osname', window._settings, entryRow));
customTextsPredefinedRow.add_suffix(createGtkButton(_('Kernel Version'), 'custom-text', 'kernel', window._settings, entryRow));
customTextGroup.add(customTextsPredefinedRow);
//
// custom indicators group
const customIndicatorsGroup = new Adw.PreferencesGroup({
title: _('Custom Indicators'),
});
page.add(customIndicatorsGroup);
const showCustomIndicatorsRow = new Adw.SwitchRow({
title: _('Show Custom Indicator'),
});
customIndicatorsGroup.add(showCustomIndicatorsRow);
const customIndicatorColorRow = new Adw.ActionRow({
title: _('Custom Indicator Color'),
});
customIndicatorsGroup.add(colorButton(_('Reset'), window._indicatorColorButton, 'indicator-color', window._settings, customIndicatorColorRow));
//
window._settings.bind('hide-pills', workSpaceIndicatorsRow, 'active', Gio.SettingsBindFlags.DEFAULT);
window._settings.bind('show-logo', showLogoRow, 'active', Gio.SettingsBindFlags.DEFAULT);
window._settings.bind('show-custom-text', showCustomTextRow, 'active', Gio.SettingsBindFlags.DEFAULT);
window._settings.bind('show-custom-indicator', showCustomIndicatorsRow, 'active', Gio.SettingsBindFlags.DEFAULT);
}
}