-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefs-es6.js
More file actions
1435 lines (1223 loc) · 50.3 KB
/
prefs-es6.js
File metadata and controls
1435 lines (1223 loc) · 50.3 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'use strict';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Pango from 'gi://Pango';
import Gdk from 'gi://Gdk';
import { ExtensionPreferences, gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
export default class ClipFlowProPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
// Translations are provided via the extension's gettext domain.
const widget = new ClipFlowProPrefsWidget({
orientation: Gtk.Orientation.VERTICAL,
}, settings, this.metadata);
widget.set_hexpand(true);
widget.set_vexpand(true);
window.set_default_size?.(920, 640);
// Attach our GTK widget as the window content. This keeps the Adw
// headerbar (close/minimize) while letting us reuse the existing UI.
window.set_child?.(widget) ?? window.add?.(widget);
}
}
const ClipFlowProPrefsWidget = GObject.registerClass(
class ClipFlowProPrefsWidget extends Gtk.Box {
_init(params, settings, metadata) {
super._init(params);
this._settings = settings;
this._metadata = metadata ?? {};
this._shortcutRows = new Map();
this._tabIndexLookup = new Map();
this._settingsSignals = [];
this._buildUI();
}
destroy() {
if (this._settings && this._settingsSignals) {
this._settingsSignals.forEach(id => this._settings.disconnect(id));
this._settingsSignals = [];
}
this._shortcutRows?.clear();
super.destroy();
}
_buildUI() {
// Helper to access metadata
this._getMeta = (key) => (
this._metadata?.[key] ?? null
);
this.set_orientation(Gtk.Orientation.VERTICAL);
this.set_spacing(20);
this.set_margin_start(20);
this.set_margin_end(20);
this.set_margin_top(20);
this.set_margin_bottom(20);
this.set_hexpand(true);
this.set_vexpand(true);
// Create notebook for tabs
this._notebook = new Gtk.Notebook();
this._notebook.set_tab_pos(Gtk.PositionType.TOP);
this._notebook.set_margin_top(12);
this._notebook.set_margin_bottom(12);
this._notebook.set_margin_start(6);
this._notebook.set_margin_end(6);
this._notebook.set_hexpand(true);
this._notebook.set_vexpand(true);
if (!this._settings) {
this._renderMissingSchemaMessage();
return;
}
this.append(this._notebook);
// Detect GNOME Shell target from metadata to tailor UI
const shells = Array.isArray(this._metadata['shell-version']) ? this._metadata['shell-version'] : [];
const isGS45Plus = shells.some(v => {
const n = parseInt(String(v), 10); return Number.isFinite(n) && n >= 45;
});
// Add tabs
this._addGeneralTab({ isGS45Plus });
this._addBehaviorTab({ isGS45Plus });
this._addAppearanceTab({ isGS45Plus });
this._addShortcutsTab({ isGS45Plus });
this._addAboutTab({ isGS45Plus });
this._applyInitialTab();
}
_addGeneralTab(ctx = {}) {
const { isGS45Plus = false } = ctx;
const generalBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 15
});
generalBox.set_margin_top(12);
// Header
const header = this._createSectionHeader(_('General Settings'));
generalBox.append(header);
// History Management
const historyFrame = this._createFrame(_('History Management'));
const historyBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
historyFrame.set_child(historyBox);
// Max entries
const maxEntriesBox = this._createSpinRow(
_('Maximum Entries'),
_('Maximum number of clipboard entries to keep in history'),
'max-entries',
10, 100, 50
);
historyBox.append(maxEntriesBox);
// Max entry length
const maxLengthBox = this._createSpinRow(
_('Maximum Entry Length'),
_('Maximum characters per clipboard entry'),
'max-entry-length',
100, 10000, 1000
);
historyBox.append(maxLengthBox);
// Minimum entry length
const minLengthBox = this._createSpinRow(
_('Minimum Entry Length'),
_('Ignore entries shorter than this length'),
'min-entry-length',
0, 100, 1
);
historyBox.append(minLengthBox);
// Entries per page (Enhanced UI only)
if (isGS45Plus) {
const entriesPerPageBox = this._createSpinRow(
_('Entries Per Page'),
_('Number of entries to show per page in the menu'),
'entries-per-page',
5, 50, 10
);
historyBox.append(entriesPerPageBox);
}
// Legacy rows toggle only relevant on 45+ fallback scenarios
if (isGS45Plus) {
const legacyRowsSwitch = this._createSwitchRow(
_('Use Legacy Menu Rows'),
_('Render the clipboard menu using the older popup layout in case the new Wayland-safe view has issues on your Shell version.'),
'use-legacy-menu-items'
);
historyBox.append(legacyRowsSwitch);
}
// Clear history button
const clearButton = new Gtk.Button({ label: _('Clear All History') });
clearButton.set_halign(Gtk.Align.START);
clearButton.add_css_class('destructive-action');
clearButton.connect('clicked', () => this._clearHistory());
historyBox.append(clearButton);
generalBox.append(historyFrame);
// Privacy & Security
const privacyFrame = this._createFrame(_('Privacy & Security'));
const privacyBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
privacyFrame.set_child(privacyBox);
// Ignore passwords
const ignorePasswordsBox = this._createSwitchRow(
_('Ignore Passwords'),
_("Don't save clipboard content that looks like passwords. Uses a simple heuristic to detect password-like strings (e.g., contains the word 'password') and prevents them from being saved to history."),
'ignore-passwords'
);
privacyBox.append(ignorePasswordsBox);
// Clear on logout
const clearOnLogoutBox = this._createSwitchRow(
_('Clear on Logout'),
_('Clear clipboard history when logging out'),
'clear-on-logout'
);
privacyBox.append(clearOnLogoutBox);
// Auto-clear sensitive data
const autoClearSensitiveBox = this._createSwitchRow(
_('Auto-clear Sensitive Data'),
_('Automatically remove password-like entries after 5 minutes. Any entry detected as sensitive will be automatically deleted from the history 5 minutes after it was copied.'),
'auto-clear-sensitive'
);
privacyBox.append(autoClearSensitiveBox);
generalBox.append(privacyFrame);
// Add to notebook
this._notebook.append_page(generalBox, new Gtk.Label({ label: _('General') }));
this._setTabIndex('general', this._notebook.get_n_pages() - 1);
}
_addBehaviorTab() {
const behaviorBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 15
});
behaviorBox.set_margin_top(12);
// Header
const header = this._createSectionHeader(_('Behavior Settings'));
behaviorBox.append(header);
// Notifications
const notifyFrame = this._createFrame(_('Notifications'));
const notifyBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
notifyFrame.set_child(notifyBox);
const notificationSwitch = this._createSwitchRow(
_('Show Notifications'),
_('Display a GNOME notification when ClipFlow Pro copies an entry'),
'show-copy-notifications'
);
notifyBox.append(notificationSwitch);
const showCopiedPreview = this._createSwitchRow(
_('Show Copied Preview'),
_('Include a short preview of copied text in notifications'),
'show-copied-preview'
);
notifyBox.append(showCopiedPreview);
const previewLen = this._createSpinRow(
_('Copied Preview Length'),
_('Characters to show in copy notification preview'),
'copied-preview-length',
10, 200, 40
);
notifyBox.append(previewLen);
behaviorBox.append(notifyFrame);
// Panel Position
const panelFrame = this._createFrame(_('Panel Position'));
const panelBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
panelFrame.set_child(panelBox);
const panelPositionBox = this._createComboRow(
_('Panel Icon Position'),
_('Position of clipboard icon in the top panel'),
'panel-position',
[
['left', _('Left')],
['center', _('Center')],
['right', _('Right')]
]
);
panelBox.append(panelPositionBox);
behaviorBox.append(panelFrame);
// Clipboard Behavior
const clipFrame = this._createFrame(_('Clipboard Behavior'));
const clipBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
clipFrame.set_child(clipBox);
const capturePrimaryBox = this._createSwitchRow(
_('Capture PRIMARY Selection'),
_('Also capture selections from the PRIMARY buffer'),
'capture-primary'
);
clipBox.append(capturePrimaryBox);
const dedupeModeBox = this._createComboRow(
_('Duplicate Handling'),
_('Choose how to handle duplicate entries'),
'dedupe-mode',
[
['ignore', _('Ignore duplicates')],
['promote', _('Move duplicate to top')]
]
);
clipBox.append(dedupeModeBox);
const pauseDurationBox = this._createSpinRow(
_('Pause Duration (minutes)'),
_('Default duration for Pause Monitoring action'),
'pause-duration-minutes',
1, 120, 5
);
clipBox.append(pauseDurationBox);
behaviorBox.append(clipFrame);
// Import/Export
const ioFrame = this._createFrame(_('Import / Export'));
const ioBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
ioFrame.set_child(ioBox);
const ioRow = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 10 });
const ioLabels = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, spacing: 4 });
const ioTitle = new Gtk.Label({ label: _('Import/Export Folder'), use_markup: true });
ioTitle.set_halign(Gtk.Align.START);
const ioDesc = new Gtk.Label({ label: _('Folder used for export and import. Empty uses Desktop, then Downloads, then Home.'), wrap: true });
ioDesc.set_halign(Gtk.Align.START);
ioLabels.append(ioTitle);
ioLabels.append(ioDesc);
ioRow.append(ioLabels);
const ioControls = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 6 });
ioControls.set_halign(Gtk.Align.END);
const currentLabel = new Gtk.Label({ label: this._settings.get_string('io-folder') || _('(Default)'), xalign: 1 });
const chooseBtn = new Gtk.Button({ label: _('Choose…') });
const clearBtn = new Gtk.Button({ label: _('Clear') });
const openBtn = new Gtk.Button({ label: _('Open') });
chooseBtn.connect('clicked', () => {
try {
const dlg = new Gtk.FileDialog();
// For GTK4, select_folder(root, cancellable, callback)
const root = this.get_root && this.get_root();
dlg.select_folder(root, null, (self, res) => {
try {
const gfile = dlg.select_folder_finish(res);
const path = gfile?.get_path?.() || '';
if (path) {
this._settings.set_string('io-folder', path);
currentLabel.set_label(path);
}
} catch (_e) {}
});
} catch (_e) {}
});
clearBtn.connect('clicked', () => {
try { this._settings.set_string('io-folder', ''); currentLabel.set_label(_('(Default)')); } catch (_e) {}
});
openBtn.connect('clicked', () => {
try {
const GioNs = Gio;
const path = this._settings.get_string('io-folder');
const dir = path && path.trim() ? path : (GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP) || GLib.get_home_dir());
GioNs.AppInfo.launch_default_for_uri(`file://${dir}`, null);
} catch (_e) {}
});
ioControls.append(currentLabel);
ioControls.append(chooseBtn);
ioControls.append(clearBtn);
ioControls.append(openBtn);
ioRow.append(ioControls);
ioBox.append(ioRow);
behaviorBox.append(ioFrame);
// Add to notebook
this._notebook.append_page(behaviorBox, new Gtk.Label({ label: _('Behavior') }));
this._setTabIndex('behavior', this._notebook.get_n_pages() - 1);
}
_addAppearanceTab(ctx = {}) {
const { isGS45Plus = false } = ctx;
const appearanceBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 15
});
appearanceBox.set_margin_top(12);
// Header
const header = this._createSectionHeader(_('Appearance Settings'));
appearanceBox.append(header);
// Display Options
const displayFrame = this._createFrame(_('Display Options'));
const displayBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
displayFrame.set_child(displayBox);
// Show numbers
const showNumbersBox = this._createSwitchRow(
_('Show Entry Numbers'),
_('Display numbers next to clipboard entries'),
'show-numbers'
);
displayBox.append(showNumbersBox);
// Show preview
const showPreviewBox = this._createSwitchRow(
_('Show Entry Preview'),
_('Show preview of clipboard entry content in menu'),
'show-preview'
);
displayBox.append(showPreviewBox);
// Show timestamps
const showTimestampsBox = this._createSwitchRow(
_('Show Entry Timestamps'),
_('Display when each clipboard entry was copied'),
'show-timestamps'
);
displayBox.append(showTimestampsBox);
// Hide pinned/starred sections
const hidePinned = this._createSwitchRow(
_('Hide Pinned Section'),
_('Do not show the pinned section at the top of the list.'),
'hide-pinned'
);
displayBox.append(hidePinned);
const hideStarred = this._createSwitchRow(
_('Hide Starred Section'),
_('Do not show the dedicated Starred section above the main list.'),
'hide-starred'
);
displayBox.append(hideStarred);
// Plain text sanitize toggle
const plainToggle = this._createSwitchRow(
_('Copy as Plain Text'),
_('Strip zero-width/control characters and normalize whitespace when copying from history.'),
'copy-as-plain-text'
);
displayBox.append(plainToggle);
appearanceBox.append(displayFrame);
// Menu Styling (only relevant when CSS is active, i.e. 45+)
if (isGS45Plus) {
const styleFrame = this._createFrame(_('Menu Styling'));
const styleBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
styleFrame.set_child(styleBox);
const themeInfo = new Gtk.Label({
label: _('ClipFlow Pro automatically adapts to your GNOME theme.\nThe menu will match your system\'s dark/light mode preference.'),
wrap: true,
wrap_mode: Pango.WrapMode.WORD
});
themeInfo.set_halign(Gtk.Align.START);
styleBox.append(themeInfo);
const compactToggle = this._createSwitchRow(
_('Use Compact UI Layout'),
_('Switch back to the slimmer legacy spacing and lighter backgrounds instead of the modern boxed look.'),
'use-compact-ui'
);
styleBox.append(compactToggle);
appearanceBox.append(styleFrame);
}
// Rendering mode (compatibility)
const renderFrame = this._createFrame(_('Compatibility'));
const renderBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
renderFrame.set_child(renderBox);
if (isGS45Plus) {
const renderingModeBox = this._createComboRow(
_('Rendering Mode'),
_('Auto chooses a safe default for your GNOME Shell. Classic uses simple PopupMenu rows. Enhanced uses a container with pagination.'),
'rendering-mode',
[
['auto', _('Auto')],
['classic', _('Classic')],
['enhanced', _('Enhanced')],
]
);
renderBox.append(renderingModeBox);
}
const classicMaxRowsBox = this._createSpinRow(
_('Classic Mode: Max Rows'),
isGS45Plus ? _('Maximum number of rows to show in Classic mode (10–200).') : _('Maximum number of rows to show in Classic mode (10–12).'),
'classic-max-rows',
10,
isGS45Plus ? 200 : 12,
isGS45Plus ? 50 : 12
);
renderBox.append(classicMaxRowsBox);
// Disable CSS toggle only makes sense when stylesheet is in use (45+ build)
if (isGS45Plus) {
const disableCssToggle = this._createSwitchRow(
_('Disable Extension Stylesheet'),
_('Turn off ClipFlow's CSS for troubleshooting theme conflicts.'),
'disable-css'
);
renderBox.append(disableCssToggle);
}
appearanceBox.append(renderFrame);
// styleFrame appended only for 45+
// App Exclusions
const exclFrame = this._createFrame(_('App Exclusions'));
const exclBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
exclFrame.set_child(exclBox);
const exclRow = this._createTextRow(
_('Ignore Apps (comma-separated)'),
_('App names or IDs to ignore when capturing (e.g., Passwords, org.keepassxc.keepassxc)'),
'ignore-apps'
);
exclBox.append(exclRow);
appearanceBox.append(exclFrame);
// Lock Behavior
const lockFrame = this._createFrame(_('Lock Behavior'));
const lockBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
lockFrame.set_child(lockBox);
const pauseOnLock = this._createSwitchRow(
_('Pause on Screen Lock'),
_('Stop monitoring while the screen is locked; resume on unlock.'),
'pause-on-lock'
);
const clearOnLock = this._createSwitchRow(
_('Clear on Screen Lock'),
_('Clear clipboard history when the screen locks.'),
'clear-on-lock'
);
lockBox.append(pauseOnLock);
lockBox.append(clearOnLock);
appearanceBox.append(lockFrame);
// Panel Icon
const iconFrame = this._createFrame(_('Panel Icon'));
const iconBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
iconFrame.set_child(iconBox);
const iconSizeOverride = this._createSpinRow(
_('Icon Size Override (px)'),
_('0 = auto-size based on panel height and scale'),
'icon-size-override',
0, 64, 0
);
iconBox.append(iconSizeOverride);
appearanceBox.append(iconFrame);
// Add to notebook
this._notebook.append_page(appearanceBox, new Gtk.Label({ label: _('Appearance') }));
this._setTabIndex('appearance', this._notebook.get_n_pages() - 1);
}
_addShortcutsTab() {
const shortcutsBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 15
});
shortcutsBox.set_margin_top(12);
// Header
const header = this._createSectionHeader(_('Keyboard Shortcuts'));
shortcutsBox.append(header);
// Shortcuts Frame
const shortcutsFrame = this._createFrame(_('Keyboard Shortcuts'));
const shortcutsListBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
shortcutsFrame.set_child(shortcutsListBox);
// Show menu shortcut
const showMenuBox = this._createShortcutRow(
_('Show Clipboard Menu'),
_('Open the clipboard history menu'),
'show-menu-shortcut',
'<Super><Shift>v'
);
shortcutsListBox.append(showMenuBox);
// Enhanced copy shortcut
const copyShortcutBox = this._createShortcutRow(
_('Enhanced Copy'),
_('Copy selected text to clipboard history'),
'enhanced-copy-shortcut',
'<Super>c'
);
shortcutsListBox.append(copyShortcutBox);
// Enhanced paste shortcut
const pasteShortcutBox = this._createShortcutRow(
_('Enhanced Paste'),
_('Paste with formatting cleanup'),
'enhanced-paste-shortcut',
'<Super>v'
);
shortcutsListBox.append(pasteShortcutBox);
// Classic filter and toggle shortcuts
const filterAllBox = this._createShortcutRow(
_('Classic: Filter All'),
_('Switch Classic filter to All and open the menu'),
'classic-filter-all-shortcut',
''
);
shortcutsListBox.append(filterAllBox);
const filterPinnedBox = this._createShortcutRow(
_('Classic: Filter Pinned'),
_('Switch Classic filter to Pinned and open the menu'),
'classic-filter-pinned-shortcut',
''
);
shortcutsListBox.append(filterPinnedBox);
const filterStarredBox = this._createShortcutRow(
_('Classic: Filter Starred'),
_('Switch Classic filter to Starred and open the menu'),
'classic-filter-starred-shortcut',
''
);
shortcutsListBox.append(filterStarredBox);
const togglePinTopBox = this._createShortcutRow(
_('Classic: Toggle Pin (Top)'),
_('Toggle pinned on the most recent history item'),
'classic-toggle-pin-top-shortcut',
''
);
shortcutsListBox.append(togglePinTopBox);
const toggleStarTopBox = this._createShortcutRow(
_('Classic: Toggle Star (Top)'),
_('Toggle starred on the most recent history item'),
'classic-toggle-star-top-shortcut',
''
);
shortcutsListBox.append(toggleStarTopBox);
shortcutsBox.append(shortcutsFrame);
// Shortcut info
const infoBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 5
});
const infoLabel = new Gtk.Label({
label: _('Tip: Click a shortcut above to record a new combination. Use Clear to remove it.'),
wrap: true,
wrap_mode: Pango.WrapMode.WORD
});
infoLabel.set_halign(Gtk.Align.START);
infoBox.append(infoLabel);
shortcutsBox.append(infoBox);
// Add to notebook
this._notebook.append_page(shortcutsBox, new Gtk.Label({ label: _('Shortcuts') }));
this._setTabIndex('shortcuts', this._notebook.get_n_pages() - 1);
}
_addAboutTab() {
const aboutBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 20
});
aboutBox.set_margin_top(12);
// Header
const header = this._createSectionHeader(_('About ClipFlow Pro'));
aboutBox.append(header);
// App info
const appInfoFrame = this._createFrame(_('Application Information'));
const appInfoBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 15
});
appInfoFrame.set_child(appInfoBox);
// Description
const description = new Gtk.Label({
label: _('ClipFlow Pro is a powerful and intelligent clipboard manager for GNOME Shell that provides comprehensive clipboard history management with advanced features like intelligent organization, search capabilities, pin/star functionality, and privacy protection.'),
wrap: true,
wrap_mode: Pango.WrapMode.WORD
});
description.set_halign(Gtk.Align.START);
appInfoBox.append(description);
// Version info
const versionBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
const versionLabel = new Gtk.Label({ label: _('Version:') });
const versionValue = new Gtk.Label({
label: (this._metadata['version-name'] || String(this._metadata.version ?? ''))
});
versionBox.append(versionLabel);
versionBox.append(versionValue);
appInfoBox.append(versionBox);
// Developer info
const developerBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
const developerLabel = new Gtk.Label({ label: _('Developer:') });
const developerValue = new Gtk.Label({ label: 'Nick Otmazgin' });
developerBox.append(developerLabel);
developerBox.append(developerValue);
appInfoBox.append(developerBox);
// Contact info
const contactBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
const contactLabel = new Gtk.Label({ label: _('Contact:') });
const contactValue = new Gtk.Label({
label: '<a href="mailto:nickotmazgin.dev@gmail.com">nickotmazgin.dev@gmail.com</a>',
use_markup: true
});
contactBox.append(contactLabel);
contactBox.append(contactValue);
appInfoBox.append(contactBox);
// License info
const licenseBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
const licenseLabel = new Gtk.Label({ label: _('License:') });
const licenseValue = new Gtk.Label({
label: '<a href="https://github.com/nickotmazgin/clipflow-pro/blob/main/LICENSE">GPL-3.0-or-later</a>',
use_markup: true
});
licenseBox.append(licenseLabel);
licenseBox.append(licenseValue);
appInfoBox.append(licenseBox);
// Copyright info
const copyrightBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
const copyrightLabel = new Gtk.Label({ label: _('Copyright:') });
const copyrightValue = new Gtk.Label({ label: '© 2025 Nick Otmazgin' });
copyrightBox.append(copyrightLabel);
copyrightBox.append(copyrightValue);
appInfoBox.append(copyrightBox);
aboutBox.append(appInfoFrame);
// Links
const linksFrame = this._createFrame(_('Links'));
const linksBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 10
});
linksFrame.set_child(linksBox);
// GitHub link
const githubButton = new Gtk.Button({ label: _('GitHub Repository') });
githubButton.set_halign(Gtk.Align.START);
githubButton.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://github.com/nickotmazgin/clipflow-pro', null);
});
linksBox.append(githubButton);
// README link
const readmeButton = new Gtk.Button({ label: _('Read Documentation (README.md)') });
readmeButton.set_halign(Gtk.Align.START);
readmeButton.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://github.com/nickotmazgin/clipflow-pro/blob/main/README.md', null);
});
linksBox.append(readmeButton);
// PayPal link
const paypalButton = new Gtk.Button({ label: _('Donate via PayPal') });
paypalButton.set_halign(Gtk.Align.START);
paypalButton.connect('clicked', () => {
Gio.AppInfo.launch_default_for_uri('https://www.paypal.com/donate/?hosted_button_id=4HM44VH47LSMW', null);
});
linksBox.append(paypalButton);
aboutBox.append(linksFrame);
// Features
const featuresFrame = this._createFrame(_('Features'));
const featuresBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 5
});
featuresFrame.set_child(featuresBox);
const features = [
_('- Advanced clipboard history management'),
_('- Intelligent search and filtering with debouncing'),
_('- Pin and star system for important entries'),
_('- Smart content type detection (URLs, emails, code)'),
_('- Password detection and filtering'),
_('- Secure local-only storage with privacy protection'),
_('- Keyboard shortcuts support'),
_('- Search-aware pagination'),
_('- GNOME theme integration'),
_('- Auto-clear sensitive data option')
];
features.forEach(feature => {
const featureLabel = new Gtk.Label({ label: feature });
featureLabel.set_halign(Gtk.Align.START);
featuresBox.append(featureLabel);
});
aboutBox.append(featuresFrame);
// Reset to defaults
const resetFrame = this._createFrame(_('Maintenance'));
const resetBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, spacing: 10 });
resetFrame.set_child(resetBox);
const resetInfo = new Gtk.Label({
label: _('Reset all ClipFlow Pro settings to their defaults.'),
wrap: true,
wrap_mode: Pango.WrapMode.WORD
});
resetInfo.set_halign(Gtk.Align.START);
const resetButton = new Gtk.Button({ label: _('Reset to Defaults') });
resetButton.set_halign(Gtk.Align.START);
resetButton.connect('clicked', () => {
try {
const schema = this._settings.settings_schema;
if (schema && typeof schema.list_keys === 'function') {
const keys = schema.list_keys();
keys.forEach(key => {
try { this._settings.reset(key); } catch (_e) {}
});
}
} catch (_e) {}
});
resetBox.append(resetInfo);
resetBox.append(resetButton);
aboutBox.append(resetFrame);
// Add to notebook
this._notebook.append_page(aboutBox, new Gtk.Label({ label: _('About') }));
this._setTabIndex('about', this._notebook.get_n_pages() - 1);
}
_renderMissingSchemaMessage() {
const messageBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
hexpand: true,
vexpand: true,
spacing: 12
});
const titleText = _('ClipFlow Pro');
const title = new Gtk.Label({ use_markup: true });
title.set_markup(`<b>${GLib.markup_escape_text(titleText, -1)}</b>`);
title.set_halign(Gtk.Align.START);
title.set_xalign(0);
const body = new Gtk.Label({
label: _('Settings schema not found. Run the build script and reinstall the extension.'),
wrap: true,
wrap_mode: Pango.WrapMode.WORD,
xalign: 0
});
body.set_halign(Gtk.Align.START);
body.add_css_class('dim-label');
messageBox.append(title);
messageBox.append(body);
this.append(messageBox);
}
_setTabIndex(name, index) {
if (!this._tabIndexLookup) {
this._tabIndexLookup = new Map();
}
this._tabIndexLookup.set(name, index);
}
_resolveTabIndex(target) {
if (!target || !this._tabIndexLookup || !this._tabIndexLookup.has(target)) {
return null;
}
return this._tabIndexLookup.get(target);
}
_applyInitialTab() {
const schema = this._settings?.settings_schema;
if (!schema?.has_key?.('target-prefs-tab'))
return;
const target = this._settings.get_string('target-prefs-tab');
const tabIndex = this._resolveTabIndex(target);
if (typeof tabIndex === 'number')
this._notebook.set_current_page(tabIndex);
this._settings.set_string('target-prefs-tab', 'general');
}
_createSectionHeader(title) {
const header = new Gtk.Label({ label: title });
header.set_markup(`<span size="large" weight="bold">${title}</span>`);
header.set_halign(Gtk.Align.START);
return header;
}
_createFrame(title) {
const frame = new Gtk.Frame({ label: title });
frame.set_margin_top(10);
frame.set_margin_bottom(10);
frame.set_margin_start(6);
frame.set_margin_end(6);
frame.set_hexpand(true);
return frame;
}
_createSwitchRow(title, description, settingKey) {
const box = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 10
});
box.set_hexpand(true);
box.set_halign(Gtk.Align.FILL);
box.set_margin_top(6);
box.set_margin_bottom(6);
const labelBox = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
spacing: 2
});
labelBox.set_hexpand(true);
labelBox.set_valign(Gtk.Align.CENTER);
labelBox.set_margin_end(12);
const titleLabel = new Gtk.Label({ use_markup: true });
titleLabel.set_markup(`<b>${GLib.markup_escape_text(title, -1)}</b>`);
titleLabel.set_halign(Gtk.Align.START);
titleLabel.set_xalign(0);
const descLabel = new Gtk.Label({ label: description });
descLabel.set_halign(Gtk.Align.START);
descLabel.set_wrap(true);
descLabel.set_wrap_mode(Pango.WrapMode.WORD);
descLabel.add_css_class('dim-label');
descLabel.set_xalign(0);
labelBox.append(titleLabel);
labelBox.append(descLabel);
const switch_widget = new Gtk.Switch();
switch_widget.set_halign(Gtk.Align.END);
switch_widget.set_valign(Gtk.Align.CENTER);
switch_widget.set_hexpand(false);
// Bind to setting
this._settings.bind(settingKey, switch_widget, 'active', Gio.SettingsBindFlags.DEFAULT);
box.append(labelBox);
box.append(switch_widget);
return box;
}