diff --git a/.gitignore b/.gitignore index aa64aaa..c1c68e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ build node_modules +**/*.ui~ + tests/**/_variants.js diff --git a/Makefile b/Makefile index a6388b0..627f2ab 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,9 @@ build: build-clean --extra-source=./compat.js \ --extra-source=./config.js \ --extra-source=./convenience.js \ - --extra-source=./prefs.ui \ --extra-source=./utils.js \ --extra-source=./modules/ \ + --extra-source=./preferences/ \ --extra-source=./schemas/ \ --extra-source=./settings/ \ --podir=./po/ \ @@ -86,7 +86,7 @@ pot: --package-name="$(NAME)" \ --package-version="$(VERSION)" \ --output=./src/po/$(UUID).pot \ - ./src/*.js ./src/**/*.js ./src/**/*.xml ./src/*.ui + ./src/*.js ./src/**/*.js ./src/schemas/*.xml ./src/preferences/ui/*.ui sed -i '1,4s/SOME DESCRIPTIVE TITLE./$(NAME)/g' ./src/po/$(UUID).pot sed -i '1,4s/YEAR/$(COPYRIGHT_YEAR)/' ./src/po/$(UUID).pot sed -i "1,4s/THE PACKAGE'S COPYRIGHT HOLDER/$(AUTHOR_NAME)/" ./src/po/$(UUID).pot diff --git a/src/po/fr.po b/src/po/fr.po index 003d458..c48a033 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Night Theme Switcher 7\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-09-23 11:56+0200\n" -"PO-Revision-Date: 2020-09-23 11:57+0200\n" +"POT-Creation-Date: 2020-09-23 20:13+0200\n" +"PO-Revision-Date: 2020-09-23 20:13+0200\n" "Last-Translator: Romain Vigier \n" "Language-Team: French - France \n" "Language: fr_FR\n" @@ -18,14 +18,6 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1)\n" "X-Generator: Gtranslator 3.36.0\n" -#: src/prefs.js:230 src/prefs.ui:643 -msgid "Choose" -msgstr "Choisir" - -#: src/prefs.js:350 -msgid "Default" -msgstr "Par défaut" - #: src/modules/GtkThemer.js:179 #, javascript-format msgid "" @@ -55,6 +47,42 @@ msgstr "Passer au thème nocturne" msgid "Switch to day theme" msgstr "Passer au thème diurne" +#: src/preferences/Backgrounds.js:36 src/preferences/ui/backgrounds.ui:145 +msgid "Backgrounds" +msgstr "Arrière-plans" + +#: src/preferences/Commands.js:36 src/preferences/ui/commands.ui:132 +msgid "Commands" +msgstr "Commandes" + +#: src/preferences/CursorTheme.js:38 +msgid "Cursor theme" +msgstr "Thème de curseur" + +#: src/preferences/GtkTheme.js:38 +msgid "GTK theme" +msgstr "Thème GTK" + +#: src/preferences/IconTheme.js:38 +msgid "Icon theme" +msgstr "Thème d’icônes" + +#: src/preferences/Schedule.js:38 +msgid "Schedule" +msgstr "Horaires" + +#: src/preferences/Schedule.js:193 src/preferences/ui/schedule.ui:595 +msgid "Choose" +msgstr "Choisir" + +#: src/preferences/ShellTheme.js:38 +msgid "Shell theme" +msgstr "Thème du shell" + +#: src/preferences/ShellTheme.js:80 +msgid "Default" +msgstr "Par défaut" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 msgid "Settings version" msgstr "Version des paramètres" @@ -65,7 +93,7 @@ msgstr "La version actuelle des paramètres de l’extension" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:13 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:6 -#: src/prefs.ui:821 +#: src/preferences/ui/gtk_theme.ui:76 msgid "Switch GTK variants" msgstr "Permuter les variantes GTK" @@ -146,7 +174,7 @@ msgstr "Désactiver la détection automatique des variantes du thème shell" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:57 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:46 -#: src/prefs.ui:1509 +#: src/preferences/ui/icon_theme.ui:76 msgid "Switch icon variants" msgstr "Permuter les variantes d’icônes" @@ -177,7 +205,7 @@ msgstr "Le thème d’icônes à utiliser la nuit" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:74 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:61 -#: src/prefs.ui:1755 +#: src/preferences/ui/cursor_theme.ui:76 msgid "Switch cursor variants" msgstr "Permuter les variantes de curseur" @@ -218,7 +246,7 @@ msgstr "Les commandes seront lancées au changement d’horaire" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:96 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:131 -#: src/prefs.ui:2432 +#: src/preferences/ui/commands.ui:174 msgid "Sunrise command" msgstr "Commande du lever de soleil" @@ -229,7 +257,7 @@ msgstr "La commande à lancer quand le soleil se lève" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:101 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:136 -#: src/prefs.ui:2523 +#: src/preferences/ui/commands.ui:268 msgid "Sunset command" msgstr "Commande du coucher de soleil" @@ -250,7 +278,7 @@ msgstr "L’arrière-plan changera au changement d’horaire" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:113 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:146 -#: src/prefs.ui:2088 +#: src/preferences/ui/backgrounds.ui:187 msgid "Day background" msgstr "Arrière-plan diurne" @@ -261,7 +289,7 @@ msgstr "Chemin vers l’arrière-plan diurne" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:118 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:151 -#: src/prefs.ui:2177 +#: src/preferences/ui/backgrounds.ui:279 msgid "Night background" msgstr "Arrière-plan nocturne" @@ -340,99 +368,60 @@ msgstr "Heure du coucher" msgid "When the day ends" msgstr "Quand le jour se couche" -#: src/prefs.ui:58 -msgid "Press your keyboard shortcut..." -msgstr "Pressez votre raccourci clavier…" +#: src/preferences/ui/backgrounds.ui:97 +msgid "Switch backgrounds" +msgstr "Permuter les arrière-plans" -#: src/prefs.ui:72 src/prefs.ui:629 -msgid "Keyboard shortcut" -msgstr "Raccourci clavier" +#: src/preferences/ui/backgrounds.ui:210 src/preferences/ui/backgrounds.ui:302 +msgid "Select your background image" +msgstr "Sélectionnez votre image d’arrière-plan" -#: src/prefs.ui:75 -msgid "Cancel" -msgstr "Annuler" - -#: src/prefs.ui:159 -msgid "Automatic time source" -msgstr "Source d’horaires automatique" - -#: src/prefs.ui:172 -msgid "" -"The extension will try to use Night Light or Location Services to " -"automatically set your current sunrise and sunset times if they are enabled. " -"If you prefer, you can manually choose a time source." -msgstr "" -"S’ils sont activés, l’extension tentera d’utiliser le mode nuit ou " -"les services de localisation pour déterminer automatiquement les heures de " -"lever et de coucher du soleil. Si vous préférez, vous pouvez choisir " -"manuellement une source d’horaires." - -#: src/prefs.ui:236 -msgid "Manual time source" -msgstr "Source d’horaires manuelle" - -#: src/prefs.ui:256 -msgid "Night Light" -msgstr "Mode nuit" - -#: src/prefs.ui:271 -msgid "Location Services" -msgstr "Services de localisation" - -#: src/prefs.ui:286 -msgid "Manual schedule" -msgstr "Horaire manuel" - -#: src/prefs.ui:301 src/prefs.ui:590 -msgid "On-demand" -msgstr "À la demande" - -#: src/prefs.ui:343 -msgid "Manual schedule times" -msgstr "Horaires manuels" - -#: src/prefs.ui:382 -msgid "Sunrise" -msgstr "Lever du soleil" - -#: src/prefs.ui:418 src/prefs.ui:522 -msgid ":" -msgstr ":" - -#: src/prefs.ui:486 -msgid "Sunset" -msgstr "Coucher du soleil" - -#: src/prefs.ui:658 src/prefs.ui:2121 src/prefs.ui:2210 src/prefs.ui:2464 -#: src/prefs.ui:2555 +#: src/preferences/ui/backgrounds.ui:220 src/preferences/ui/backgrounds.ui:312 +#: src/preferences/ui/commands.ui:206 src/preferences/ui/commands.ui:300 +#: src/preferences/ui/schedule.ui:610 msgid "Clear" msgstr "Effacer" -#: src/prefs.ui:718 -msgid "Button location" -msgstr "Emplacement du bouton" +#: src/preferences/ui/commands.ui:57 +msgid "Run commands" +msgstr "Lancer des commandes" -#: src/prefs.ui:733 -msgid "None" -msgstr "Aucun" +#: src/preferences/ui/commands.ui:70 +msgid "" +"You can set custom commands that will be run when the time of the day " +"changes." +msgstr "" +"Vous pouvez définir des commandes personnalisées qui seront lancées " +"quand le moment du jour change." -#: src/prefs.ui:734 -msgid "Top bar" -msgstr "Barre supérieure" +#: src/preferences/ui/commands.ui:195 +msgid "notify-send \"Hello sunshine!\"" +msgstr "notify-send \"Bonjour!\"" -#: src/prefs.ui:735 -msgid "System menu" -msgstr "Menu système" +#: src/preferences/ui/commands.ui:289 +msgid "notify-send \"Hello moonshine!\"" +msgstr "notify-send \"Bonsoir!\"" -#: src/prefs.ui:773 -msgid "Schedule" -msgstr "Horaires" +#: src/preferences/ui/cursor_theme.ui:125 src/preferences/ui/icon_theme.ui:125 +msgid "Variants" +msgstr "Variantes" -#: src/prefs.ui:893 src/prefs.ui:968 src/prefs.ui:1237 src/prefs.ui:1312 +#: src/preferences/ui/cursor_theme.ui:167 src/preferences/ui/gtk_theme.ui:268 +#: src/preferences/ui/icon_theme.ui:167 src/preferences/ui/shell_theme.ui:268 +msgid "Day variant" +msgstr "Variante diurne" + +#: src/preferences/ui/cursor_theme.ui:226 src/preferences/ui/gtk_theme.ui:327 +#: src/preferences/ui/icon_theme.ui:226 src/preferences/ui/shell_theme.ui:327 +msgid "Night variant" +msgstr "Variante nocturne" + +#: src/preferences/ui/gtk_theme.ui:151 src/preferences/ui/gtk_theme.ui:226 +#: src/preferences/ui/shell_theme.ui:151 src/preferences/ui/shell_theme.ui:226 msgid "Manual variants" msgstr "Variantes manuelles" -#: src/prefs.ui:906 +#: src/preferences/ui/gtk_theme.ui:164 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GTK theme. Please soumettre une requête pour obtenir le support " "de votre thème." -#: src/prefs.ui:1007 src/prefs.ui:1351 src/prefs.ui:1597 src/prefs.ui:1843 -msgid "Day variant" -msgstr "Variante diurne" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:62 +msgid "Press your keyboard shortcut..." +msgstr "Pressez votre raccourci clavier…" -#: src/prefs.ui:1063 src/prefs.ui:1407 src/prefs.ui:1653 src/prefs.ui:1899 -msgid "Night variant" -msgstr "Variante nocturne" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:76 +#: src/preferences/ui/schedule.ui:581 +msgid "Keyboard shortcut" +msgstr "Raccourci clavier" -#: src/prefs.ui:1116 -msgid "GTK theme" -msgstr "Thème GTK" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:79 +msgid "Cancel" +msgstr "Annuler" -#: src/prefs.ui:1165 +#: src/preferences/ui/schedule.ui:82 +msgid "Automatic time source" +msgstr "Source d’horaires automatique" + +#: src/preferences/ui/schedule.ui:95 +msgid "" +"The extension will try to use Night Light or Location Services to " +"automatically set your current sunrise and sunset times if they are enabled. " +"If you prefer, you can manually choose a time source." +msgstr "" +"S’ils sont activés, l’extension tentera d’utiliser le mode nuit ou " +"les services de localisation pour déterminer automatiquement les heures de " +"lever et de coucher du soleil. Si vous préférez, vous pouvez choisir " +"manuellement une source d’horaires." + +#: src/preferences/ui/schedule.ui:158 +msgid "Manual time source" +msgstr "Source d’horaires manuelle" + +#: src/preferences/ui/schedule.ui:178 +msgid "Night Light" +msgstr "Mode nuit" + +#: src/preferences/ui/schedule.ui:193 +msgid "Location Services" +msgstr "Services de localisation" + +#: src/preferences/ui/schedule.ui:208 +msgid "Manual schedule" +msgstr "Horaire manuel" + +#: src/preferences/ui/schedule.ui:223 src/preferences/ui/schedule.ui:539 +#: src/preferences/ui/schedule.ui:719 +msgid "On-demand" +msgstr "À la demande" + +#: src/preferences/ui/schedule.ui:271 +msgid "No preferences" +msgstr "Pas de préférences" + +#: src/preferences/ui/schedule.ui:286 src/preferences/ui/schedule.ui:523 +msgid "Manual schedule times" +msgstr "Horaires manuels" + +#: src/preferences/ui/schedule.ui:328 +msgid "Sunrise" +msgstr "Lever du soleil" + +#: src/preferences/ui/schedule.ui:364 src/preferences/ui/schedule.ui:471 +msgid ":" +msgstr ":" + +#: src/preferences/ui/schedule.ui:435 +msgid "Sunset" +msgstr "Coucher du soleil" + +#: src/preferences/ui/schedule.ui:673 +msgid "Button location" +msgstr "Emplacement du bouton" + +#: src/preferences/ui/schedule.ui:689 +msgid "None" +msgstr "Aucun" + +#: src/preferences/ui/schedule.ui:690 +msgid "Top bar" +msgstr "Barre supérieure" + +#: src/preferences/ui/schedule.ui:691 +msgid "System menu" +msgstr "Menu système" + +#: src/preferences/ui/shell_theme.ui:76 msgid "Switch Shell variants" msgstr "Permuter les variantes Shell" -#: src/prefs.ui:1250 +#: src/preferences/ui/shell_theme.ui:164 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GNOME Shell theme. Please soumettre une requête pour obtenir le " "support de votre thème." -#: src/prefs.ui:1460 -msgid "Shell theme" -msgstr "Thème du shell" - -#: src/prefs.ui:1558 src/prefs.ui:1804 -msgid "Variants" -msgstr "Variantes" - -#: src/prefs.ui:1706 -msgid "Icon theme" -msgstr "Thème d’icônes" - -#: src/prefs.ui:1952 -msgid "Cursor theme" -msgstr "Thème de curseur" - -#: src/prefs.ui:2001 -msgid "Switch backgrounds" -msgstr "Permuter les arrière-plans" - -#: src/prefs.ui:2049 src/prefs.ui:2263 -msgid "Backgrounds" -msgstr "Arrière-plans" - -#: src/prefs.ui:2111 src/prefs.ui:2200 -msgid "Select your background image" -msgstr "Sélectionnez votre image d’arrière-plan" - -#: src/prefs.ui:2318 -msgid "Run commands" -msgstr "Lancer des commandes" - -#: src/prefs.ui:2331 -msgid "" -"You can set custom commands that will be run when the time of the day " -"changes." -msgstr "" -"Vous pouvez définir des commandes personnalisées qui seront lancées " -"quand le moment du jour change." - -#: src/prefs.ui:2393 src/prefs.ui:2611 -msgid "Commands" -msgstr "Commandes" - -#: src/prefs.ui:2453 -msgid "notify-send \"Hello sunshine!\"" -msgstr "notify-send \"Bonjour!\"" - -#: src/prefs.ui:2544 -msgid "notify-send \"Hello moonshine!\"" -msgstr "notify-send \"Bonsoir!\"" - #~ msgid "Original GTK theme" #~ msgstr "Thème GTK original" diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot index 8e3e4e7..df0b3e9 100644 --- a/src/po/nightthemeswitcher@romainvigier.fr.pot +++ b/src/po/nightthemeswitcher@romainvigier.fr.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Night Theme Switcher 37\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-09-23 11:56+0200\n" +"POT-Creation-Date: 2020-09-23 20:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,14 +17,6 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/prefs.js:230 src/prefs.ui:643 -msgid "Choose" -msgstr "" - -#: src/prefs.js:350 -msgid "Default" -msgstr "" - #: src/modules/GtkThemer.js:179 #, javascript-format msgid "" @@ -48,6 +40,42 @@ msgstr "" msgid "Switch to day theme" msgstr "" +#: src/preferences/Backgrounds.js:36 src/preferences/ui/backgrounds.ui:145 +msgid "Backgrounds" +msgstr "" + +#: src/preferences/Commands.js:36 src/preferences/ui/commands.ui:132 +msgid "Commands" +msgstr "" + +#: src/preferences/CursorTheme.js:38 +msgid "Cursor theme" +msgstr "" + +#: src/preferences/GtkTheme.js:38 +msgid "GTK theme" +msgstr "" + +#: src/preferences/IconTheme.js:38 +msgid "Icon theme" +msgstr "" + +#: src/preferences/Schedule.js:38 +msgid "Schedule" +msgstr "" + +#: src/preferences/Schedule.js:193 src/preferences/ui/schedule.ui:595 +msgid "Choose" +msgstr "" + +#: src/preferences/ShellTheme.js:38 +msgid "Shell theme" +msgstr "" + +#: src/preferences/ShellTheme.js:80 +msgid "Default" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 msgid "Settings version" msgstr "" @@ -58,7 +86,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:13 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:6 -#: src/prefs.ui:821 +#: src/preferences/ui/gtk_theme.ui:76 msgid "Switch GTK variants" msgstr "" @@ -139,7 +167,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:57 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:46 -#: src/prefs.ui:1509 +#: src/preferences/ui/icon_theme.ui:76 msgid "Switch icon variants" msgstr "" @@ -170,7 +198,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:74 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:61 -#: src/prefs.ui:1755 +#: src/preferences/ui/cursor_theme.ui:76 msgid "Switch cursor variants" msgstr "" @@ -211,7 +239,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:96 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:131 -#: src/prefs.ui:2432 +#: src/preferences/ui/commands.ui:174 msgid "Sunrise command" msgstr "" @@ -222,7 +250,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:101 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:136 -#: src/prefs.ui:2523 +#: src/preferences/ui/commands.ui:268 msgid "Sunset command" msgstr "" @@ -243,7 +271,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:113 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:146 -#: src/prefs.ui:2088 +#: src/preferences/ui/backgrounds.ui:187 msgid "Day background" msgstr "" @@ -254,7 +282,7 @@ msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:118 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:151 -#: src/prefs.ui:2177 +#: src/preferences/ui/backgrounds.ui:279 msgid "Night background" msgstr "" @@ -333,95 +361,58 @@ msgstr "" msgid "When the day ends" msgstr "" -#: src/prefs.ui:58 -msgid "Press your keyboard shortcut..." +#: src/preferences/ui/backgrounds.ui:97 +msgid "Switch backgrounds" msgstr "" -#: src/prefs.ui:72 src/prefs.ui:629 -msgid "Keyboard shortcut" +#: src/preferences/ui/backgrounds.ui:210 src/preferences/ui/backgrounds.ui:302 +msgid "Select your background image" msgstr "" -#: src/prefs.ui:75 -msgid "Cancel" -msgstr "" - -#: src/prefs.ui:159 -msgid "Automatic time source" -msgstr "" - -#: src/prefs.ui:172 -msgid "" -"The extension will try to use Night Light or Location Services to " -"automatically set your current sunrise and sunset times if they are enabled. " -"If you prefer, you can manually choose a time source." -msgstr "" - -#: src/prefs.ui:236 -msgid "Manual time source" -msgstr "" - -#: src/prefs.ui:256 -msgid "Night Light" -msgstr "" - -#: src/prefs.ui:271 -msgid "Location Services" -msgstr "" - -#: src/prefs.ui:286 -msgid "Manual schedule" -msgstr "" - -#: src/prefs.ui:301 src/prefs.ui:590 -msgid "On-demand" -msgstr "" - -#: src/prefs.ui:343 -msgid "Manual schedule times" -msgstr "" - -#: src/prefs.ui:382 -msgid "Sunrise" -msgstr "" - -#: src/prefs.ui:418 src/prefs.ui:522 -msgid ":" -msgstr "" - -#: src/prefs.ui:486 -msgid "Sunset" -msgstr "" - -#: src/prefs.ui:658 src/prefs.ui:2121 src/prefs.ui:2210 src/prefs.ui:2464 -#: src/prefs.ui:2555 +#: src/preferences/ui/backgrounds.ui:220 src/preferences/ui/backgrounds.ui:312 +#: src/preferences/ui/commands.ui:206 src/preferences/ui/commands.ui:300 +#: src/preferences/ui/schedule.ui:610 msgid "Clear" msgstr "" -#: src/prefs.ui:718 -msgid "Button location" +#: src/preferences/ui/commands.ui:57 +msgid "Run commands" msgstr "" -#: src/prefs.ui:733 -msgid "None" +#: src/preferences/ui/commands.ui:70 +msgid "" +"You can set custom commands that will be run when the time of the day " +"changes." msgstr "" -#: src/prefs.ui:734 -msgid "Top bar" +#: src/preferences/ui/commands.ui:195 +msgid "notify-send \"Hello sunshine!\"" msgstr "" -#: src/prefs.ui:735 -msgid "System menu" +#: src/preferences/ui/commands.ui:289 +msgid "notify-send \"Hello moonshine!\"" msgstr "" -#: src/prefs.ui:773 -msgid "Schedule" +#: src/preferences/ui/cursor_theme.ui:125 src/preferences/ui/icon_theme.ui:125 +msgid "Variants" msgstr "" -#: src/prefs.ui:893 src/prefs.ui:968 src/prefs.ui:1237 src/prefs.ui:1312 +#: src/preferences/ui/cursor_theme.ui:167 src/preferences/ui/gtk_theme.ui:268 +#: src/preferences/ui/icon_theme.ui:167 src/preferences/ui/shell_theme.ui:268 +msgid "Day variant" +msgstr "" + +#: src/preferences/ui/cursor_theme.ui:226 src/preferences/ui/gtk_theme.ui:327 +#: src/preferences/ui/icon_theme.ui:226 src/preferences/ui/shell_theme.ui:327 +msgid "Night variant" +msgstr "" + +#: src/preferences/ui/gtk_theme.ui:151 src/preferences/ui/gtk_theme.ui:226 +#: src/preferences/ui/shell_theme.ui:151 src/preferences/ui/shell_theme.ui:226 msgid "Manual variants" msgstr "" -#: src/prefs.ui:906 +#: src/preferences/ui/gtk_theme.ui:164 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GTK theme. Please submit a request to get your theme supported." msgstr "" -#: src/prefs.ui:1007 src/prefs.ui:1351 src/prefs.ui:1597 src/prefs.ui:1843 -msgid "Day variant" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:62 +msgid "Press your keyboard shortcut..." msgstr "" -#: src/prefs.ui:1063 src/prefs.ui:1407 src/prefs.ui:1653 src/prefs.ui:1899 -msgid "Night variant" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:76 +#: src/preferences/ui/schedule.ui:581 +msgid "Keyboard shortcut" msgstr "" -#: src/prefs.ui:1116 -msgid "GTK theme" +#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:79 +msgid "Cancel" msgstr "" -#: src/prefs.ui:1165 +#: src/preferences/ui/schedule.ui:82 +msgid "Automatic time source" +msgstr "" + +#: src/preferences/ui/schedule.ui:95 +msgid "" +"The extension will try to use Night Light or Location Services to " +"automatically set your current sunrise and sunset times if they are enabled. " +"If you prefer, you can manually choose a time source." +msgstr "" + +#: src/preferences/ui/schedule.ui:158 +msgid "Manual time source" +msgstr "" + +#: src/preferences/ui/schedule.ui:178 +msgid "Night Light" +msgstr "" + +#: src/preferences/ui/schedule.ui:193 +msgid "Location Services" +msgstr "" + +#: src/preferences/ui/schedule.ui:208 +msgid "Manual schedule" +msgstr "" + +#: src/preferences/ui/schedule.ui:223 src/preferences/ui/schedule.ui:539 +#: src/preferences/ui/schedule.ui:719 +msgid "On-demand" +msgstr "" + +#: src/preferences/ui/schedule.ui:271 +msgid "No preferences" +msgstr "" + +#: src/preferences/ui/schedule.ui:286 src/preferences/ui/schedule.ui:523 +msgid "Manual schedule times" +msgstr "" + +#: src/preferences/ui/schedule.ui:328 +msgid "Sunrise" +msgstr "" + +#: src/preferences/ui/schedule.ui:364 src/preferences/ui/schedule.ui:471 +msgid ":" +msgstr "" + +#: src/preferences/ui/schedule.ui:435 +msgid "Sunset" +msgstr "" + +#: src/preferences/ui/schedule.ui:673 +msgid "Button location" +msgstr "" + +#: src/preferences/ui/schedule.ui:689 +msgid "None" +msgstr "" + +#: src/preferences/ui/schedule.ui:690 +msgid "Top bar" +msgstr "" + +#: src/preferences/ui/schedule.ui:691 +msgid "System menu" +msgstr "" + +#: src/preferences/ui/shell_theme.ui:76 msgid "Switch Shell variants" msgstr "" -#: src/prefs.ui:1250 +#: src/preferences/ui/shell_theme.ui:164 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GNOME Shell theme. Please submit a request to get your theme supported." msgstr "" - -#: src/prefs.ui:1460 -msgid "Shell theme" -msgstr "" - -#: src/prefs.ui:1558 src/prefs.ui:1804 -msgid "Variants" -msgstr "" - -#: src/prefs.ui:1706 -msgid "Icon theme" -msgstr "" - -#: src/prefs.ui:1952 -msgid "Cursor theme" -msgstr "" - -#: src/prefs.ui:2001 -msgid "Switch backgrounds" -msgstr "" - -#: src/prefs.ui:2049 src/prefs.ui:2263 -msgid "Backgrounds" -msgstr "" - -#: src/prefs.ui:2111 src/prefs.ui:2200 -msgid "Select your background image" -msgstr "" - -#: src/prefs.ui:2318 -msgid "Run commands" -msgstr "" - -#: src/prefs.ui:2331 -msgid "" -"You can set custom commands that will be run when the time of the day " -"changes." -msgstr "" - -#: src/prefs.ui:2393 src/prefs.ui:2611 -msgid "Commands" -msgstr "" - -#: src/prefs.ui:2453 -msgid "notify-send \"Hello sunshine!\"" -msgstr "" - -#: src/prefs.ui:2544 -msgid "notify-send \"Hello moonshine!\"" -msgstr "" diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js new file mode 100644 index 0000000..1fecd4e --- /dev/null +++ b/src/preferences/Backgrounds.js @@ -0,0 +1,117 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { GdkPixbuf, Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var BackgroundsPreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'backgrounds.ui'])); + + this.widget = this._builder.get_object('backgrounds'); + this.name = 'backgrounds'; + this.title = _('Backgrounds'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.backgrounds.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const choosers = this._builder.get_object('choosers'); + settings.backgrounds.settings.bind( + 'enabled', + choosers, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const dayChooser = this._builder.get_object('day_chooser'); + const dayBackgroundPreview = this._builder.get_object('day_background_preview'); + const updateDayChooserUri = () => { + dayChooser.set_uri(settings.backgrounds.day); + }; + settings.backgrounds.connect('day-changed', () => updateDayChooserUri()); + dayChooser.connect('update-preview', () => { + const file = dayChooser.get_preview_filename(); + const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff']; + if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { + const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); + dayBackgroundPreview.set_from_pixbuf(pixbuf); + } + }); + dayChooser.connect('file-set', () => { + settings.backgrounds.day = dayChooser.get_uri(); + }); + updateDayChooserUri(); + + const dayClearButton = this._builder.get_object('day_clear_button'); + dayClearButton.connect('clicked', () => { + settings.backgrounds.day = ''; + }); + const updateDayClearButtonSensitivity = () => { + dayClearButton.sensitive = !!settings.backgrounds.day; + }; + settings.backgrounds.connect('day-changed', () => updateDayClearButtonSensitivity()); + updateDayClearButtonSensitivity(); + + const nightChooser = this._builder.get_object('night_chooser'); + const nightBackgroundPreview = this._builder.get_object('night_background_preview'); + const updateNightChooserUri = () => { + nightChooser.set_uri(settings.backgrounds.night); + }; + settings.backgrounds.connect('night-changed', () => updateNightChooserUri()); + nightChooser.connect('update-preview', () => { + const file = nightChooser.get_preview_filename(); + const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff']; + if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { + const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); + nightBackgroundPreview.set_from_pixbuf(pixbuf); + } + }); + nightChooser.connect('file-set', () => { + settings.backgrounds.night = nightChooser.get_uri(); + }); + updateNightChooserUri(); + + const nightClearButton = this._builder.get_object('night_clear_button'); + nightClearButton.connect('clicked', () => { + settings.backgrounds.night = ''; + }); + const updateNightClearButtonSensitivity = () => { + nightClearButton.sensitive = !!settings.backgrounds.night; + }; + settings.backgrounds.connect('night-changed', () => updateNightClearButtonSensitivity()); + updateNightClearButtonSensitivity(); + } + +}; diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js new file mode 100644 index 0000000..504398d --- /dev/null +++ b/src/preferences/Commands.js @@ -0,0 +1,95 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var CommandsPreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'commands.ui'])); + + this.widget = this._builder.get_object('commands'); + this.name = 'commands'; + this.title = _('Commands'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.commands.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const entries = this._builder.get_object('entries'); + settings.commands.settings.bind( + 'enabled', + entries, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const sunriseEntry = this._builder.get_object('sunrise_entry'); + settings.commands.settings.bind( + 'sunrise', + sunriseEntry, + 'text', + Gio.SettingsBindFlags.DEFAULT + ); + + const sunriseClearButton = this._builder.get_object('sunrise_clear_button'); + sunriseClearButton.connect('clicked', () => { + settings.commands.sunrise = ''; + }); + const updateSunriseClearButtonSensitivity = () => { + sunriseClearButton.sensitive = !!settings.commands.sunrise; + }; + settings.commands.connect('sunrise-changed', () => updateSunriseClearButtonSensitivity()); + updateSunriseClearButtonSensitivity(); + + const sunsetEntry = this._builder.get_object('sunset_entry'); + settings.commands.settings.bind( + 'sunset', + sunsetEntry, + 'text', + Gio.SettingsBindFlags.DEFAULT + ); + + const sunsetClearButton = this._builder.get_object('sunset_clear_button'); + sunsetClearButton.connect('clicked', () => { + settings.commands.sunset = ''; + }); + const updateSunsetClearButtonSensitivity = () => { + sunsetClearButton.sensitive = !!settings.commands.sunset; + }; + settings.commands.connect('sunset-changed', () => updateSunsetClearButtonSensitivity()); + updateSunsetClearButtonSensitivity(); + } + +}; diff --git a/src/preferences/CursorTheme.js b/src/preferences/CursorTheme.js new file mode 100644 index 0000000..2126df7 --- /dev/null +++ b/src/preferences/CursorTheme.js @@ -0,0 +1,81 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var CursorThemePreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'cursor_theme.ui'])); + + this.widget = this._builder.get_object('cursor_theme'); + this.name = 'cursor-theme'; + this.title = _('Cursor theme'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.cursorVariants.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const variants = this._builder.get_object('variants'); + settings.cursorVariants.settings.bind( + 'enabled', + variants, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const installedCursorThemes = Array.from(utils.getInstalledCursorThemes()).sort(); + const dayCombo = this._builder.get_object('day_combo'); + const nightCombo = this._builder.get_object('night_combo'); + installedCursorThemes.forEach(theme => { + dayCombo.append(theme, theme); + nightCombo.append(theme, theme); + }); + settings.cursorVariants.settings.bind( + 'day', + dayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + settings.cursorVariants.settings.bind( + 'night', + nightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + +}; diff --git a/src/preferences/GtkTheme.js b/src/preferences/GtkTheme.js new file mode 100644 index 0000000..aedc35a --- /dev/null +++ b/src/preferences/GtkTheme.js @@ -0,0 +1,97 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var GtkThemePreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'gtk_theme.ui'])); + + this.widget = this._builder.get_object('gtk_theme'); + this.name = 'gtk-theme'; + this.title = _('GTK theme'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.gtkVariants.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const manual = this._builder.get_object('manual'); + settings.gtkVariants.settings.bind( + 'enabled', + manual, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const manualSwitch = this._builder.get_object('manual_switch'); + settings.gtkVariants.settings.bind( + 'manual', + manualSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const variants = this._builder.get_object('variants'); + const updateVariantsSensitivity = () => { + variants.sensitive = !!(settings.gtkVariants.enabled && settings.gtkVariants.manual); + }; + settings.gtkVariants.connect('status-changed', () => updateVariantsSensitivity()); + settings.gtkVariants.connect('manual-changed', () => updateVariantsSensitivity()); + updateVariantsSensitivity(); + + const dayCombo = this._builder.get_object('day_combo'); + const nightCombo = this._builder.get_object('night_combo'); + const installedGtkThemes = Array.from(utils.getInstalledGtkThemes()).sort(); + installedGtkThemes.forEach(theme => { + dayCombo.append(theme, theme); + nightCombo.append(theme, theme); + }); + settings.gtkVariants.settings.bind( + 'day', + dayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + settings.gtkVariants.settings.bind( + 'night', + nightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + +}; diff --git a/src/preferences/IconTheme.js b/src/preferences/IconTheme.js new file mode 100644 index 0000000..5b3351c --- /dev/null +++ b/src/preferences/IconTheme.js @@ -0,0 +1,81 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var IconThemePreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'icon_theme.ui'])); + + this.widget = this._builder.get_object('icon_theme'); + this.name = 'icon-theme'; + this.title = _('Icon theme'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.iconVariants.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const variants = this._builder.get_object('variants'); + settings.iconVariants.settings.bind( + 'enabled', + variants, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const installedIconThemes = Array.from(utils.getInstalledIconThemes()).sort(); + const dayCombo = this._builder.get_object('day_combo'); + const nightCombo = this._builder.get_object('night_combo'); + installedIconThemes.forEach(theme => { + dayCombo.append(theme, theme); + nightCombo.append(theme, theme); + }); + settings.iconVariants.settings.bind( + 'day', + dayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + settings.iconVariants.settings.bind( + 'night', + nightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + +}; diff --git a/src/preferences/OndemandKeyboardShortcutDialog.js b/src/preferences/OndemandKeyboardShortcutDialog.js new file mode 100644 index 0000000..4bdc963 --- /dev/null +++ b/src/preferences/OndemandKeyboardShortcutDialog.js @@ -0,0 +1,89 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gdk, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + +const utils = Me.imports.utils; + + +var OndemandKeyboardShortcutDialog = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ondemand_keyboard_shortcut_dialog.ui'])); + + this.widget = this._builder.get_object('dialog'); + + this._connectSettings(settings); + + return this.widget; + } + + _connectSettings(settings) { + this.widget.connect('key-press-event', (_widget, event) => { + const state = event.get_state()[1]; + let mask = state & Gtk.accelerator_get_default_mod_mask(); + mask &= ~Gdk.ModifierType.LOCK_MASK; + const keycode = event.get_keycode()[1]; + const eventKeyval = event.get_keyval()[1]; + let keyval = Gdk.keyval_to_lower(eventKeyval); + + if (mask === 0 && keyval === Gdk.KEY_Escape) { + this.widget.visible = false; + return Gdk.EVENT_STOP; + } + + if (keyval === Gdk.KEY_ISO_Left_Tab) + keyval = Gdk.KEY_Tab; + + if (keyval !== eventKeyval) + mask |= Gdk.ModifierType.SHIFT_MASK; + + if (keyval === Gdk.KEY_Sys_Req && (mask & Gdk.ModifierType.MOD1_MASK) !== 0) + keyval = Gdk.KEY_Print; + + if ( + !utils.isBindingValid({ mask, keycode, keyval }) || + !utils.isAccelValid({ mask, keyval }) + ) + return Gdk.EVENT_STOP; + + const binding = Gtk.accelerator_name_with_keycode( + null, + keyval, + keycode, + mask + ); + settings.time.ondemandKeybinding = binding; + this.widget.close(); + return Gdk.EVENT_STOP; + }); + + const cancelButton = this._builder.get_object('cancel_button'); + cancelButton.connect('clicked', () => { + this.widget.close(); + }); + } + +}; diff --git a/src/preferences/Preferences.js b/src/preferences/Preferences.js new file mode 100644 index 0000000..0c8a8cf --- /dev/null +++ b/src/preferences/Preferences.js @@ -0,0 +1,75 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const { Settings } = Me.imports.settings.Settings; + +const { BackgroundsPreferences } = Me.imports.preferences.Backgrounds; +const { CommandsPreferences } = Me.imports.preferences.Commands; +const { CursorThemePreferences } = Me.imports.preferences.CursorTheme; +const { GtkThemePreferences } = Me.imports.preferences.GtkTheme; +const { IconThemePreferences } = Me.imports.preferences.IconTheme; +const { SchedulePreferences } = Me.imports.preferences.Schedule; +const { ShellThemePreferences } = Me.imports.preferences.ShellTheme; + + +var Preferences = class { + + constructor() { + this.settings = new Settings(); + this.settings.enable(); + + this.widget = new Gtk.Stack({ + interpolate_size: true, + vhomogeneous: false, + transition_type: Gtk.StackTransitionType.SLIDE_LEFT_RIGHT, + visible: true, + }); + + const schedulePreferences = new SchedulePreferences(this.settings); + this.widget.add_titled(schedulePreferences.widget, schedulePreferences.name, schedulePreferences.title); + + const gtkThemePreferences = new GtkThemePreferences(this.settings); + this.widget.add_titled(gtkThemePreferences.widget, gtkThemePreferences.name, gtkThemePreferences.title); + + const shellThemePreferences = new ShellThemePreferences(this.settings); + this.widget.add_titled(shellThemePreferences.widget, shellThemePreferences.name, shellThemePreferences.title); + + const iconThemePreferences = new IconThemePreferences(this.settings); + this.widget.add_titled(iconThemePreferences.widget, iconThemePreferences.name, iconThemePreferences.title); + + const cursorThemePreferences = new CursorThemePreferences(this.settings); + this.widget.add_titled(cursorThemePreferences.widget, cursorThemePreferences.name, cursorThemePreferences.title); + + const backgroundsPreferences = new BackgroundsPreferences(this.settings); + this.widget.add_titled(backgroundsPreferences.widget, backgroundsPreferences.name, backgroundsPreferences.title); + + const commandsPreferences = new CommandsPreferences(this.settings); + this.widget.add_titled(commandsPreferences.widget, commandsPreferences.name, commandsPreferences.title); + + this.titlebar = new Gtk.StackSwitcher({ + stack: this.widget, + visible: true, + }); + } + +}; diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js new file mode 100644 index 0000000..3453fe1 --- /dev/null +++ b/src/preferences/Schedule.js @@ -0,0 +1,222 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const { OndemandKeyboardShortcutDialog } = Me.imports.preferences.OndemandKeyboardShortcutDialog; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var SchedulePreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'schedule.ui'])); + + this.widget = this._builder.get_object('schedule'); + this.name = 'schedule'; + this.title = _('Schedule'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const autoSwitch = this._builder.get_object('auto_switch'); + settings.time.settings.bind( + 'manual-time-source', + autoSwitch, + 'active', + Gio.SettingsBindFlags.INVERT_BOOLEAN + ); + + const manual = this._builder.get_object('manual'); + settings.time.settings.bind( + 'manual-time-source', + manual, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const manualNightlightRadio = this._builder.get_object('manual_nightlight_radio'); + const updateManualNightlightRadioActivity = () => { + manualNightlightRadio.active = settings.time.timeSource === 'nightlight'; + }; + settings.time.connect('time-source-changed', () => updateManualNightlightRadioActivity()); + settings.system.colorSettings.bind( + 'night-light-enabled', + manualNightlightRadio, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + manualNightlightRadio.connect('toggled', () => { + if (manualNightlightRadio.active) + settings.time.timeSource = 'nightlight'; + }); + updateManualNightlightRadioActivity(); + + const manualLocationRadio = this._builder.get_object('manual_location_radio'); + const updateManualLocationRadioActivity = () => { + manualLocationRadio.active = settings.time.timeSource === 'location'; + }; + settings.time.connect('time-source-changed', () => updateManualLocationRadioActivity()); + settings.system.locationSettings.bind( + 'enabled', + manualLocationRadio, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + manualLocationRadio.connect('toggled', () => { + if (manualLocationRadio.active) + settings.time.timeSource = 'location'; + }); + updateManualLocationRadioActivity(); + + const manualScheduleRadio = this._builder.get_object('manual_schedule_radio'); + const updateManualScheduleRadioActivity = () => { + manualScheduleRadio.active = settings.time.timeSource === 'schedule'; + }; + settings.time.connect('time-source-changed', () => updateManualScheduleRadioActivity()); + manualScheduleRadio.connect('toggled', () => { + if (manualScheduleRadio.active) + settings.time.timeSource = 'schedule'; + }); + updateManualScheduleRadioActivity(); + + const manualOndemandRadio = this._builder.get_object('manual_ondemand_radio'); + const updateManualOndemandRadioActivity = () => { + manualOndemandRadio.active = settings.time.timeSource === 'ondemand'; + }; + settings.time.connect('time-source-changed', () => updateManualOndemandRadioActivity()); + manualOndemandRadio.connect('toggled', () => { + if (manualOndemandRadio.active) + settings.time.timeSource = 'ondemand'; + }); + updateManualOndemandRadioActivity(); + + const manualPrefsStack = this._builder.get_object('manual_prefs_stack'); + const updateManualPrefsStackVisible = () => { + switch (settings.time.timeSource) { + case 'schedule': + manualPrefsStack.set_visible_child_name('schedule_times'); + break; + case 'ondemand': + manualPrefsStack.set_visible_child_name('ondemand'); + break; + default: + manualPrefsStack.set_visible_child_name('none'); + } + }; + settings.time.connect('time-source-changed', () => updateManualPrefsStackVisible()); + updateManualPrefsStackVisible(); + + const scheduleTimesSunriseHoursSpin = this._builder.get_object('schedule_times_sunrise_hours_spin'); + scheduleTimesSunriseHoursSpin.value = Math.trunc(settings.time.scheduleSunrise); + scheduleTimesSunriseHoursSpin.connect('output', () => { + const text = scheduleTimesSunriseHoursSpin.adjustment.value.toString().padStart(2, '0'); + scheduleTimesSunriseHoursSpin.set_text(text); + return true; + }); + scheduleTimesSunriseHoursSpin.connect('value-changed', () => { + const oldTime = settings.time.scheduleSunrise; + const oldHour = Math.trunc(oldTime); + const newMinutes = oldTime - oldHour; + const newTime = scheduleTimesSunriseHoursSpin.value + newMinutes; + settings.time.scheduleSunrise = newTime; + }); + + const scheduleTimesSunriseMinutesSpin = this._builder.get_object('schedule_times_sunrise_minutes_spin'); + scheduleTimesSunriseMinutesSpin.value = Math.round((settings.time.scheduleSunrise - Math.trunc(settings.time.scheduleSunrise)) * 60); + scheduleTimesSunriseMinutesSpin.connect('output', () => { + const text = scheduleTimesSunriseMinutesSpin.adjustment.value.toString().padStart(2, '0'); + scheduleTimesSunriseMinutesSpin.set_text(text); + return true; + }); + scheduleTimesSunriseMinutesSpin.connect('value-changed', () => { + const hour = Math.trunc(settings.time.scheduleSunrise); + const newMinutes = scheduleTimesSunriseMinutesSpin.value / 60; + const newTime = hour + newMinutes; + settings.time.scheduleSunrise = newTime; + }); + + const scheduleTimesSunsetHoursSpin = this._builder.get_object('schedule_times_sunset_hours_spin'); + scheduleTimesSunsetHoursSpin.value = Math.trunc(settings.time.scheduleSunset); + scheduleTimesSunsetHoursSpin.connect('output', () => { + const text = scheduleTimesSunsetHoursSpin.adjustment.value.toString().padStart(2, '0'); + scheduleTimesSunsetHoursSpin.set_text(text); + return true; + }); + scheduleTimesSunsetHoursSpin.connect('value-changed', () => { + const oldTime = settings.time.scheduleSunset; + const oldHour = Math.trunc(oldTime); + const newMinutes = oldTime - oldHour; + const newTime = scheduleTimesSunsetHoursSpin.value + newMinutes; + settings.time.scheduleSunset = newTime; + }); + + const scheduleTimesSunsetMinutesSpin = this._builder.get_object('schedule_times_sunset_minutes_spin'); + scheduleTimesSunsetMinutesSpin.value = Math.round((settings.time.scheduleSunset - Math.trunc(settings.time.scheduleSunset)) * 60); + scheduleTimesSunsetMinutesSpin.connect('output', () => { + const text = scheduleTimesSunsetMinutesSpin.adjustment.value.toString().padStart(2, '0'); + scheduleTimesSunsetMinutesSpin.set_text(text); + return true; + }); + scheduleTimesSunsetMinutesSpin.connect('value-changed', () => { + const hour = Math.trunc(settings.time.scheduleSunset); + const newMinutes = scheduleTimesSunsetMinutesSpin.value / 60; + const newTime = hour + newMinutes; + settings.time.scheduleSunset = newTime; + }); + + const ondemandShortcutButton = this._builder.get_object('ondemand_shortcut_button'); + const updateOndemandShortcutButtonLabel = () => { + const label = settings.time.ondemandKeybinding; + ondemandShortcutButton.label = label || _('Choose'); + }; + settings.time.connect('ondemand-keybinding-changed', () => updateOndemandShortcutButtonLabel()); + ondemandShortcutButton.connect('clicked', () => { + const dialog = new OndemandKeyboardShortcutDialog(settings); + dialog.set_transient_for(this.widget.get_toplevel()); + dialog.present(); + }); + updateOndemandShortcutButtonLabel(); + + const ondemandShortcutClearButton = this._builder.get_object('ondemand_shortcut_clear_button'); + ondemandShortcutClearButton.connect('clicked', () => { + settings.time.ondemandKeybinding = ''; + }); + const updateOndemandShortcutClearButtonVisibility = () => { + ondemandShortcutClearButton.visible = !!settings.time.ondemandKeybinding; + }; + settings.time.connect('ondemand-keybinding-changed', () => updateOndemandShortcutClearButtonVisibility()); + updateOndemandShortcutClearButtonVisibility(); + + const ondemandButtonPlacementCombo = this._builder.get_object('ondemand_button_placement_combo'); + settings.time.settings.bind( + 'ondemand-button-placement', + ondemandButtonPlacementCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + +}; diff --git a/src/preferences/ShellTheme.js b/src/preferences/ShellTheme.js new file mode 100644 index 0000000..b3ed865 --- /dev/null +++ b/src/preferences/ShellTheme.js @@ -0,0 +1,98 @@ +/* +Night Theme Switcher Gnome Shell extension + +Copyright (C) 2020 Romain Vigier + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +*/ + +const { Gio, GLib, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + + +var ShellThemePreferences = class { + + constructor(settings) { + this._builder = new Gtk.Builder(); + this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'shell_theme.ui'])); + + this.widget = this._builder.get_object('shell_theme'); + this.name = 'shell-theme'; + this.title = _('Shell theme'); + + this._connectSettings(settings); + } + + _connectSettings(settings) { + const enabledSwitch = this._builder.get_object('enabled_switch'); + settings.shellVariants.settings.bind( + 'enabled', + enabledSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const manual = this._builder.get_object('manual'); + settings.shellVariants.settings.bind( + 'enabled', + manual, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const manualSwitch = this._builder.get_object('manual_switch'); + settings.shellVariants.settings.bind( + 'manual', + manualSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const variants = this._builder.get_object('variants'); + const updateVariantsSensitivity = () => { + variants.sensitive = !!(settings.shellVariants.enabled && settings.shellVariants.manual); + }; + settings.shellVariants.connect('status-changed', () => updateVariantsSensitivity()); + settings.shellVariants.connect('manual-changed', () => updateVariantsSensitivity()); + updateVariantsSensitivity(); + + const dayCombo = this._builder.get_object('day_combo'); + const nightCombo = this._builder.get_object('night_combo'); + const installedShellThemes = Array.from(utils.getInstalledShellThemes()).sort(); + installedShellThemes.forEach(theme => { + const themeName = theme === '' ? _('Default') : theme; + dayCombo.append(theme, themeName); + nightCombo.append(theme, themeName); + }); + settings.shellVariants.settings.bind( + 'day', + dayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + settings.shellVariants.settings.bind( + 'night', + nightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + +}; diff --git a/src/preferences/ui/backgrounds.ui b/src/preferences/ui/backgrounds.ui new file mode 100644 index 0000000..0558aa4 --- /dev/null +++ b/src/preferences/ui/backgrounds.ui @@ -0,0 +1,357 @@ + + + + + + + + + + True + False + 256 + image-missing + 0 + + + + image/jpeg + image/png + image/tiff + + + + True + False + 256 + image-missing + 0 + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Switch backgrounds + + + False + True + 0 + + + + + True + True + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 8 + + + True + False + start + Backgrounds + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Day background + + + False + True + 0 + + + + + True + False + end + 8 + + + True + False + end + center + image_filter + day_background_preview + False + Select your background image + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Night background + + + False + True + 0 + + + + + True + False + end + 8 + + + True + False + end + center + image_filter + night_background_preview + False + Select your background image + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 1 + + + + diff --git a/src/preferences/ui/commands.ui b/src/preferences/ui/commands.ui new file mode 100644 index 0000000..fb12fdf --- /dev/null +++ b/src/preferences/ui/commands.ui @@ -0,0 +1,348 @@ + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + vertical + + + True + False + start + Run commands + + + False + True + 0 + + + + + True + False + start + <small>You can set custom commands that will be run when the time of the day changes.</small> + True + True + 50 + 0 + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 8 + + + True + False + start + Commands + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Sunrise command + + + False + True + 0 + + + + + True + False + end + + + True + True + end + center + 28 + True + notify-send "Hello sunshine!" + terminal + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Sunset command + + + False + True + 0 + + + + + True + False + end + + + True + True + end + center + 28 + True + notify-send "Hello moonshine!" + terminal + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 1 + + + + diff --git a/src/preferences/ui/cursor_theme.ui b/src/preferences/ui/cursor_theme.ui new file mode 100644 index 0000000..985e30e --- /dev/null +++ b/src/preferences/ui/cursor_theme.ui @@ -0,0 +1,271 @@ + + + + + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Switch cursor variants + + + False + True + 0 + + + + + True + True + end + center + True + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 8 + + + True + False + start + Variants + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Day variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Night variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 1 + + + + diff --git a/src/preferences/ui/gtk_theme.ui b/src/preferences/ui/gtk_theme.ui new file mode 100644 index 0000000..543fc37 --- /dev/null +++ b/src/preferences/ui/gtk_theme.ui @@ -0,0 +1,372 @@ + + + + + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Switch GTK variants + + + False + True + 0 + + + + + True + True + end + center + True + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + vertical + + + True + False + start + Manual variants + + + False + True + 0 + + + + + True + True + start + <small>You can manually set variants if the extension cannot automatically detect the day and night variants of your GTK theme. Please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a> to get your theme supported.</small> + True + True + 50 + 0 + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + True + False + vertical + 8 + + + True + False + start + Manual variants + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Day variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Night variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 2 + + + + diff --git a/src/preferences/ui/icon_theme.ui b/src/preferences/ui/icon_theme.ui new file mode 100644 index 0000000..12f3731 --- /dev/null +++ b/src/preferences/ui/icon_theme.ui @@ -0,0 +1,271 @@ + + + + + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Switch icon variants + + + False + True + 0 + + + + + True + True + end + center + True + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 8 + + + True + False + start + Variants + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Day variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Night variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 1 + + + + diff --git a/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui b/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui new file mode 100644 index 0000000..bf2ea54 --- /dev/null +++ b/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui @@ -0,0 +1,88 @@ + + + + + + + + + + False + True + 440 + 200 + dialog + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + True + False + Press your keyboard shortcut... + + + True + True + 1 + + + + + + + True + False + Keyboard shortcut + + + Cancel + True + True + True + + + + + + diff --git a/src/preferences/ui/schedule.ui b/src/preferences/ui/schedule.ui new file mode 100644 index 0000000..2974459 --- /dev/null +++ b/src/preferences/ui/schedule.ui @@ -0,0 +1,747 @@ + + + + + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + vertical + + + True + False + start + Automatic time source + + + False + True + 0 + + + + + True + False + start + <small>The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled. If you prefer, you can manually choose a time source.</small> + True + True + 50 + 0 + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + end + center + True + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + vertical + 8 + + + True + False + start + Manual time source + + + + + + False + True + 0 + + + + + 600 + True + False + center + True + + + Night Light + True + True + False + True + False + + + False + True + 0 + + + + + Location Services + True + True + False + False + manual_nightlight_radio + + + False + True + 1 + + + + + Manual schedule + True + True + False + False + manual_nightlight_radio + + + False + True + 2 + + + + + On-demand + True + True + False + False + manual_nightlight_radio + + + False + True + 3 + + + + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + False + crossfade + True + + + True + False + vertical + + + + + + none + No preferences + + + + + 600 + True + False + vertical + 8 + + + True + False + start + Manual schedule times + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Sunrise + + + False + True + 0 + + + + + True + False + end + 8 + + + True + True + 2 + 2 + 0 + vertical + sunrise_hours_adjustment + True + True + + + False + True + 0 + + + + + True + False + : + + + False + True + 1 + + + + + True + True + 2 + 2 + 0 + vertical + sunrise_minutes_adjustment + True + True + + + False + True + 2 + + + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Sunset + + + False + True + 0 + + + + + True + False + end + 8 + + + True + True + 2 + 2 + 0 + vertical + sunset_hours_adjustment + True + True + + + False + True + 0 + + + + + True + False + : + + + False + True + 1 + + + + + True + True + 2 + 2 + 0 + vertical + sunset_minutes_adjustment + True + True + + + False + True + 2 + + + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + schedule_times + Manual schedule times + 1 + + + + + 600 + True + False + vertical + 8 + + + True + False + start + On-demand + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Keyboard shortcut + + + False + True + 0 + + + + + True + False + + + Choose + True + True + True + end + center + + + False + True + 0 + + + + + Clear + True + True + True + + + + False + True + 1 + + + + + + False + False + end + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Button location + + + False + True + 0 + + + + + True + False + end + 1 + panel + + None + Top bar + System menu + + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + ondemand + On-demand + 2 + + + + + False + True + 2 + + + + + 23 + 1 + + + 59 + 1 + + + 23 + 1 + + + 59 + 1 + + diff --git a/src/preferences/ui/shell_theme.ui b/src/preferences/ui/shell_theme.ui new file mode 100644 index 0000000..73f68c2 --- /dev/null +++ b/src/preferences/ui/shell_theme.ui @@ -0,0 +1,372 @@ + + + + + + + + + + 600 + True + False + center + start + 36 + 36 + 36 + 36 + 36 + 36 + vertical + 30 + top + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Switch Shell variants + + + False + True + 0 + + + + + True + True + end + center + True + + + True + True + 1 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + vertical + + + True + False + start + Manual variants + + + False + True + 0 + + + + + True + True + start + <small>You can manually set variants if the extension cannot automatically detect the day and night variants of your GNOME Shell theme. Please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a> to get your theme supported.</small> + True + True + 50 + 0 + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + True + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + True + False + vertical + 8 + + + True + False + start + Manual variants + + + + + + False + True + 0 + + + + + True + False + 0 + + + 600 + True + False + none + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Day variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + True + True + False + False + + + True + False + + + + + + + True + True + False + + + True + False + 16 + 16 + 16 + 16 + 16 + 16 + 30 + + + True + False + Night variant + + + False + True + 0 + + + + + True + False + end + center + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 2 + + + + diff --git a/src/prefs.js b/src/prefs.js index c9ca10d..b8f0d75 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -18,16 +18,13 @@ this program. If not, see . 'use strict'; -const { Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk } = imports.gi; +const { GLib } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); const { compat, utils } = Me.imports; -const { Settings } = Me.imports.settings.Settings; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; +const { Preferences } = Me.imports.preferences.Preferences; function init() { @@ -35,587 +32,12 @@ function init() { } function buildPrefsWidget() { - const prefsWidget = new Preferences(); - return prefsWidget; + const preferences = new Preferences(); + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { + const window = preferences.widget.get_toplevel(); + window.resize(800, 200); + const titlebar = window.get_titlebar(); + titlebar.custom_title = preferences.titlebar; + }); + return preferences.widget; } - - -const Preferences = class { - - constructor() { - // this.settings = compat.getExtensionSettings(); - this.settings = new Settings(); - this.settings.enable(); - // this.colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' }); - // this.locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' }); - - this.builder = new Gtk.Builder(); - this.builder.set_translation_domain(Me.metadata.uuid); - this.builder.add_from_file(GLib.build_filenamev([Me.path, 'prefs.ui'])); - - this.widget = this.builder.get_object('prefs_notebook'); - - this._connectSchedulePreferences(); - this._connectGtkThemePreferences(); - this._connectShellThemePreferences(); - this._connectIconThemePreferences(); - this._connectCursorThemePreferences(); - this._connectBackgroundPreferences(); - this._connectCommandsPreferences(); - this._connectOndemandKeyboardShortcutDialog(); - - return this.widget; - } - - _connectSchedulePreferences() { - const scheduleAutoSwitch = this.builder.get_object('prefs_schedule_auto_switch'); - this.settings.time.settings.bind( - 'manual-time-source', - scheduleAutoSwitch, - 'active', - Gio.SettingsBindFlags.INVERT_BOOLEAN - ); - - const scheduleManualTimeSource = this.builder.get_object('prefs_schedule_manual_time_source'); - this.settings.time.settings.bind( - 'manual-time-source', - scheduleManualTimeSource, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const scheduleManualTimeSourceNightlightRadio = this.builder.get_object('prefs_schedule_manual_time_source_nightlight_radio'); - const updateScheduleManualTimeSourceNightlightRadioActivity = () => { - scheduleManualTimeSourceNightlightRadio.active = this.settings.time.timeSource === 'nightlight'; - }; - this.settings.time.connect('time-source-changed', () => updateScheduleManualTimeSourceNightlightRadioActivity()); - this.settings.system.colorSettings.bind( - 'night-light-enabled', - scheduleManualTimeSourceNightlightRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - scheduleManualTimeSourceNightlightRadio.connect('toggled', () => { - if (scheduleManualTimeSourceNightlightRadio.active) - this.settings.time.timeSource = 'nightlight'; - }); - updateScheduleManualTimeSourceNightlightRadioActivity(); - - const scheduleManualTimeSourceLocationRadio = this.builder.get_object('prefs_schedule_manual_time_source_location_radio'); - const updateScheduleManualTimeSourceLocationRadioActivity = () => { - scheduleManualTimeSourceLocationRadio.active = this.settings.time.timeSource === 'location'; - }; - this.settings.time.connect('time-source-changed', () => updateScheduleManualTimeSourceLocationRadioActivity()); - this.settings.system.locationSettings.bind( - 'enabled', - scheduleManualTimeSourceLocationRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - scheduleManualTimeSourceLocationRadio.connect('toggled', () => { - if (scheduleManualTimeSourceLocationRadio.active) - this.settings.time.timeSource = 'location'; - }); - updateScheduleManualTimeSourceLocationRadioActivity(); - - const scheduleManualTimeSourceManualRadio = this.builder.get_object('prefs_schedule_manual_time_source_manual_radio'); - const updateScheduleManualTimeSourceManualRadioActivity = () => { - scheduleManualTimeSourceManualRadio.active = this.settings.time.timeSource === 'schedule'; - }; - this.settings.time.connect('time-source-changed', () => updateScheduleManualTimeSourceManualRadioActivity()); - scheduleManualTimeSourceManualRadio.connect('toggled', () => { - if (scheduleManualTimeSourceManualRadio.active) - this.settings.time.timeSource = 'schedule'; - }); - updateScheduleManualTimeSourceManualRadioActivity(); - - const scheduleManualTimeSourceOndemandRadio = this.builder.get_object('prefs_schedule_manual_time_source_ondemand_radio'); - const updateScheduleManualTimeSourceOndemandRadioActivity = () => { - scheduleManualTimeSourceOndemandRadio.active = this.settings.time.timeSource === 'ondemand'; - }; - this.settings.time.connect('time-source-changed', () => updateScheduleManualTimeSourceOndemandRadioActivity()); - scheduleManualTimeSourceOndemandRadio.connect('toggled', () => { - if (scheduleManualTimeSourceOndemandRadio.active) - this.settings.time.timeSource = 'ondemand'; - }); - updateScheduleManualTimeSourceOndemandRadioActivity(); - - const scheduleManualScheduleTimes = this.builder.get_object('prefs_schedule_manual_schedule_times'); - const updateScheduleManualScheduleTimesVisibility = () => { - scheduleManualScheduleTimes.visible = this.settings.time.timeSource === 'schedule'; - }; - this.settings.time.settings.bind( - 'manual-time-source', - scheduleManualScheduleTimes, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.time.connect('time-source-changed', () => updateScheduleManualScheduleTimesVisibility()); - updateScheduleManualScheduleTimesVisibility(); - - const scheduleManualScheduleTimesSunriseHoursSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunrise_hours_spin'); - scheduleManualScheduleTimesSunriseHoursSpin.value = Math.trunc(this.settings.time.scheduleSunrise); - scheduleManualScheduleTimesSunriseHoursSpin.connect('output', () => { - const text = scheduleManualScheduleTimesSunriseHoursSpin.adjustment.value.toString().padStart(2, '0'); - scheduleManualScheduleTimesSunriseHoursSpin.set_text(text); - return true; - }); - scheduleManualScheduleTimesSunriseHoursSpin.connect('value-changed', () => { - const oldTime = this.settings.time.scheduleSunrise; - const oldHour = Math.trunc(oldTime); - const newMinutes = oldTime - oldHour; - const newTime = scheduleManualScheduleTimesSunriseHoursSpin.value + newMinutes; - this.settings.time.scheduleSunrise = newTime; - }); - - const scheduleManualScheduleTimesSunriseMinutesSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunrise_minutes_spin'); - scheduleManualScheduleTimesSunriseMinutesSpin.value = Math.round((this.settings.time.scheduleSunrise - Math.trunc(this.settings.time.scheduleSunrise)) * 60); - scheduleManualScheduleTimesSunriseMinutesSpin.connect('output', () => { - const text = scheduleManualScheduleTimesSunriseMinutesSpin.adjustment.value.toString().padStart(2, '0'); - scheduleManualScheduleTimesSunriseMinutesSpin.set_text(text); - return true; - }); - scheduleManualScheduleTimesSunriseMinutesSpin.connect('value-changed', () => { - const hour = Math.trunc(this.settings.time.scheduleSunrise); - const newMinutes = scheduleManualScheduleTimesSunriseMinutesSpin.value / 60; - const newTime = hour + newMinutes; - this.settings.time.scheduleSunrise = newTime; - }); - - const scheduleManualScheduleTimesSunsetHoursSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunset_hours_spin'); - scheduleManualScheduleTimesSunsetHoursSpin.value = Math.trunc(this.settings.time.scheduleSunset); - scheduleManualScheduleTimesSunsetHoursSpin.connect('output', () => { - const text = scheduleManualScheduleTimesSunsetHoursSpin.adjustment.value.toString().padStart(2, '0'); - scheduleManualScheduleTimesSunsetHoursSpin.set_text(text); - return true; - }); - scheduleManualScheduleTimesSunsetHoursSpin.connect('value-changed', () => { - const oldTime = this.settings.time.scheduleSunset; - const oldHour = Math.trunc(oldTime); - const newMinutes = oldTime - oldHour; - const newTime = scheduleManualScheduleTimesSunsetHoursSpin.value + newMinutes; - this.settings.time.scheduleSunset = newTime; - }); - - const scheduleManualScheduleTimesSunsetMinutesSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunset_minutes_spin'); - scheduleManualScheduleTimesSunsetMinutesSpin.value = Math.round((this.settings.time.scheduleSunset - Math.trunc(this.settings.time.scheduleSunset)) * 60); - scheduleManualScheduleTimesSunsetMinutesSpin.connect('output', () => { - const text = scheduleManualScheduleTimesSunsetMinutesSpin.adjustment.value.toString().padStart(2, '0'); - scheduleManualScheduleTimesSunsetMinutesSpin.set_text(text); - return true; - }); - scheduleManualScheduleTimesSunsetMinutesSpin.connect('value-changed', () => { - const hour = Math.trunc(this.settings.time.scheduleSunset); - const newMinutes = scheduleManualScheduleTimesSunsetMinutesSpin.value / 60; - const newTime = hour + newMinutes; - this.settings.time.scheduleSunset = newTime; - }); - - const scheduleOndemand = this.builder.get_object('prefs_schedule_ondemand'); - const updateScheduleOndemandVisibility = () => { - scheduleOndemand.visible = this.settings.time.timeSource === 'ondemand'; - }; - this.settings.time.settings.bind( - 'manual-time-source', - scheduleOndemand, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.time.connect('time-source-changed', () => updateScheduleOndemandVisibility()); - updateScheduleOndemandVisibility(); - - const scheduleOndemandShortcutButton = this.builder.get_object('prefs_schedule_ondemand_shortcut_button'); - const updateScheduleOndemandShortcutButtonLabel = () => { - const label = this.settings.time.ondemandKeybinding; - scheduleOndemandShortcutButton.label = label || _('Choose'); - }; - this.settings.time.connect('ondemand-keybinding-changed', () => updateScheduleOndemandShortcutButtonLabel()); - scheduleOndemandShortcutButton.connect('clicked', () => { - const dialog = this.builder.get_object('ondemand_keyboard_shortcut_dialog'); - dialog.set_transient_for(this.widget.get_toplevel()); - dialog.show_all(); - }); - updateScheduleOndemandShortcutButtonLabel(); - - const scheduleOndemandShortcutClearButton = this.builder.get_object('prefs_schedule_ondemand_shortcut_clear_button'); - scheduleOndemandShortcutClearButton.connect('clicked', () => { - this.settings.time.ondemandKeybinding = ''; - }); - const updateScheduleOndemandShortcutClearButtonVisibility = () => { - scheduleOndemandShortcutClearButton.visible = !!this.settings.time.ondemandKeybinding; - }; - this.settings.time.connect('ondemand-keybinding-changed', () => updateScheduleOndemandShortcutClearButtonVisibility()); - updateScheduleOndemandShortcutClearButtonVisibility(); - - const scheduleOndemandButtonPlacementCombo = this.builder.get_object('prefs_schedule_ondemand_button_placement_combo'); - this.settings.time.settings.bind( - 'ondemand-button-placement', - scheduleOndemandButtonPlacementCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } - - _connectGtkThemePreferences() { - const gtkThemeSwitchVariantsSwitch = this.builder.get_object('prefs_gtk_theme_switch_variants_switch'); - this.settings.gtkVariants.settings.bind( - 'enabled', - gtkThemeSwitchVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const gtkThemeManualVariants = this.builder.get_object('prefs_gtk_theme_manual_variants'); - this.settings.gtkVariants.settings.bind( - 'enabled', - gtkThemeManualVariants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const gtkThemeManualVariantsSwitch = this.builder.get_object('prefs_gtk_theme_manual_variants_switch'); - this.settings.gtkVariants.settings.bind( - 'manual', - gtkThemeManualVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const gtkThemeVariants = this.builder.get_object('prefs_gtk_theme_variants'); - const updateGtkThemeVariantsSensitivity = () => { - gtkThemeVariants.sensitive = !!(this.settings.gtkVariants.enabled && this.settings.gtkVariants.manual); - }; - this.settings.gtkVariants.connect('status-changed', () => updateGtkThemeVariantsSensitivity()); - this.settings.gtkVariants.connect('manual-changed', () => updateGtkThemeVariantsSensitivity()); - updateGtkThemeVariantsSensitivity(); - - const gtkThemeVariantsDayCombo = this.builder.get_object('prefs_gtk_theme_variants_day_combo'); - const gtkThemeVariantsNightCombo = this.builder.get_object('prefs_gtk_theme_variants_night_combo'); - const installedGtkThemes = Array.from(utils.getInstalledGtkThemes()).sort(); - installedGtkThemes.forEach(theme => { - gtkThemeVariantsDayCombo.append(theme, theme); - gtkThemeVariantsNightCombo.append(theme, theme); - }); - this.settings.gtkVariants.settings.bind( - 'day', - gtkThemeVariantsDayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.gtkVariants.settings.bind( - 'night', - gtkThemeVariantsNightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } - - _connectShellThemePreferences() { - const shellThemeSwitchVariantsSwitch = this.builder.get_object('prefs_shell_theme_switch_variants_switch'); - this.settings.shellVariants.settings.bind( - 'enabled', - shellThemeSwitchVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const shellThemeManualVariants = this.builder.get_object('prefs_shell_theme_manual_variants'); - this.settings.shellVariants.settings.bind( - 'enabled', - shellThemeManualVariants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const shellThemeManualVariantsSwitch = this.builder.get_object('prefs_shell_theme_manual_variants_switch'); - this.settings.shellVariants.settings.bind( - 'manual', - shellThemeManualVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const shellThemeVariants = this.builder.get_object('prefs_shell_theme_variants'); - const updateShellThemeVariantsSensitivity = () => { - shellThemeVariants.sensitive = !!(this.settings.shellVariants.enabled && this.settings.shellVariants.manual); - }; - this.settings.shellVariants.connect('status-changed', () => updateShellThemeVariantsSensitivity()); - this.settings.shellVariants.connect('manual-changed', () => updateShellThemeVariantsSensitivity()); - updateShellThemeVariantsSensitivity(); - - const shellThemeVariantsDayCombo = this.builder.get_object('prefs_shell_theme_variants_day_combo'); - const shellThemeVariantsNightCombo = this.builder.get_object('prefs_shell_theme_variants_night_combo'); - const installedShellThemes = Array.from(utils.getInstalledShellThemes()).sort(); - installedShellThemes.forEach(theme => { - const themeName = theme === '' ? _('Default') : theme; - shellThemeVariantsDayCombo.append(theme, themeName); - shellThemeVariantsNightCombo.append(theme, themeName); - }); - this.settings.shellVariants.settings.bind( - 'day', - shellThemeVariantsDayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.shellVariants.settings.bind( - 'night', - shellThemeVariantsNightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } - - _connectIconThemePreferences() { - const iconThemeSwitchVariantsSwitch = this.builder.get_object('prefs_icon_theme_switch_variants_switch'); - this.settings.iconVariants.settings.bind( - 'enabled', - iconThemeSwitchVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const iconThemeVariants = this.builder.get_object('prefs_icon_theme_variants'); - this.settings.iconVariants.settings.bind( - 'enabled', - iconThemeVariants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const installedIconThemes = Array.from(utils.getInstalledIconThemes()).sort(); - const iconThemeVariantsDayCombo = this.builder.get_object('prefs_icon_theme_variants_day_combo'); - const iconThemeVariantsNightCombo = this.builder.get_object('prefs_icon_theme_variants_night_combo'); - installedIconThemes.forEach(theme => { - iconThemeVariantsDayCombo.append(theme, theme); - iconThemeVariantsNightCombo.append(theme, theme); - }); - this.settings.iconVariants.settings.bind( - 'day', - iconThemeVariantsDayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.iconVariants.settings.bind( - 'night', - iconThemeVariantsNightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } - - _connectCursorThemePreferences() { - const cursorThemeSwitchVariantsSwitch = this.builder.get_object('prefs_cursor_theme_switch_variants_switch'); - this.settings.cursorVariants.settings.bind( - 'enabled', - cursorThemeSwitchVariantsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const cursorThemeVariants = this.builder.get_object('prefs_cursor_theme_variants'); - this.settings.cursorVariants.settings.bind( - 'enabled', - cursorThemeVariants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const installedCursorThemes = Array.from(utils.getInstalledCursorThemes()).sort(); - const cursorThemeVariantsDayCombo = this.builder.get_object('prefs_cursor_theme_variants_day_combo'); - const cursorThemeVariantsNightCombo = this.builder.get_object('prefs_cursor_theme_variants_night_combo'); - installedCursorThemes.forEach(theme => { - cursorThemeVariantsDayCombo.append(theme, theme); - cursorThemeVariantsNightCombo.append(theme, theme); - }); - this.settings.cursorVariants.settings.bind( - 'day', - cursorThemeVariantsDayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - this.settings.cursorVariants.settings.bind( - 'night', - cursorThemeVariantsNightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } - - _connectBackgroundPreferences() { - const backgroundSwitchBackgroundsSwitch = this.builder.get_object('prefs_backgrounds_switch_backgrounds_switch'); - this.settings.backgrounds.settings.bind( - 'enabled', - backgroundSwitchBackgroundsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const backgroundsBackgrounds = this.builder.get_object('prefs_backgrounds_backgrounds'); - this.settings.backgrounds.settings.bind( - 'enabled', - backgroundsBackgrounds, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const backgroundsBackgroundsDayBackgroundButton = this.builder.get_object('prefs_backgrounds_backgrounds_day_background_button'); - const dayBackgroundPreview = this.builder.get_object('day_background_preview'); - const updateBackgroundsBackgroundsDayBackgroundButtonUri = () => { - backgroundsBackgroundsDayBackgroundButton.set_uri(this.settings.backgrounds.day); - }; - this.settings.backgrounds.connect('day-changed', () => updateBackgroundsBackgroundsDayBackgroundButtonUri()); - backgroundsBackgroundsDayBackgroundButton.connect('update-preview', () => { - const file = backgroundsBackgroundsDayBackgroundButton.get_preview_filename(); - const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff']; - if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { - const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); - dayBackgroundPreview.set_from_pixbuf(pixbuf); - } - }); - backgroundsBackgroundsDayBackgroundButton.connect('file-set', () => { - this.settings.backgrounds.day = backgroundsBackgroundsDayBackgroundButton.get_uri(); - }); - updateBackgroundsBackgroundsDayBackgroundButtonUri(); - - const backgroundsBackgroundsDayBackgroundClearButton = this.builder.get_object('prefs_backgrounds_backgrounds_day_background_clear_button'); - backgroundsBackgroundsDayBackgroundClearButton.connect('clicked', () => { - this.settings.backgrounds.day = ''; - }); - const updateBackgroundsBackgroundsDayBackgroundClearButtonSensitivity = () => { - backgroundsBackgroundsDayBackgroundClearButton.sensitive = !!this.settings.backgrounds.day; - }; - this.settings.backgrounds.connect('day-changed', () => updateBackgroundsBackgroundsDayBackgroundClearButtonSensitivity()); - updateBackgroundsBackgroundsDayBackgroundClearButtonSensitivity(); - - const backgroundsBackgroundsNightBackgroundButton = this.builder.get_object('prefs_backgrounds_backgrounds_night_background_button'); - const nightBackgroundPreview = this.builder.get_object('night_background_preview'); - const updateBackgroundsBackgroundsNightBackgroundButtonUri = () => { - backgroundsBackgroundsNightBackgroundButton.set_uri(this.settings.backgrounds.night); - }; - this.settings.backgrounds.connect('night-changed', () => updateBackgroundsBackgroundsNightBackgroundButtonUri()); - backgroundsBackgroundsNightBackgroundButton.connect('update-preview', () => { - const file = backgroundsBackgroundsNightBackgroundButton.get_preview_filename(); - const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff']; - if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { - const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); - nightBackgroundPreview.set_from_pixbuf(pixbuf); - } - }); - backgroundsBackgroundsNightBackgroundButton.connect('file-set', () => { - this.settings.backgrounds.night = backgroundsBackgroundsNightBackgroundButton.get_uri(); - }); - updateBackgroundsBackgroundsNightBackgroundButtonUri(); - - const backgroundsBackgroundsNightBackgroundClearButton = this.builder.get_object('prefs_backgrounds_backgrounds_night_background_clear_button'); - backgroundsBackgroundsNightBackgroundClearButton.connect('clicked', () => { - this.settings.backgrounds.night = ''; - }); - const updateBackgroundsBackgroundsNightBackgroundClearButtonSensitivity = () => { - backgroundsBackgroundsNightBackgroundClearButton.sensitive = !!this.settings.backgrounds.night; - }; - this.settings.backgrounds.connect('night-changed', () => updateBackgroundsBackgroundsNightBackgroundClearButtonSensitivity()); - updateBackgroundsBackgroundsNightBackgroundClearButtonSensitivity(); - } - - _connectCommandsPreferences() { - const commandsSwitchCommandsSwitch = this.builder.get_object('prefs_commands_switch_commands_switch'); - this.settings.commands.settings.bind( - 'enabled', - commandsSwitchCommandsSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const commandsCommands = this.builder.get_object('prefs_commands_commands'); - this.settings.commands.settings.bind( - 'enabled', - commandsCommands, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const commandsCommandsSunriseCommandEntry = this.builder.get_object('prefs_commands_commands_sunrise_command_entry'); - this.settings.commands.settings.bind( - 'sunrise', - commandsCommandsSunriseCommandEntry, - 'text', - Gio.SettingsBindFlags.DEFAULT - ); - - const commandsCommandsSunriseCommandClearButton = this.builder.get_object('prefs_commands_commands_sunrise_command_clear_button'); - commandsCommandsSunriseCommandClearButton.connect('clicked', () => { - this.settings.commands.sunrise = ''; - }); - const updateCommandsCommandsSunriseCommandClearButtonSensitivity = () => { - commandsCommandsSunriseCommandClearButton.sensitive = !!this.settings.commands.sunrise; - }; - this.settings.commands.connect('sunrise-changed', () => updateCommandsCommandsSunriseCommandClearButtonSensitivity()); - updateCommandsCommandsSunriseCommandClearButtonSensitivity(); - - const commandsCommandsSunsetCommandEntry = this.builder.get_object('prefs_commands_commands_sunset_command_entry'); - this.settings.commands.settings.bind( - 'sunset', - commandsCommandsSunsetCommandEntry, - 'text', - Gio.SettingsBindFlags.DEFAULT - ); - - const commandsCommandsSunsetCommandClearButton = this.builder.get_object('prefs_commands_commands_sunset_command_clear_button'); - commandsCommandsSunsetCommandClearButton.connect('clicked', () => { - this.settings.commands.sunset = ''; - }); - const updateCommandsCommandsSunsetCommandClearButtonSensitivity = () => { - commandsCommandsSunsetCommandClearButton.sensitive = !!this.settings.commands.sunset; - }; - this.settings.commands.connect('sunset-changed', () => updateCommandsCommandsSunsetCommandClearButtonSensitivity()); - updateCommandsCommandsSunsetCommandClearButtonSensitivity(); - } - - _connectOndemandKeyboardShortcutDialog() { - const ondemandKeyboardShortcutDialog = this.builder.get_object('ondemand_keyboard_shortcut_dialog'); - ondemandKeyboardShortcutDialog.connect('key-press-event', (_widget, event) => { - const state = event.get_state()[1]; - let mask = state & Gtk.accelerator_get_default_mod_mask(); - mask &= ~Gdk.ModifierType.LOCK_MASK; - const keycode = event.get_keycode()[1]; - const eventKeyval = event.get_keyval()[1]; - let keyval = Gdk.keyval_to_lower(eventKeyval); - - if (mask === 0 && keyval === Gdk.KEY_Escape) { - ondemandKeyboardShortcutDialog.visible = false; - return Gdk.EVENT_STOP; - } - - if (keyval === Gdk.KEY_ISO_Left_Tab) - keyval = Gdk.KEY_Tab; - - if (keyval !== eventKeyval) - mask |= Gdk.ModifierType.SHIFT_MASK; - - if (keyval === Gdk.KEY_Sys_Req && (mask & Gdk.ModifierType.MOD1_MASK) !== 0) - keyval = Gdk.KEY_Print; - - if ( - !utils.isBindingValid({ mask, keycode, keyval }) || - !utils.isAccelValid({ mask, keyval }) - ) - return Gdk.EVENT_STOP; - - const binding = Gtk.accelerator_name_with_keycode( - null, - keyval, - keycode, - mask - ); - this.settings.time.ondemandKeybinding = binding; - ondemandKeyboardShortcutDialog.visible = false; - return Gdk.EVENT_STOP; - }); - - const ondemandKeyboardShortcutDialogCancelButton = this.builder.get_object('ondemand_keyboard_shortcut_dialog_cancel_button'); - ondemandKeyboardShortcutDialogCancelButton.connect('clicked', () => { - ondemandKeyboardShortcutDialog.visible = false; - }); - } - -}; diff --git a/src/prefs.ui b/src/prefs.ui deleted file mode 100644 index 71acbd1..0000000 --- a/src/prefs.ui +++ /dev/null @@ -1,2619 +0,0 @@ - - - - - - True - False - 256 - image-missing - 0 - - - - image/jpeg - image/png - image/tiff - - - - True - False - 256 - image-missing - 0 - - - False - True - 440 - 200 - dialog - - - False - vertical - 2 - - - False - end - - - - - - - - - False - False - 0 - - - - - True - False - Press your keyboard shortcut... - - - True - True - 1 - - - - - - - True - False - Keyboard shortcut - - - Cancel - True - True - True - - - - - - - 23 - 1 - - - 59 - 1 - - - 23 - 1 - - - 59 - 1 - - - -1 - True - True - center - start - 16 - 16 - 16 - 16 - True - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - vertical - - - True - False - start - Automatic time source - - - False - True - 0 - - - - - True - True - start - <small>The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled. If you prefer, you can manually choose a time source.</small> - True - True - 50 - 0 - - - - False - False - 1 - - - - - False - True - 0 - - - - - True - True - end - center - True - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - vertical - 8 - - - True - False - start - Manual time source - - - - - - False - True - 0 - - - - - 600 - True - False - center - True - - - Night Light - True - True - False - True - False - - - False - True - 0 - - - - - Location Services - True - True - False - False - prefs_schedule_manual_time_source_nightlight_radio - - - False - True - 1 - - - - - Manual schedule - True - True - False - False - prefs_schedule_manual_time_source_nightlight_radio - - - False - True - 2 - - - - - On-demand - True - True - False - False - prefs_schedule_manual_time_source_nightlight_radio - - - False - True - 3 - - - - - - False - True - 1 - - - - - False - True - 1 - - - - - 600 - True - False - vertical - 8 - - - True - False - start - Manual schedule times - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunrise - - - False - True - 0 - - - - - True - False - end - 8 - - - True - True - 2 - 2 - 00 - vertical - sunrise_hours_adjustment - True - True - - - False - True - 0 - - - - - True - False - : - - - False - True - 1 - - - - - True - True - 2 - 2 - 00 - vertical - sunrise_minutes_adjustment - True - True - - - False - True - 2 - - - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunset - - - False - True - 0 - - - - - True - False - end - 8 - - - True - True - 2 - 2 - 00 - vertical - sunset_hours_adjustment - True - True - - - False - True - 0 - - - - - True - False - : - - - False - True - 1 - - - - - True - True - 2 - 2 - 00 - vertical - sunset_minutes_adjustment - True - True - - - False - True - 2 - - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 2 - - - - - 600 - True - False - vertical - 8 - - - True - False - start - On-demand - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Keyboard shortcut - - - False - True - 0 - - - - - True - False - - - Choose - True - True - True - end - center - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - - False - False - end - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Button location - - - False - True - 0 - - - - - True - False - end - panel - - None - Top bar - System menu - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 3 - - - - - - - True - False - Schedule - - - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Switch GTK variants - - - False - True - 0 - - - - - True - True - end - center - True - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - vertical - - - True - False - start - Manual variants - - - False - True - 0 - - - - - True - False - start - <small>You can manually set variants if the extension cannot automatically detect the day and night variants of your GTK theme. Please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a> to get your theme supported.</small> - True - True - 50 - 0 - - - - False - False - 1 - - - - - False - True - 0 - - - - - True - True - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - True - False - vertical - 8 - - - True - False - start - Manual variants - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Day variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Night variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 2 - - - - - 1 - - - - - True - False - GTK theme - - - 1 - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Switch Shell variants - - - False - True - 0 - - - - - True - True - end - center - True - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - vertical - - - True - False - start - Manual variants - - - False - True - 0 - - - - - True - True - start - <small>You can manually set variants if the extension cannot automatically detect the day and night variants of your GNOME Shell theme. Please <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a> to get your theme supported.</small> - True - True - 50 - 0 - - - - False - False - 1 - - - - - False - True - 0 - - - - - True - True - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - True - False - vertical - 8 - - - True - False - start - Manual variants - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Day variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Night variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 2 - - - - - 2 - - - - - True - False - Shell theme - - - 2 - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Switch icon variants - - - False - True - 0 - - - - - True - True - end - center - True - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - vertical - 8 - - - True - False - start - Variants - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Day variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Night variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 1 - - - - - 3 - - - - - True - False - Icon theme - - - 3 - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Switch cursor variants - - - False - True - 0 - - - - - True - True - end - center - True - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - vertical - 8 - - - True - False - start - Variants - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Day variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Night variant - - - False - True - 0 - - - - - True - False - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 1 - - - - - 4 - - - - - True - False - Cursor theme - - - 4 - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Switch backgrounds - - - False - True - 0 - - - - - True - True - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - vertical - 8 - - - True - False - start - Backgrounds - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Day background - - - False - True - 0 - - - - - True - False - end - 8 - - - True - False - end - center - image_filter - day_background_preview - False - Select your background image - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Night background - - - False - True - 0 - - - - - True - False - end - 8 - - - True - False - end - center - image_filter - night_background_preview - False - Select your background image - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 1 - - - - - 5 - - - - - True - False - Backgrounds - - - 5 - False - - - - - 600 - True - False - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - vertical - - - True - False - start - Run commands - - - False - True - 0 - - - - - True - False - start - <small>You can set custom commands that will be run when the time of the day changes.</small> - True - True - 50 - 0 - - - - False - False - 1 - - - - - False - True - 0 - - - - - True - True - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - vertical - 8 - - - True - False - start - Commands - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunrise command - - - False - True - 0 - - - - - True - False - end - - - True - True - end - center - 28 - True - notify-send "Hello sunshine!" - terminal - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - - - True - False - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunset command - - - False - True - 0 - - - - - True - False - end - - - True - True - end - center - 28 - True - notify-send "Hello moonshine!" - terminal - - - False - True - 0 - - - - - Clear - True - True - True - - - - False - True - 1 - - - - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - - False - True - 1 - - - - - 6 - - - - - True - False - Commands - - - 6 - False - - - -