diff --git a/README.md b/README.md index fb7a6b1..782dcd2 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ SPDX-License-Identifier: CC-BY-SA-4.0 # Night Theme Switcher ![](./res/screenshot.png) - Automatically toggle your light and dark GTK, GNOME Shell, icon and cursor themes variants, switch backgrounds and run custom commands at sunset and sunrise. diff --git a/res/example-wallpaper-day.jpg b/res/example-wallpaper-day.jpg new file mode 100644 index 0000000..470acbd Binary files /dev/null and b/res/example-wallpaper-day.jpg differ diff --git a/res/example-wallpaper-day.jpg.license b/res/example-wallpaper-day.jpg.license new file mode 100644 index 0000000..34101fb --- /dev/null +++ b/res/example-wallpaper-day.jpg.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2021 Romain Vigier + +SPDX-License-Identifier: CC-BY-SA-4.0 \ No newline at end of file diff --git a/res/example-wallpaper-night.jpg b/res/example-wallpaper-night.jpg new file mode 100644 index 0000000..529b68c Binary files /dev/null and b/res/example-wallpaper-night.jpg differ diff --git a/res/example-wallpaper-night.jpg.license b/res/example-wallpaper-night.jpg.license new file mode 100644 index 0000000..34101fb --- /dev/null +++ b/res/example-wallpaper-night.jpg.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2021 Romain Vigier + +SPDX-License-Identifier: CC-BY-SA-4.0 \ No newline at end of file diff --git a/res/screenshot.png b/res/screenshot.png index 3775679..ba6bb65 100644 Binary files a/res/screenshot.png and b/res/screenshot.png differ diff --git a/src/icons/hicolor/scalable/actions/nightthemeswitcher-code-symbolic.svg b/src/icons/hicolor/scalable/actions/nightthemeswitcher-code-symbolic.svg new file mode 100644 index 0000000..587c3d3 --- /dev/null +++ b/src/icons/hicolor/scalable/actions/nightthemeswitcher-code-symbolic.svg @@ -0,0 +1,10 @@ + + + + + + + diff --git a/src/icons/hicolor/scalable/actions/nightthemeswitcher-support-symbolic.svg b/src/icons/hicolor/scalable/actions/nightthemeswitcher-support-symbolic.svg new file mode 100644 index 0000000..67bb36f --- /dev/null +++ b/src/icons/hicolor/scalable/actions/nightthemeswitcher-support-symbolic.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/src/icons/hicolor/scalable/actions/nightthemeswitcher-translate-symbolic.svg b/src/icons/hicolor/scalable/actions/nightthemeswitcher-translate-symbolic.svg new file mode 100644 index 0000000..43a3335 --- /dev/null +++ b/src/icons/hicolor/scalable/actions/nightthemeswitcher-translate-symbolic.svg @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-gtktheme-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-appearance-symbolic.svg similarity index 64% rename from src/icons/hicolor/scalable/categories/nightthemeswitcher-gtktheme-symbolic.svg rename to src/icons/hicolor/scalable/categories/nightthemeswitcher-appearance-symbolic.svg index e4506b3..9c4878d 100644 --- a/src/icons/hicolor/scalable/categories/nightthemeswitcher-gtktheme-symbolic.svg +++ b/src/icons/hicolor/scalable/categories/nightthemeswitcher-appearance-symbolic.svg @@ -4,5 +4,5 @@ SPDX-FileCopyrightText: 2021 Romain Vigier SPDX-License-Identifier: CC-BY-SA-4.0 --> - + diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg deleted file mode 100644 index 8161789..0000000 --- a/src/icons/hicolor/scalable/categories/nightthemeswitcher-backgrounds-symbolic.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-cursortheme-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-cursortheme-symbolic.svg deleted file mode 100644 index 90b5710..0000000 --- a/src/icons/hicolor/scalable/categories/nightthemeswitcher-cursortheme-symbolic.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-icontheme-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-icontheme-symbolic.svg deleted file mode 100644 index f0bb207..0000000 --- a/src/icons/hicolor/scalable/categories/nightthemeswitcher-icontheme-symbolic.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/src/icons/hicolor/scalable/categories/nightthemeswitcher-shelltheme-symbolic.svg b/src/icons/hicolor/scalable/categories/nightthemeswitcher-shelltheme-symbolic.svg deleted file mode 100644 index 53ba7cf..0000000 --- a/src/icons/hicolor/scalable/categories/nightthemeswitcher-shelltheme-symbolic.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot index 81639c2..141f726 100644 --- a/src/po/nightthemeswitcher@romainvigier.fr.pot +++ b/src/po/nightthemeswitcher@romainvigier.fr.pot @@ -1,30 +1,30 @@ -# Night Theme Switcher -# Copyright (C) 2019, 2020 Romain Vigier +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the Night Theme Switcher package. -# Romain Vigier <>, 2019, 2020. +# FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Night Theme Switcher 43\n" +"Project-Id-Version: Night Theme Switcher\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-12-13 09:50+0100\n" +"POT-Creation-Date: 2021-08-19 14:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/modules/GtkThemer.js:177 +#: src/modules/GtkThemer.js:162 #, 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:183 +#: src/modules/ShellThemer.js:168 #, javascript-format msgid "" "Unable to automatically detect the day and night variants for the \"%s\" " @@ -32,521 +32,503 @@ msgid "" "preferences." msgstr "" -#: src/modules/TimerOndemand.js:216 +#: src/modules/TimerOndemand.js:237 msgid "Switch to night theme" msgstr "" -#: src/modules/TimerOndemand.js:216 +#: src/modules/TimerOndemand.js:237 msgid "Switch to day theme" msgstr "" -#: src/preferences/Backgrounds.js:35 src/preferences/ui/backgrounds.ui:146 -#: src/preferences/ui/headerbar.ui:338 -msgid "Backgrounds" +#: src/preferences/Schedule.js:57 src/preferences/ui/Schedule.ui:62 +msgid "Night Light" msgstr "" -#: src/preferences/Commands.js:35 src/preferences/ui/commands.ui:132 -#: src/preferences/ui/headerbar.ui:391 -msgid "Commands" +#: src/preferences/Schedule.js:67 +msgid "Location Services" msgstr "" -#: src/preferences/CursorTheme.js:37 src/preferences/ui/headerbar.ui:285 -msgid "Cursor theme" +#: src/preferences/Schedule.js:80 +msgid "Manual schedule" msgstr "" -#: src/preferences/GtkTheme.js:37 src/preferences/ui/headerbar.ui:126 -msgid "GTK theme" +#: src/preferences/Schedule.js:81 src/preferences/ui/Schedule.ui:135 +msgid "On-demand" msgstr "" -#: src/preferences/IconTheme.js:37 src/preferences/ui/headerbar.ui:232 -msgid "Icon theme" -msgstr "" - -#: src/preferences/Schedule.js:37 src/preferences/ui/headerbar.ui:73 -msgid "Schedule" -msgstr "" - -#: src/preferences/Schedule.js:216 src/preferences/ui/schedule.ui:842 -msgid "Choose" -msgstr "" - -#: src/preferences/ShellTheme.js:37 src/preferences/ui/headerbar.ui:179 -msgid "Shell theme" -msgstr "" - -#: src/preferences/ShellTheme.js:79 +#: src/preferences/ShellPreferences.js:55 msgid "Default" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:10 msgid "Settings version" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:7 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:11 msgid "The current extension settings version" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:13 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:6 -#: src/preferences/ui/gtk_theme.ui:76 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:17 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:10 msgid "Switch GTK variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:14 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:7 -msgid "Enable GTK variants switching" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:18 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:11 -msgid "Day GTK theme" +msgid "Enable GTK variants switching" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:19 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:12 -msgid "The GTK theme to use during daytime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:22 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:15 +msgid "Day GTK theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:23 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:16 -msgid "Night GTK theme" +msgid "The GTK theme to use during daytime" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:24 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:17 -msgid "The GTK theme to use during nighttime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:27 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:20 +msgid "Night GTK theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:28 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:21 +msgid "The GTK theme to use during nighttime" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:32 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:25 msgid "Use manual GTK variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:29 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:22 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:33 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:26 msgid "Disable automatic GTK theme variants detection" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:35 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:26 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:39 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:30 msgid "Switch shell variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:36 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:27 -msgid "Enable shell variants switching" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:40 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:31 -msgid "Day shell theme" +msgid "Enable shell variants switching" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:41 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:32 -msgid "The shell theme to use during daytime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:44 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:35 +msgid "Day shell theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:45 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:36 -msgid "Night shell theme" +msgid "The shell theme to use during daytime" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:46 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:37 -msgid "The shell theme to use during nighttime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:49 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:40 +msgid "Night shell theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:50 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:41 +msgid "The shell theme to use during nighttime" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:54 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:45 msgid "Use manual shell variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:51 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:42 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:55 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:46 msgid "Disable automatic shell theme variants detection" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:57 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:46 -#: src/preferences/ui/icon_theme.ui:76 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:61 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:50 msgid "Switch icon variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:58 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:47 -msgid "Enable icon variants switching" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:62 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:51 -msgid "Day icon theme" +msgid "Enable icon variants switching" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:63 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:52 -msgid "The icon theme to use during daytime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:66 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:55 +msgid "Day icon theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:67 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:56 +msgid "The icon theme to use during daytime" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:71 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:60 msgid "Night icon theme" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:68 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:57 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:72 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:61 msgid "The icon theme to use during nighttime" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:74 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:61 -#: src/preferences/ui/cursor_theme.ui:76 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:78 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:65 msgid "Switch cursor variants" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:75 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:62 -msgid "Enable cursor variants switching" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:79 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:66 -msgid "Day cursor theme" +msgid "Enable cursor variants switching" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:80 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:67 -msgid "The cursor theme to use during daytime" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:83 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:70 +msgid "Day cursor theme" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:84 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:71 +msgid "The cursor theme to use during daytime" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:88 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:75 msgid "Night cursor theme" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:85 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:72 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:89 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:76 msgid "The cursor theme to use during nighttime" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:91 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:126 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:95 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:130 msgid "Enable commands" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:92 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:127 -msgid "Commands will be spawned on time change" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:96 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:131 -#: src/preferences/ui/commands.ui:174 -msgid "Sunrise command" +msgid "Commands will be spawned on time change" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:97 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:132 -msgid "The command to spawn at sunrise" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:100 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:135 +msgid "Sunrise command" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:101 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:136 -#: src/preferences/ui/commands.ui:268 +msgid "The command to spawn at sunrise" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:105 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:140 msgid "Sunset command" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:102 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:137 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:106 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:141 msgid "The command to spawn at sunset" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:108 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:141 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:112 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:145 msgid "Enable backgrounds" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:109 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:142 -msgid "Background will be changed on time change" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:113 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:146 -#: src/preferences/ui/backgrounds.ui:188 -msgid "Day background" +msgid "Background will be changed on time change" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:114 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:147 -msgid "Path to the day background" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:117 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:150 +#: src/preferences/ui/BackgroundsPreferences.ui:39 +msgid "Day background" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:118 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:151 -#: src/preferences/ui/backgrounds.ui:280 +msgid "Path to the day background" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:122 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:155 +#: src/preferences/ui/BackgroundsPreferences.ui:47 msgid "Night background" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:119 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:152 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:123 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:156 msgid "Path to the night background" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:131 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:82 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:135 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:86 +#: src/preferences/ui/Schedule.ui:36 msgid "Time source" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:132 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:83 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:87 msgid "The source used to check current time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:140 msgid "Follow Night Light \"Disable until tomorrow\"" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:137 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 msgid "Switch back to day time when Night Light is temporarily disabled" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:145 msgid "Always enable the on-demand timer" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 msgid "The on-demand timer will always be enabled alongside other timers" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:150 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:91 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:154 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:95 msgid "On-demand time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:92 -msgid "The current time used in on-demand mode" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:155 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:96 +msgid "The current time used in on-demand mode" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:159 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:100 msgid "Key combination to toggle time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:97 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:160 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:101 msgid "The key combination that will toggle time in on-demand mode" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:165 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:106 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:169 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:110 msgid "On-demand button placement" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:107 -msgid "Where the on-demand button will be placed" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:170 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:111 -msgid "Use manual time source" +msgid "Where the on-demand button will be placed" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:112 -msgid "Disable automatic time source detection" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:174 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:115 +msgid "Use manual time source" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:175 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:116 -msgid "Sunrise time" +msgid "Disable automatic time source detection" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:176 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:117 -msgid "When the day starts" +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:179 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:120 +msgid "Sunrise time" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:180 #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:121 +msgid "When the day starts" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:184 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:125 msgid "Sunset time" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:181 -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:122 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:185 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.v0.gschema.xml:126 msgid "When the day ends" msgstr "" -#: src/preferences/ui/backgrounds.ui:98 -msgid "Switch backgrounds" +#: src/preferences/ui/BackgroundButton.ui:15 +#: src/preferences/ui/ShortcutButton.ui:15 +msgid "Choose…" msgstr "" -#: src/preferences/ui/backgrounds.ui:211 src/preferences/ui/backgrounds.ui:303 -msgid "Select your background image" +#: src/preferences/ui/BackgroundButton.ui:32 +msgid "Change background" msgstr "" -#: src/preferences/ui/backgrounds.ui:221 src/preferences/ui/backgrounds.ui:313 -#: src/preferences/ui/commands.ui:206 src/preferences/ui/commands.ui:300 -#: src/preferences/ui/schedule.ui:857 +#: src/preferences/ui/BackgroundButton.ui:44 +#: src/preferences/ui/BackgroundButton.ui:46 +#: src/preferences/ui/ClearableEntry.ui:10 +#: src/preferences/ui/ShortcutButton.ui:43 +#: src/preferences/ui/ShortcutButton.ui:45 msgid "Clear" msgstr "" -#: src/preferences/ui/commands.ui:57 +#: src/preferences/ui/BackgroundButton.ui:61 +msgid "Select your background image" +msgstr "" + +#: src/preferences/ui/BackgroundsPreferences.ui:15 +msgid "Switch backgrounds" +msgstr "" + +#: src/preferences/ui/Commands.ui:31 msgid "Run commands" msgstr "" -#: src/preferences/ui/commands.ui:70 -msgid "" -"You can set custom commands that will be run when the time of the day " -"changes." -msgstr "" - -#: src/preferences/ui/commands.ui:195 -msgid "notify-send \"Hello sunshine!\"" -msgstr "" - -#: src/preferences/ui/commands.ui:289 -msgid "notify-send \"Hello moonshine!\"" -msgstr "" - -#: src/preferences/ui/cursor_theme.ui:125 src/preferences/ui/icon_theme.ui:125 -msgid "Variants" -msgstr "" - -#: src/preferences/ui/cursor_theme.ui:167 src/preferences/ui/gtk_theme.ui:268 -#: src/preferences/ui/icon_theme.ui:167 src/preferences/ui/shell_theme.ui:268 -msgid "Day variant" -msgstr "" - -#: src/preferences/ui/cursor_theme.ui:226 src/preferences/ui/gtk_theme.ui:327 -#: src/preferences/ui/icon_theme.ui:226 src/preferences/ui/shell_theme.ui:327 -msgid "Night variant" -msgstr "" - -#: src/preferences/ui/gtk_theme.ui:151 src/preferences/ui/gtk_theme.ui:226 -#: src/preferences/ui/shell_theme.ui:151 src/preferences/ui/shell_theme.ui:226 -msgid "Manual variants" -msgstr "" - -#: src/preferences/ui/gtk_theme.ui:164 -msgid "" -"You can manually set variants if the extension cannot automatically " -"detect the day and night variants of your GTK theme. Please submit a request to get your theme supported." -msgstr "" - -#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:62 -msgid "Press your keyboard shortcut..." -msgstr "" - -#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:76 -#: src/preferences/ui/schedule.ui:828 -msgid "Keyboard shortcut" -msgstr "" - -#: src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui:79 -msgid "Cancel" -msgstr "" - -#: src/preferences/ui/schedule.ui:98 -msgid "Automatic time source" -msgstr "" - -#: src/preferences/ui/schedule.ui:111 -msgid "" -"The extension will try to use Night Light or Location Services to " -"automatically set your current sunrise and sunset times if they are enabled. " -"If you prefer, you can manually choose a time source." -msgstr "" - -#: src/preferences/ui/schedule.ui:191 -msgid "Always show on-demand controls" -msgstr "" - -#: src/preferences/ui/schedule.ui:204 -msgid "" -"This allows you to override the current time when using a schedule." -msgstr "" - -#: src/preferences/ui/schedule.ui:266 -msgid "Manual time source" -msgstr "" - -#: src/preferences/ui/schedule.ui:286 src/preferences/ui/schedule.ui:392 -#: src/preferences/ui/schedule.ui:508 -msgid "Night Light" -msgstr "" - -#: src/preferences/ui/schedule.ui:301 -msgid "Location Services" -msgstr "" - -#: src/preferences/ui/schedule.ui:316 -msgid "Manual schedule" -msgstr "" - -#: src/preferences/ui/schedule.ui:331 src/preferences/ui/schedule.ui:786 -msgid "On-demand" -msgstr "" - -#: src/preferences/ui/schedule.ui:379 -msgid "No preferences" -msgstr "" - -#: src/preferences/ui/schedule.ui:440 -msgid "Follow Disable until tomorrow" -msgstr "" - -#: src/preferences/ui/schedule.ui:454 -msgid "" -"When Night Light is temporarily disabled, the extension will switch " -"to day variants." -msgstr "" - -#: src/preferences/ui/schedule.ui:524 src/preferences/ui/schedule.ui:761 -msgid "Manual schedule times" -msgstr "" - -#: src/preferences/ui/schedule.ui:566 +#: src/preferences/ui/Commands.ui:55 src/preferences/ui/Schedule.ui:107 msgid "Sunrise" msgstr "" -#: src/preferences/ui/schedule.ui:602 src/preferences/ui/schedule.ui:709 -msgid ":" +#. Don't translate the `notify-send` command. +#: src/preferences/ui/Commands.ui:58 +msgid "notify-send \"Hello sunshine!\"" msgstr "" -#: src/preferences/ui/schedule.ui:673 +#: src/preferences/ui/Commands.ui:67 src/preferences/ui/Schedule.ui:115 msgid "Sunset" msgstr "" -#: src/preferences/ui/schedule.ui:920 +#. Don't translate the `notify-send` command. +#: src/preferences/ui/Commands.ui:70 +msgid "notify-send \"Hello moonshine!\"" +msgstr "" + +#: src/preferences/ui/CursorPreferences.ui:15 +msgid "Switch cursor theme variants" +msgstr "" + +#: src/preferences/ui/CursorPreferences.ui:39 +#: src/preferences/ui/GtkPreferences.ui:48 +#: src/preferences/ui/IconPreferences.ui:39 +#: src/preferences/ui/ShellPreferences.ui:48 +msgid "Day variant" +msgstr "" + +#: src/preferences/ui/CursorPreferences.ui:49 +#: src/preferences/ui/GtkPreferences.ui:59 +#: src/preferences/ui/IconPreferences.ui:49 +#: src/preferences/ui/ShellPreferences.ui:59 +msgid "Night variant" +msgstr "" + +#: src/preferences/ui/GtkPreferences.ui:15 +msgid "Switch GTK theme variants" +msgstr "" + +#: src/preferences/ui/GtkPreferences.ui:39 +#: src/preferences/ui/ShellPreferences.ui:39 +msgid "Manual variants" +msgstr "" + +#: src/preferences/ui/Headerbar.ui:12 src/preferences/ui/Headerbar.ui:24 +msgid "Support us" +msgstr "" + +#: src/preferences/ui/Headerbar.ui:48 +msgid "View code on GitLab" +msgstr "" + +#: src/preferences/ui/Headerbar.ui:71 +msgid "Translate on Weblate" +msgstr "" + +#: src/preferences/ui/Headerbar.ui:94 +msgid "Donate on Liberapay" +msgstr "" + +#: src/preferences/ui/IconPreferences.ui:15 +msgid "Switch icon theme variants" +msgstr "" + +#: src/preferences/ui/Preferences.ui:14 +msgid "Schedule" +msgstr "" + +#: src/preferences/ui/Preferences.ui:24 +msgid "Appearance" +msgstr "" + +#: src/preferences/ui/Preferences.ui:34 +msgid "Commands" +msgstr "" + +#: src/preferences/ui/Schedule.ui:27 +msgid "Manual time source" +msgstr "" + +#: src/preferences/ui/Schedule.ui:28 +msgid "" +"The extension will try to use Night Light or Location Services to " +"automatically set your current sunrise and sunset times if they are enabled. " +"If you prefer, you can manually choose a time source." +msgstr "" + +#: src/preferences/ui/Schedule.ui:45 +msgid "Always show on-demand controls" +msgstr "" + +#: src/preferences/ui/Schedule.ui:46 +msgid "Allows you to override the current time when using a schedule." +msgstr "" + +#: src/preferences/ui/Schedule.ui:74 +msgid "Follow Disable until tomorrow" +msgstr "" + +#: src/preferences/ui/Schedule.ui:75 +msgid "" +"When Night Light is temporarily disabled, the extension will switch to day " +"variants." +msgstr "" + +#: src/preferences/ui/Schedule.ui:95 +msgid "Manual schedule times" +msgstr "" + +#: src/preferences/ui/Schedule.ui:147 +msgid "Keyboard shortcut" +msgstr "" + +#: src/preferences/ui/Schedule.ui:155 msgid "Button location" msgstr "" -#: src/preferences/ui/schedule.ui:936 +#: src/preferences/ui/Schedule.ui:160 msgid "None" msgstr "" -#: src/preferences/ui/schedule.ui:937 +#: src/preferences/ui/Schedule.ui:161 msgid "Top bar" msgstr "" -#: src/preferences/ui/schedule.ui:938 +#: src/preferences/ui/Schedule.ui:162 msgid "System menu" msgstr "" -#: src/preferences/ui/shell_theme.ui:76 -msgid "Switch Shell variants" +#: src/preferences/ui/ShellPreferences.ui:15 +msgid "Switch Shell theme variants" msgstr "" -#: src/preferences/ui/shell_theme.ui:164 -msgid "" -"You can manually set variants if the extension cannot automatically " -"detect the day and night variants of your GNOME Shell theme. Please submit a request to get your theme supported." +#: src/preferences/ui/ShortcutButton.ui:32 +msgid "Change keyboard shortcut" +msgstr "" + +#: src/preferences/ui/ShortcutButton.ui:100 +msgid "Press your keyboard shortcut…" +msgstr "" + +#. Time separator (eg. 08:27) +#: src/preferences/ui/TimeChooser.ui:23 +msgid ":" msgstr "" diff --git a/src/preferences/Appearance.js b/src/preferences/Appearance.js new file mode 100644 index 0000000..2b34062 --- /dev/null +++ b/src/preferences/Appearance.js @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + + +var Appearance = GObject.registerClass({ + GTypeName: 'Appearance', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Appearance.ui'])}`, +}, class Appearance extends Gtk.ScrolledWindow {}); diff --git a/src/preferences/BackgroundButton.js b/src/preferences/BackgroundButton.js new file mode 100644 index 0000000..fe4071d --- /dev/null +++ b/src/preferences/BackgroundButton.js @@ -0,0 +1,59 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gdk, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + + +var BackgroundButton = GObject.registerClass({ + GTypeName: 'BackgroundButton', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundButton.ui'])}`, + InternalChildren: ['choose_button', 'change_button', 'clear_button', 'filechooser'], + Properties: { + path: GObject.ParamSpec.string( + 'path', + 'Path', + 'Path to the background file', + GObject.ParamFlags.READWRITE, + null + ), + }, +}, class BackgroundButton extends Gtk.Stack { + activate() { + if (this.path) + return this._change_button.activate(); + else + return this._choose_button.activate(); + } + + openFileChooser() { + this._filechooser.transient_for = this.get_root(); + this._filechooser.show(); + } + + onFileChooserResponse(fileChooser, responseId) { + if (responseId !== Gtk.ResponseType.ACCEPT) + return; + this.path = fileChooser.get_file().get_uri(); + } + + onPathChanged(button) { + button.visible_child_name = button.path ? 'edit' : 'choose'; + } + + onChooseButtonClicked(_button) { + this.openFileChooser(); + } + + onChangeButtonClicked(_button) { + this.openFileChooser(); + } + + onClearButtonClicked(_button) { + this.path = ''; + } +}); diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js deleted file mode 100644 index 65a714e..0000000 --- a/src/preferences/Backgrounds.js +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { GdkPixbuf, Gio, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - - -var BackgroundsPreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'backgrounds.ui'])); - - this.widget = this._builder.get_object('backgrounds'); - this.name = 'backgrounds'; - this.title = _('Backgrounds'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.backgrounds.settings.bind( - 'enabled', - enabledSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const choosers = this._builder.get_object('choosers'); - settings.backgrounds.settings.bind( - 'enabled', - choosers, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const dayChooserButton = this._builder.get_object('day_chooser_button'); - const dayChooser = this._builder.get_object('day_chooser'); - const updateDayChooserButtonLabel = () => { - dayChooserButton.set_label(settings.backgrounds.day ? GLib.filename_display_basename(settings.backgrounds.day) : _('Choose...')); - }; - settings.backgrounds.connect('day-changed', () => updateDayChooserButtonLabel()); - dayChooser.connect('response', (_fileChooser, responseId) => { - if (responseId !== Gtk.ResponseType.ACCEPT) - return; - settings.backgrounds.day = dayChooser.get_file().get_uri(); - }); - dayChooserButton.connect('clicked', () => { - dayChooser.set_transient_for(dayChooserButton.get_root()); - dayChooser.show(); - }); - updateDayChooserButtonLabel(); - - const dayClearButton = this._builder.get_object('day_clear_button'); - dayClearButton.connect('clicked', () => { - settings.backgrounds.day = ''; - }); - const updateDayClearButtonSensitivity = () => { - dayClearButton.sensitive = !!settings.backgrounds.day; - }; - settings.backgrounds.connect('day-changed', () => updateDayClearButtonSensitivity()); - updateDayClearButtonSensitivity(); - - const nightChooserButton = this._builder.get_object('night_chooser_button'); - const nightChooser = this._builder.get_object('night_chooser'); - const updateNightChooserButtonLabel = () => { - nightChooserButton.set_label(settings.backgrounds.night ? GLib.filename_display_basename(settings.backgrounds.night) : _('Choose...')); - }; - settings.backgrounds.connect('night-changed', () => updateNightChooserButtonLabel()); - nightChooser.connect('response', (_fileChooser, responseId) => { - if (responseId !== Gtk.ResponseType.ACCEPT) - return; - settings.backgrounds.night = nightChooser.get_file().get_uri(); - }); - nightChooserButton.connect('clicked', () => { - nightChooser.set_transient_for(nightChooserButton.get_root()); - nightChooser.show(); - }); - updateNightChooserButtonLabel(); - - const nightClearButton = this._builder.get_object('night_clear_button'); - nightClearButton.connect('clicked', () => { - settings.backgrounds.night = ''; - }); - const updateNightClearButtonSensitivity = () => { - nightClearButton.sensitive = !!settings.backgrounds.night; - }; - settings.backgrounds.connect('night-changed', () => updateNightClearButtonSensitivity()); - updateNightClearButtonSensitivity(); - } -}; diff --git a/src/preferences/BackgroundsPreferences.js b/src/preferences/BackgroundsPreferences.js new file mode 100644 index 0000000..8f4a2e2 --- /dev/null +++ b/src/preferences/BackgroundsPreferences.js @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + + +var BackgroundsPreferences = GObject.registerClass({ + GTypeName: 'BackgroundsPreferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'BackgroundsPreferences.ui'])}`, + InternalChildren: [ + 'enabled_switch', + 'day_button', + 'night_button', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Backgrounds GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class BackgroundsPreferences extends Gtk.Box { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('backgrounds')); + + this.settings.bind( + 'enabled', + this._enabled_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + this.settings.bind( + 'day', + this._day_button, + 'path', + Gio.SettingsBindFlags.DEFAULT + ); + + this.settings.bind( + 'night', + this._night_button, + 'path', + Gio.SettingsBindFlags.DEFAULT + ); + } +}); diff --git a/src/preferences/ClearableEntry.js b/src/preferences/ClearableEntry.js new file mode 100644 index 0000000..19d94c7 --- /dev/null +++ b/src/preferences/ClearableEntry.js @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + + +var ClearableEntry = GObject.registerClass({ + GTypeName: 'ClearableEntry', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ClearableEntry.ui'])}`, +}, class ClearableEntry extends Gtk.Entry { + onIconReleased(entry, position) { + if (position === Gtk.EntryIconPosition.SECONDARY) + entry.text = ''; + } +}); diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js index 7d88d78..44cbf5f 100644 --- a/src/preferences/Commands.js +++ b/src/preferences/Commands.js @@ -1,78 +1,51 @@ // SPDX-FileCopyrightText: 2020, 2021 Romain Vigier // SPDX-License-Identifier: GPL-3.0-or-later -const { Gio, GLib, Gtk } = imports.gi; +const { Gio, GLib, GObject, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; +const utils = Me.imports.utils; -var CommandsPreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'commands.ui'])); +var Commands = GObject.registerClass({ + GTypeName: 'Commands', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Commands.ui'])}`, + InternalChildren: ['enabled_switch', 'sunrise_entry', 'sunset_entry'], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Command GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class Commands extends Gtk.ScrolledWindow { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('commands')); - this.widget = this._builder.get_object('commands'); - this.name = 'commands'; - this.title = _('Commands'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.commands.settings.bind( + this.settings.bind( 'enabled', - enabledSwitch, + this._enabled_switch, 'active', Gio.SettingsBindFlags.DEFAULT ); - const entries = this._builder.get_object('entries'); - settings.commands.settings.bind( - 'enabled', - entries, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const sunriseEntry = this._builder.get_object('sunrise_entry'); - settings.commands.settings.bind( + this.settings.bind( 'sunrise', - sunriseEntry, + this._sunrise_entry, 'text', Gio.SettingsBindFlags.DEFAULT ); - const sunriseClearButton = this._builder.get_object('sunrise_clear_button'); - sunriseClearButton.connect('clicked', () => { - settings.commands.sunrise = ''; - }); - const updateSunriseClearButtonSensitivity = () => { - sunriseClearButton.sensitive = !!settings.commands.sunrise; - }; - settings.commands.connect('sunrise-changed', () => updateSunriseClearButtonSensitivity()); - updateSunriseClearButtonSensitivity(); - - const sunsetEntry = this._builder.get_object('sunset_entry'); - settings.commands.settings.bind( + this.settings.bind( 'sunset', - sunsetEntry, + this._sunset_entry, 'text', Gio.SettingsBindFlags.DEFAULT ); - - const sunsetClearButton = this._builder.get_object('sunset_clear_button'); - sunsetClearButton.connect('clicked', () => { - settings.commands.sunset = ''; - }); - const updateSunsetClearButtonSensitivity = () => { - sunsetClearButton.sensitive = !!settings.commands.sunset; - }; - settings.commands.connect('sunset-changed', () => updateSunsetClearButtonSensitivity()); - updateSunsetClearButtonSensitivity(); } -}; +}); diff --git a/src/preferences/CursorPreferences.js b/src/preferences/CursorPreferences.js new file mode 100644 index 0000000..2ee1401 --- /dev/null +++ b/src/preferences/CursorPreferences.js @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const { DropDownChoice } = Me.imports.preferences.DropDownChoice; + + +var CursorPreferences = GObject.registerClass({ + GTypeName: 'CursorPreferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'CursorPreferences.ui'])}`, + InternalChildren: [ + 'enabled_switch', + 'day_dropdown', + 'night_dropdown', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Cursor GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class CursorPreferences extends Gtk.Box { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('cursor-variants')); + + this.settings.bind( + 'enabled', + this._enabled_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const themeChoices = Gio.ListStore.new(DropDownChoice); + themeChoices.splice(0, 0, Array.from(utils.getInstalledCursorThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme }))); + + this._day_dropdown.model = themeChoices; + this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id)); + const updateDayDropDownSelected = () => { + this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day')); + }; + this.settings.connect('changed::day', () => updateDayDropDownSelected()); + updateDayDropDownSelected(); + + this._night_dropdown.model = themeChoices; + this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id)); + const updateNightDropDownSelected = () => { + this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night')); + }; + this.settings.connect('changed::night', () => updateNightDropDownSelected()); + updateNightDropDownSelected(); + } +}); diff --git a/src/preferences/CursorTheme.js b/src/preferences/CursorTheme.js deleted file mode 100644 index 4c67049..0000000 --- a/src/preferences/CursorTheme.js +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { Gio, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const utils = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - - -var CursorThemePreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'cursor_theme.ui'])); - - this.widget = this._builder.get_object('cursor_theme'); - this.name = 'cursor-theme'; - this.title = _('Cursor theme'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.cursorVariants.settings.bind( - 'enabled', - enabledSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const variants = this._builder.get_object('variants'); - settings.cursorVariants.settings.bind( - 'enabled', - variants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const installedCursorThemes = Array.from(utils.getInstalledCursorThemes()).sort(); - const dayCombo = this._builder.get_object('day_combo'); - const nightCombo = this._builder.get_object('night_combo'); - installedCursorThemes.forEach(theme => { - dayCombo.append(theme, theme); - nightCombo.append(theme, theme); - }); - settings.cursorVariants.settings.bind( - 'day', - dayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - settings.cursorVariants.settings.bind( - 'night', - nightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } -}; diff --git a/src/preferences/DropDownChoice.js b/src/preferences/DropDownChoice.js new file mode 100644 index 0000000..867d569 --- /dev/null +++ b/src/preferences/DropDownChoice.js @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { GObject } = imports.gi; + + +var DropDownChoice = GObject.registerClass({ + GTypeName: 'DropDownChoice', + Properties: { + id: GObject.ParamSpec.string( + 'id', + 'ID', + 'Identifier', + GObject.ParamFlags.READWRITE, + null + ), + title: GObject.ParamSpec.string( + 'title', + 'Title', + 'Displayed title', + GObject.ParamFlags.READWRITE, + null + ), + enabled: GObject.ParamSpec.boolean( + 'enabled', + 'Enabled', + 'If the choice is enabled', + GObject.ParamFlags.READWRITE, + true + ), + }, +}, class DropDownChoice extends GObject.Object {}); diff --git a/src/preferences/GtkPreferences.js b/src/preferences/GtkPreferences.js new file mode 100644 index 0000000..be61b6e --- /dev/null +++ b/src/preferences/GtkPreferences.js @@ -0,0 +1,72 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const { DropDownChoice } = Me.imports.preferences.DropDownChoice; + + +var GtkPreferences = GObject.registerClass({ + GTypeName: 'GtkPreferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'GtkPreferences.ui'])}`, + InternalChildren: [ + 'enabled_switch', + 'manual_switch', + 'day_dropdown', + 'night_dropdown', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'GTK GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class GtkPreferences extends Gtk.Box { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('gtk-variants')); + + this.settings.bind( + 'enabled', + this._enabled_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + this.settings.bind( + 'manual', + this._manual_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const themeChoices = Gio.ListStore.new(DropDownChoice); + themeChoices.splice(0, 0, Array.from(utils.getInstalledGtkThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme }))); + + this._day_dropdown.model = themeChoices; + this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id)); + const updateDayDropDownSelected = () => { + this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day')); + }; + this.settings.connect('changed::day', () => updateDayDropDownSelected()); + updateDayDropDownSelected(); + + this._night_dropdown.model = themeChoices; + this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id)); + const updateNightDropDownSelected = () => { + this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night')); + }; + this.settings.connect('changed::night', () => updateNightDropDownSelected()); + updateNightDropDownSelected(); + } +}); diff --git a/src/preferences/GtkTheme.js b/src/preferences/GtkTheme.js deleted file mode 100644 index 3894cef..0000000 --- a/src/preferences/GtkTheme.js +++ /dev/null @@ -1,80 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { Gio, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const utils = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - - -var GtkThemePreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'gtk_theme.ui'])); - - this.widget = this._builder.get_object('gtk_theme'); - this.name = 'gtk-theme'; - this.title = _('GTK theme'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.gtkVariants.settings.bind( - 'enabled', - enabledSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const manual = this._builder.get_object('manual'); - settings.gtkVariants.settings.bind( - 'enabled', - manual, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const manualSwitch = this._builder.get_object('manual_switch'); - settings.gtkVariants.settings.bind( - 'manual', - manualSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const variants = this._builder.get_object('variants'); - const updateVariantsSensitivity = () => { - variants.sensitive = !!(settings.gtkVariants.enabled && settings.gtkVariants.manual); - }; - settings.gtkVariants.connect('status-changed', () => updateVariantsSensitivity()); - settings.gtkVariants.connect('manual-changed', () => updateVariantsSensitivity()); - updateVariantsSensitivity(); - - const dayCombo = this._builder.get_object('day_combo'); - const nightCombo = this._builder.get_object('night_combo'); - const installedGtkThemes = Array.from(utils.getInstalledGtkThemes()).sort(); - installedGtkThemes.forEach(theme => { - dayCombo.append(theme, theme); - nightCombo.append(theme, theme); - }); - settings.gtkVariants.settings.bind( - 'day', - dayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - settings.gtkVariants.settings.bind( - 'night', - nightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } -}; diff --git a/src/preferences/Headerbar.js b/src/preferences/Headerbar.js index cbec89c..b621cb3 100644 --- a/src/preferences/Headerbar.js +++ b/src/preferences/Headerbar.js @@ -1,49 +1,47 @@ // SPDX-FileCopyrightText: 2020, 2021 Romain Vigier // SPDX-License-Identifier: GPL-3.0-or-later -const { GLib, Gtk } = imports.gi; +const { GLib, GObject, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; -const utils = Me.imports.utils; - - -var Headerbar = class { - constructor(stack) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'headerbar.ui'])); - - this.widget = this._builder.get_object('headerbar'); - - this._connect(stack); - - return this.widget; +var Headerbar = GObject.registerClass({ + GTypeName: 'Headerbar', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Headerbar.ui'])}`, + Properties: { + preferences: GObject.ParamSpec.object( + 'preferences', + 'Preferences', + 'A Preferences stack', + GObject.ParamFlags.READWRITE, + Gtk.Stack.$gtype + ), + }, +}, class Headerbar extends Gtk.HeaderBar { + onPreferencesChanged(headerbar) { + headerbar.title_widget = null; + if (!headerbar.preferences) + return; + const pages = headerbar.preferences.pages; + const box = new Gtk.Box({ orientation: 'horizontal', css_classes: ['linked'] }); + for (let i = 0; i < pages.get_n_items(); i++) { + const page = pages.get_item(i); + const button = new Gtk.ToggleButton({ active: pages.is_selected(i) }); + const buttonBox = new Gtk.Box({ orientation: 'horizontal', margin_start: 12, margin_end: 12, spacing: 6 }); + buttonBox.append(new Gtk.Image({ icon_name: page.icon_name })); + buttonBox.append(new Gtk.Label({ label: page.title })); + button.set_child(buttonBox); + button.connect('clicked', () => { + pages.select_item(i, true); + button.active = true; + }); + pages.connect('selection-changed', () => { + button.active = pages.is_selected(i); + }); + box.append(button); + } + headerbar.title_widget = box; } - - _connect(stack) { - const scheduleRadio = this._builder.get_object('schedule_radio'); - scheduleRadio.connect('clicked', () => stack.set_visible_child_name('schedule')); - - const gtkThemeRadio = this._builder.get_object('gtk_theme_radio'); - gtkThemeRadio.connect('clicked', () => stack.set_visible_child_name('gtk-theme')); - - const shellThemeRadio = this._builder.get_object('shell_theme_radio'); - shellThemeRadio.connect('clicked', () => stack.set_visible_child_name('shell-theme')); - - const iconThemeRadio = this._builder.get_object('icon_theme_radio'); - iconThemeRadio.connect('clicked', () => stack.set_visible_child_name('icon-theme')); - - const cursorThemeRadio = this._builder.get_object('cursor_theme_radio'); - cursorThemeRadio.connect('clicked', () => stack.set_visible_child_name('cursor-theme')); - - const backgroundsRadio = this._builder.get_object('backgrounds_radio'); - backgroundsRadio.connect('clicked', () => stack.set_visible_child_name('backgrounds')); - - const commandsRadio = this._builder.get_object('commands_radio'); - commandsRadio.connect('clicked', () => stack.set_visible_child_name('commands')); - } -}; +}); diff --git a/src/preferences/IconPreferences.js b/src/preferences/IconPreferences.js new file mode 100644 index 0000000..ed3b781 --- /dev/null +++ b/src/preferences/IconPreferences.js @@ -0,0 +1,64 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const { DropDownChoice } = Me.imports.preferences.DropDownChoice; + + +var IconPreferences = GObject.registerClass({ + GTypeName: 'IconPreferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'IconPreferences.ui'])}`, + InternalChildren: [ + 'enabled_switch', + 'day_dropdown', + 'night_dropdown', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Icon GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class IconPreferences extends Gtk.Box { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('icon-variants')); + + this.settings.bind( + 'enabled', + this._enabled_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const themeChoices = Gio.ListStore.new(DropDownChoice); + themeChoices.splice(0, 0, Array.from(utils.getInstalledIconThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme }))); + + this._day_dropdown.model = themeChoices; + this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id)); + const updateDayDropDownSelected = () => { + this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day')); + }; + this.settings.connect('changed::day', () => updateDayDropDownSelected()); + updateDayDropDownSelected(); + + this._night_dropdown.model = themeChoices; + this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id)); + const updateNightDropDownSelected = () => { + this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night')); + }; + this.settings.connect('changed::night', () => updateNightDropDownSelected()); + updateNightDropDownSelected(); + } +}); diff --git a/src/preferences/IconTheme.js b/src/preferences/IconTheme.js deleted file mode 100644 index aa3194c..0000000 --- a/src/preferences/IconTheme.js +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { Gio, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const utils = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - - -var IconThemePreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'icon_theme.ui'])); - - this.widget = this._builder.get_object('icon_theme'); - this.name = 'icon-theme'; - this.title = _('Icon theme'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.iconVariants.settings.bind( - 'enabled', - enabledSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const variants = this._builder.get_object('variants'); - settings.iconVariants.settings.bind( - 'enabled', - variants, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const installedIconThemes = Array.from(utils.getInstalledIconThemes()).sort(); - const dayCombo = this._builder.get_object('day_combo'); - const nightCombo = this._builder.get_object('night_combo'); - installedIconThemes.forEach(theme => { - dayCombo.append(theme, theme); - nightCombo.append(theme, theme); - }); - settings.iconVariants.settings.bind( - 'day', - dayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - settings.iconVariants.settings.bind( - 'night', - nightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } -}; diff --git a/src/preferences/OndemandKeyboardShortcutDialog.js b/src/preferences/OndemandKeyboardShortcutDialog.js deleted file mode 100644 index 7438624..0000000 --- a/src/preferences/OndemandKeyboardShortcutDialog.js +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { Gdk, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - -const utils = Me.imports.utils; - - -var OndemandKeyboardShortcutDialog = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ondemand_keyboard_shortcut_dialog.ui'])); - - this.widget = this._builder.get_object('dialog'); - - this._connectSettings(settings); - - return this.widget; - } - - _connectSettings(settings) { - const eventController = this._builder.get_object('event-controller'); - eventController.connect('key-pressed', (_widget, keyval, keycode, state) => { - let mask = state & Gtk.accelerator_get_default_mod_mask(); - mask &= ~Gdk.ModifierType.LOCK_MASK; - - if (mask === 0 && keyval === Gdk.KEY_Escape) { - this.widget.visible = false; - return Gdk.EVENT_STOP; - } - - if ( - !utils.isBindingValid({ mask, keycode, keyval }) || - !utils.isAccelValid({ mask, keyval }) - ) - return Gdk.EVENT_STOP; - - const binding = Gtk.accelerator_name_with_keycode( - null, - keyval, - keycode, - mask - ); - settings.time.ondemandKeybinding = binding; - this.widget.close(); - return Gdk.EVENT_STOP; - }); - } -}; diff --git a/src/preferences/PreferenceRow.js b/src/preferences/PreferenceRow.js new file mode 100644 index 0000000..b809134 --- /dev/null +++ b/src/preferences/PreferenceRow.js @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + + +var PreferenceRow = GObject.registerClass({ + GTypeName: 'PreferenceRow', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'PreferenceRow.ui'])}`, + InternalChildren: ['subtitle_label', 'end_box'], + Properties: { + title: GObject.ParamSpec.string( + 'title', + 'Title', + 'Title of the preference', + GObject.ParamFlags.READWRITE, + null + ), + subtitle: GObject.ParamSpec.string( + 'subtitle', + 'Subtitle', + 'Description of the preference', + GObject.ParamFlags.READWRITE, + null + ), + activatable_widget: GObject.ParamSpec.object( + 'activatable-widget', + 'Activatable widget', + 'The widget to activate when the row is activated', + GObject.ParamFlags.READWRITE, + Gtk.Widget.$gtype + ), + }, +}, class PreferenceRow extends Gtk.ListBoxRow { + activate() { + if (this.activatable_widget) + return this.activatable_widget.activate(); + else + return false; + } + + onSubtitleChanged(list) { + list._subtitle_label.visible = !!list.subtitle; + } + + onActivatableWidgetChanged(list) { + while (list._end_box.get_last_child()) + list._end_box.remove(list._end_box.get_last_child()); + list.activatable = false; + if (list.activatable_widget) { + list._end_box.append(list.activatable_widget); + list.activatable = true; + } + } +}); diff --git a/src/preferences/Preferences.js b/src/preferences/Preferences.js index ae7fe40..9505eee 100644 --- a/src/preferences/Preferences.js +++ b/src/preferences/Preferences.js @@ -1,57 +1,28 @@ // SPDX-FileCopyrightText: 2020, 2021 Romain Vigier // SPDX-License-Identifier: GPL-3.0-or-later -const { Gtk } = imports.gi; +const { GLib, GObject, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const { Settings } = Me.imports.settings.Settings; - -const { BackgroundsPreferences } = Me.imports.preferences.Backgrounds; -const { CommandsPreferences } = Me.imports.preferences.Commands; -const { CursorThemePreferences } = Me.imports.preferences.CursorTheme; -const { GtkThemePreferences } = Me.imports.preferences.GtkTheme; -const { IconThemePreferences } = Me.imports.preferences.IconTheme; -const { SchedulePreferences } = Me.imports.preferences.Schedule; -const { ShellThemePreferences } = Me.imports.preferences.ShellTheme; - -const { Headerbar } = Me.imports.preferences.Headerbar; +const { Appearance } = Me.imports.preferences.Appearance; +const { BackgroundButton } = Me.imports.preferences.BackgroundButton; +const { BackgroundsPreferences } = Me.imports.preferences.BackgroundsPreferences; +const { ClearableEntry } = Me.imports.preferences.ClearableEntry; +const { Commands } = Me.imports.preferences.Commands; +const { CursorPreferences } = Me.imports.preferences.CursorPreferences; +const { GtkPreferences } = Me.imports.preferences.GtkPreferences; +const { IconPreferences } = Me.imports.preferences.IconPreferences; +const { PreferenceRow } = Me.imports.preferences.PreferenceRow; +const { PreferencesList } = Me.imports.preferences.PreferencesList; +const { Schedule } = Me.imports.preferences.Schedule; +const { ShellPreferences } = Me.imports.preferences.ShellPreferences; +const { ShortcutButton } = Me.imports.preferences.ShortcutButton; +const { TimeChooser } = Me.imports.preferences.TimeChooser; -var Preferences = class { - constructor() { - this.settings = new Settings(); - this.settings.enable(); - - this.widget = new Gtk.Stack({ - interpolate_size: true, - vhomogeneous: false, - transition_type: Gtk.StackTransitionType.SLIDE_LEFT_RIGHT, - visible: true, - }); - - const schedulePreferences = new SchedulePreferences(this.settings); - this.widget.add_titled(schedulePreferences.widget, schedulePreferences.name, schedulePreferences.title); - - const gtkThemePreferences = new GtkThemePreferences(this.settings); - this.widget.add_titled(gtkThemePreferences.widget, gtkThemePreferences.name, gtkThemePreferences.title); - - const shellThemePreferences = new ShellThemePreferences(this.settings); - this.widget.add_titled(shellThemePreferences.widget, shellThemePreferences.name, shellThemePreferences.title); - - const iconThemePreferences = new IconThemePreferences(this.settings); - this.widget.add_titled(iconThemePreferences.widget, iconThemePreferences.name, iconThemePreferences.title); - - const cursorThemePreferences = new CursorThemePreferences(this.settings); - this.widget.add_titled(cursorThemePreferences.widget, cursorThemePreferences.name, cursorThemePreferences.title); - - const backgroundsPreferences = new BackgroundsPreferences(this.settings); - this.widget.add_titled(backgroundsPreferences.widget, backgroundsPreferences.name, backgroundsPreferences.title); - - const commandsPreferences = new CommandsPreferences(this.settings); - this.widget.add_titled(commandsPreferences.widget, commandsPreferences.name, commandsPreferences.title); - - this.headerbar = new Headerbar(this.widget); - } -}; +var Preferences = GObject.registerClass({ + GTypeName: 'Preferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Preferences.ui'])}`, +}, class Preferences extends Gtk.Stack {}); diff --git a/src/preferences/PreferencesList.js b/src/preferences/PreferencesList.js new file mode 100644 index 0000000..e41025e --- /dev/null +++ b/src/preferences/PreferencesList.js @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + + +var PreferencesList = GObject.registerClass({ + GTypeName: 'PreferencesList', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'PreferencesList.ui'])}`, +}, class PreferencesList extends Gtk.ListBox { + onRowActivated(_list, row) { + row.activate(); + } +}); diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js index b88d119..81994d7 100644 --- a/src/preferences/Schedule.js +++ b/src/preferences/Schedule.js @@ -1,229 +1,149 @@ // SPDX-FileCopyrightText: 2020, 2021 Romain Vigier // SPDX-License-Identifier: GPL-3.0-or-later -const { Gio, GLib, Gtk } = imports.gi; +const { Gio, GLib, GObject, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const { OndemandKeyboardShortcutDialog } = Me.imports.preferences.OndemandKeyboardShortcutDialog; +const utils = Me.imports.utils; + +const { DropDownChoice } = Me.imports.preferences.DropDownChoice; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; -var SchedulePreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'schedule.ui'])); +var Schedule = GObject.registerClass({ + GTypeName: 'Schedule', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'Schedule.ui'])}`, + InternalChildren: [ + 'manual_time_source_switch', + 'time_source_dropdown', + 'always_show_ondemand_switch', + 'nightlight_preferences_revealer', + 'nightlight_follow_disable_switch', + 'schedule_preferences_revealer', + 'schedule_sunrise_time_chooser', + 'schedule_sunset_time_chooser', + 'ondemand_preferences_revealer', + 'ondemand_shortcut_button', + 'ondemand_button_location_combo', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Time GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class Schedule extends Gtk.ScrolledWindow { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('time')); - this.widget = this._builder.get_object('schedule'); - this.name = 'schedule'; - this.title = _('Schedule'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const autoSwitch = this._builder.get_object('auto_switch'); - settings.time.settings.bind( + this.settings.bind( 'manual-time-source', - autoSwitch, - 'active', - Gio.SettingsBindFlags.INVERT_BOOLEAN - ); - - const alwaysEnableOndemandSwitch = this._builder.get_object('always_enable_ondemand_switch'); - settings.time.settings.bind( - 'always-enable-ondemand', - alwaysEnableOndemandSwitch, + this._manual_time_source_switch, 'active', Gio.SettingsBindFlags.DEFAULT ); - const manual = this._builder.get_object('manual'); - settings.time.settings.bind( - 'manual-time-source', - manual, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); + const choiceFilter = new Gtk.BoolFilter({ expression: Gtk.PropertyExpression.new(DropDownChoice, null, 'enabled') }); - const manualNightlightRadio = this._builder.get_object('manual_nightlight_radio'); - const updateManualNightlightRadioActivity = () => { - manualNightlightRadio.active = settings.time.timeSource === 'nightlight'; - }; - settings.time.connect('time-source-changed', () => updateManualNightlightRadioActivity()); - settings.system.colorSettings.bind( + const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' }); + const nightlightChoice = new DropDownChoice({ id: 'nightlight', title: _('Night Light') }); + nightlightChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT)); + colorSettings.bind( 'night-light-enabled', - manualNightlightRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - manualNightlightRadio.connect('toggled', () => { - if (manualNightlightRadio.active) - settings.time.timeSource = 'nightlight'; - }); - updateManualNightlightRadioActivity(); - - const manualLocationRadio = this._builder.get_object('manual_location_radio'); - const updateManualLocationRadioActivity = () => { - manualLocationRadio.active = settings.time.timeSource === 'location'; - }; - settings.time.connect('time-source-changed', () => updateManualLocationRadioActivity()); - settings.system.locationSettings.bind( + nightlightChoice, 'enabled', - manualLocationRadio, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT + Gio.SettingsBindFlags.GET ); - manualLocationRadio.connect('toggled', () => { - if (manualLocationRadio.active) - settings.time.timeSource = 'location'; + + const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' }); + const locationChoice = new DropDownChoice({ id: 'location', title: _('Location Services') }); + locationChoice.connect('notify::enabled', () => choiceFilter.changed(Gtk.FilterChange.DIFFERENT)); + locationSettings.bind( + 'enabled', + locationChoice, + 'enabled', + Gio.SettingsBindFlags.GET + ); + + const timeSources = Gio.ListStore.new(DropDownChoice); + timeSources.splice(0, 0, [ + nightlightChoice, + locationChoice, + new DropDownChoice({ id: 'schedule', title: _('Manual schedule') }), + new DropDownChoice({ id: 'ondemand', title: _('On-demand') }), + ]); + + this._time_source_dropdown.model = new Gtk.FilterListModel({ + model: timeSources, + filter: choiceFilter, }); - updateManualLocationRadioActivity(); - - const manualScheduleRadio = this._builder.get_object('manual_schedule_radio'); - const updateManualScheduleRadioActivity = () => { - manualScheduleRadio.active = settings.time.timeSource === 'schedule'; + this._time_source_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._time_source_dropdown.connect('notify::selected-item', () => this.settings.set_string('time-source', this._time_source_dropdown.selected_item.id)); + const updateTimeSourceDropDownSelected = () => { + this._time_source_dropdown.selected = utils.findItemPositionInModel(this._time_source_dropdown.model, item => item.id === this.settings.get_string('time-source')); }; - settings.time.connect('time-source-changed', () => updateManualScheduleRadioActivity()); - manualScheduleRadio.connect('toggled', () => { - if (manualScheduleRadio.active) - settings.time.timeSource = 'schedule'; - }); - updateManualScheduleRadioActivity(); + this.settings.connect('changed::time-source', () => updateTimeSourceDropDownSelected()); + updateTimeSourceDropDownSelected(); - const manualOndemandRadio = this._builder.get_object('manual_ondemand_radio'); - const updateManualOndemandRadioActivity = () => { - manualOndemandRadio.active = settings.time.timeSource === 'ondemand'; - }; - settings.time.connect('time-source-changed', () => updateManualOndemandRadioActivity()); - manualOndemandRadio.connect('toggled', () => { - if (manualOndemandRadio.active) - settings.time.timeSource = 'ondemand'; - }); - updateManualOndemandRadioActivity(); - - const manualPrefsStack = this._builder.get_object('manual_prefs_stack'); - const updateManualPrefsStackVisible = () => { - switch (settings.time.timeSource) { - case 'nightlight': - manualPrefsStack.set_visible_child_name('nightlight'); - break; - case 'schedule': - manualPrefsStack.set_visible_child_name('schedule_times'); - break; - default: - manualPrefsStack.set_visible_child_name('none'); - } - }; - settings.time.connect('time-source-changed', () => updateManualPrefsStackVisible()); - updateManualPrefsStackVisible(); - - const nightlightFollowDisableSwitch = this._builder.get_object('nightlight_follow_disable_switch'); - settings.time.settings.bind( - 'nightlight-follow-disable', - nightlightFollowDisableSwitch, + this.settings.bind( + 'always-enable-ondemand', + this._always_show_ondemand_switch, 'active', Gio.SettingsBindFlags.DEFAULT ); - const scheduleTimesSunriseHoursSpin = this._builder.get_object('schedule_times_sunrise_hours_spin'); - scheduleTimesSunriseHoursSpin.value = Math.trunc(settings.time.scheduleSunrise); - scheduleTimesSunriseHoursSpin.connect('output', () => { - const text = scheduleTimesSunriseHoursSpin.adjustment.value.toString().padStart(2, '0'); - scheduleTimesSunriseHoursSpin.set_text(text); - return true; - }); - scheduleTimesSunriseHoursSpin.connect('value-changed', () => { - const oldTime = settings.time.scheduleSunrise; - const oldHour = Math.trunc(oldTime); - const newMinutes = oldTime - oldHour; - const newTime = scheduleTimesSunriseHoursSpin.value + newMinutes; - settings.time.scheduleSunrise = newTime; - }); + this.settings.bind( + 'nightlight-follow-disable', + this._nightlight_follow_disable_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); - const scheduleTimesSunriseMinutesSpin = this._builder.get_object('schedule_times_sunrise_minutes_spin'); - scheduleTimesSunriseMinutesSpin.value = Math.round((settings.time.scheduleSunrise - Math.trunc(settings.time.scheduleSunrise)) * 60); - scheduleTimesSunriseMinutesSpin.connect('output', () => { - const text = scheduleTimesSunriseMinutesSpin.adjustment.value.toString().padStart(2, '0'); - scheduleTimesSunriseMinutesSpin.set_text(text); - return true; - }); - scheduleTimesSunriseMinutesSpin.connect('value-changed', () => { - const hour = Math.trunc(settings.time.scheduleSunrise); - const newMinutes = scheduleTimesSunriseMinutesSpin.value / 60; - const newTime = hour + newMinutes; - settings.time.scheduleSunrise = newTime; - }); + this.settings.bind( + 'schedule-sunrise', + this._schedule_sunrise_time_chooser, + 'time', + Gio.SettingsBindFlags.DEFAULT + ); - const scheduleTimesSunsetHoursSpin = this._builder.get_object('schedule_times_sunset_hours_spin'); - scheduleTimesSunsetHoursSpin.value = Math.trunc(settings.time.scheduleSunset); - scheduleTimesSunsetHoursSpin.connect('output', () => { - const text = scheduleTimesSunsetHoursSpin.adjustment.value.toString().padStart(2, '0'); - scheduleTimesSunsetHoursSpin.set_text(text); - return true; - }); - scheduleTimesSunsetHoursSpin.connect('value-changed', () => { - const oldTime = settings.time.scheduleSunset; - const oldHour = Math.trunc(oldTime); - const newMinutes = oldTime - oldHour; - const newTime = scheduleTimesSunsetHoursSpin.value + newMinutes; - settings.time.scheduleSunset = newTime; - }); + this.settings.bind( + 'schedule-sunset', + this._schedule_sunset_time_chooser, + 'time', + Gio.SettingsBindFlags.DEFAULT + ); - const scheduleTimesSunsetMinutesSpin = this._builder.get_object('schedule_times_sunset_minutes_spin'); - scheduleTimesSunsetMinutesSpin.value = Math.round((settings.time.scheduleSunset - Math.trunc(settings.time.scheduleSunset)) * 60); - scheduleTimesSunsetMinutesSpin.connect('output', () => { - const text = scheduleTimesSunsetMinutesSpin.adjustment.value.toString().padStart(2, '0'); - scheduleTimesSunsetMinutesSpin.set_text(text); - return true; + this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => { + this._ondemand_shortcut_button.keybinding = this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; }); - scheduleTimesSunsetMinutesSpin.connect('value-changed', () => { - const hour = Math.trunc(settings.time.scheduleSunset); - const newMinutes = scheduleTimesSunsetMinutesSpin.value / 60; - const newTime = hour + newMinutes; - settings.time.scheduleSunset = newTime; + this._ondemand_shortcut_button.connect('notify::keybinding', () => { + this.settings.set_strv('nightthemeswitcher-ondemand-keybinding', [this._ondemand_shortcut_button.keybinding]); }); + this._ondemand_shortcut_button.keybinding = this.settings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; - const ondemand = this._builder.get_object('ondemand'); - const updateOndemandVisibility = () => { - ondemand.visible = settings.time.alwaysEnableOndemand || settings.time.timeSource === 'ondemand'; - }; - settings.time.connect('always-enable-ondemand-changed', () => updateOndemandVisibility()); - settings.time.connect('time-source-changed', () => updateOndemandVisibility()); - updateOndemandVisibility(); - - const ondemandShortcutButton = this._builder.get_object('ondemand_shortcut_button'); - const updateOndemandShortcutButtonLabel = () => { - const label = settings.time.ondemandKeybinding; - ondemandShortcutButton.label = label || _('Choose'); - }; - settings.time.connect('ondemand-keybinding-changed', () => updateOndemandShortcutButtonLabel()); - ondemandShortcutButton.connect('clicked', () => { - const dialog = new OndemandKeyboardShortcutDialog(settings); - dialog.set_transient_for(this.widget.get_root()); - dialog.present(); - }); - updateOndemandShortcutButtonLabel(); - - const ondemandShortcutClearButton = this._builder.get_object('ondemand_shortcut_clear_button'); - ondemandShortcutClearButton.connect('clicked', () => { - settings.time.ondemandKeybinding = ''; - }); - const updateOndemandShortcutClearButtonVisibility = () => { - ondemandShortcutClearButton.visible = !!settings.time.ondemandKeybinding; - }; - settings.time.connect('ondemand-keybinding-changed', () => updateOndemandShortcutClearButtonVisibility()); - updateOndemandShortcutClearButtonVisibility(); - - const ondemandButtonPlacementCombo = this._builder.get_object('ondemand_button_placement_combo'); - settings.time.settings.bind( + this.settings.bind( 'ondemand-button-placement', - ondemandButtonPlacementCombo, + this._ondemand_button_location_combo, 'active-id', Gio.SettingsBindFlags.DEFAULT ); + + const updatePreferencesVisibility = () => { + const timeSource = this.settings.get_string('time-source'); + this._nightlight_preferences_revealer.reveal_child = timeSource === 'nightlight'; + this._schedule_preferences_revealer.reveal_child = timeSource === 'schedule'; + this._ondemand_preferences_revealer.reveal_child = timeSource === 'ondemand' || this.settings.get_boolean('always-enable-ondemand'); + }; + this.settings.connect('changed::time-source', () => updatePreferencesVisibility()); + this.settings.connect('changed::always-enable-ondemand', () => updatePreferencesVisibility()); + updatePreferencesVisibility(); } -}; +}); diff --git a/src/preferences/ShellPreferences.js b/src/preferences/ShellPreferences.js new file mode 100644 index 0000000..25f6609 --- /dev/null +++ b/src/preferences/ShellPreferences.js @@ -0,0 +1,75 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gio, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + +const { DropDownChoice } = Me.imports.preferences.DropDownChoice; + +const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); +const _ = Gettext.gettext; + + +var ShellPreferences = GObject.registerClass({ + GTypeName: 'ShellPreferences', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ShellPreferences.ui'])}`, + InternalChildren: [ + 'enabled_switch', + 'manual_switch', + 'day_dropdown', + 'night_dropdown', + ], + Properties: { + settings: GObject.ParamSpec.object( + 'settings', + 'Settings', + 'Shell GSettings', + GObject.ParamFlags.READWRITE, + Gio.Settings.$gtype + ), + }, +}, class ShellPreferences extends Gtk.Box { + _init(props = {}) { + super._init(props); + this.settings = extensionUtils.getSettings(utils.getSettingsSchema('shell-variants')); + + this.settings.bind( + 'enabled', + this._enabled_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + this.settings.bind( + 'manual', + this._manual_switch, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + + const themeChoices = Gio.ListStore.new(DropDownChoice); + themeChoices.splice(0, 0, Array.from(utils.getInstalledShellThemes()).sort().map(theme => new DropDownChoice({ id: theme, title: theme || _('Default') }))); + + this._day_dropdown.model = themeChoices; + this._day_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._day_dropdown.connect('notify::selected-item', () => this.settings.set_string('day', this._day_dropdown.selected_item.id)); + const updateDayDropDownSelected = () => { + this._day_dropdown.selected = utils.findItemPositionInModel(this._day_dropdown.model, item => item.id === this.settings.get_string('day')); + }; + this.settings.connect('changed::day', () => updateDayDropDownSelected()); + updateDayDropDownSelected(); + + this._night_dropdown.model = themeChoices; + this._night_dropdown.expression = Gtk.PropertyExpression.new(DropDownChoice, null, 'title'); + this._night_dropdown.connect('notify::selected-item', () => this.settings.set_string('night', this._night_dropdown.selected_item.id)); + const updateNightDropDownSelected = () => { + this._night_dropdown.selected = utils.findItemPositionInModel(this._night_dropdown.model, item => item.id === this.settings.get_string('night')); + }; + this.settings.connect('changed::night', () => updateNightDropDownSelected()); + updateNightDropDownSelected(); + } +}); diff --git a/src/preferences/ShellTheme.js b/src/preferences/ShellTheme.js deleted file mode 100644 index 8ea71d2..0000000 --- a/src/preferences/ShellTheme.js +++ /dev/null @@ -1,81 +0,0 @@ -// SPDX-FileCopyrightText: 2020, 2021 Romain Vigier -// SPDX-License-Identifier: GPL-3.0-or-later - -const { Gio, GLib, Gtk } = imports.gi; -const { extensionUtils } = imports.misc; - -const Me = extensionUtils.getCurrentExtension(); - -const utils = Me.imports.utils; - -const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); -const _ = Gettext.gettext; - - -var ShellThemePreferences = class { - constructor(settings) { - this._builder = new Gtk.Builder(); - this._builder.add_from_file(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'shell_theme.ui'])); - - this.widget = this._builder.get_object('shell_theme'); - this.name = 'shell-theme'; - this.title = _('Shell theme'); - - this._connectSettings(settings); - } - - _connectSettings(settings) { - const enabledSwitch = this._builder.get_object('enabled_switch'); - settings.shellVariants.settings.bind( - 'enabled', - enabledSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const manual = this._builder.get_object('manual'); - settings.shellVariants.settings.bind( - 'enabled', - manual, - 'sensitive', - Gio.SettingsBindFlags.DEFAULT - ); - - const manualSwitch = this._builder.get_object('manual_switch'); - settings.shellVariants.settings.bind( - 'manual', - manualSwitch, - 'active', - Gio.SettingsBindFlags.DEFAULT - ); - - const variants = this._builder.get_object('variants'); - const updateVariantsSensitivity = () => { - variants.sensitive = !!(settings.shellVariants.enabled && settings.shellVariants.manual); - }; - settings.shellVariants.connect('status-changed', () => updateVariantsSensitivity()); - settings.shellVariants.connect('manual-changed', () => updateVariantsSensitivity()); - updateVariantsSensitivity(); - - const dayCombo = this._builder.get_object('day_combo'); - const nightCombo = this._builder.get_object('night_combo'); - const installedShellThemes = Array.from(utils.getInstalledShellThemes()).sort(); - installedShellThemes.forEach(theme => { - const themeName = theme === '' ? _('Default') : theme; - dayCombo.append(theme, themeName); - nightCombo.append(theme, themeName); - }); - settings.shellVariants.settings.bind( - 'day', - dayCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - settings.shellVariants.settings.bind( - 'night', - nightCombo, - 'active-id', - Gio.SettingsBindFlags.DEFAULT - ); - } -}; diff --git a/src/preferences/ShortcutButton.js b/src/preferences/ShortcutButton.js new file mode 100644 index 0000000..d8108af --- /dev/null +++ b/src/preferences/ShortcutButton.js @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { Gdk, GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + +const utils = Me.imports.utils; + + +var ShortcutButton = GObject.registerClass({ + GTypeName: 'ShortcutButton', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'ShortcutButton.ui'])}`, + InternalChildren: ['choose_button', 'change_button', 'clear_button', 'dialog'], + Properties: { + keybinding: GObject.ParamSpec.string( + 'keybinding', + 'Keybinding', + 'Key sequence', + GObject.ParamFlags.READWRITE, + null + ), + }, +}, class ShortcutButton extends Gtk.Stack { + activate() { + if (this.keybinding) + return this._change_button.activate(); + else + return this._choose_button.activate(); + } + + openDialog() { + this._dialog.transient_for = this.get_root(); + this._dialog.present(); + } + + onKeybindingChanged(button) { + button.visible_child_name = button.keybinding ? 'edit' : 'choose'; + } + + onChooseButtonClicked(_button) { + this.openDialog(); + } + + onChangeButtonClicked(_button) { + this.openDialog(); + } + + onClearButtonClicked(_button) { + this.keybinding = ''; + } + + onKeyPressed(_widget, keyval, keycode, state) { + let mask = state & Gtk.accelerator_get_default_mod_mask(); + mask &= ~Gdk.ModifierType.LOCK_MASK; + + if (mask === 0 && keyval === Gdk.KEY_Escape) { + this._dialog.close(); + return Gdk.EVENT_STOP; + } + + if ( + !utils.isBindingValid({ mask, keycode, keyval }) || + !utils.isAccelValid({ mask, keyval }) + ) + return Gdk.EVENT_STOP; + + this.keybinding = Gtk.accelerator_name_with_keycode( + null, + keyval, + keycode, + mask + ); + this._dialog.close(); + return Gdk.EVENT_STOP; + } +}); diff --git a/src/preferences/TimeChooser.js b/src/preferences/TimeChooser.js new file mode 100644 index 0000000..54cb05c --- /dev/null +++ b/src/preferences/TimeChooser.js @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2021 Romain Vigier +// SPDX-License-Identifier: GPL-3.0-or-later + +const { GLib, GObject, Gtk } = imports.gi; +const { extensionUtils } = imports.misc; + +const Me = extensionUtils.getCurrentExtension(); + + +var TimeChooser = GObject.registerClass({ + GTypeName: 'TimeChooser', + Template: `file://${GLib.build_filenamev([Me.path, 'preferences', 'ui', 'TimeChooser.ui'])}`, + InternalChildren: ['hours', 'minutes'], + Properties: { + time: GObject.ParamSpec.double( + 'time', + 'Time', + 'The time of the chooser', + GObject.ParamFlags.READWRITE, + 0, + 24, + 0 + ), + }, +}, class TimeChooser extends Gtk.Box { + onTimeChanged(chooser) { + const hours = Math.trunc(chooser.time); + const minutes = Math.round((chooser.time - hours) * 60); + chooser._hours.value = hours; + chooser._minutes.value = minutes; + } + + onValueChanged(_spin) { + const hours = this._hours.value; + const minutes = this._minutes.value / 60; + this.time = hours + minutes; + } + + onOutputChanged(spin) { + spin.text = spin.value.toString().padStart(2, '0'); + return true; + } +}); diff --git a/src/preferences/ui/Appearance.ui b/src/preferences/ui/Appearance.ui new file mode 100644 index 0000000..7223a8d --- /dev/null +++ b/src/preferences/ui/Appearance.ui @@ -0,0 +1,42 @@ + + + + + diff --git a/src/preferences/ui/BackgroundButton.ui b/src/preferences/ui/BackgroundButton.ui new file mode 100644 index 0000000..be21d3e --- /dev/null +++ b/src/preferences/ui/BackgroundButton.ui @@ -0,0 +1,75 @@ + + + + + + True + open + Select your background image + False + + + + + image/jpeg + image/png + image/tiff + application/xml + + + + + diff --git a/src/preferences/ui/BackgroundsPreferences.ui b/src/preferences/ui/BackgroundsPreferences.ui new file mode 100644 index 0000000..46559be --- /dev/null +++ b/src/preferences/ui/BackgroundsPreferences.ui @@ -0,0 +1,58 @@ + + + + + diff --git a/src/preferences/ui/ClearableEntry.ui b/src/preferences/ui/ClearableEntry.ui new file mode 100644 index 0000000..26ed7a1 --- /dev/null +++ b/src/preferences/ui/ClearableEntry.ui @@ -0,0 +1,13 @@ + + + + + diff --git a/src/preferences/ui/Commands.ui b/src/preferences/ui/Commands.ui new file mode 100644 index 0000000..ec6948a --- /dev/null +++ b/src/preferences/ui/Commands.ui @@ -0,0 +1,88 @@ + + + + + diff --git a/src/preferences/ui/CursorPreferences.ui b/src/preferences/ui/CursorPreferences.ui new file mode 100644 index 0000000..d40e908 --- /dev/null +++ b/src/preferences/ui/CursorPreferences.ui @@ -0,0 +1,62 @@ + + + + + diff --git a/src/preferences/ui/GtkPreferences.ui b/src/preferences/ui/GtkPreferences.ui new file mode 100644 index 0000000..bcdc6e9 --- /dev/null +++ b/src/preferences/ui/GtkPreferences.ui @@ -0,0 +1,73 @@ + + + + + diff --git a/src/preferences/ui/Headerbar.ui b/src/preferences/ui/Headerbar.ui new file mode 100644 index 0000000..f3ac7ff --- /dev/null +++ b/src/preferences/ui/Headerbar.ui @@ -0,0 +1,108 @@ + + + + + diff --git a/src/preferences/ui/IconPreferences.ui b/src/preferences/ui/IconPreferences.ui new file mode 100644 index 0000000..79e6ca4 --- /dev/null +++ b/src/preferences/ui/IconPreferences.ui @@ -0,0 +1,62 @@ + + + + + diff --git a/src/preferences/ui/PreferenceRow.ui b/src/preferences/ui/PreferenceRow.ui new file mode 100644 index 0000000..e8a86a9 --- /dev/null +++ b/src/preferences/ui/PreferenceRow.ui @@ -0,0 +1,56 @@ + + + + + diff --git a/src/preferences/ui/Preferences.ui b/src/preferences/ui/Preferences.ui new file mode 100644 index 0000000..6b62e2e --- /dev/null +++ b/src/preferences/ui/Preferences.ui @@ -0,0 +1,42 @@ + + + + + diff --git a/src/preferences/ui/PreferencesList.ui b/src/preferences/ui/PreferencesList.ui new file mode 100644 index 0000000..8d8a023 --- /dev/null +++ b/src/preferences/ui/PreferencesList.ui @@ -0,0 +1,17 @@ + + + + + diff --git a/src/preferences/ui/Schedule.ui b/src/preferences/ui/Schedule.ui new file mode 100644 index 0000000..7801763 --- /dev/null +++ b/src/preferences/ui/Schedule.ui @@ -0,0 +1,179 @@ + + + + + diff --git a/src/preferences/ui/ShellPreferences.ui b/src/preferences/ui/ShellPreferences.ui new file mode 100644 index 0000000..00292dc --- /dev/null +++ b/src/preferences/ui/ShellPreferences.ui @@ -0,0 +1,73 @@ + + + + + diff --git a/src/preferences/ui/ShortcutButton.ui b/src/preferences/ui/ShortcutButton.ui new file mode 100644 index 0000000..50ab3cf --- /dev/null +++ b/src/preferences/ui/ShortcutButton.ui @@ -0,0 +1,120 @@ + + + + + + True + 440 + 200 + True + False + + + + True + True + + + + + start + 6 + 6 + 6 + + + start + + + + + end + + + + + + + + + True + True + 36 + 36 + 36 + 36 + Press your keyboard shortcut… + center + True + + + + + + + + + + + + + + + + diff --git a/src/preferences/ui/TimeChooser.ui b/src/preferences/ui/TimeChooser.ui new file mode 100644 index 0000000..3729330 --- /dev/null +++ b/src/preferences/ui/TimeChooser.ui @@ -0,0 +1,47 @@ + + + + + + 0 + 23 + 1 + + + 0 + 59 + 1 + + diff --git a/src/preferences/ui/backgrounds.ui b/src/preferences/ui/backgrounds.ui deleted file mode 100644 index db6a7d5..0000000 --- a/src/preferences/ui/backgrounds.ui +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - image/jpeg - image/png - image/tiff - application/xml - - - - 1 - open - Select your background image - 0 - image_filter - - - 1 - open - Select your background image - 0 - image_filter - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Switch backgrounds - - - - - 1 - end - center - - - - - - - - - - - - - vertical - 8 - - - start - Backgrounds - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Day background - - - - - 1 - end - - - end - center - Choose... - - - - - Clear - 1 - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Night background - - - - - 1 - end - - - end - center - Choose... - - - - - Clear - 1 - - - - - - - - - - - - - - - - - - diff --git a/src/preferences/ui/commands.ui b/src/preferences/ui/commands.ui deleted file mode 100644 index 34e6354..0000000 --- a/src/preferences/ui/commands.ui +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - vertical - - - start - Run commands - - - - - center - start - <small>You can set custom commands that will be run when the time of the day changes.</small> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - - - - - - - - - - - - - vertical - 8 - - - start - Commands - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Sunrise command - - - - - 1 - end - - - end - center - 28 - 1 - notify-send "Hello sunshine!" - terminal - - - - - Clear - - - - - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Sunset command - - - - - 1 - end - - - end - center - 28 - 1 - notify-send "Hello moonshine!" - terminal - - - - - Clear - - - - - - - - - - - - - - - - - - diff --git a/src/preferences/ui/cursor_theme.ui b/src/preferences/ui/cursor_theme.ui deleted file mode 100644 index 8293783..0000000 --- a/src/preferences/ui/cursor_theme.ui +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Switch cursor variants - - - - - 1 - end - center - 1 - - - - - - - - - - - - - vertical - 8 - - - start - Variants - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Day variant - - - - - 1 - end - center - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Night variant - - - - - 1 - end - center - - - - - - - - - - - - - - diff --git a/src/preferences/ui/gtk_theme.ui b/src/preferences/ui/gtk_theme.ui deleted file mode 100644 index 540c05e..0000000 --- a/src/preferences/ui/gtk_theme.ui +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Switch GTK variants - - - - - 1 - end - center - 1 - - - - - - - - - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - vertical - - - start - Manual variants - - - - - center - 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> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - - - - - - - - - - - - - vertical - 8 - - - start - Manual variants - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Day variant - - - - - 1 - end - center - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Night variant - - - - - 1 - end - center - - - - - - - - - - - - - - diff --git a/src/preferences/ui/headerbar.ui b/src/preferences/ui/headerbar.ui deleted file mode 100644 index ee1f855..0000000 --- a/src/preferences/ui/headerbar.ui +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - 1 - - - 0 - 1 - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-schedule-symbolic - 1 - - - - - Schedule - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-gtktheme-symbolic - 1 - - - - - GTK theme - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-shelltheme-symbolic - 1 - - - - - Shell theme - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-icontheme-symbolic - 1 - - - - - Icon theme - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-cursortheme-symbolic - 1 - - - - - Cursor theme - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-backgrounds-symbolic - 1 - - - - - Backgrounds - - - - - - - - - - - - 0 - schedule_radio - - - 4 - 4 - vertical - 4 - - - nightthemeswitcher-commands-symbolic - 1 - - - - - Commands - - - - - - - - - - - - - - diff --git a/src/preferences/ui/icon_theme.ui b/src/preferences/ui/icon_theme.ui deleted file mode 100644 index e0ba76d..0000000 --- a/src/preferences/ui/icon_theme.ui +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Switch icon variants - - - - - 1 - end - center - 1 - - - - - - - - - - - - - vertical - 8 - - - start - Variants - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Day variant - - - - - 1 - end - center - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Night variant - - - - - 1 - end - center - - - - - - - - - - - - - - diff --git a/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui b/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui deleted file mode 100644 index fad35e5..0000000 --- a/src/preferences/ui/ondemand_keyboard_shortcut_dialog.ui +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - 1 - 440 - 200 - - - vertical - 2 - - - 1 - Press your keyboard shortcut... - - - - - - - - - Keyboard shortcut - 1 - end - 5 - - - - - - - - - - diff --git a/src/preferences/ui/schedule.ui b/src/preferences/ui/schedule.ui deleted file mode 100644 index b447250..0000000 --- a/src/preferences/ui/schedule.ui +++ /dev/null @@ -1,599 +0,0 @@ - - - - - - 23 - 1 - - - 59 - 1 - - - 23 - 1 - - - 59 - 1 - - - 600 - 0 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - 0 - - - 600 - 0 - none - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - vertical - - - 0 - start - Automatic time source - - - - - center - 0 - 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> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - 1 - - - - - - - - - 0 - 0 - - - 0 - - - - - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - vertical - - - 0 - start - Always show on-demand controls - - - - - center - 0 - start - <small>This allows you to override the current time when using a schedule.</small> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - - - - - - - - - - - - - 0 - vertical - 8 - - - 0 - start - Manual time source - - - - - - - - 600 - 0 - center - 1 - - - Night Light - 1 - - - - - Location Services - manual_nightlight_radio - - - - - Manual schedule - manual_nightlight_radio - - - - - On-demand - manual_nightlight_radio - - - - - - - - - - 0 - 0 - crossfade - 1 - - - none - No preferences - - - 0 - vertical - - - - - - - nightlight - Night Light - - - 0 - vertical - 8 - - - 0 - start - Night Light - - - - - - - - 0 - - - 600 - 0 - none - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - vertical - - - 0 - start - Follow <i>Disable until tomorrow</i> - 1 - - - - - center - 0 - start - <small>When Night Light is temporarily disabled, the extension will switch to day variants.</small> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - - - - - - - - - - - - - - - - - schedule_times - Manual schedule times - - - 600 - 0 - vertical - 8 - - - 0 - start - Manual schedule times - - - - - - - - 0 - - - 600 - 0 - none - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - Sunrise - - - - - 1 - 0 - end - 8 - - - 2 - 0 - vertical - sunrise_hours_adjustment - 1 - 1 - - - - - 0 - : - - - - - 2 - 0 - vertical - sunrise_minutes_adjustment - 1 - 1 - - - - - - - - - - - 0 - 0 - - - 0 - - - - - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - Sunset - - - - - 1 - 0 - end - 8 - - - 2 - 0 - vertical - sunset_hours_adjustment - 1 - 1 - - - - - 0 - : - - - - - 2 - 0 - vertical - sunset_minutes_adjustment - 1 - 1 - - - - - - - - - - - - - - - - - - - - - 0 - vertical - 8 - - - 0 - start - On-demand - - - - - - - - 0 - - - 600 - 0 - none - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - Keyboard shortcut - - - - - 1 - end - 0 - - - Choose - 1 - end - center - - - - - Clear - 1 - - - - - - - - - - - - - 0 - 0 - - - 0 - - - - - - - 0 - - - 0 - 16 - 16 - 16 - 16 - 30 - - - 0 - Button location - - - - - 1 - 0 - end - 1 - panel - - None - Top bar - System menu - - - - - - - - - - - - - - - diff --git a/src/preferences/ui/shell_theme.ui b/src/preferences/ui/shell_theme.ui deleted file mode 100644 index 8d30900..0000000 --- a/src/preferences/ui/shell_theme.ui +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - 600 - center - start - 36 - 36 - 36 - 36 - vertical - 30 - top - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Switch Shell variants - - - - - 1 - end - center - 1 - - - - - - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - vertical - - - start - Manual variants - - - - - center - 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> - 1 - 1 - 50 - 0 - - - - - - - - 1 - end - center - - - - - - - - - - - - - vertical - 8 - - - start - Manual variants - - - - - - - - - - 600 - none - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Day variant - - - - - 1 - end - center - - - - - - - - - 0 - 0 - - - - - - - - - 0 - - - 16 - 16 - 16 - 16 - 30 - - - Night variant - - - - - 1 - end - center - - - - - - - - - - - - - - diff --git a/src/preferences/ui/style.css b/src/preferences/ui/style.css new file mode 100644 index 0000000..66a26ad --- /dev/null +++ b/src/preferences/ui/style.css @@ -0,0 +1,104 @@ +/* +SPDX-FileCopyrightText: 2020, 2021 Romain Vigier +SPDX-License-Identifier: GPL-3.0-or-later +*/ + +window.nightthemeswitcher, +window.toolbox +{ + border-radius: 8px; +} + +window.nightthemeswitcher headerbar +{ + background: #000; + color: alpha(#fff, 0.9); + border: none; +} + +window.nightthemeswitcher headerbar button +{ + background: alpha(#fff, 0.2); + color: inherit; + border: none; + font-weight: bold; + transition: all 200ms; +} + +window.nightthemeswitcher headerbar button.close +{ + background: none; +} + +window.nightthemeswitcher headerbar button:hover +{ + background: alpha(#fff, 0.3); +} + +window.nightthemeswitcher headerbar button:active +{ + background: alpha(#fff, 0.4); +} + +window.nightthemeswitcher headerbar button:checked +{ + background: alpha(#fff, 0.1); +} + +window.nightthemeswitcher headerbar .linked button.toggle +{ + border-right: 1px solid alpha(#000, 0.4); +} + +window.nightthemeswitcher headerbar .linked button.toggle:last-child +{ + border-right: none; +} + +window.nightthemeswitcher list.frame +{ + border-radius: 8px; +} + +window.nightthemeswitcher list.frame row:last-child +{ + border-bottom: none; +} + +window.nightthemeswitcher .support button +{ + margin: 0; +} + +window.nightthemeswitcher .support button.gitlab +{ + background-color: rgba(250, 112, 53, 1); + color: #fff; +} + +window.nightthemeswitcher .support button.gitlab:hover +{ + background-color: rgba(250, 112, 53, 1); +} + +window.nightthemeswitcher .support button.liberapay +{ + background-color: rgba(246, 201, 21, 0.8); + color: #1a171b; +} + +window.nightthemeswitcher .support button.liberapay:hover +{ + background-color: rgba(246, 201, 21, 1); +} + +window.nightthemeswitcher .support button.weblate +{ + background-color: rgba(46, 204, 170, 0.8); + color: #fff; +} + +window.nightthemeswitcher .support button.weblate:hover +{ + background-color: rgba(46, 204, 170, 1); +} diff --git a/src/prefs.js b/src/prefs.js index e8602b5..8104a53 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -8,7 +8,7 @@ const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const { utils } = Me.imports; +const { Headerbar } = Me.imports.preferences.Headerbar; const { Preferences } = Me.imports.preferences.Preferences; @@ -16,9 +16,14 @@ const { Preferences } = Me.imports.preferences.Preferences; * Initialize the preferences. */ function init() { - extensionUtils.initTranslations(Me.metadata.uuid); + extensionUtils.initTranslations(); + const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()); iconTheme.add_search_path(GLib.build_filenamev([Me.path, 'icons'])); + + const styleProvider = new Gtk.CssProvider(); + styleProvider.load_from_path(GLib.build_filenamev([Me.path, 'preferences', 'ui', 'style.css'])); + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), styleProvider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } /** @@ -27,8 +32,10 @@ function init() { function buildPrefsWidget() { const preferences = new Preferences(); GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { - const window = preferences.widget.get_root(); - window.set_titlebar(preferences.headerbar); + const window = preferences.get_root(); + window.add_css_class('nightthemeswitcher'); + const headerbar = new Headerbar({ preferences }); + window.set_titlebar(headerbar); }); - return preferences.widget; + return preferences; } diff --git a/src/utils.js b/src/utils.js index ec1fcc4..8eda56e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -295,3 +295,19 @@ function findShellAggregateMenuItemPosition(menuItem) { const items = menu._getMenuItems(); return items.indexOf(menuItem); } + +/** + * Find an item in a `Gio.ListModel`. + * + * @param {Gio.ListModel} model The ListModel to search. + * @param {Function} findFunction The function used to find the item. Gets the item as argument. + * @returns {(*|undefined)} The found item or `undefined`. + */ +function findItemPositionInModel(model, findFunction) { + const nItems = model.get_n_items(); + for (let i = 0; i < nItems; i++) { + if (findFunction(model.get_item(i))) + return i; + } + return undefined; +}