From 6ff6df8248006ff3dd0c35ccd3b30679c6f81530 Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 6 Aug 2020 06:35:21 +0000 Subject: [PATCH] Add options for on-demand button placement --- src/modules/SettingsManager.js | 11 ++ src/modules/TimerOndemand.js | 93 ++++++++---- src/po/fr.po | 130 ++++++++++------ src/po/nightthemeswitcher@romainvigier.fr.pot | 140 +++++++++++------- src/prefs.js | 8 + src/prefs.ui | 61 ++++++++ ....extensions.nightthemeswitcher.gschema.xml | 10 ++ src/utils.js | 11 ++ 8 files changed, 332 insertions(+), 132 deletions(-) diff --git a/src/modules/SettingsManager.js b/src/modules/SettingsManager.js index 85c5abc..a7e72b7 100644 --- a/src/modules/SettingsManager.js +++ b/src/modules/SettingsManager.js @@ -65,6 +65,7 @@ var SettingsManager = class { this._timeSourceChangedConnect = this._extensionsSettings.connect('changed::time-source', this._onTimeSourceChanged.bind(this)); this._manualTimeSourceChangedConnect = this._extensionsSettings.connect('changed::manual-time-source', this._onManualTimeSourceChanged.bind(this)); this._ondemandKeybindingChangedConnect = this._extensionsSettings.connect('changed::nightthemeswitcher-ondemand-keybinding', this._onOndemandKeybindingChanged.bind(this)); + this._ondemandButtonPlacementChangedConnect = this._extensionsSettings.connect('changed::ondemand-button-placement', this._onOndemandButtonPlacementChanged.bind(this)); this._commandsStatusConnect = this._extensionsSettings.connect('changed::commands-enabled', this._onCommandsStatusChanged.bind(this)); this._backgroundsStatusConnect = this._extensionsSettings.connect('changed::backgrounds-enabled', this._onBackgroundsStatusChanged.bind(this)); this._backgroundDayChangedConnect = this._extensionsSettings.connect('changed::background-day', this._onBackgroundDayChanged.bind(this)); @@ -101,6 +102,7 @@ var SettingsManager = class { this._extensionsSettings.disconnect(this._timeSourceChangedConnect); this._extensionsSettings.disconnect(this._manualTimeSourceChangedConnect); this._extensionsSettings.disconnect(this._ondemandKeybindingChangedConnect); + this._extensionsSettings.disconnect(this._ondemandButtonPlacementChangedConnect); this._extensionsSettings.disconnect(this._commandsStatusConnect); this._extensionsSettings.disconnect(this._backgroundsStatusConnect); this._extensionsSettings.disconnect(this._backgroundDayChangedConnect); @@ -318,6 +320,10 @@ var SettingsManager = class { return this._extensionsSettings.get_strv('nightthemeswitcher-ondemand-keybinding')[0]; } + get ondemandButtonPlacement() { + return this._extensionsSettings.get_string('ondemand-button-placement'); + } + get scheduleSunrise() { return this._extensionsSettings.get_double('schedule-sunrise'); } @@ -568,6 +574,11 @@ var SettingsManager = class { this.emit('ondemand-keybinding-changed', this.ondemandKeybinding); } + _onOndemandButtonPlacementChanged(_settings, _changedKey) { + logDebug(`On-demand button placement has changed to ${this.ondemandButtonPlacement}`); + this.emit('ondemand-button-placement-changed', this.ondemandButtonPlacement); + } + /* Commands */ diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index 0c7f61c..e80695a 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -20,14 +20,17 @@ const { Shell, St } = imports.gi; const { extensionUtils } = imports.misc; const Signals = imports.signals; -const { main, panelMenu } = imports.ui; +const { main, panelMenu: PanelMenu, popupMenu: PopupMenu } = imports.ui; const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; -const { logDebug } = Me.imports.utils; +const { logDebug, findShellAggregateMenuItemPosition } = Me.imports.utils; const { keyBindingAutoRepeat, getActor } = Me.imports.compat; +const Gettext = imports.gettext.domain(Me.metadata.uuid); +const _ = Gettext.gettext; + /** * The On-demand Timer allows the user to manually switch between the day and * night variants with a button in the top bar and a keybinding. @@ -38,8 +41,8 @@ var TimerOndemand = class { constructor() { this._button = null; - this._icon = null; this._ondemandKeybindingConnect = null; + this._ondemandButtonPlacementConnect = null; } enable() { @@ -68,6 +71,7 @@ var TimerOndemand = class { _connectSettings() { logDebug('Connecting On-demand Timer to settings...'); this._ondemandKeybindingConnect = e.settingsManager.connect('ondemand-keybinding-changed', this._onOndemandKeybindingChanged.bind(this)); + this._ondemandButtonPlacementConnect = e.settingsManager.connect('ondemand-button-placement-changed', this._onOndemandButtonPlacementChanged.bind(this)); } _disconnectSettings() { @@ -76,6 +80,10 @@ var TimerOndemand = class { e.settingsManager.disconnect(this._ondemandKeybindingConnect); this._ondemandKeybindingConnect = null; } + if (this._ondemandButtonPlacementConnect) { + e.settingsManager.disconnect(this._ondemandButtonPlacementConnect); + this._ondemandButtonPlacementConnect = null; + } } @@ -84,6 +92,11 @@ var TimerOndemand = class { this._addKeybinding(); } + _onOndemandButtonPlacementChanged(_settings, _placement) { + this._removeButton(); + this._addButton(); + } + _addKeybinding() { if (!e.settingsManager.ondemandKeybinding) @@ -106,40 +119,62 @@ var TimerOndemand = class { } _addButton() { - logDebug('Adding On-demand Timer button...'); - - this._icon = new St.Icon({ - icon_name: this._getIconNameForCurrentTime(), - style_class: 'system-status-icon', - }); - - this._button = new panelMenu.Button(0.0); - const buttonActor = getActor(this._button); - buttonActor.add_actor(this._icon); - buttonActor.connect( - 'button-press-event', - this._toggleTime.bind(this) - ); - main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); - - logDebug('Added On-demand Timer button.'); + switch (e.settingsManager.ondemandButtonPlacement) { + case 'panel': + this._addButtonToPanel(); + break; + case 'menu': + this._addButtonToMenu(); + break; + } } _removeButton() { - logDebug('Removing On-demand Timer button...'); - this._button.destroy(); - logDebug('Removed On-demand Timer button.'); + if (this._button) { + logDebug('Removing On-demand Timer button...'); + this._button.destroy(); + this._button = null; + logDebug('Removed On-demand Timer button.'); + } + } + + _addButtonToPanel() { + logDebug('Adding On-demand Timer button to the panel...'); + const getIconNameForCurrentTime = () => e.timer.time === 'day' ? 'weather-clear-symbolic' : 'weather-clear-night-symbolic'; + const icon = new St.Icon({ + icon_name: getIconNameForCurrentTime(), + style_class: 'system-status-icon', + }); + this._button = new PanelMenu.Button(0.0); + const buttonActor = getActor(this._button); + buttonActor.add_actor(icon); + buttonActor.connect('button-press-event', () => { + this._toggleTime(); + icon.icon_name = getIconNameForCurrentTime(); + }); + main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); + logDebug('Added On-demand Timer button to the panel.'); + } + + _addButtonToMenu() { + logDebug('Adding On-demand Timer button to the menu...'); + const aggregateMenu = main.panel.statusArea.aggregateMenu; + const position = findShellAggregateMenuItemPosition(aggregateMenu._system.menu) - 1; + const getLabelForCurrentTime = () => e.timer.time === 'day' ? _('Switch to night theme') : _('Switch to day theme'); + const getIconNameForCurrentTime = () => e.timer.time === 'day' ? 'weather-clear-night-symbolic' : 'weather-clear-symbolic'; + this._button = new PopupMenu.PopupImageMenuItem(getLabelForCurrentTime(), getIconNameForCurrentTime()); + this._button.connect('activate', () => { + this._toggleTime(); + this._button.label.text = getLabelForCurrentTime(); + this._button.setIcon(getIconNameForCurrentTime()); + }); + aggregateMenu.menu.addMenuItem(this._button, position); + logDebug('Added On-demand Timer button to the menu.'); } _toggleTime() { e.settingsManager.ondemandTime = e.timer.time === 'day' ? 'night' : 'day'; this.emit('time-changed', this.time); - this._icon.icon_name = this._getIconNameForCurrentTime(); - - } - - _getIconNameForCurrentTime() { - return e.timer.time === 'day' ? 'weather-clear-symbolic' : 'weather-clear-night-symbolic'; } }; diff --git a/src/po/fr.po b/src/po/fr.po index 5532da4..f711c88 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Night Theme Switcher 7\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-03 20:16+0200\n" -"PO-Revision-Date: 2020-08-03 23:31+0200\n" +"POT-Creation-Date: 2020-08-05 08:43+0200\n" +"PO-Revision-Date: 2020-08-05 08:45+0200\n" "Last-Translator: Romain Vigier \n" "Language-Team: French - France \n" "Language: fr_FR\n" @@ -18,11 +18,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1)\n" "X-Generator: Gtranslator 3.36.0\n" -#: src/prefs.js:212 src/prefs.ui:644 +#: src/prefs.js:227 src/prefs.ui:644 msgid "Choose" msgstr "Choisir" -#: src/prefs.js:324 +#: src/prefs.js:347 msgid "Default" msgstr "Par défaut" @@ -47,8 +47,16 @@ msgstr "" "pour le thème GNOME Shell \"%s\". Veuillez les sélectionner manuellement " "dans les préférences de l’extension." +#: src/modules/TimerOndemand.js:162 +msgid "Switch to night theme" +msgstr "Passer au thème nocturne" + +#: src/modules/TimerOndemand.js:162 +msgid "Switch to day theme" +msgstr "Passer au thème diurne" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 -#: src/prefs.ui:755 +#: src/prefs.ui:816 msgid "Switch GTK variants" msgstr "Permuter les variantes GTK" @@ -129,7 +137,7 @@ msgid "Disable automatic shell theme variants detection" msgstr "Désactiver la détection automatique des variantes du thème shell" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 -#: src/prefs.ui:1443 +#: src/prefs.ui:1504 msgid "Switch icon variants" msgstr "Permuter les variantes d’icônes" @@ -162,7 +170,7 @@ msgid "The icon theme to restore when the extension is disabled" msgstr "Le thème d’icônes à restaurer quand l’extension est désactivée" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 -#: src/prefs.ui:1689 +#: src/prefs.ui:1750 msgid "Switch cursor variants" msgstr "Permuter les variantes de curseur" @@ -218,79 +226,87 @@ msgstr "Combinaison de touches pour permuter le temps" msgid "The key combination that will toggle time in on-demand mode" msgstr "La combinaison de touches qui permutera le temps en mode à la demande" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:121 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:126 +msgid "On-demand button placement" +msgstr "Emplacement du bouton à la demande" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:127 +msgid "Where the on-demand button will be placed" +msgstr "Où le bouton du changement à la demande sera placé" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:131 msgid "Use manual time source" msgstr "Utiliser une source d’horaires manuelle" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:122 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:132 msgid "Disable automatic time source detection" msgstr "Désactive la détection automatique de la source d’horaires" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:126 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136 msgid "Sunrise time" msgstr "Heure du lever" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:127 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:137 msgid "When the day starts" msgstr "Quand le jour se lève" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:131 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 msgid "Sunset time" msgstr "Heure du coucher" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:132 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 msgid "When the day ends" msgstr "Quand le jour se couche" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 msgid "Enable commands" msgstr "Activer les commandes" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:137 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:147 msgid "Commands will be spawned on time change" msgstr "Les commandes seront lancées au changement d’horaire" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 -#: src/prefs.ui:2308 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 +#: src/prefs.ui:2369 msgid "Sunrise command" msgstr "Commande du lever de soleil" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:152 msgid "The command to spawn at sunrise" msgstr "La commande à lancer quand le soleil se lève" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 -#: src/prefs.ui:2367 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 +#: src/prefs.ui:2428 msgid "Sunset command" msgstr "Commande du coucher de soleil" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:147 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:157 msgid "The command to spawn at sunset" msgstr "La commande à lancer quand le soleil se couche" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 msgid "Enable backgrounds" msgstr "Activer les arrière-plans" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:152 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:162 msgid "Background will be changed on time change" msgstr "L’arrière-plan changera au changement d’horaire" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 -#: src/prefs.ui:2022 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 +#: src/prefs.ui:2083 msgid "Day background" msgstr "Arrière-plan diurne" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:157 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:167 msgid "Path to the day background" msgstr "Chemin vers l’arrière-plan diurne" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 -#: src/prefs.ui:2082 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 +#: src/prefs.ui:2143 msgid "Night background" msgstr "Arrière-plan nocturne" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:162 +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:172 msgid "Path to the night background" msgstr "Chemin vers l’arrière-plan nocturne" @@ -361,15 +377,31 @@ msgstr "Coucher du soleil" msgid "Clear" msgstr "Effacer" -#: src/prefs.ui:707 +#: src/prefs.ui:713 +msgid "Button location" +msgstr "Emplacement du bouton" + +#: src/prefs.ui:728 +msgid "None" +msgstr "Aucun" + +#: src/prefs.ui:729 +msgid "Top bar" +msgstr "Barre supérieure" + +#: src/prefs.ui:730 +msgid "System menu" +msgstr "Menu système" + +#: src/prefs.ui:768 msgid "Schedule" msgstr "Horaires" -#: src/prefs.ui:827 src/prefs.ui:902 src/prefs.ui:1171 src/prefs.ui:1246 +#: src/prefs.ui:888 src/prefs.ui:963 src/prefs.ui:1232 src/prefs.ui:1307 msgid "Manual variants" msgstr "Variantes manuelles" -#: src/prefs.ui:840 +#: src/prefs.ui:901 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GTK theme. Please soumettre une requête pour obtenir le support " "de votre thème." -#: src/prefs.ui:941 src/prefs.ui:1285 src/prefs.ui:1531 src/prefs.ui:1777 +#: src/prefs.ui:1002 src/prefs.ui:1346 src/prefs.ui:1592 src/prefs.ui:1838 msgid "Day variant" msgstr "Variante diurne" -#: src/prefs.ui:997 src/prefs.ui:1341 src/prefs.ui:1587 src/prefs.ui:1833 +#: src/prefs.ui:1058 src/prefs.ui:1402 src/prefs.ui:1648 src/prefs.ui:1894 msgid "Night variant" msgstr "Variante nocturne" -#: src/prefs.ui:1050 +#: src/prefs.ui:1111 msgid "GTK theme" msgstr "Thème GTK" -#: src/prefs.ui:1099 +#: src/prefs.ui:1160 msgid "Switch Shell variants" msgstr "Permuter les variantes Shell" -#: src/prefs.ui:1184 +#: src/prefs.ui:1245 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GNOME Shell theme. Please soumettre une requête pour obtenir le " "support de votre thème." -#: src/prefs.ui:1394 +#: src/prefs.ui:1455 msgid "Shell theme" msgstr "Thème du shell" -#: src/prefs.ui:1492 src/prefs.ui:1738 +#: src/prefs.ui:1553 src/prefs.ui:1799 msgid "Variants" msgstr "Variantes" -#: src/prefs.ui:1640 +#: src/prefs.ui:1701 msgid "Icon theme" msgstr "Thème d’icônes" -#: src/prefs.ui:1886 +#: src/prefs.ui:1947 msgid "Cursor theme" msgstr "Thème de curseur" -#: src/prefs.ui:1935 +#: src/prefs.ui:1996 msgid "Switch backgrounds" msgstr "Permuter les arrière-plans" -#: src/prefs.ui:1983 src/prefs.ui:2139 +#: src/prefs.ui:2044 src/prefs.ui:2200 msgid "Backgrounds" msgstr "Arrière-plans" -#: src/prefs.ui:2039 src/prefs.ui:2099 +#: src/prefs.ui:2100 src/prefs.ui:2160 msgid "Select your background image" msgstr "Sélectionnez votre image d’arrière-plan" -#: src/prefs.ui:2194 +#: src/prefs.ui:2255 msgid "Run commands" msgstr "Lancer des commandes" -#: src/prefs.ui:2207 +#: src/prefs.ui:2268 msgid "" "You can set custom commands that will be run when the time of the day " "changes." @@ -451,15 +483,15 @@ msgstr "" "Vous pouvez définir des commandes personnalisées qui seront lancées " "quand le moment du jour change." -#: src/prefs.ui:2269 src/prefs.ui:2423 +#: src/prefs.ui:2330 src/prefs.ui:2484 msgid "Commands" msgstr "Commandes" -#: src/prefs.ui:2324 +#: src/prefs.ui:2385 msgid "notify-send \"Hello sunshine!\"" msgstr "notify-send \"Bonjour!\"" -#: src/prefs.ui:2383 +#: src/prefs.ui:2444 msgid "notify-send \"Hello moonshine!\"" msgstr "notify-send \"Bonsoir\"" diff --git a/src/po/nightthemeswitcher@romainvigier.fr.pot b/src/po/nightthemeswitcher@romainvigier.fr.pot index d667512..a4a4bae 100644 --- a/src/po/nightthemeswitcher@romainvigier.fr.pot +++ b/src/po/nightthemeswitcher@romainvigier.fr.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Night Theme Switcher 32\n" +"Project-Id-Version: Night Theme Switcher 34\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-08-03 20:16+0200\n" +"POT-Creation-Date: 2020-08-05 08:43+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,11 +17,11 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/prefs.js:212 src/prefs.ui:644 +#: src/prefs.js:227 src/prefs.ui:644 msgid "Choose" msgstr "" -#: src/prefs.js:324 +#: src/prefs.js:347 msgid "Default" msgstr "" @@ -40,8 +40,16 @@ msgid "" "preferences." msgstr "" +#: src/modules/TimerOndemand.js:162 +msgid "Switch to night theme" +msgstr "" + +#: src/modules/TimerOndemand.js:162 +msgid "Switch to day theme" +msgstr "" + #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:6 -#: src/prefs.ui:755 +#: src/prefs.ui:816 msgid "Switch GTK variants" msgstr "" @@ -122,7 +130,7 @@ msgid "Disable automatic shell theme variants detection" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:56 -#: src/prefs.ui:1443 +#: src/prefs.ui:1504 msgid "Switch icon variants" msgstr "" @@ -155,7 +163,7 @@ msgid "The icon theme to restore when the extension is disabled" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:76 -#: src/prefs.ui:1689 +#: src/prefs.ui:1750 msgid "Switch cursor variants" msgstr "" @@ -211,79 +219,87 @@ msgstr "" msgid "The key combination that will toggle time in on-demand mode" msgstr "" -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:121 -msgid "Use manual time source" -msgstr "" - -#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:122 -msgid "Disable automatic time source detection" -msgstr "" - #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:126 -msgid "Sunrise time" +msgid "On-demand button placement" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:127 -msgid "When the day starts" +msgid "Where the on-demand button will be placed" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:131 -msgid "Sunset time" +msgid "Use manual time source" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:132 -msgid "When the day ends" +msgid "Disable automatic time source detection" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:136 -msgid "Enable commands" +msgid "Sunrise time" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:137 -msgid "Commands will be spawned on time change" +msgid "When the day starts" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:141 -#: src/prefs.ui:2308 -msgid "Sunrise command" +msgid "Sunset time" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:142 -msgid "The command to spawn at sunrise" +msgid "When the day ends" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:146 -#: src/prefs.ui:2367 -msgid "Sunset command" +msgid "Enable commands" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:147 -msgid "The command to spawn at sunset" +msgid "Commands will be spawned on time change" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:151 -msgid "Enable backgrounds" +#: src/prefs.ui:2369 +msgid "Sunrise command" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:152 -msgid "Background will be changed on time change" +msgid "The command to spawn at sunrise" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:156 -#: src/prefs.ui:2022 -msgid "Day background" +#: src/prefs.ui:2428 +msgid "Sunset command" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:157 -msgid "Path to the day background" +msgid "The command to spawn at sunset" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:161 -#: src/prefs.ui:2082 -msgid "Night background" +msgid "Enable backgrounds" msgstr "" #: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:162 +msgid "Background will be changed on time change" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:166 +#: src/prefs.ui:2083 +msgid "Day background" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:167 +msgid "Path to the day background" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:171 +#: src/prefs.ui:2143 +msgid "Night background" +msgstr "" + +#: src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml:172 msgid "Path to the night background" msgstr "" @@ -350,15 +366,31 @@ msgstr "" msgid "Clear" msgstr "" -#: src/prefs.ui:707 +#: src/prefs.ui:713 +msgid "Button location" +msgstr "" + +#: src/prefs.ui:728 +msgid "None" +msgstr "" + +#: src/prefs.ui:729 +msgid "Top bar" +msgstr "" + +#: src/prefs.ui:730 +msgid "System menu" +msgstr "" + +#: src/prefs.ui:768 msgid "Schedule" msgstr "" -#: src/prefs.ui:827 src/prefs.ui:902 src/prefs.ui:1171 src/prefs.ui:1246 +#: src/prefs.ui:888 src/prefs.ui:963 src/prefs.ui:1232 src/prefs.ui:1307 msgid "Manual variants" msgstr "" -#: src/prefs.ui:840 +#: src/prefs.ui:901 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GTK theme. Please submit a request to get your theme supported." msgstr "" -#: src/prefs.ui:941 src/prefs.ui:1285 src/prefs.ui:1531 src/prefs.ui:1777 +#: src/prefs.ui:1002 src/prefs.ui:1346 src/prefs.ui:1592 src/prefs.ui:1838 msgid "Day variant" msgstr "" -#: src/prefs.ui:997 src/prefs.ui:1341 src/prefs.ui:1587 src/prefs.ui:1833 +#: src/prefs.ui:1058 src/prefs.ui:1402 src/prefs.ui:1648 src/prefs.ui:1894 msgid "Night variant" msgstr "" -#: src/prefs.ui:1050 +#: src/prefs.ui:1111 msgid "GTK theme" msgstr "" -#: src/prefs.ui:1099 +#: src/prefs.ui:1160 msgid "Switch Shell variants" msgstr "" -#: src/prefs.ui:1184 +#: src/prefs.ui:1245 msgid "" "You can manually set variants if the extension cannot automatically " "detect the day and night variants of your GNOME Shell theme. Please submit a request to get your theme supported." msgstr "" -#: src/prefs.ui:1394 +#: src/prefs.ui:1455 msgid "Shell theme" msgstr "" -#: src/prefs.ui:1492 src/prefs.ui:1738 +#: src/prefs.ui:1553 src/prefs.ui:1799 msgid "Variants" msgstr "" -#: src/prefs.ui:1640 +#: src/prefs.ui:1701 msgid "Icon theme" msgstr "" -#: src/prefs.ui:1886 +#: src/prefs.ui:1947 msgid "Cursor theme" msgstr "" -#: src/prefs.ui:1935 +#: src/prefs.ui:1996 msgid "Switch backgrounds" msgstr "" -#: src/prefs.ui:1983 src/prefs.ui:2139 +#: src/prefs.ui:2044 src/prefs.ui:2200 msgid "Backgrounds" msgstr "" -#: src/prefs.ui:2039 src/prefs.ui:2099 +#: src/prefs.ui:2100 src/prefs.ui:2160 msgid "Select your background image" msgstr "" -#: src/prefs.ui:2194 +#: src/prefs.ui:2255 msgid "Run commands" msgstr "" -#: src/prefs.ui:2207 +#: src/prefs.ui:2268 msgid "" "You can set custom commands that will be run when the time of the day " "changes." msgstr "" -#: src/prefs.ui:2269 src/prefs.ui:2423 +#: src/prefs.ui:2330 src/prefs.ui:2484 msgid "Commands" msgstr "" -#: src/prefs.ui:2324 +#: src/prefs.ui:2385 msgid "notify-send \"Hello sunshine!\"" msgstr "" -#: src/prefs.ui:2383 +#: src/prefs.ui:2444 msgid "notify-send \"Hello moonshine!\"" msgstr "" diff --git a/src/prefs.js b/src/prefs.js index d0e1f92..6403f39 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -243,6 +243,14 @@ const Preferences = class { }; this.settings.connect('changed::nightthemeswitcher-ondemand-keybinding', () => updateScheduleOndemandShortcutClearButtonVisibility()); updateScheduleOndemandShortcutClearButtonVisibility(); + + const scheduleOndemandButtonPlacementCombo = this.builder.get_object('prefs_schedule_ondemand_button_placement_combo'); + this.settings.bind( + 'ondemand-button-placement', + scheduleOndemandButtonPlacementCombo, + 'active-id', + Gio.SettingsBindFlags.DEFAULT + ); } _connectGtkThemePreferences() { diff --git a/src/prefs.ui b/src/prefs.ui index 4fd5005..d7c97ce 100644 --- a/src/prefs.ui +++ b/src/prefs.ui @@ -679,6 +679,67 @@ + + + True + True + False + False + + + True + False + + + + + + + True + True + + + True + False + 16 + 16 + 16 + 16 + 30 + + + True + False + Button location + + + False + True + 0 + + + + + True + False + end + panel + + None + Top bar + System menu + + + + True + True + 1 + + + + + + diff --git a/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml b/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml index eeda907..e2ea5a2 100644 --- a/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml +++ b/src/schemas/org.gnome.shell.extensions.nightthemeswitcher.gschema.xml @@ -116,6 +116,16 @@ Key combination to toggle time The key combination that will toggle time in on-demand mode + + + + + + + "panel" + On-demand button placement + Where the on-demand button will be placed + false Use manual time source diff --git a/src/utils.js b/src/utils.js index 2a41082..ba30841 100644 --- a/src/utils.js +++ b/src/utils.js @@ -270,3 +270,14 @@ function isBindingValid({ mask, keycode, keyval }) { function isAccelValid({ mask, keyval }) { return Gtk.accelerator_valid(keyval, mask) || (keyval === Gdk.KEY_Tab && mask !== 0); } + +/** + * Find the position of a menu item in the Shell aggregate menu. + * @param {*} menuItem The desired menu item. + * @returns {number} The position of the menu item, `-1` if not found. + */ +function findShellAggregateMenuItemPosition(menuItem) { + const menu = imports.ui.main.panel.statusArea.aggregateMenu.menu; + const items = menu._getMenuItems(); + return items.indexOf(menuItem); +}