From e477be9ae61cad899ba29990099b42dedc141eb9 Mon Sep 17 00:00:00 2001 From: Romain Date: Mon, 3 Aug 2020 20:11:47 +0000 Subject: [PATCH] Build preferences from UI file --- Makefile | 4 +- src/po/fr.po | 490 ++-- src/po/nightthemeswitcher@romainvigier.fr.pot | 371 +-- src/preferences/Backgrounds.js | 118 - src/preferences/Commands.js | 106 - src/preferences/CursorTheme.js | 102 - src/preferences/GtkTheme.js | 126 - src/preferences/IconTheme.js | 102 - src/preferences/Schedule.js | 306 --- src/preferences/ShellTheme.js | 126 - src/preferences/bases.js | 109 - src/prefs.js | 567 +++- src/prefs.ui | 2431 +++++++++++++++++ src/utils.js | 45 +- 14 files changed, 3485 insertions(+), 1518 deletions(-) delete mode 100644 src/preferences/Backgrounds.js delete mode 100644 src/preferences/Commands.js delete mode 100644 src/preferences/CursorTheme.js delete mode 100644 src/preferences/GtkTheme.js delete mode 100644 src/preferences/IconTheme.js delete mode 100644 src/preferences/Schedule.js delete mode 100644 src/preferences/ShellTheme.js delete mode 100644 src/preferences/bases.js create mode 100644 src/prefs.ui diff --git a/Makefile b/Makefile index af78546..089d57d 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/ \ --podir=./po/ \ --gettext-domain=$(UUID) \ @@ -85,7 +85,7 @@ pot: --package-name="$(NAME)" \ --package-version="$(VERSION)" \ --output=./src/po/$(UUID).pot \ - ./src/*.js ./src/**/*.js ./src/**/*.xml + ./src/*.js ./src/**/*.js ./src/**/*.xml ./src/*.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 83aef70..8bb38f1 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-06-15 17:50+0200\n" -"PO-Revision-Date: 2020-06-15 17:56+0200\n" +"POT-Creation-Date: 2020-08-03 20:16+0200\n" +"PO-Revision-Date: 2020-08-03 20:18+0200\n" "Last-Translator: Romain Vigier \n" "Language-Team: French - France \n" "Language: fr_FR\n" @@ -18,7 +18,15 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1)\n" "X-Generator: Gtranslator 3.36.0\n" -#: src/modules/GtkThemer.js:175 +#: src/prefs.js:212 src/prefs.ui:644 +msgid "Choose" +msgstr "Choisir" + +#: src/prefs.js:324 +msgid "Default" +msgstr "Par défaut" + +#: src/modules/GtkThemer.js:176 #, javascript-format msgid "" "Unable to automatically detect the day and night variants for the \"%s\" GTK " @@ -28,7 +36,7 @@ msgstr "" "pour le thème GTK \"%s\". Veuillez les sélectionner manuellement dans les " "préférences de l’extension." -#: src/modules/ShellThemer.js:182 +#: src/modules/ShellThemer.js:183 #, javascript-format msgid "" "Unable to automatically detect the day and night variants for the \"%s\" " @@ -39,209 +47,11 @@ msgstr "" "pour le thème GNOME Shell \"%s\". Veuillez les sélectionner manuellement " "dans les préférences de l’extension." -#: src/preferences/Backgrounds.js:41 -msgid "Backgrounds" -msgstr "Arrière-plans" - -#: src/preferences/Backgrounds.js:42 -msgid "You can set different backgrounds for day and night." -msgstr "Vous pouvez définir des arrière-plans diurnes et nocturnes différents." - -#: src/preferences/Backgrounds.js:45 -msgid "Switch backgrounds" -msgstr "Permuter les arrière-plans" - -#: src/preferences/Backgrounds.js:47 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 -msgid "Day background" -msgstr "Arrière-plan diurne" - -#: src/preferences/Backgrounds.js:56 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 -msgid "Night background" -msgstr "Arrière-plan nocturne" - -#: src/preferences/Backgrounds.js:105 -msgid "Select your background image" -msgstr "Sélectionnez votre image d’arrière-plan" - -#: src/preferences/Commands.js:41 -msgid "Commands" -msgstr "Commandes" - -#: src/preferences/Commands.js:42 -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 au " -"moment du changement." - -#: src/preferences/Commands.js:45 -msgid "Use custom commands" -msgstr "Utiliser des commandes personnalisées" - -#: src/preferences/Commands.js:47 src/preferences/Schedule.js:63 -msgid "Sunrise" -msgstr "Lever du soleil" - -#: src/preferences/Commands.js:56 src/preferences/Schedule.js:70 -msgid "Sunset" -msgstr "Coucher du soleil" - -#: src/preferences/Commands.js:94 -msgid "Hello sunshine!" -msgstr "Bonjour!" - -#: src/preferences/Commands.js:95 -msgid "Hello moonshine!" -msgstr "Bonsoir!" - -#: src/preferences/CursorTheme.js:42 -msgid "Cursor theme" -msgstr "Thème de curseur" - -#: src/preferences/CursorTheme.js:43 -msgid "You can set different cursor themes for day and night." -msgstr "" -"Vous pouvez définir des thèmes de curseurs diurnes et nocturnes différents." - -#: src/preferences/CursorTheme.js:46 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 -msgid "Switch cursor variants" -msgstr "Permuter les variantes de curseur" - -#: src/preferences/CursorTheme.js:48 src/preferences/GtkTheme.js:57 -#: src/preferences/IconTheme.js:48 src/preferences/ShellTheme.js:57 -msgid "Day variant" -msgstr "Variante diurne" - -#: src/preferences/CursorTheme.js:57 src/preferences/GtkTheme.js:64 -#: src/preferences/IconTheme.js:57 src/preferences/ShellTheme.js:64 -msgid "Night variant" -msgstr "Variante nocturne" - -#: src/preferences/GtkTheme.js:42 -msgid "GTK theme" -msgstr "Thème GTK" - -#: src/preferences/GtkTheme.js:43 -msgid "" -"The extension will try to automatically detect the day and night variants of " -"your GTK theme.\n" -"\n" -"If the theme you use isn't supported, please submit a request. You can also manually set variants." -msgstr "" -"L’extension essayera de déterminer automatiquement les variantes diurnes et " -"nocturnes de votre thème GTK.\n" -"\n" -"Si le thème que vous utilisez n’est pas pris en charge, merci d’ouvrir une demande. Vous pouvez aussi sélectionner manuellement les " -"variantes." - -#: src/preferences/GtkTheme.js:46 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 +#: src/prefs.ui:755 msgid "Switch GTK variants" msgstr "Permuter les variantes GTK" -#: src/preferences/GtkTheme.js:48 src/preferences/ShellTheme.js:48 -msgid "Manual variants" -msgstr "Variantes manuelles" - -#: src/preferences/IconTheme.js:42 -msgid "Icon theme" -msgstr "Thème d’icônes" - -#: src/preferences/IconTheme.js:43 -msgid "You can set different icon themes for day and night." -msgstr "" -"Vous pouvez définir des thèmes d’icônes diurnes et nocturnes différents." - -#: src/preferences/IconTheme.js:46 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 -msgid "Switch icon variants" -msgstr "Permuter les variantes d’icônes" - -#: src/preferences/Schedule.js:41 -msgid "Schedule" -msgstr "Horaires" - -#: src/preferences/Schedule.js:42 -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.\n" -"\n" -"If you prefer, you can manually choose a time source." -msgstr "" -"S’ils sont activés, l’extension essayera d’utiliser le mode nuit ou les " -"services de localisation pour déterminer automatiquement les heures " -"actuelles de lever et de coucher du soleil.\n" -"\n" -"Si vous préférez, vous pouvez sélectionner manuellement une source " -"d’horaires." - -#: src/preferences/Schedule.js:45 -msgid "Automatic time source" -msgstr "Source d’horaires automatique" - -#: src/preferences/Schedule.js:47 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:102 -msgid "Time source" -msgstr "Source d’horaires" - -#: src/preferences/Schedule.js:56 -msgid "On-demand shortcut" -msgstr "Raccourci à la demande" - -#: src/preferences/Schedule.js:115 -msgid "Night Light" -msgstr "Mode nuit" - -#: src/preferences/Schedule.js:132 -msgid "Location Services" -msgstr "Services de localisation" - -#: src/preferences/Schedule.js:150 -msgid "Manual schedule" -msgstr "Horaire manuel" - -#: src/preferences/Schedule.js:168 -msgid "On-demand" -msgstr "À la demande" - -#: src/preferences/ShellTheme.js:42 -msgid "Shell theme" -msgstr "Thème du shell" - -#: src/preferences/ShellTheme.js:43 -msgid "" -"The extension will try to automatically detect the day and night variants of " -"your GNOME Shell theme.\n" -"\n" -"If the theme you use isn't supported, please submit a request. You can also manually set variants." -msgstr "" -"L’extension essayera de déterminer automatiquement les variantes diurnes et " -"nocturnes de votre thème GNOME Shell.\n" -"\n" -"Si le thème que vous utilisez n’est pas pris en charge, merci d’ouvrir une demande. Vous pouvez aussi sélectionner manuellement les " -"variantes." - -#: src/preferences/ShellTheme.js:46 -msgid "Switch Shell variants" -msgstr "Permuter les variantes Shell" - -#: src/preferences/ShellTheme.js:121 -msgid "Default" -msgstr "Par défaut" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:7 msgid "Enable GTK variants switching" msgstr "Activer le changement de variantes GTK" @@ -318,6 +128,11 @@ msgstr "Utiliser des variantes shell manuelles" msgid "Disable automatic shell theme variants detection" msgstr "Désactiver la détection automatique des variantes du thème shell" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 +#: src/prefs.ui:1443 +msgid "Switch icon variants" +msgstr "Permuter les variantes d’icônes" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:57 msgid "Enable icon variants switching" msgstr "Activer le changement de variantes d’icônes" @@ -346,6 +161,11 @@ msgstr "Thème d’icônes original" msgid "The icon theme to restore when the extension is disabled" msgstr "Le thème d’icônes à restaurer quand l’extension est désactivée" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 +#: src/prefs.ui:1689 +msgid "Switch cursor variants" +msgstr "Permuter les variantes de curseur" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:77 msgid "Enable cursor variants switching" msgstr "Activer le changement de variantes de curseur" @@ -374,6 +194,10 @@ msgstr "Thème de curseurs original" msgid "The cursor theme to restore when the extension is disabled" msgstr "Le thème de curseurs à restaurer quand l’extension est désactivée" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:102 +msgid "Time source" +msgstr "Source d’horaires" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:103 msgid "The source used to check current time" msgstr "Source utilisée pour vérifier les horaires" @@ -427,6 +251,7 @@ msgid "Commands will be spawned on time change" msgstr "Les commandes seront lancées au changement d’horaire" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 +#: src/prefs.ui:2308 msgid "Sunrise command" msgstr "Commande du lever de soleil" @@ -435,6 +260,7 @@ msgid "The command to spawn at sunrise" msgstr "La commande à lancer quand le soleil se lève" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 +#: src/prefs.ui:2367 msgid "Sunset command" msgstr "Commande du coucher de soleil" @@ -450,16 +276,270 @@ msgstr "Activer les arrière-plans" msgid "Background will be changed on time change" msgstr "L’arrière-plan changera au changement d’horaire" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 +#: src/prefs.ui:2022 +msgid "Day background" +msgstr "Arrière-plan diurne" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:157 msgid "Path to the day background" msgstr "Chemin vers l’arrière-plan diurne" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 +#: src/prefs.ui:2082 +msgid "Night background" +msgstr "Arrière-plan nocturne" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:162 msgid "Path to the night background" msgstr "Chemin vers l’arrière-plan nocturne" -#~ msgid "Manual time source" -#~ msgstr "Source d’horaires manuelle" +#: src/prefs.ui:58 +msgid "Press your keyboard shortcut..." +msgstr "Pressez votre raccourci clavier…" + +#: src/prefs.ui:72 src/prefs.ui:629 +msgid "Keyboard shortcut" +msgstr "Raccourci clavier" + +#: 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:659 +msgid "Clear" +msgstr "Effacer" + +#: src/prefs.ui:707 +msgid "Schedule" +msgstr "Horaires" + +#: src/prefs.ui:827 src/prefs.ui:902 src/prefs.ui:1171 src/prefs.ui:1246 +msgid "Manual variants" +msgstr "Variantes manuelles" + +#: src/prefs.ui:840 +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 "" +"Vous pouvez manuellement définir les variants si l’extension ne " +"parvient pas à déterminer les variantes diurnes et nocturnes de votre thème " +"GTK. Merci de soumettre une requête pour obtenir le support " +"de votre thème." + +#: src/prefs.ui:941 src/prefs.ui:1285 src/prefs.ui:1531 src/prefs.ui:1777 +msgid "Day variant" +msgstr "Variante diurne" + +#: src/prefs.ui:997 src/prefs.ui:1341 src/prefs.ui:1587 src/prefs.ui:1833 +msgid "Night variant" +msgstr "Variante nocturne" + +#: src/prefs.ui:1050 +msgid "GTK theme" +msgstr "Thème GTK" + +#: src/prefs.ui:1099 +msgid "Switch Shell variants" +msgstr "Permuter les variantes Shell" + +#: src/prefs.ui:1184 +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 "" +"Vous pouvez manuellement définir les variants si l’extension ne " +"parvient pas à déterminer les variantes diurnes et nocturnes de votre thème " +"GNOME Shell. Merci de soumettre une requête pour obtenir le " +"support de votre thème." + +#: src/prefs.ui:1394 +msgid "Shell theme" +msgstr "Thème du shell" + +#: src/prefs.ui:1492 src/prefs.ui:1738 +msgid "Variants" +msgstr "Variantes" + +#: src/prefs.ui:1640 +msgid "Icon theme" +msgstr "Thème d’icônes" + +#: src/prefs.ui:1886 +msgid "Cursor theme" +msgstr "Thème de curseur" + +#: src/prefs.ui:1935 +msgid "Switch backgrounds" +msgstr "Permuter les arrière-plans" + +#: src/prefs.ui:1983 src/prefs.ui:2139 +msgid "Backgrounds" +msgstr "Arrière-plans" + +#: src/prefs.ui:2039 src/prefs.ui:2099 +msgid "Select your background image" +msgstr "Sélectionnez votre image d’arrière-plan" + +#: src/prefs.ui:2194 +msgid "Run commands" +msgstr "Lancer des commandes" + +#: src/prefs.ui:2207 +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:2269 src/prefs.ui:2423 +msgid "Commands" +msgstr "Commandes" + +#: src/prefs.ui:2324 +msgid "notify-send \"Hello sunshine!\"" +msgstr "notify-send \"Bonjour!\"" + +#: src/prefs.ui:2383 +msgid "notify-send \"Hello moonshine!\"" +msgstr "notify-send \"Bonsoir\"" + +#~ msgid "You can set different backgrounds for day and night." +#~ msgstr "" +#~ "Vous pouvez définir des arrière-plans diurnes et nocturnes différents." + +#~ 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 au " +#~ "moment du changement." + +#~ msgid "Use custom commands" +#~ msgstr "Utiliser des commandes personnalisées" + +#~ msgid "Hello sunshine!" +#~ msgstr "Bonjour!" + +#~ msgid "Hello moonshine!" +#~ msgstr "Bonsoir!" + +#~ msgid "You can set different cursor themes for day and night." +#~ msgstr "" +#~ "Vous pouvez définir des thèmes de curseurs diurnes et nocturnes " +#~ "différents." + +#~ msgid "" +#~ "The extension will try to automatically detect the day and night variants " +#~ "of your GTK theme.\n" +#~ "\n" +#~ "If the theme you use isn't supported, please submit a " +#~ "request. You can also manually set variants." +#~ msgstr "" +#~ "L’extension essayera de déterminer automatiquement les variantes diurnes " +#~ "et nocturnes de votre thème GTK.\n" +#~ "\n" +#~ "Si le thème que vous utilisez n’est pas pris en charge, merci d’ouvrir une demande. Vous pouvez aussi sélectionner " +#~ "manuellement les variantes." + +#~ msgid "You can set different icon themes for day and night." +#~ msgstr "" +#~ "Vous pouvez définir des thèmes d’icônes diurnes et nocturnes différents." + +#~ 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.\n" +#~ "\n" +#~ "If you prefer, you can manually choose a time source." +#~ msgstr "" +#~ "S’ils sont activés, l’extension essayera d’utiliser le mode nuit ou les " +#~ "services de localisation pour déterminer automatiquement les heures " +#~ "actuelles de lever et de coucher du soleil.\n" +#~ "\n" +#~ "Si vous préférez, vous pouvez sélectionner manuellement une source " +#~ "d’horaires." + +#~ msgid "On-demand shortcut" +#~ msgstr "Raccourci à la demande" + +#~ msgid "" +#~ "The extension will try to automatically detect the day and night variants " +#~ "of your GNOME Shell theme.\n" +#~ "\n" +#~ "If the theme you use isn't supported, please submit a " +#~ "request. You can also manually set variants." +#~ msgstr "" +#~ "L’extension essayera de déterminer automatiquement les variantes diurnes " +#~ "et nocturnes de votre thème GNOME Shell.\n" +#~ "\n" +#~ "Si le thème que vous utilisez n’est pas pris en charge, merci d’ouvrir une demande. Vous pouvez aussi sélectionner " +#~ "manuellement les variantes." #~ msgid "Shortcut" #~ msgstr "Raccourci" diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot index 43cd831..d667512 100644 --- a/src/po/nightthemeswitcher@romainvigier.fr.pot +++ b/src/po/nightthemeswitcher@romainvigier.fr.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Night Theme Switcher 31\n" +"Project-Id-Version: Night Theme Switcher 32\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-06-15 17:50+0200\n" +"POT-Creation-Date: 2020-08-03 20:16+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,14 +17,22 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/modules/GtkThemer.js:175 +#: src/prefs.js:212 src/prefs.ui:644 +msgid "Choose" +msgstr "" + +#: src/prefs.js:324 +msgid "Default" +msgstr "" + +#: src/modules/GtkThemer.js:176 #, javascript-format msgid "" "Unable to automatically detect the day and night variants for the \"%s\" GTK " "theme. Please manually choose them in the extension's preferences." msgstr "" -#: src/modules/ShellThemer.js:182 +#: src/modules/ShellThemer.js:183 #, javascript-format msgid "" "Unable to automatically detect the day and night variants for the \"%s\" " @@ -32,185 +40,11 @@ msgid "" "preferences." msgstr "" -#: src/preferences/Backgrounds.js:41 -msgid "Backgrounds" -msgstr "" - -#: src/preferences/Backgrounds.js:42 -msgid "You can set different backgrounds for day and night." -msgstr "" - -#: src/preferences/Backgrounds.js:45 -msgid "Switch backgrounds" -msgstr "" - -#: src/preferences/Backgrounds.js:47 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 -msgid "Day background" -msgstr "" - -#: src/preferences/Backgrounds.js:56 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 -msgid "Night background" -msgstr "" - -#: src/preferences/Backgrounds.js:105 -msgid "Select your background image" -msgstr "" - -#: src/preferences/Commands.js:41 -msgid "Commands" -msgstr "" - -#: src/preferences/Commands.js:42 -msgid "" -"You can set custom commands that will be run when the time of the day " -"changes." -msgstr "" - -#: src/preferences/Commands.js:45 -msgid "Use custom commands" -msgstr "" - -#: src/preferences/Commands.js:47 src/preferences/Schedule.js:63 -msgid "Sunrise" -msgstr "" - -#: src/preferences/Commands.js:56 src/preferences/Schedule.js:70 -msgid "Sunset" -msgstr "" - -#: src/preferences/Commands.js:94 -msgid "Hello sunshine!" -msgstr "" - -#: src/preferences/Commands.js:95 -msgid "Hello moonshine!" -msgstr "" - -#: src/preferences/CursorTheme.js:42 -msgid "Cursor theme" -msgstr "" - -#: src/preferences/CursorTheme.js:43 -msgid "You can set different cursor themes for day and night." -msgstr "" - -#: src/preferences/CursorTheme.js:46 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 -msgid "Switch cursor variants" -msgstr "" - -#: src/preferences/CursorTheme.js:48 src/preferences/GtkTheme.js:57 -#: src/preferences/IconTheme.js:48 src/preferences/ShellTheme.js:57 -msgid "Day variant" -msgstr "" - -#: src/preferences/CursorTheme.js:57 src/preferences/GtkTheme.js:64 -#: src/preferences/IconTheme.js:57 src/preferences/ShellTheme.js:64 -msgid "Night variant" -msgstr "" - -#: src/preferences/GtkTheme.js:42 -msgid "GTK theme" -msgstr "" - -#: src/preferences/GtkTheme.js:43 -msgid "" -"The extension will try to automatically detect the day and night variants of " -"your GTK theme.\n" -"\n" -"If the theme you use isn't supported, please submit a request. You can also manually set variants." -msgstr "" - -#: src/preferences/GtkTheme.js:46 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 +#: src/prefs.ui:755 msgid "Switch GTK variants" msgstr "" -#: src/preferences/GtkTheme.js:48 src/preferences/ShellTheme.js:48 -msgid "Manual variants" -msgstr "" - -#: src/preferences/IconTheme.js:42 -msgid "Icon theme" -msgstr "" - -#: src/preferences/IconTheme.js:43 -msgid "You can set different icon themes for day and night." -msgstr "" - -#: src/preferences/IconTheme.js:46 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 -msgid "Switch icon variants" -msgstr "" - -#: src/preferences/Schedule.js:41 -msgid "Schedule" -msgstr "" - -#: src/preferences/Schedule.js:42 -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.\n" -"\n" -"If you prefer, you can manually choose a time source." -msgstr "" - -#: src/preferences/Schedule.js:45 -msgid "Automatic time source" -msgstr "" - -#: src/preferences/Schedule.js:47 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:102 -msgid "Time source" -msgstr "" - -#: src/preferences/Schedule.js:56 -msgid "On-demand shortcut" -msgstr "" - -#: src/preferences/Schedule.js:115 -msgid "Night Light" -msgstr "" - -#: src/preferences/Schedule.js:132 -msgid "Location Services" -msgstr "" - -#: src/preferences/Schedule.js:150 -msgid "Manual schedule" -msgstr "" - -#: src/preferences/Schedule.js:168 -msgid "On-demand" -msgstr "" - -#: src/preferences/ShellTheme.js:42 -msgid "Shell theme" -msgstr "" - -#: src/preferences/ShellTheme.js:43 -msgid "" -"The extension will try to automatically detect the day and night variants of " -"your GNOME Shell theme.\n" -"\n" -"If the theme you use isn't supported, please submit a request. You can also manually set variants." -msgstr "" - -#: src/preferences/ShellTheme.js:46 -msgid "Switch Shell variants" -msgstr "" - -#: src/preferences/ShellTheme.js:121 -msgid "Default" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:7 msgid "Enable GTK variants switching" msgstr "" @@ -287,6 +121,11 @@ msgstr "" msgid "Disable automatic shell theme variants detection" msgstr "" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 +#: src/prefs.ui:1443 +msgid "Switch icon variants" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:57 msgid "Enable icon variants switching" msgstr "" @@ -315,6 +154,11 @@ msgstr "" msgid "The icon theme to restore when the extension is disabled" msgstr "" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 +#: src/prefs.ui:1689 +msgid "Switch cursor variants" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:77 msgid "Enable cursor variants switching" msgstr "" @@ -343,6 +187,10 @@ msgstr "" msgid "The cursor theme to restore when the extension is disabled" msgstr "" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:102 +msgid "Time source" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:103 msgid "The source used to check current time" msgstr "" @@ -396,6 +244,7 @@ msgid "Commands will be spawned on time change" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 +#: src/prefs.ui:2308 msgid "Sunrise command" msgstr "" @@ -404,6 +253,7 @@ msgid "The command to spawn at sunrise" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 +#: src/prefs.ui:2367 msgid "Sunset command" msgstr "" @@ -419,10 +269,173 @@ msgstr "" msgid "Background will be changed on time change" msgstr "" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 +#: src/prefs.ui:2022 +msgid "Day background" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:157 msgid "Path to the day background" msgstr "" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 +#: src/prefs.ui:2082 +msgid "Night background" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:162 msgid "Path to the night background" msgstr "" + +#: src/prefs.ui:58 +msgid "Press your keyboard shortcut..." +msgstr "" + +#: src/prefs.ui:72 src/prefs.ui:629 +msgid "Keyboard shortcut" +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:659 +msgid "Clear" +msgstr "" + +#: src/prefs.ui:707 +msgid "Schedule" +msgstr "" + +#: src/prefs.ui:827 src/prefs.ui:902 src/prefs.ui:1171 src/prefs.ui:1246 +msgid "Manual variants" +msgstr "" + +#: src/prefs.ui:840 +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:941 src/prefs.ui:1285 src/prefs.ui:1531 src/prefs.ui:1777 +msgid "Day variant" +msgstr "" + +#: src/prefs.ui:997 src/prefs.ui:1341 src/prefs.ui:1587 src/prefs.ui:1833 +msgid "Night variant" +msgstr "" + +#: src/prefs.ui:1050 +msgid "GTK theme" +msgstr "" + +#: src/prefs.ui:1099 +msgid "Switch Shell variants" +msgstr "" + +#: src/prefs.ui:1184 +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:1394 +msgid "Shell theme" +msgstr "" + +#: src/prefs.ui:1492 src/prefs.ui:1738 +msgid "Variants" +msgstr "" + +#: src/prefs.ui:1640 +msgid "Icon theme" +msgstr "" + +#: src/prefs.ui:1886 +msgid "Cursor theme" +msgstr "" + +#: src/prefs.ui:1935 +msgid "Switch backgrounds" +msgstr "" + +#: src/prefs.ui:1983 src/prefs.ui:2139 +msgid "Backgrounds" +msgstr "" + +#: src/prefs.ui:2039 src/prefs.ui:2099 +msgid "Select your background image" +msgstr "" + +#: src/prefs.ui:2194 +msgid "Run commands" +msgstr "" + +#: src/prefs.ui:2207 +msgid "" +"You can set custom commands that will be run when the time of the day " +"changes." +msgstr "" + +#: src/prefs.ui:2269 src/prefs.ui:2423 +msgid "Commands" +msgstr "" + +#: src/prefs.ui:2324 +msgid "notify-send \"Hello sunshine!\"" +msgstr "" + +#: src/prefs.ui:2383 +msgid "notify-send \"Hello moonshine!\"" +msgstr "" diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js deleted file mode 100644 index 91a2403..0000000 --- a/src/preferences/Backgrounds.js +++ /dev/null @@ -1,118 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var BackgroundsPreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Backgrounds'); - const description = _('You can set different backgrounds for day and night.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Switch backgrounds'), new BackgroundsEnabledControl())); - - const dayBackgroundRow = new SettingsListRow(_('Day background'), new TimeBackgroundControl('day')); - settings.bind( - 'backgrounds-enabled', - dayBackgroundRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(dayBackgroundRow); - - const nightBackgroundRow = new SettingsListRow(_('Night background'), new TimeBackgroundControl('night')); - settings.bind( - 'backgrounds-enabled', - nightBackgroundRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(nightBackgroundRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class BackgroundsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('backgrounds-enabled'), - }); - settings.bind( - 'backgrounds-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class TimeBackgroundControl { - - constructor(time) { - const settings = compat.getExtensionSettings(); - - const filter = new Gtk.FileFilter(); - filter.add_mime_type('image/jpeg'); - filter.add_mime_type('image/png'); - filter.add_mime_type('image/tiff'); - - const preview = new Gtk.Image({ - pixel_size: 256, - }); - - const button = new Gtk.FileChooserButton({ - title: _('Select your background image'), - action: Gtk.FileChooserAction.OPEN, - filter, - preview_widget: preview, - use_preview_label: false, - }); - button.set_uri(settings.get_string(`background-${time}`)); - button.connect('update-preview', () => { - const file = button.get_preview_filename(); - const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); - preview.set_from_pixbuf(pixbuf); - }); - button.connect('file-set', () => settings.set_string(`background-${time}`, button.get_uri())); - settings.connect(`changed::background-${time}`, () => button.set_uri(settings.get_string(`background-${time}`))); - - return button; - } - -} diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js deleted file mode 100644 index 8575677..0000000 --- a/src/preferences/Commands.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var CommandsPreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Commands'); - const description = _('You can set custom commands that will be run when the time of the day changes.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Use custom commands'), new CommandsEnabledControl())); - - const dayCommandRow = new SettingsListRow(_('Sunrise'), new SuntimeCommandControl('sunrise')); - settings.bind( - 'commands-enabled', - dayCommandRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(dayCommandRow); - - const nightCommandRow = new SettingsListRow(_('Sunset'), new SuntimeCommandControl('sunset')); - settings.bind( - 'commands-enabled', - nightCommandRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(nightCommandRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class CommandsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('commands-enabled'), - }); - settings.bind( - 'commands-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class SuntimeCommandControl { - - constructor(suntime) { - const message = new Map([ - ['sunrise', _('Hello sunshine!')], - ['sunset', _('Hello moonshine!')], - ]); - const settings = compat.getExtensionSettings(); - const entry = new Gtk.Entry({ - width_request: 300, - placeholder_text: _(`notify-send "${message.get(suntime)}"`), - }); - settings.bind( - `command-${suntime}`, - entry, - 'text', - Gio.SettingsBindFlags.DEFAULT - ); - return entry; - } - -} diff --git a/src/preferences/CursorTheme.js b/src/preferences/CursorTheme.js deleted file mode 100644 index 5645fea..0000000 --- a/src/preferences/CursorTheme.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; -const { getInstalledCursorThemes } = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var CursorThemePreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Cursor theme'); - const description = _('You can set different cursor themes for day and night.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Switch cursor variants'), new CursorVariantsEnabledControl())); - - const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeCursorVariantControl('day')); - settings.bind( - 'cursor-variants-enabled', - dayVariantRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(dayVariantRow); - - const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeCursorVariantControl('night')); - settings.bind( - 'cursor-variants-enabled', - nightVariantRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(nightVariantRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class CursorVariantsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('cursor-variants-enabled'), - }); - settings.bind( - 'cursor-variants-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class TimeCursorVariantControl { - - constructor(time) { - const settings = compat.getExtensionSettings(); - const combo = new Gtk.ComboBoxText(); - const themes = Array.from(getInstalledCursorThemes()).sort(); - themes.forEach(theme => combo.append(theme, theme)); - settings.bind( - `cursor-variant-${time}`, - combo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - return combo; - } - -} diff --git a/src/preferences/GtkTheme.js b/src/preferences/GtkTheme.js deleted file mode 100644 index 75a8854..0000000 --- a/src/preferences/GtkTheme.js +++ /dev/null @@ -1,126 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; -const { getInstalledGtkThemes } = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var GtkThemePreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('GTK theme'); - const description = _('The extension will try to automatically detect the day and night variants of your GTK theme.\n\nIf the theme you use isn\'t supported, please submit a request. You can also manually set variants.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Switch GTK variants'), new GtkVariantsEnabledControl())); - - const manualVariantsRow = new SettingsListRow(_('Manual variants'), new ManualGtkVariantsControl()); - settings.bind( - 'gtk-variants-enabled', - manualVariantsRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(manualVariantsRow); - - const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeGtkVariantControl('day')); - const updateDayVariantRowSensitivity = () => dayVariantRow.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants'))); - settings.connect('changed::gtk-variants-enabled', updateDayVariantRowSensitivity); - settings.connect('changed::manual-gtk-variants', updateDayVariantRowSensitivity); - updateDayVariantRowSensitivity(); - content.add_row(dayVariantRow); - - const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeGtkVariantControl('night')); - const updateNightVariantRowSensitivity = () => nightVariantRow.set_sensitive(!!(settings.get_boolean('gtk-variants-enabled') && settings.get_boolean('manual-gtk-variants'))); - settings.connect('changed::gtk-variants-enabled', updateNightVariantRowSensitivity); - settings.connect('changed::manual-gtk-variants', updateNightVariantRowSensitivity); - updateNightVariantRowSensitivity(); - content.add_row(nightVariantRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class GtkVariantsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('gtk-variants-enabled'), - }); - settings.bind( - 'gtk-variants-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class ManualGtkVariantsControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: false, - }); - settings.bind( - 'manual-gtk-variants', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class TimeGtkVariantControl { - - constructor(time) { - const settings = compat.getExtensionSettings(); - const combo = new Gtk.ComboBoxText(); - const themes = Array.from(getInstalledGtkThemes()).sort(); - themes.forEach(theme => combo.append(theme, theme)); - settings.bind( - `gtk-variant-${time}`, - combo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - return combo; - } - -} diff --git a/src/preferences/IconTheme.js b/src/preferences/IconTheme.js deleted file mode 100644 index 7751d0a..0000000 --- a/src/preferences/IconTheme.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; -const { getInstalledIconThemes } = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var IconThemePreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Icon theme'); - const description = _('You can set different icon themes for day and night.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Switch icon variants'), new IconVariantsEnabledControl())); - - const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeIconVariantControl('day')); - settings.bind( - 'icon-variants-enabled', - dayVariantRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(dayVariantRow); - - const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeIconVariantControl('night')); - settings.bind( - 'icon-variants-enabled', - nightVariantRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(nightVariantRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class IconVariantsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('icon-variants-enabled'), - }); - settings.bind( - 'icon-variants-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class TimeIconVariantControl { - - constructor(time) { - const settings = compat.getExtensionSettings(); - const combo = new Gtk.ComboBoxText(); - const themes = Array.from(getInstalledIconThemes()).sort(); - themes.forEach(theme => combo.append(theme, theme)); - settings.bind( - `icon-variant-${time}`, - combo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - return combo; - } - -} diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js deleted file mode 100644 index 4078a12..0000000 --- a/src/preferences/Schedule.js +++ /dev/null @@ -1,306 +0,0 @@ -/* -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, GObject, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var SchedulePreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Schedule'); - const description = _('The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled.\n\nIf you prefer, you can manually choose a time source.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Automatic time source'), new ManualTimeSourceControl())); - - const timeSourceRow = new SettingsListRow(_('Time source'), new TimeSourceControl()); - settings.bind( - 'manual-time-source', - timeSourceRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(timeSourceRow); - - const ondemandShortcutRow = new SettingsListRow(_('On-demand shortcut'), new KeyBindingControl()); - const updateOndemandShortcutRowSensitivity = () => ondemandShortcutRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'ondemand')); - settings.connect('changed::manual-time-source', () => updateOndemandShortcutRowSensitivity()); - settings.connect('changed::time-source', () => updateOndemandShortcutRowSensitivity()); - updateOndemandShortcutRowSensitivity(); - content.add_row(ondemandShortcutRow); - - const sunriseRow = new SettingsListRow(_('Sunrise'), new SuntimeControl('sunrise')); - const updateSunriseRowSensitivity = () => sunriseRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule')); - settings.connect('changed::manual-time-source', () => updateSunriseRowSensitivity()); - settings.connect('changed::time-source', () => updateSunriseRowSensitivity()); - updateSunriseRowSensitivity(); - content.add_row(sunriseRow); - - const sunsetRow = new SettingsListRow(_('Sunset'), new SuntimeControl('sunset')); - const updateSunsetRowSensitivity = () => sunsetRow.set_sensitive(!!(settings.get_boolean('manual-time-source') && settings.get_string('time-source') === 'schedule')); - settings.connect('changed::manual-time-source', () => updateSunsetRowSensitivity()); - settings.connect('changed::time-source', () => updateSunsetRowSensitivity()); - updateSunsetRowSensitivity(); - content.add_row(sunsetRow); - - return new SettingsPage(label, description, content); - } - -}; - -class ManualTimeSourceControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: false, - }); - settings.bind( - 'manual-time-source', - toggle, - 'active', - Gio.SettingsBindFlags.INVERT_BOOLEAN - ); - return toggle; - } - -} - - -class TimeSourceControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' }); - const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' }); - - const box = new Gtk.Box({ - spacing: 8, - orientation: Gtk.Orientation.HORIZONTAL, - can_focus: false, - }); - - const nightlightRadio = new Gtk.RadioButton({ - label: _('Night Light'), - active: settings.get_string('time-source') === 'nightlight', - }); - nightlightRadio.connect('toggled', () => { - if (nightlightRadio.get_active()) - settings.set_string('time-source', 'nightlight'); - }); - colorSettings.bind( - 'night-light-enabled', - nightlightRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - box.pack_start(nightlightRadio, false, false, 0); - - const locationRadio = new Gtk.RadioButton({ - label: _('Location Services'), - group: nightlightRadio, - active: settings.get_string('time-source') === 'location', - }); - locationRadio.connect('toggled', () => { - if (locationRadio.get_active()) - settings.set_string('time-source', 'location'); - }); - locationSettings.bind( - 'enabled', - locationRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - box.pack_start(locationRadio, false, false, 0); - - const scheduleRadio = new Gtk.RadioButton({ - label: _('Manual schedule'), - group: nightlightRadio, - active: settings.get_string('time-source') === 'schedule', - }); - scheduleRadio.connect('toggled', () => { - if (scheduleRadio.get_active()) - settings.set_string('time-source', 'schedule'); - }); - settings.bind( - 'manual-time-source', - scheduleRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - box.pack_start(scheduleRadio, false, false, 0); - - const ondemandRadio = new Gtk.RadioButton({ - label: _('On-demand'), - group: nightlightRadio, - active: settings.get_string('time-source') === 'ondemand', - }); - ondemandRadio.connect('toggled', () => { - settings.set_string('time-source', 'ondemand'); - }); - settings.bind( - 'manual-time-source', - ondemandRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - box.pack_start(ondemandRadio, false, false, 0); - - return box; - } - -} - - -class KeyBindingControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const KEYBINDING_KEY = 'nightthemeswitcher-ondemand-keybinding'; - const COLUMN_KEY = 0; - const COLUMN_MODS = 1; - - const listStore = new Gtk.ListStore(); - listStore.set_column_types([GObject.TYPE_INT, GObject.TYPE_INT]); - const treeView = new Gtk.TreeView({ model: listStore }); - treeView.set_headers_visible(false); - - const renderer = new Gtk.CellRendererAccel({ editable: true }); - const column = new Gtk.TreeViewColumn(); - const iter = listStore.append(); - - const updateShortcutRow = accel => { - const [key, mods] = accel ? Gtk.accelerator_parse(accel) : [0, 0]; - listStore.set(iter, [COLUMN_KEY, COLUMN_MODS], [key, mods]); - }; - - renderer.connect('accel-edited', (_renderer, _path, key, mods) => { - const accel = Gtk.accelerator_name(key, mods); - updateShortcutRow(accel); - settings.set_strv(KEYBINDING_KEY, [accel]); - }); - - renderer.connect('accel-cleared', () => { - updateShortcutRow(null); - settings.set_strv(KEYBINDING_KEY, []); - }); - - settings.connect(`changed::${KEYBINDING_KEY}`, () => { - updateShortcutRow(settings.get_strv(KEYBINDING_KEY)[0]); - }); - - column.pack_start(renderer, true); - column.add_attribute(renderer, 'accel-key', COLUMN_KEY); - column.add_attribute(renderer, 'accel-mods', COLUMN_MODS); - - treeView.append_column(column); - updateShortcutRow(settings.get_strv(KEYBINDING_KEY)[0]); - - return treeView; - } - -} - - -class SuntimeControl { - - constructor(suntime) { - const settings = compat.getExtensionSettings(); - const box = new Gtk.Box({ - spacing: 8, - orientation: Gtk.Orientation.HORIZONTAL, - can_focus: false, - }); - - const time = settings.get_double(`schedule-${suntime}`); - const hours = Math.trunc(time); - const minutes = Math.round((time - hours) * 60); - - const hoursSpin = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - value: hours, - lower: 0, - upper: 23, - step_increment: 1, - page_increment: 0, - page_size: 0, - }), - value: hours, - numeric: true, - wrap: true, - orientation: Gtk.Orientation.VERTICAL, - }); - hoursSpin.connect('output', () => { - const text = hoursSpin.adjustment.value.toString().padStart(2, '0'); - hoursSpin.set_text(text); - return true; - }); - hoursSpin.connect('value-changed', () => { - const oldTime = settings.get_double(`schedule-${suntime}`); - const oldHour = Math.trunc(oldTime); - const newMinutes = oldTime - oldHour; - const newTime = hoursSpin.value + newMinutes; - settings.set_double(`schedule-${suntime}`, newTime); - }); - - const separator = new Gtk.Label({ label: ':' }); - - const minutesSpin = new Gtk.SpinButton({ - adjustment: new Gtk.Adjustment({ - value: minutes, - lower: 0, - upper: 59, - step_increment: 1, - page_increment: 0, - page_size: 0, - }), - value: minutes, - numeric: true, - wrap: true, - orientation: Gtk.Orientation.VERTICAL, - }); - minutesSpin.connect('output', () => { - const text = minutesSpin.adjustment.value.toString().padStart(2, '0'); - minutesSpin.set_text(text); - return true; - }); - minutesSpin.connect('value-changed', () => { - const hour = Math.trunc(settings.get_double(`schedule-${suntime}`)); - const newMinutes = minutesSpin.value / 60; - const newTime = hour + newMinutes; - settings.set_double(`schedule-${suntime}`, newTime); - }); - - box.pack_start(hoursSpin, false, false, 0); - box.pack_start(separator, false, false, 0); - box.pack_start(minutesSpin, false, false, 0); - return box; - } - -} diff --git a/src/preferences/ShellTheme.js b/src/preferences/ShellTheme.js deleted file mode 100644 index b8c57ee..0000000 --- a/src/preferences/ShellTheme.js +++ /dev/null @@ -1,126 +0,0 @@ -/* -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, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const compat = Me.imports.compat; -const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases; -const { getInstalledShellThemes } = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata.uuid); -const _ = Gettext.gettext; - - -var ShellThemePreferences = class { - - constructor() { - const settings = compat.getExtensionSettings(); - - const label = _('Shell theme'); - const description = _('The extension will try to automatically detect the day and night variants of your GNOME Shell theme.\n\nIf the theme you use isn\'t supported, please submit a request. You can also manually set variants.'); - const content = new SettingsList(); - - content.add_row(new SettingsListRow(_('Switch Shell variants'), new ShellVariantsEnabledControl())); - - const manualVariantsRow = new SettingsListRow(_('Manual variants'), new ManualShellVariantsControl()); - settings.bind( - 'shell-variants-enabled', - manualVariantsRow, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - content.add_row(manualVariantsRow); - - const dayVariantRow = new SettingsListRow(_('Day variant'), new TimeShellVariantControl('day')); - const updateDayVariantRowSensitivity = () => dayVariantRow.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants'))); - settings.connect('changed::shell-variants-enabled', updateDayVariantRowSensitivity); - settings.connect('changed::manual-shell-variants', updateDayVariantRowSensitivity); - updateDayVariantRowSensitivity(); - content.add_row(dayVariantRow); - - const nightVariantRow = new SettingsListRow(_('Night variant'), new TimeShellVariantControl('night')); - const updateNightVariantRowSensitivity = () => nightVariantRow.set_sensitive(!!(settings.get_boolean('shell-variants-enabled') && settings.get_boolean('manual-shell-variants'))); - settings.connect('changed::shell-variants-enabled', updateNightVariantRowSensitivity); - settings.connect('changed::manual-shell-variants', updateNightVariantRowSensitivity); - updateNightVariantRowSensitivity(); - content.add_row(nightVariantRow); - - return new SettingsPage(label, description, content); - } - -}; - - -class ShellVariantsEnabledControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: settings.get_boolean('shell-variants-enabled'), - }); - settings.bind( - 'shell-variants-enabled', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class ManualShellVariantsControl { - - constructor() { - const settings = compat.getExtensionSettings(); - const toggle = new Gtk.Switch({ - active: false, - }); - settings.bind( - 'manual-shell-variants', - toggle, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - return toggle; - } - -} - - -class TimeShellVariantControl { - - constructor(time) { - const settings = compat.getExtensionSettings(); - const combo = new Gtk.ComboBoxText(); - const themes = Array.from(getInstalledShellThemes()).sort(); - themes.forEach(theme => combo.append(theme, theme === '' ? _('Default') : theme)); - settings.bind( - `shell-variant-${time}`, - combo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - return combo; - } - -} diff --git a/src/preferences/bases.js b/src/preferences/bases.js deleted file mode 100644 index 6622794..0000000 --- a/src/preferences/bases.js +++ /dev/null @@ -1,109 +0,0 @@ -/* -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; - - -var SettingsPage = class { - - constructor(label, description, contentWidget) { - this.label = new Gtk.Label({ - label, - }); - - this.page = new Gtk.Box({ - orientation: Gtk.Orientation.VERTICAL, - spacing: 30, - margin_top: 30, - margin_end: 36, - margin_start: 36, - margin_bottom: 36, - valign: Gtk.Align.START, - halign: Gtk.Align.CENTER, - }); - - const descriptionWidget = new Gtk.Label({ - label: description, - use_markup: true, - width_request: 600, - max_width_chars: 60, - wrap: true, - justify: Gtk.Justification.LEFT, - halign: Gtk.Align.START, - }); - this.page.pack_start(descriptionWidget, false, false, 0); - - this.page.pack_start(contentWidget, false, false, 0); - } - -}; - -var SettingsList = class { - - constructor() { - const frame = new Gtk.Frame({ - can_focus: false, - }); - - const list = new Gtk.ListBox({ - border_width: 0, - margin: 0, - can_focus: false, - selection_mode: Gtk.SelectionMode.NONE, - }); - frame.add(list); - - frame.add_row = widget => { - if (list.get_children().length > 0) { - const separator = new Gtk.Separator({ - orientation: Gtk.Orientation.VERTICAL, - can_focus: false, - }); - list.add(separator); - } - list.add(widget); - }; - - return frame; - } - -}; - -var SettingsListRow = class { - - constructor(label, widget) { - const row = new Gtk.Box({ - margin: 16, - spacing: 30, - orientation: Gtk.Orientation.HORIZONTAL, - can_focus: false, - }); - - const labelWidget = new Gtk.Label({ - label, - halign: Gtk.Align.START, - }); - row.pack_start(labelWidget, true, true, 0); - - widget.set_halign(Gtk.Align.END); - row.pack_start(widget, false, false, 0); - - return row; - } - -}; diff --git a/src/prefs.js b/src/prefs.js index d32b595..abf1ffb 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -18,19 +18,15 @@ this program. If not, see . 'use strict'; -const { Gtk } = imports.gi; +const { Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; -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; +const { compat, utils } = Me.imports; + +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; function init() { @@ -38,32 +34,531 @@ function init() { } function buildPrefsWidget() { - const prefsWidget = new Gtk.Notebook({ - visible: true, - }); - - const schedulePreferences = new SchedulePreferences(); - prefsWidget.append_page(schedulePreferences.page, schedulePreferences.label); - - const gtkThemePreferences = new GtkThemePreferences(); - prefsWidget.append_page(gtkThemePreferences.page, gtkThemePreferences.label); - - const shellThemePreferences = new ShellThemePreferences(); - prefsWidget.append_page(shellThemePreferences.page, shellThemePreferences.label); - - const iconThemePreferences = new IconThemePreferences(); - prefsWidget.append_page(iconThemePreferences.page, iconThemePreferences.label); - - const cursorThemePreferences = new CursorThemePreferences(); - prefsWidget.append_page(cursorThemePreferences.page, cursorThemePreferences.label); - - const backgroundsPreferences = new BackgroundsPreferences(); - prefsWidget.append_page(backgroundsPreferences.page, backgroundsPreferences.label); - - const commandsPreferences = new CommandsPreferences(); - prefsWidget.append_page(commandsPreferences.page, commandsPreferences.label); - - prefsWidget.show_all(); - + const prefsWidget = new Preferences(); return prefsWidget; } + + +const Preferences = class { + + constructor() { + this.settings = compat.getExtensionSettings(); + 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.bind( + 'manual-time-source', + scheduleAutoSwitch, + 'active', + Gio.SettingsBindFlags.INVERT_BOOLEAN + ); + + const scheduleManualTimeSource = this.builder.get_object('prefs_schedule_manual_time_source'); + this.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.get_string('time-source') === 'nightlight'; + }; + this.settings.connect('changed::time-source', () => updateScheduleManualTimeSourceNightlightRadioActivity()); + this.colorSettings.bind( + 'night-light-enabled', + scheduleManualTimeSourceNightlightRadio, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + scheduleManualTimeSourceNightlightRadio.connect('toggled', () => { + if (scheduleManualTimeSourceNightlightRadio.active) + this.settings.set_string('time-source', 'nightlight'); + }); + updateScheduleManualTimeSourceNightlightRadioActivity(); + + const scheduleManualTimeSourceLocationRadio = this.builder.get_object('prefs_schedule_manual_time_source_location_radio'); + const updateScheduleManualTimeSourceLocationRadioActivity = () => { + scheduleManualTimeSourceLocationRadio.active = this.settings.get_string('time-source') === 'location'; + }; + this.settings.connect('changed::time-source', () => updateScheduleManualTimeSourceLocationRadioActivity()); + this.locationSettings.bind( + 'enabled', + scheduleManualTimeSourceLocationRadio, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + scheduleManualTimeSourceLocationRadio.connect('toggled', () => { + if (scheduleManualTimeSourceLocationRadio.active) + this.settings.set_string('time-source', 'location'); + }); + updateScheduleManualTimeSourceLocationRadioActivity(); + + const scheduleManualTimeSourceManualRadio = this.builder.get_object('prefs_schedule_manual_time_source_manual_radio'); + const updateScheduleManualTimeSourceManualRadioActivity = () => { + scheduleManualTimeSourceManualRadio.active = this.settings.get_string('time-source') === 'schedule'; + }; + this.settings.connect('changed::time-source', () => updateScheduleManualTimeSourceManualRadioActivity()); + scheduleManualTimeSourceManualRadio.connect('toggled', () => { + if (scheduleManualTimeSourceManualRadio.active) + this.settings.set_string('time-source', 'schedule'); + }); + updateScheduleManualTimeSourceManualRadioActivity(); + + const scheduleManualTimeSourceOndemandRadio = this.builder.get_object('prefs_schedule_manual_time_source_ondemand_radio'); + const updateScheduleManualTimeSourceOndemandRadioActivity = () => { + scheduleManualTimeSourceOndemandRadio.active = this.settings.get_string('time-source') === 'ondemand'; + }; + this.settings.connect('changed::time-source', () => updateScheduleManualTimeSourceOndemandRadioActivity()); + scheduleManualTimeSourceOndemandRadio.connect('toggled', () => { + if (scheduleManualTimeSourceOndemandRadio.active) + this.settings.set_string('time-source', 'ondemand'); + }); + updateScheduleManualTimeSourceOndemandRadioActivity(); + + const scheduleManualScheduleTimes = this.builder.get_object('prefs_schedule_manual_schedule_times'); + const updateScheduleManualScheduleTimesVisibility = () => { + scheduleManualScheduleTimes.visible = this.settings.get_string('time-source') === 'schedule'; + }; + this.settings.bind( + 'manual-time-source', + scheduleManualScheduleTimes, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.connect('changed::time-source', () => updateScheduleManualScheduleTimesVisibility()); + updateScheduleManualScheduleTimesVisibility(); + + const scheduleManualScheduleTimesSunriseHoursSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunrise_hours_spin'); + scheduleManualScheduleTimesSunriseHoursSpin.value = Math.trunc(this.settings.get_double('schedule-sunrise')); + 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.get_double('schedule-sunrise'); + const oldHour = Math.trunc(oldTime); + const newMinutes = oldTime - oldHour; + const newTime = scheduleManualScheduleTimesSunriseHoursSpin.value + newMinutes; + this.settings.set_double('schedule-sunrise', newTime); + }); + + const scheduleManualScheduleTimesSunriseMinutesSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunrise_minutes_spin'); + scheduleManualScheduleTimesSunriseMinutesSpin.value = Math.round((this.settings.get_double('schedule-sunrise') - Math.trunc(this.settings.get_double('schedule-sunrise'))) * 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.get_double('schedule-sunrise')); + const newMinutes = scheduleManualScheduleTimesSunriseMinutesSpin.value / 60; + const newTime = hour + newMinutes; + this.settings.set_double('schedule-sunrise', newTime); + }); + + const scheduleManualScheduleTimesSunsetHoursSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunset_hours_spin'); + scheduleManualScheduleTimesSunsetHoursSpin.value = Math.trunc(this.settings.get_double('schedule-sunset')); + 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.get_double('schedule-sunset'); + const oldHour = Math.trunc(oldTime); + const newMinutes = oldTime - oldHour; + const newTime = scheduleManualScheduleTimesSunsetHoursSpin.value + newMinutes; + this.settings.set_double('schedule-sunset', newTime); + }); + + const scheduleManualScheduleTimesSunsetMinutesSpin = this.builder.get_object('prefs_schedule_manual_schedule_times_sunset_minutes_spin'); + scheduleManualScheduleTimesSunsetMinutesSpin.value = Math.round((this.settings.get_double('schedule-sunset') - Math.trunc(this.settings.get_double('schedule-sunset'))) * 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.get_double('schedule-sunset')); + const newMinutes = scheduleManualScheduleTimesSunsetMinutesSpin.value / 60; + const newTime = hour + newMinutes; + this.settings.set_double('schedule-sunset', newTime); + }); + + const scheduleOndemand = this.builder.get_object('prefs_schedule_ondemand'); + const updateScheduleOndemandVisibility = () => { + scheduleOndemand.visible = this.settings.get_string('time-source') === 'ondemand'; + }; + this.settings.bind( + 'manual-time-source', + scheduleOndemand, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.connect('changed::time-source', () => updateScheduleOndemandVisibility()); + updateScheduleOndemandVisibility(); + + const scheduleOndemandShortcutButton = this.builder.get_object('prefs_schedule_ondemand_shortcut_button'); + const updateScheduleOndemandShortcutButtonLabel = () => { + const label = this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; + scheduleOndemandShortcutButton.label = label || _('Choose'); + }; + this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => 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.set_strv('nightthemeswitcher-ondemand-keybinding', ['']); + }); + const updateScheduleOndemandShortcutClearButtonVisibility = () => { + scheduleOndemandShortcutClearButton.visible = !!this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; + }; + this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => updateScheduleOndemandShortcutClearButtonVisibility()); + updateScheduleOndemandShortcutClearButtonVisibility(); + } + + _connectGtkThemePreferences() { + const gtkThemeSwitchVariantsSwitch = this.builder.get_object('prefs_gtk_theme_switch_variants_switch'); + this.settings.bind( + 'gtk-variants-enabled', + gtkThemeSwitchVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const gtkThemeManualVariants = this.builder.get_object('prefs_gtk_theme_manual_variants'); + this.settings.bind( + 'gtk-variants-enabled', + gtkThemeManualVariants, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const gtkThemeManualVariantsSwitch = this.builder.get_object('prefs_gtk_theme_manual_variants_switch'); + this.settings.bind( + 'manual-gtk-variants', + gtkThemeManualVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const gtkThemeVariants = this.builder.get_object('prefs_gtk_theme_variants'); + const updateGtkThemeVariantsSensitivity = () => { + gtkThemeVariants.sensitive = !!(this.settings.get_boolean('gtk-variants-enabled') && this.settings.get_boolean('manual-gtk-variants')); + }; + this.settings.connect('changed::gtk-variants-enabled', () => updateGtkThemeVariantsSensitivity()); + this.settings.connect('changed::manual-gtk-variants', () => 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.bind( + 'gtk-variant-day', + gtkThemeVariantsDayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.bind( + 'gtk-variant-night', + gtkThemeVariantsNightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + + _connectShellThemePreferences() { + const shellThemeSwitchVariantsSwitch = this.builder.get_object('prefs_shell_theme_switch_variants_switch'); + this.settings.bind( + 'shell-variants-enabled', + shellThemeSwitchVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const shellThemeManualVariants = this.builder.get_object('prefs_shell_theme_manual_variants'); + this.settings.bind( + 'shell-variants-enabled', + shellThemeManualVariants, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const shellThemeManualVariantsSwitch = this.builder.get_object('prefs_shell_theme_manual_variants_switch'); + this.settings.bind( + 'manual-shell-variants', + shellThemeManualVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const shellThemeVariants = this.builder.get_object('prefs_shell_theme_variants'); + const updateShellThemeVariantsSensitivity = () => { + shellThemeVariants.sensitive = !!(this.settings.get_boolean('shell-variants-enabled') && this.settings.get_boolean('manual-shell-variants')); + }; + this.settings.connect('changed::shell-variants-enabled', () => updateShellThemeVariantsSensitivity()); + this.settings.connect('changed::manual-shell-variants', () => 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.bind( + 'shell-variant-day', + shellThemeVariantsDayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.bind( + 'shell-variant-night', + shellThemeVariantsNightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + + _connectIconThemePreferences() { + const iconThemeSwitchVariantsSwitch = this.builder.get_object('prefs_icon_theme_switch_variants_switch'); + this.settings.bind( + 'icon-variants-enabled', + iconThemeSwitchVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const iconThemeVariants = this.builder.get_object('prefs_icon_theme_variants'); + this.settings.bind( + 'icon-variants-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.bind( + 'icon-variant-day', + iconThemeVariantsDayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.bind( + 'icon-variant-night', + iconThemeVariantsNightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + + _connectCursorThemePreferences() { + const cursorThemeSwitchVariantsSwitch = this.builder.get_object('prefs_cursor_theme_switch_variants_switch'); + this.settings.bind( + 'cursor-variants-enabled', + cursorThemeSwitchVariantsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const cursorThemeVariants = this.builder.get_object('prefs_cursor_theme_variants'); + this.settings.bind( + 'cursor-variants-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.bind( + 'cursor-variant-day', + cursorThemeVariantsDayCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + this.settings.bind( + 'cursor-variant-night', + cursorThemeVariantsNightCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); + } + + _connectBackgroundPreferences() { + const backgroundSwitchBackgroundsSwitch = this.builder.get_object('prefs_backgrounds_switch_backgrounds_switch'); + this.settings.bind( + 'backgrounds-enabled', + backgroundSwitchBackgroundsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const backgroundsBackgrounds = this.builder.get_object('prefs_backgrounds_backgrounds'); + this.settings.bind( + 'backgrounds-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.get_string('background-day')); + }; + this.settings.connect('changed::background-day', () => updateBackgroundsBackgroundsDayBackgroundButtonUri()); + backgroundsBackgroundsDayBackgroundButton.connect('update-preview', () => { + const file = backgroundsBackgroundsDayBackgroundButton.get_preview_filename(); + const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); + dayBackgroundPreview.set_from_pixbuf(pixbuf); + }); + backgroundsBackgroundsDayBackgroundButton.connect('file-set', () => { + this.settings.set_string('background-day', backgroundsBackgroundsDayBackgroundButton.get_uri()); + }); + updateBackgroundsBackgroundsDayBackgroundButtonUri(); + + 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.get_string('background-night')); + }; + this.settings.connect('changed::background-night', () => updateBackgroundsBackgroundsNightBackgroundButtonUri()); + backgroundsBackgroundsNightBackgroundButton.connect('update-preview', () => { + const file = backgroundsBackgroundsNightBackgroundButton.get_preview_filename(); + const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); + nightBackgroundPreview.set_from_pixbuf(pixbuf); + }); + backgroundsBackgroundsNightBackgroundButton.connect('file-set', () => { + this.settings.set_string('background-night', backgroundsBackgroundsNightBackgroundButton.get_uri()); + }); + updateBackgroundsBackgroundsNightBackgroundButtonUri(); + } + + _connectCommandsPreferences() { + const commandsSwitchCommandsSwitch = this.builder.get_object('prefs_commands_switch_commands_switch'); + this.settings.bind( + 'commands-enabled', + commandsSwitchCommandsSwitch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const commandsCommands = this.builder.get_object('prefs_commands_commands'); + this.settings.bind( + 'commands-enabled', + commandsCommands, + 'sensitive', + Gio.SettingsBindFlags.DEFAULT + ); + + const commandsCommandsSunriseCommandEntry = this.builder.get_object('prefs_commands_commands_sunrise_command_entry'); + this.settings.bind( + 'command-sunrise', + commandsCommandsSunriseCommandEntry, + 'text', + Gio.SettingsBindFlags.DEFAULT + ); + + const commandsCommandsSunsetCommandEntry = this.builder.get_object('prefs_commands_commands_sunset_command_entry'); + this.settings.bind( + 'command-sunset', + commandsCommandsSunsetCommandEntry, + 'text', + Gio.SettingsBindFlags.DEFAULT + ); + } + + _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.set_strv('nightthemeswitcher-ondemand-keybinding', [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 new file mode 100644 index 0000000..301c296 --- /dev/null +++ b/src/prefs.ui @@ -0,0 +1,2431 @@ + + + + + + True + False + 256 + image-missing + 0 + + + + image/jpeg + image/png + image/tiff + + + + True + False + 256 + image-loading + 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 + 8 + + + Choose + True + True + True + end + center + + + False + True + 0 + + + + + Clear + True + True + True + + + False + True + 1 + + + + + False + False + end + 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 + center + image_filter + day_background_preview + False + Select your background image + + + 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 + center + image_filter + night_background_preview + False + Select your background image + + + 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 + True + end + center + 36 + True + notify-send "Hello sunshine!" + + + 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 + True + end + center + 36 + True + notify-send "Hello moonshine!" + + + True + True + 1 + + + + + + + + + + + + + + False + True + 1 + + + + + False + True + 1 + + + + + 6 + + + + + True + False + Commands + + + 6 + False + + + + diff --git a/src/utils.js b/src/utils.js index 2a3b22d..1a6aaee 100644 --- a/src/utils.js +++ b/src/utils.js @@ -16,7 +16,7 @@ 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 { Gdk, Gio, GLib, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); @@ -210,3 +210,46 @@ function applyShellStylesheet(stylesheet) { imports.ui.main.loadTheme(); logDebug('Shell stylesheet applied.'); } + +function isKeyvalForbidden(keyval) { + const forbiddenKeyvals = [ + Gdk.KEY_Home, + Gdk.KEY_Left, + Gdk.KEY_Up, + Gdk.KEY_Right, + Gdk.KEY_Down, + Gdk.KEY_Page_Up, + Gdk.KEY_Page_Down, + Gdk.KEY_End, + Gdk.KEY_Tab, + Gdk.KEY_KP_Enter, + Gdk.KEY_Return, + Gdk.KEY_Mode_switch, + ]; + return forbiddenKeyvals.includes(keyval); +} + +function isBindingValid({ mask, keycode, keyval }) { + if ((mask === 0 || mask === Gdk.SHIFT_MASK) && keycode !== 0) { + if ( + (keyval >= Gdk.KEY_a && keyval <= Gdk.KEY_z) || + (keyval >= Gdk.KEY_A && keyval <= Gdk.KEY_Z) || + (keyval >= Gdk.KEY_0 && keyval <= Gdk.KEY_9) || + (keyval >= Gdk.KEY_kana_fullstop && keyval <= Gdk.KEY_semivoicedsound) || + (keyval >= Gdk.KEY_Arabic_comma && keyval <= Gdk.KEY_Arabic_sukun) || + (keyval >= Gdk.KEY_Serbian_dje && keyval <= Gdk.KEY_Cyrillic_HARDSIGN) || + (keyval >= Gdk.KEY_Greek_ALPHAaccent && keyval <= Gdk.KEY_Greek_omega) || + (keyval >= Gdk.KEY_hebrew_doublelowline && keyval <= Gdk.KEY_hebrew_taf) || + (keyval >= Gdk.KEY_Thai_kokai && keyval <= Gdk.KEY_Thai_lekkao) || + (keyval >= Gdk.KEY_Hangul_Kiyeog && keyval <= Gdk.KEY_Hangul_J_YeorinHieuh) || + (keyval === Gdk.KEY_space && mask === 0) || + isKeyvalForbidden(keyval) + ) + return false; + } + return true; +} + +function isAccelValid({ mask, keyval }) { + return Gtk.accelerator_valid(keyval, mask) || (keyval === Gdk.KEY_Tab && mask !== 0); +}