-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprefs.js
More file actions
1456 lines (1265 loc) · 58.7 KB
/
prefs.js
File metadata and controls
1456 lines (1265 loc) · 58.7 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
/** CSS Gnomme Preferences */
import Adw from "gi://Adw";
import Gio from "gi://Gio";
import Gtk from "gi://Gtk";
import GObject from "gi://GObject";
import Gdk from "gi://Gdk";
import GLib from "gi://GLib";
import { ExtensionPreferences, gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
import { ColorPalette } from "./colorPalette.js";
import { ThemeUtils } from "./themeUtils.js";
import { GlobalSignalsHandler } from "./signalHandler.js";
/**
* Discover installed GTK themes from standard locations
* @returns {string[]} Array of theme names
*/
function _discoverInstalledThemes() {
const themes = new Set();
// Standard theme locations
const themeDirs = [
GLib.get_home_dir() + "/.themes",
GLib.get_home_dir() + "/.local/share/themes",
"/usr/share/themes"
];
themeDirs.forEach(dir => {
try {
const dirFile = Gio.File.new_for_path(dir);
if (!dirFile.query_exists(null)) {
return;
}
const enumerator = dirFile.enumerate_children(
"standard::name,standard::type",
Gio.FileQueryInfoFlags.NONE,
null
);
let info;
while ((info = enumerator.next_file(null)) !== null) {
if (info.get_file_type() === Gio.FileType.DIRECTORY) {
const themeName = info.get_name();
// Skip hidden directories and our overlay
if (themeName.startsWith(".") || themeName === "CSSGnomme") {
continue;
}
// Check if theme has GTK 3 or GTK 4 support
const themePath = dir + "/" + themeName;
// Check for GTK CSS files with actual content (> 100 bytes)
const gtk3Path = themePath + "/gtk-3.0/gtk.css";
const gtk4Path = themePath + "/gtk-4.0/gtk.css";
let hasValidGtk3 = false;
let hasValidGtk4 = false;
// GTK 3 check - file must exist and be > 100 bytes
if (GLib.file_test(gtk3Path, GLib.FileTest.EXISTS)) {
try {
const gtk3File = Gio.File.new_for_path(gtk3Path);
const info = gtk3File.query_info("standard::size", Gio.FileQueryInfoFlags.NONE, null);
const size = info.get_size();
hasValidGtk3 = size > 100; // Must have actual CSS content
} catch (e) {
// Invalid file, skip
}
}
// GTK 4 check - file must exist and be > 100 bytes
if (GLib.file_test(gtk4Path, GLib.FileTest.EXISTS)) {
try {
const gtk4File = Gio.File.new_for_path(gtk4Path);
const info = gtk4File.query_info("standard::size", Gio.FileQueryInfoFlags.NONE, null);
const size = info.get_size();
hasValidGtk4 = size > 100; // Must have actual CSS content
} catch (e) {
// Invalid file, skip
}
}
// Only add themes with valid GTK CSS files
if (hasValidGtk3 || hasValidGtk4) {
themes.add(themeName);
}
}
}
enumerator.close(null);
} catch (e) {
log(`Error scanning theme directory ${dir}: ${e.message}`);
}
});
// Convert Set to sorted Array
const themeArray = Array.from(themes).sort();
// Ensure Adwaita is first if it exists
const adwaitaIndex = themeArray.indexOf("Adwaita");
if (adwaitaIndex > 0) {
themeArray.splice(adwaitaIndex, 1);
themeArray.unshift("Adwaita");
}
return themeArray;
}
/**
* Check if Zorin Menu extension is installed and enabled
* @returns {boolean} True if Zorin Menu is available
*/
function _isZorinMenuAvailable() {
try {
// Check if extension is in enabled-extensions list
const shellSettings = new Gio.Settings({ schema_id: "org.gnome.shell" });
const enabledExtensions = shellSettings.get_strv("enabled-extensions");
return enabledExtensions.includes("zorin-menu@zorinos.com");
} catch (e) {
// If org.gnome.shell schema not accessible (unlikely in prefs context)
return false;
}
}
export default class CSSGnommePreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
// GlobalSignalsHandler for automatic signal tracking and cleanup
const signalsHandler = new GlobalSignalsHandler();
// Track interface settings separately (different Settings object)
let interfaceSettings = null;
// Track UI element signals for cleanup (prevent memory leaks)
let comboRowSignalId = null;
// Guard flag to prevent signal feedback loops
let blockSignals = false;
// Set window size to accommodate all tabs comfortably
window.set_default_size(900, 800);
// === THEME OVERLAY PAGE (FIRST) ===
const overlayPage = new Adw.PreferencesPage({
title: _("Theme Overlay"),
icon_name: "applications-graphics-symbolic"
});
// Theme Integration Group
const themeIntegrationGroup = new Adw.PreferencesGroup({
title: _("Theme Integration"),
description: _("CSS Gnomme creates a dynamic overlay theme that sits on top of your current theme")
});
// Enable overlay theme switch
const enableOverlayRow = new Adw.ActionRow({
title: _("Enable Overlay Theme"),
subtitle: _("Activate CSS Gnomme overlay with custom styling and color extraction")
});
const enableOverlaySwitch = new Gtk.Switch({
valign: Gtk.Align.CENTER
});
settings.bind("enable-overlay-theme", enableOverlaySwitch, "active", Gio.SettingsBindFlags.DEFAULT);
enableOverlayRow.add_suffix(enableOverlaySwitch);
enableOverlayRow.activatable_widget = enableOverlaySwitch;
themeIntegrationGroup.add(enableOverlayRow);
// Source theme selector dropdown
const sourceThemeRow = new Adw.ComboRow({
title: _("Base Theme"),
subtitle: _("Select the theme to use as foundation for overlay")
});
/**
* Filter themes based on auto-switch and color-scheme settings
* When auto-switch is ON:
* - Extension.js automatically switches between theme variants on Dark/Light toggle
* - Dropdown shows only themes matching current appearance (-Dark or -Light suffix)
* When auto-switch is OFF:
* - User manually selects theme from full list
* - All themes shown in dropdown
* @returns {Array} Filtered theme list
*/
const getFilteredThemes = () => {
const allThemes = _discoverInstalledThemes();
const autoSwitch = settings.get_boolean("auto-switch-color-scheme");
// If auto-switch OFF, show all themes (user has full control)
if (!autoSwitch) {
return allThemes;
}
// Get system color-scheme preference
let interfaceSettings;
try {
interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
} catch (e) {
// Fallback if can't read settings - show all themes
log("[CSSGnomme:Prefs] Could not read color-scheme, showing all themes");
return allThemes;
}
const colorScheme = interfaceSettings.get_string("color-scheme");
const prefersDark = colorScheme === "prefer-dark";
// Filter: Only show themes with explicit -Dark or -Light suffix
// Case-insensitive matching at the END of theme name
const filtered = allThemes.filter(themeName => {
const lowerName = themeName.toLowerCase();
// Check if theme has explicit -Dark or -Light suffix
const hasDarkSuffix = lowerName.endsWith("-dark");
const hasLightSuffix = lowerName.endsWith("-light");
// Only accept themes with explicit suffix
if (!hasDarkSuffix && !hasLightSuffix) {
return false; // Skip themes without suffix (e.g., "Fluent-round-grey", "Adwaita")
}
// Show -Dark themes in dark mode, -Light themes in light mode
if (prefersDark) {
return hasDarkSuffix;
} else {
return hasLightSuffix;
}
});
// Fallback: if filter results in empty list, show all themes
if (filtered.length === 0) {
log("[CSSGnomme:Prefs] Filter resulted in empty list, showing all themes");
return allThemes;
}
return filtered;
};
// Populate dropdown with filtered themes
const themeList = new Gtk.StringList();
let availableThemes = getFilteredThemes();
const currentSourceTheme = settings.get_string("overlay-source-theme") || "Adwaita";
let selectedIndex = 0;
availableThemes.forEach((themeName, index) => {
themeList.append(themeName);
if (themeName === currentSourceTheme) {
selectedIndex = index;
}
});
sourceThemeRow.set_model(themeList);
sourceThemeRow.set_selected(selectedIndex);
// Connect source theme change - use closure-safe theme retrieval
// Track signal ID for cleanup on window close
comboRowSignalId = sourceThemeRow.connect("notify::selected", () => {
// GUARD: Prevent signal feedback loop during programmatic updates
if (blockSignals) {
log("[CSSGnomme:Prefs] ComboRow signal blocked (programmatic update)");
return;
}
const selectedIndex = sourceThemeRow.get_selected();
const model = sourceThemeRow.get_model();
const selectedTheme = model.get_string(selectedIndex);
if (selectedTheme) {
log(`[CSSGnomme:Prefs] User selected theme: ${selectedTheme}`);
// Block signals to prevent triggering our own handler
blockSignals = true;
settings.set_string("overlay-source-theme", selectedTheme);
blockSignals = false;
}
});
// Refresh dropdown when auto-switch or color-scheme changes
const refreshDropdown = () => {
// Block signals during programmatic update
blockSignals = true;
// Save current selection
const currentSelection = settings.get_string("overlay-source-theme");
// Create completely new model (don't reuse themeList)
const newThemeList = new Gtk.StringList();
availableThemes = getFilteredThemes();
let newSelectedIndex = 0;
availableThemes.forEach((themeName, index) => {
newThemeList.append(themeName);
if (themeName === currentSelection) {
newSelectedIndex = index;
}
});
// Set new model and selection
sourceThemeRow.set_model(newThemeList);
sourceThemeRow.set_selected(newSelectedIndex);
// Unblock signals after update complete
blockSignals = false;
};
// Monitor auto-switch toggle using GlobalSignalsHandler
signalsHandler.add([settings, "changed::auto-switch-color-scheme", refreshDropdown]);
// Monitor system color-scheme changes (for live updates while prefs open)
// Keep interfaceSettings alive by storing it outside try block
try {
interfaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
signalsHandler.add([
interfaceSettings,
"changed::color-scheme",
() => {
// Don't interfere if auto-switch is enabled (extension.js handles theme switching)
if (settings.get_boolean("auto-switch-color-scheme")) {
log("[CSSGnomme:Prefs] Auto-switch enabled, skipping dropdown refresh");
return;
}
log("[CSSGnomme:Prefs] Color-scheme changed, refreshing dropdown");
refreshDropdown();
}
]);
} catch (e) {
log(`[CSSGnomme:Prefs] Warning: Could not monitor color-scheme changes: ${e}`);
}
// Monitor external changes to overlay-source-theme (e.g., from extension.js via "Apply Overlay" button)
signalsHandler.add([
settings,
"changed::overlay-source-theme",
() => {
// GUARD: If signal is blocked, we triggered this change ourselves
if (blockSignals) {
log("[CSSGnomme:Prefs] Theme change signal blocked (originated from us)");
return;
}
const newTheme = settings.get_string("overlay-source-theme") || "Adwaita";
log(`[CSSGnomme:Prefs] External theme change detected: ${newTheme}`);
// Block signals during update
blockSignals = true;
// Rebuild dropdown to ensure new theme is in the list (in case filter changed)
refreshDropdown();
// After rebuild, find and select the new theme
const model = sourceThemeRow.get_model();
for (let i = 0; i < model.get_n_items(); i++) {
if (model.get_string(i) === newTheme) {
sourceThemeRow.set_selected(i);
// DON'T call notify() - it triggers our handler!
break;
}
}
// Unblock signals
blockSignals = false;
}
]);
themeIntegrationGroup.add(sourceThemeRow);
// Overlay status display
const statusRow = new Adw.ActionRow({
title: _("Overlay Status"),
subtitle: _("Checking...")
});
// Update status based on settings
const updateStatus = () => {
const enabled = settings.get_boolean("enable-overlay-theme");
const sourceTheme = settings.get_string("overlay-source-theme");
if (enabled) {
statusRow.subtitle = _(`Active - Using ${sourceTheme} as base`);
} else {
statusRow.subtitle = _("Inactive - Enable overlay to apply custom theme");
}
};
updateStatus();
signalsHandler.add(
[settings, "changed::enable-overlay-theme", updateStatus],
[settings, "changed::overlay-source-theme", updateStatus]
);
themeIntegrationGroup.add(statusRow);
// Auto-detect radius
const autoDetectRadiusRow = new Adw.ActionRow({
title: _("Auto-detect theme border radius"),
subtitle: _("Automatically detect and use border-radius from current theme")
});
const autoDetectRadiusSwitch = new Gtk.Switch({ valign: Gtk.Align.CENTER });
settings.bind("auto-detect-radius", autoDetectRadiusSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
autoDetectRadiusRow.add_suffix(autoDetectRadiusSwitch);
autoDetectRadiusRow.set_activatable_widget(autoDetectRadiusSwitch);
themeIntegrationGroup.add(autoDetectRadiusRow);
overlayPage.add(themeIntegrationGroup);
// Automatic Color Extraction Group
const colorExtractionGroup = new Adw.PreferencesGroup({
title: _("Automatic Color Extraction") //,
//description: _("Extract colors from your wallpaper and apply them automatically")
});
// Auto-extract on wallpaper change
const autoExtractRow = new Adw.ActionRow({
title: _("Auto-detect colors on wallpaper change"),
subtitle: _("Automatically extract and apply colors when you change your desktop background")
});
const autoExtractSwitch = new Gtk.Switch({
valign: Gtk.Align.CENTER
});
settings.bind("auto-color-extraction", autoExtractSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
autoExtractRow.add_suffix(autoExtractSwitch);
autoExtractRow.activatable_widget = autoExtractSwitch;
colorExtractionGroup.add(autoExtractRow);
// Manual extract button
const extractButtonRow = new Adw.ActionRow({
title: _("Extract Colors Now"),
subtitle: _("Manually trigger color extraction from current wallpaper")
});
const extractButton = new Gtk.Button({
label: _("Extract from Wallpaper"),
valign: Gtk.Align.CENTER,
css_classes: ["suggested-action"]
});
extractButton.connect("clicked", () => {
// Trigger extraction via settings toggle (DRY - avoid duplicate logic)
// Extension will handle extraction and show notification
settings.set_boolean("trigger-color-extraction", !settings.get_boolean("trigger-color-extraction"));
});
extractButtonRow.add_suffix(extractButton);
colorExtractionGroup.add(extractButtonRow);
overlayPage.add(colorExtractionGroup);
// Manual Controls Group
const manualControlGroup = new Adw.PreferencesGroup({
title: _("Manual Controls") //,
// description: _("Manually trigger overlay updates or rebuild from scratch")
});
// Apply changes now button
const applyButtonRow = new Adw.ActionRow({
title: _("Apply Changes Now"),
subtitle: _("Manually update overlay theme (auto-update has 2s delay)")
});
const applyButton = new Gtk.Button({
label: _("Apply"),
valign: Gtk.Align.CENTER,
css_classes: ["suggested-action"]
});
applyButton.connect("clicked", () => {
log("[CSSGnomme Prefs] Apply Changes button clicked");
// Get current state for logging
const currentTrigger = settings.get_boolean("manual-apply-trigger");
log(`[CSSGnomme Prefs] Toggling manual-apply-trigger: ${currentTrigger} → ${!currentTrigger}`);
// Trigger manual apply via settings toggle
settings.set_boolean("manual-apply-trigger", !currentTrigger);
log("[CSSGnomme Prefs] Manual apply trigger set, overlay theme will update");
// Show confirmation
const messageDialog = new Gtk.MessageDialog({
transient_for: window,
modal: true,
buttons: Gtk.ButtonsType.OK,
text: _("Overlay Update Triggered"),
secondary_text: _("The theme overlay has been updated with your current settings.")
});
messageDialog.connect("response", () => messageDialog.destroy());
messageDialog.show();
});
applyButtonRow.add_suffix(applyButton);
applyButtonRow.activatable_widget = applyButton;
manualControlGroup.add(applyButtonRow);
// Recreate overlay button
const recreateButtonRow = new Adw.ActionRow({
title: _("Recreate Overlay") //,
// subtitle: _("Delete and recreate entire overlay (useful if base theme changed)")
});
const recreateButton = new Gtk.Button({
label: _("Recreate"),
valign: Gtk.Align.CENTER,
css_classes: ["destructive-action"]
});
recreateButton.connect("clicked", () => {
log("[CSSGnomme Prefs] Recreate Overlay button clicked");
// Toggle trigger key - extension.js will handle recreation
const current = settings.get_boolean("trigger-recreate-overlay");
settings.set_boolean("trigger-recreate-overlay", !current);
log(`[CSSGnomme Prefs] Recreate trigger toggled: ${current} -> ${!current}`);
const messageDialog = new Gtk.MessageDialog({
transient_for: window,
modal: true,
buttons: Gtk.ButtonsType.OK,
text: _("Overlay Recreation Triggered"),
secondary_text: _("The theme overlay is being completely rebuilt from the selected base theme.")
});
messageDialog.connect("response", () => messageDialog.destroy());
messageDialog.show();
});
recreateButtonRow.add_suffix(recreateButton);
recreateButtonRow.activatable_widget = recreateButton;
manualControlGroup.add(recreateButtonRow);
overlayPage.add(manualControlGroup);
window.add(overlayPage);
// === TRANSPARENCY SETTINGS PAGE ===
const transparencyPage = new Adw.PreferencesPage({
title: _("Color Settings"),
icon_name: "preferences-desktop-theme-symbolic"
});
// Basic transparency controls group
const basicTransparencyGroup = new Adw.PreferencesGroup({
title: _("Basic Transparency Controls")
});
// Panel opacity
const panelOpacityRow = new Adw.ActionRow({
title: _("Panel Opacity"),
subtitle: _("Adjust the transparency of the main panel (0.0 = fully transparent, 1.0 = fully opaque)")
});
const panelOpacitySpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.0,
upper: 1.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("panel-opacity", panelOpacitySpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
panelOpacityRow.add_suffix(panelOpacitySpinButton);
basicTransparencyGroup.add(panelOpacityRow);
// Menu opacity
const menuOpacityRow = new Adw.ActionRow({
title: _("Menu Opacity"),
subtitle: _("Adjust the transparency of popup menus (0.0 = fully transparent, 1.0 = fully opaque)")
});
const menuOpacitySpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.0,
upper: 1.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("menu-opacity", menuOpacitySpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
menuOpacityRow.add_suffix(menuOpacitySpinButton);
basicTransparencyGroup.add(menuOpacityRow);
// Zorin Theme Tint Strength (only affects Zorin themes like ZorinBlue, ZorinGreen, etc.)
const tintStrengthRow = new Adw.ActionRow({
title: _("Zorin Theme Tint Strength (%)"),
subtitle: _(
"Removes color tint from Zorin theme backgrounds (0% = fully neutral grey, 100% = original colored backgrounds). Only works with Zorin themes (ZorinBlue-Dark, ZorinGreen-Light, etc.). Other themes are unaffected."
)
});
const tintStrengthSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0,
upper: 100,
step_increment: 5,
page_increment: 10
}),
digits: 0,
valign: Gtk.Align.CENTER
});
settings.bind("zorin-tint-strength", tintStrengthSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
tintStrengthRow.add_suffix(tintStrengthSpinButton);
basicTransparencyGroup.add(tintStrengthRow);
transparencyPage.add(basicTransparencyGroup);
// Panel options group
const panelOptionsGroup = new Adw.PreferencesGroup({
title: _("Panel Appearance")
});
// Panel margin (floating mode)
const panelMarginRow = new Adw.ActionRow({
title: _("Panel Margin"),
subtitle: _(
"Horizontal spacing from screen edges (0 = pinned to edges, >0 = floating panel with modern appearance)"
)
});
const panelMarginSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0,
upper: 32,
step_increment: 4,
page_increment: 8
}),
valign: Gtk.Align.CENTER
});
settings.bind("panel-margin", panelMarginSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
panelMarginRow.add_suffix(panelMarginSpinButton);
panelOptionsGroup.add(panelMarginRow);
// Override panel color
const overridePanelColorRow = new Adw.ActionRow({
title: _("Override panel color"),
subtitle: _("Use custom color for panel background instead of theme color")
});
const overridePanelColorSwitch = new Gtk.Switch({ valign: Gtk.Align.CENTER });
settings.bind("override-panel-color", overridePanelColorSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
overridePanelColorRow.add_suffix(overridePanelColorSwitch);
overridePanelColorRow.set_activatable_widget(overridePanelColorSwitch);
panelOptionsGroup.add(overridePanelColorRow);
// Choose override panel color
const choosePanelColorRow = new Adw.ActionRow({
title: _("Choose override panel color"),
subtitle: _("Select background color for panel when override is enabled")
});
const panelColorButton = new Gtk.ColorButton({
valign: Gtk.Align.CENTER,
use_alpha: true
});
// Custom binding for RGBA to string conversion
const panelColorValue = settings.get_string("choose-override-panel-color");
if (panelColorValue) {
const rgba = new Gdk.RGBA();
rgba.parse(panelColorValue);
panelColorButton.set_rgba(rgba);
}
signalsHandler.add([
panelColorButton,
"color-set",
() => {
const rgba = panelColorButton.get_rgba();
settings.set_string("choose-override-panel-color", rgba.to_string());
}
]);
// Listen for external changes (e.g., from color extraction)
signalsHandler.add([
settings,
"changed::choose-override-panel-color",
() => {
const newValue = settings.get_string("choose-override-panel-color");
if (newValue) {
const rgba = new Gdk.RGBA();
rgba.parse(newValue);
panelColorButton.set_rgba(rgba);
}
}
]);
choosePanelColorRow.add_suffix(panelColorButton);
panelOptionsGroup.add(choosePanelColorRow);
// Override popup color
const overridePopupColorRow = new Adw.ActionRow({
title: _("Override popup color"),
subtitle: _("Use custom color for popup menu backgrounds")
});
const overridePopupColorSwitch = new Gtk.Switch({ valign: Gtk.Align.CENTER });
settings.bind("override-popup-color", overridePopupColorSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
overridePopupColorRow.add_suffix(overridePopupColorSwitch);
overridePopupColorRow.set_activatable_widget(overridePopupColorSwitch);
panelOptionsGroup.add(overridePopupColorRow);
// Choose override popup color
const choosePopupColorRow = new Adw.ActionRow({
title: _("Choose override popup color"),
subtitle: _("Select background color for popup menus when override is enabled")
});
const popupColorButton = new Gtk.ColorButton({
valign: Gtk.Align.CENTER,
use_alpha: true
});
// Custom binding for RGBA to string conversion
const popupColorValue = settings.get_string("choose-override-popup-color");
if (popupColorValue) {
const rgba = new Gdk.RGBA();
rgba.parse(popupColorValue);
popupColorButton.set_rgba(rgba);
}
signalsHandler.add([
popupColorButton,
"color-set",
() => {
const rgba = popupColorButton.get_rgba();
settings.set_string("choose-override-popup-color", rgba.to_string());
}
]);
// Listen for external changes (e.g., from color extraction)
signalsHandler.add([
settings,
"changed::choose-override-popup-color",
() => {
const newValue = settings.get_string("choose-override-popup-color");
if (newValue) {
const rgba = new Gdk.RGBA();
rgba.parse(newValue);
popupColorButton.set_rgba(rgba);
}
}
]);
choosePopupColorRow.add_suffix(popupColorButton);
panelOptionsGroup.add(choosePopupColorRow);
// Border radius
const borderRadiusRow = new Adw.ActionRow({
title: _("Border Radius"),
subtitle: _("Rounded corners for panels and menus (0-25px)")
});
const borderRadiusSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0,
upper: 25,
step_increment: 1,
page_increment: 5
}),
valign: Gtk.Align.CENTER
});
settings.bind("border-radius", borderRadiusSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
borderRadiusRow.add_suffix(borderRadiusSpinButton);
panelOptionsGroup.add(borderRadiusRow);
// Apply panel radius - COMMENTED OUT (automatic behavior based on panel-margin)
// When panel-margin > 0, border-radius is automatically applied (floating mode)
// When panel-margin = 0, border-radius is disabled (flat pinned panel looks better)
// Keeping code for future reference in case manual override control is needed
/*
const applyPanelRadiusRow = new Adw.ActionRow({
title: _("Apply border radius to main panel"),
subtitle: _("Enable rounded corners on taskbar for modern appearance")
});
const applyPanelRadiusSwitch = new Gtk.Switch({ valign: Gtk.Align.CENTER });
settings.bind("apply-panel-radius", applyPanelRadiusSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
applyPanelRadiusRow.add_suffix(applyPanelRadiusSwitch);
applyPanelRadiusRow.set_activatable_widget(applyPanelRadiusSwitch);
panelOptionsGroup.add(applyPanelRadiusRow);
*/
transparencyPage.add(panelOptionsGroup);
window.add(transparencyPage);
// === BLUR EFFECTS PAGE ===
const blurPage = new Adw.PreferencesPage({
title: _("Blur Effects"),
icon_name: "preferences-desktop-effects-symbolic"
});
// Custom blur settings group
const customBlurGroup = new Adw.PreferencesGroup({
title: _("Custom Blur and Border Settings")
});
// Blur radius
const blurRadiusRow = new Adw.ActionRow({
title: _("Blur radius"),
subtitle: _("Controls the intensity of the blur effect")
});
const blurRadiusSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 1,
upper: 50,
step_increment: 1,
page_increment: 5
}),
valign: Gtk.Align.CENTER
});
settings.bind("blur-radius", blurRadiusSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurRadiusRow.add_suffix(blurRadiusSpinButton);
customBlurGroup.add(blurRadiusRow);
// Blur saturate
const blurSaturateRow = new Adw.ActionRow({
title: _("Saturation multiplier"),
subtitle: _("Adjusts color vibrancy in the blurred background")
});
const blurSaturateSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.4,
upper: 2.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("blur-saturate", blurSaturateSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurSaturateRow.add_suffix(blurSaturateSpinButton);
customBlurGroup.add(blurSaturateRow);
// Blur contrast
const blurContrastRow = new Adw.ActionRow({
title: _("Contrast multiplier"),
subtitle: _("Controls the difference between light and dark areas")
});
const blurContrastSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.4,
upper: 2.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("blur-contrast", blurContrastSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurContrastRow.add_suffix(blurContrastSpinButton);
customBlurGroup.add(blurContrastRow);
// Blur brightness
const blurBrightnessRow = new Adw.ActionRow({
title: _("Brightness multiplier"),
subtitle: _("Modifies the overall lightness of the blurred layer")
});
const blurBrightnessSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.4,
upper: 2.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("blur-brightness", blurBrightnessSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurBrightnessRow.add_suffix(blurBrightnessSpinButton);
customBlurGroup.add(blurBrightnessRow);
// Blur background
const blurBackgroundRow = new Adw.ActionRow({
title: _("Background color/tint"),
subtitle: _("Adds a tint overlay to the blur effect")
});
const blurBackgroundButton = new Gtk.ColorButton({
valign: Gtk.Align.CENTER,
use_alpha: true
});
// Custom binding for RGBA to string conversion
const blurBackgroundValue = settings.get_string("blur-background");
if (blurBackgroundValue) {
const rgba = new Gdk.RGBA();
rgba.parse(blurBackgroundValue);
blurBackgroundButton.set_rgba(rgba);
}
signalsHandler.add([
blurBackgroundButton,
"color-set",
() => {
const rgba = blurBackgroundButton.get_rgba();
settings.set_string("blur-background", rgba.to_string());
}
]);
// Listen for external changes (e.g., from color extraction)
signalsHandler.add([
settings,
"changed::blur-background",
() => {
const newValue = settings.get_string("blur-background");
if (newValue) {
const rgba = new Gdk.RGBA();
rgba.parse(newValue);
blurBackgroundButton.set_rgba(rgba);
}
}
]);
blurBackgroundRow.add_suffix(blurBackgroundButton);
customBlurGroup.add(blurBackgroundRow);
// Blur border color
const blurBorderColorRow = new Adw.ActionRow({
title: _("Border color"),
subtitle: _("Sets the color of the subtle border framing the blurred elements")
});
const blurBorderColorButton = new Gtk.ColorButton({
valign: Gtk.Align.CENTER,
use_alpha: true
});
// Custom binding for RGBA to string conversion
const blurBorderColorValue = settings.get_string("blur-border-color");
if (blurBorderColorValue) {
const rgba = new Gdk.RGBA();
rgba.parse(blurBorderColorValue);
blurBorderColorButton.set_rgba(rgba);
}
signalsHandler.add([
blurBorderColorButton,
"color-set",
() => {
const rgba = blurBorderColorButton.get_rgba();
settings.set_string("blur-border-color", rgba.to_string());
}
]);
// Listen for external changes (e.g., from color extraction)
signalsHandler.add([
settings,
"changed::blur-border-color",
() => {
const newValue = settings.get_string("blur-border-color");
if (newValue) {
const rgba = new Gdk.RGBA();
rgba.parse(newValue);
blurBorderColorButton.set_rgba(rgba);
}
}
]);
blurBorderColorRow.add_suffix(blurBorderColorButton);
customBlurGroup.add(blurBorderColorRow);
// Blur border width
const blurBorderWidthRow = new Adw.ActionRow({
title: _("Border width"),
subtitle: _("Defines the thickness of the border around blurred elements")
});
const blurBorderWidthSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0,
upper: 5,
step_increment: 1,
page_increment: 1
}),
valign: Gtk.Align.CENTER
});
settings.bind("blur-border-width", blurBorderWidthSpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurBorderWidthRow.add_suffix(blurBorderWidthSpinButton);
customBlurGroup.add(blurBorderWidthRow);
// Blur opacity
const blurOpacityRow = new Adw.ActionRow({
title: _("Blur opacity"),
subtitle: _(
"Controls the transparency of the entire blur layer (0.0 = invisible blur, 1.0 = full blur effect)"
)
});
const blurOpacitySpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.0,
upper: 1.0,
step_increment: 0.01,
page_increment: 0.1
}),
digits: 2,
valign: Gtk.Align.CENTER
});
settings.bind("blur-opacity", blurOpacitySpinButton, "value", Gio.SettingsBindFlags.DEFAULT);
blurOpacityRow.add_suffix(blurOpacitySpinButton);
customBlurGroup.add(blurOpacityRow);
blurPage.add(customBlurGroup);
// Shadow Effects Group
const shadowEffectsGroup = new Adw.PreferencesGroup({
title: _("Shadow Effects")
});
// Shadow strength (outer glow spread control)
const shadowStrengthRow = new Adw.ActionRow({
title: _("Shadow strength"),
subtitle: _("Controls outer glow spread around panels and menus (0.0 = no shadow, 0.8 = wide halo)")
});
const shadowStrengthSpinButton = new Gtk.SpinButton({
adjustment: new Gtk.Adjustment({
lower: 0.0,
upper: 0.8,