-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefs.js
More file actions
174 lines (146 loc) · 5.95 KB
/
prefs.js
File metadata and controls
174 lines (146 loc) · 5.95 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* Matrix Status Monitor – Preferences UI
*
* Here we define the Adwaita (libadwaita) interface for editing
* GSettings keys: homeserver, token, sync interval, client type.
*/
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
/**
* Preferences window structure.
* Layout:
* 1) Matrix API (homeserver, access token)
* 2) General settings (sync interval, client selector)
* 3) Links/Info
*/
export default class MatrixStatusPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
const page = new Adw.PreferencesPage();
// Matrix API Group
const apiGroup = new Adw.PreferencesGroup({
title: 'Matrix API Configuration',
description: 'Enter your homeserver and access token',
});
page.add(apiGroup);
const homeserverRow = new Adw.EntryRow({ title: 'Homeserver URL' });
settings.bind('homeserver-url', homeserverRow, 'text', Gio.SettingsBindFlags.DEFAULT);
apiGroup.add(homeserverRow);
// Access Token Row - Itt az EntryRow-t használjuk alapnak
const tokenRow = new Adw.PasswordEntryRow({
title: 'Access Token',
});
settings.bind('access-token', tokenRow, 'text', Gio.SettingsBindFlags.DEFAULT);
// Tooltip ikon hozzáadása közvetlenül a sor végére (suffix)
// Így nem kell külön sor, és vizuálisan az inputhoz tartozik
const tokenHelpIcon = new Gtk.Image({
icon_name: 'help-about-symbolic',
tooltip_text: 'For Element Desktop users:\n' +
'1. Settings > Help & About (bottom left)\n' +
'2. Scroll down to Advanced > Access Token\n' +
'3. Copy the token\n\n' +
'⚠️ Sensitive data!',
valign: Gtk.Align.CENTER,
css_classes: ['dim-label'] // Diszkrétebb megjelenés
});
tokenRow.add_suffix(tokenHelpIcon);
apiGroup.add(tokenRow);
// Separator Group for visually dividing sections
page.add(new Adw.PreferencesGroup());
// Client Settings
const configGroup = new Adw.PreferencesGroup({
title: 'General Settings',
});
page.add(configGroup);
const intervalRow = new Adw.ActionRow({
title: 'Sync Interval (seconds)',
subtitle: 'How often to check for new messages',
});
const intervalSpin = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({ lower: 5, upper: 3600, step_increment: 5, page_increment: 10 }),
valign: Gtk.Align.CENTER,
});
settings.bind('sync-interval', intervalSpin, 'value', Gio.SettingsBindFlags.DEFAULT);
intervalRow.add_suffix(intervalSpin);
configGroup.add(intervalRow);
const clientTypeRow = new Adw.ComboRow({
title: 'Preferred Client',
subtitle: 'Choose which client to use when opening rooms',
});
const clientModel = new Gtk.StringList({
strings: ['Web (matrix.to)', 'Element', 'Fractal', 'SchildiChat'],
});
clientTypeRow.model = clientModel;
clientTypeRow.selected = settings.get_enum('client-type');
clientTypeRow.connect('notify::selected', () => {
settings.set_enum('client-type', clientTypeRow.selected);
});
configGroup.add(clientTypeRow);
const qrRow = new Adw.SwitchRow({
title: 'Enable QR Code Generation',
subtitle: 'Show a button to generate and display room QR codes',
});
settings.bind('generate-qr-code-enable', qrRow, 'active', Gio.SettingsBindFlags.DEFAULT);
configGroup.add(qrRow);
// Separator Group
page.add(new Adw.PreferencesGroup());
// Project Links
const linksGroup = new Adw.PreferencesGroup({ title: 'Links & About' });
page.add(linksGroup);
// GitHub Repository
const repoRow = new Adw.ActionRow({
title: 'Source Code',
subtitle: 'View the project on GitHub',
});
const repoBtn = new Gtk.Button({
child: new Adw.ButtonContent({
icon_name: 'external-link-symbolic',
label: 'GitHub',
}),
valign: Gtk.Align.CENTER,
css_classes: ['suggested-action'],
});
repoBtn.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://github.com/nurefexc/matrix-status', null);
});
repoRow.add_suffix(repoBtn);
linksGroup.add(repoRow);
// GitHub Profile
const profileRow = new Adw.ActionRow({
title: 'GitHub Profile',
subtitle: 'Check out my other projects',
});
const profileBtn = new Gtk.Button({
child: new Adw.ButtonContent({
icon_name: 'external-link-symbolic',
label: 'nurefexc',
}),
valign: Gtk.Align.CENTER,
});
profileBtn.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://github.com/nurefexc', null);
});
profileRow.add_suffix(profileBtn);
linksGroup.add(profileRow);
// Website
const websiteRow = new Adw.ActionRow({
title: 'Personal Website',
subtitle: 'Visit nurefexc.com',
});
const websiteBtn = new Gtk.Button({
child: new Adw.ButtonContent({
icon_name: 'external-link-symbolic',
label: 'nurefexc.com',
}),
valign: Gtk.Align.CENTER,
});
websiteBtn.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://nurefexc.com', null);
});
websiteRow.add_suffix(websiteBtn);
linksGroup.add(websiteRow);
window.add(page);
}
}