From 3ec21e76d0593b9c9cd48d71a18665a2b0569dbc Mon Sep 17 00:00:00 2001 From: Romain Date: Wed, 17 Mar 2021 12:31:58 +0000 Subject: [PATCH] Support GNOME 40 --- .eslintignore | 1 - Makefile | 2 - src/compat.js | 114 -- src/convenience.js | 91 -- src/extension.js | 6 +- src/metadata.json | 2 +- src/modules/TimerOndemand.js | 12 +- src/preferences/Backgrounds.js | 52 +- .../OndemandKeyboardShortcutDialog.js | 21 +- src/preferences/Schedule.js | 2 +- src/preferences/ui/backgrounds.ui | 263 +---- src/preferences/ui/commands.ui | 207 +--- src/preferences/ui/cursor_theme.ui | 177 +-- src/preferences/ui/gtk_theme.ui | 239 +--- src/preferences/ui/headerbar.ui | 269 +---- src/preferences/ui/icon_theme.ui | 177 +-- .../ui/ondemand_keyboard_shortcut_dialog.ui | 83 +- src/preferences/ui/schedule.ui | 1006 ++++++----------- src/preferences/ui/shell_theme.ui | 242 +--- src/prefs.js | 13 +- src/settings/Backgrounds.js | 3 +- src/settings/Commands.js | 3 +- src/settings/CursorVariants.js | 3 +- src/settings/GtkVariants.js | 3 +- src/settings/IconVariants.js | 3 +- src/settings/Settings.js | 4 +- src/settings/ShellVariants.js | 3 +- src/settings/System.js | 1 - src/settings/Time.js | 3 +- src/settings/migrations/v0ToV1.js | 4 +- src/utils.js | 7 +- 31 files changed, 611 insertions(+), 2405 deletions(-) delete mode 100644 .eslintignore delete mode 100644 src/compat.js delete mode 100644 src/convenience.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 0a8ffdd..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/convenience.js diff --git a/Makefile b/Makefile index 14e403b..7e26f18 100644 --- a/Makefile +++ b/Makefile @@ -28,9 +28,7 @@ build: build-clean mkdir -p ./build gnome-extensions pack \ --extra-source=../LICENSE \ - --extra-source=./compat.js \ --extra-source=./config.js \ - --extra-source=./convenience.js \ --extra-source=./utils.js \ --extra-source=./icons/ \ --extra-source=./modules/ \ diff --git a/src/compat.js b/src/compat.js deleted file mode 100644 index 48a0cb9..0000000 --- a/src/compat.js +++ /dev/null @@ -1,114 +0,0 @@ -/* -Night Theme Switcher Gnome Shell extension - -Copyright (C) 2020 Romain Vigier - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see . -*/ - -const { extensionUtils } = imports.misc; -const Me = extensionUtils.getCurrentExtension(); - -const shellMinorVersion = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]) || parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[0]); - - -/** - * Initialize translations for a given gettext domain. - * - * @param {string} domain Gettext domain. - */ -function initTranslations(domain) { - if (shellMinorVersion <= 30) - return Me.imports.convenience.initTranslations(domain); - else - return extensionUtils.initTranslations(domain); -} - - -/** - * Get the Extension Manager initialization status. - * - * @returns {boolean} `true` if the Extension Manager is initialized, `false` - * otherwise. - */ -function extensionManagerInitialized() { - if (shellMinorVersion > 32) - return imports.ui.main.extensionManager._initialized; - else - return imports.ui.extensionSystem.initted; -} - - -/** - * Get a specific extension from the Extension Manager. - * - * @param {string} uuid UUID of the extension. - * @returns {(object|null)} The desired extension or `null` if it doesn't exist. - */ -function extensionManagerLookup(uuid) { - try { - if (shellMinorVersion > 32) - return imports.ui.main.extensionManager.lookup(uuid); - else - return extensionUtils.extensions[uuid] || null; - } catch (_) { - return null; - } -} - - -/** - * Get GSettings for the given schema ID. - * - * @param {(string|null)} schema The GSettings schema ID. If not given, will use - * the extension's schema ID. - */ -function getSettings(schema) { - if (shellMinorVersion <= 30) - return Me.imports.convenience.getSettings(schema); - else - return extensionUtils.getSettings(schema); -} - - -/** - * Get the extension's GSettings. - */ -function getExtensionSettings() { - return getSettings(); -} - - -/** - * Get the KeyBinding AutoRepeat flag. - */ -function keyBindingAutoRepeat() { - // if version is less then 3.30 the keybinding flags are NONE - if (shellMinorVersion < 30) - return imports.gi.Meta.KeyBindingFlags.NONE; - else - return imports.gi.Meta.KeyBindingFlags.IGNORE_AUTOREPEAT; -} - - -/** - * Get the actor from a given subject. - * - * @param {object} subject The object to get the actor from. - */ -function getActor(subject) { - if (shellMinorVersion > 34) - return subject; - else - return subject.actor; -} diff --git a/src/convenience.js b/src/convenience.js deleted file mode 100644 index 25ba4b0..0000000 --- a/src/convenience.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (c) 2011-2012, Giovanni Campagna - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the GNOME nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -const Gettext = imports.gettext; -const Gio = imports.gi.Gio; - -const Config = imports.misc.config; -const ExtensionUtils = imports.misc.extensionUtils; - -/** - * initTranslations: - * @domain: (optional): the gettext domain to use - * - * Initialize Gettext to load translations from extensionsdir/locale. - * If @domain is not provided, it will be taken from metadata['gettext-domain'] - */ -function initTranslations(domain) { - let extension = ExtensionUtils.getCurrentExtension(); - - domain = domain || extension.metadata['gettext-domain']; - - // check if this extension was built with "make zip-file", and thus - // has the locale files in a subfolder - // otherwise assume that extension has been installed in the - // same prefix as gnome-shell - let localeDir = extension.dir.get_child('locale'); - if (localeDir.query_exists(null)) - Gettext.bindtextdomain(domain, localeDir.get_path()); - else - Gettext.bindtextdomain(domain, Config.LOCALEDIR); -} - -/** - * getSettings: - * @schema: (optional): the GSettings schema id - * - * Builds and return a GSettings schema for @schema, using schema files - * in extensionsdir/schemas. If @schema is not provided, it is taken from - * metadata['settings-schema']. - */ -function getSettings(schema) { - let extension = ExtensionUtils.getCurrentExtension(); - - schema = schema || extension.metadata['settings-schema']; - - const GioSSS = Gio.SettingsSchemaSource; - - // check if this extension was built with "make zip-file", and thus - // has the schema files in a subfolder - // otherwise assume that extension has been installed in the - // same prefix as gnome-shell (and therefore schemas are available - // in the standard folders) - let schemaDir = extension.dir.get_child('schemas'); - let schemaSource; - if (schemaDir.query_exists(null)) - schemaSource = GioSSS.new_from_directory(schemaDir.get_path(), - GioSSS.get_default(), - false); - else - schemaSource = GioSSS.get_default(); - - let schemaObj = schemaSource.lookup(schema, true); - if (!schemaObj) - throw new Error('Schema ' + schema + ' could not be found for extension ' - + extension.metadata.uuid + '. Please check your installation.'); - - return new Gio.Settings({ settings_schema: schemaObj }); -} diff --git a/src/extension.js b/src/extension.js index 77f8ff7..6816fcc 100644 --- a/src/extension.js +++ b/src/extension.js @@ -20,10 +20,10 @@ this program. If not, see . const { GLib } = imports.gi; const { extensionUtils } = imports.misc; +const { extensionManager } = imports.ui.main; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug } = Me.imports.utils; const { Settings } = Me.imports.settings.Settings; const { Timer } = Me.imports.modules.Timer; @@ -51,7 +51,7 @@ var commander = null; */ function init() { logDebug('Initializing extension...'); - compat.initTranslations(Me.metadata['gettext-domain']); + extensionUtils.initTranslations(Me.metadata['gettext-domain']); logDebug('Extension initialized.'); } @@ -124,7 +124,7 @@ function _waitForExtensionManager() { return new Promise(resolve => { logDebug('Waiting for Extension Manager initialization...'); GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => { - while (!compat.extensionManagerInitialized()) + while (!extensionManager._initialized) continue; return false; }); diff --git a/src/metadata.json b/src/metadata.json index 5a81b56..3952cc8 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -5,6 +5,6 @@ "gettext-domain": "nightthemeswitcher@romainvigier.fr", "settings-schema": "org.gnome.shell.extensions.nightthemeswitcher", "url": "https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/", - "shell-version": ["3.28", "3.30", "3.32", "3.34", "3.36", "3.38"], + "shell-version": ["40"], "version": 46 } diff --git a/src/modules/TimerOndemand.js b/src/modules/TimerOndemand.js index c246d90..83c6f26 100644 --- a/src/modules/TimerOndemand.js +++ b/src/modules/TimerOndemand.js @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -const { Gio, GLib, Shell, St } = imports.gi; +const { Gio, GLib, Meta, Shell, St } = imports.gi; const { extensionUtils } = imports.misc; const Signals = imports.signals; @@ -29,7 +29,6 @@ const Me = extensionUtils.getCurrentExtension(); const e = Me.imports.extension; const { logDebug, findShellAggregateMenuItemPosition } = Me.imports.utils; -const { keyBindingAutoRepeat, getActor } = Me.imports.compat; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; @@ -129,7 +128,7 @@ var TimerOndemand = class { main.wm.addKeybinding( 'nightthemeswitcher-ondemand-keybinding', e.settings.time.settings, - keyBindingAutoRepeat(), + Meta.KeyBindingFlags.IGNORE_AUTOREPEAT, Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, this._toggleTime.bind(this) ); @@ -179,13 +178,12 @@ var TimerOndemand = class { style_class: 'system-status-icon', }); this._button = new PanelMenuButton(0.0); - const buttonActor = getActor(this._button); - buttonActor.add_actor(icon); + this._button.add_actor(icon); this._button.update = () => { icon.gicon = this._getIconForTime(e.timer.time); }; - buttonActor.connect('button-press-event', () => this._toggleTime()); - buttonActor.connect('touch-event', () => this._toggleTime()); + this._button.connect('button-press-event', () => this._toggleTime()); + this._button.connect('touch-event', () => this._toggleTime()); main.panel.addToStatusArea('NightThemeSwitcherButton', this._button); logDebug('Added On-demand Timer button to the panel.'); } diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js index cd0b554..332deb3 100644 --- a/src/preferences/Backgrounds.js +++ b/src/preferences/Backgrounds.js @@ -54,24 +54,22 @@ var BackgroundsPreferences = class { Gio.SettingsBindFlags.DEFAULT ); + const dayChooserButton = this._builder.get_object('day_chooser_button'); const dayChooser = this._builder.get_object('day_chooser'); - const dayBackgroundPreview = this._builder.get_object('day_background_preview'); - const updateDayChooserUri = () => { - dayChooser.set_uri(settings.backgrounds.day); + const updateDayChooserButtonLabel = () => { + dayChooserButton.set_label(settings.backgrounds.day ? GLib.filename_display_basename(settings.backgrounds.day) : _('Choose...')); }; - settings.backgrounds.connect('day-changed', () => updateDayChooserUri()); - dayChooser.connect('update-preview', () => { - const file = dayChooser.get_preview_filename(); - const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff', 'application/xml']; - if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { - const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); - dayBackgroundPreview.set_from_pixbuf(pixbuf); - } + 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(); }); - dayChooser.connect('file-set', () => { - settings.backgrounds.day = dayChooser.get_uri(); + dayChooserButton.connect('clicked', () => { + dayChooser.set_transient_for(dayChooserButton.get_root()); + dayChooser.show(); }); - updateDayChooserUri(); + updateDayChooserButtonLabel(); const dayClearButton = this._builder.get_object('day_clear_button'); dayClearButton.connect('clicked', () => { @@ -83,24 +81,22 @@ var BackgroundsPreferences = class { 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 nightBackgroundPreview = this._builder.get_object('night_background_preview'); - const updateNightChooserUri = () => { - nightChooser.set_uri(settings.backgrounds.night); + const updateNightChooserButtonLabel = () => { + nightChooserButton.set_label(settings.backgrounds.night ? GLib.filename_display_basename(settings.backgrounds.night) : _('Choose...')); }; - settings.backgrounds.connect('night-changed', () => updateNightChooserUri()); - nightChooser.connect('update-preview', () => { - const file = nightChooser.get_preview_filename(); - const allowedContentTypes = ['image/jpeg', 'image/png', 'image/tiff', 'application/xml']; - if (allowedContentTypes.includes(Gio.content_type_guess(file, null)[0])) { - const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(file, 256, 256); - nightBackgroundPreview.set_from_pixbuf(pixbuf); - } + 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(); }); - nightChooser.connect('file-set', () => { - settings.backgrounds.night = nightChooser.get_uri(); + nightChooserButton.connect('clicked', () => { + nightChooser.set_transient_for(nightChooserButton.get_root()); + nightChooser.show(); }); - updateNightChooserUri(); + updateNightChooserButtonLabel(); const nightClearButton = this._builder.get_object('night_clear_button'); nightClearButton.connect('clicked', () => { diff --git a/src/preferences/OndemandKeyboardShortcutDialog.js b/src/preferences/OndemandKeyboardShortcutDialog.js index f0d2010..5a0827a 100644 --- a/src/preferences/OndemandKeyboardShortcutDialog.js +++ b/src/preferences/OndemandKeyboardShortcutDialog.js @@ -40,28 +40,16 @@ var OndemandKeyboardShortcutDialog = class { } _connectSettings(settings) { - this.widget.connect('key-press-event', (_widget, event) => { - const state = event.get_state()[1]; + 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; - const keycode = event.get_keycode()[1]; - const eventKeyval = event.get_keyval()[1]; - let keyval = Gdk.keyval_to_lower(eventKeyval); if (mask === 0 && keyval === Gdk.KEY_Escape) { this.widget.visible = false; return Gdk.EVENT_STOP; } - if (keyval === Gdk.KEY_ISO_Left_Tab) - keyval = Gdk.KEY_Tab; - - if (keyval !== eventKeyval) - mask |= Gdk.ModifierType.SHIFT_MASK; - - if (keyval === Gdk.KEY_Sys_Req && (mask & Gdk.ModifierType.MOD1_MASK) !== 0) - keyval = Gdk.KEY_Print; - if ( !utils.isBindingValid({ mask, keycode, keyval }) || !utils.isAccelValid({ mask, keyval }) @@ -78,10 +66,5 @@ var OndemandKeyboardShortcutDialog = class { this.widget.close(); return Gdk.EVENT_STOP; }); - - const cancelButton = this._builder.get_object('cancel_button'); - cancelButton.connect('clicked', () => { - this.widget.close(); - }); } }; diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js index 8757eaa..8115cac 100644 --- a/src/preferences/Schedule.js +++ b/src/preferences/Schedule.js @@ -218,7 +218,7 @@ var SchedulePreferences = class { settings.time.connect('ondemand-keybinding-changed', () => updateOndemandShortcutButtonLabel()); ondemandShortcutButton.connect('clicked', () => { const dialog = new OndemandKeyboardShortcutDialog(settings); - dialog.set_transient_for(this.widget.get_toplevel()); + dialog.set_transient_for(this.widget.get_root()); dialog.present(); }); updateOndemandShortcutButtonLabel(); diff --git a/src/preferences/ui/backgrounds.ui b/src/preferences/ui/backgrounds.ui index 2cfa902..966175a 100644 --- a/src/preferences/ui/backgrounds.ui +++ b/src/preferences/ui/backgrounds.ui @@ -1,39 +1,6 @@ - - - - - - - - True - False - 256 - image-missing - 0 - + image/jpeg @@ -42,21 +9,24 @@ Author: Romain Vigier application/xml - - True - False - 256 - image-missing - 0 + + 1 + open + Select your background image + 0 + image_filter + + + 1 + open + Select your background image + 0 + image_filter 600 - True - False center start - 36 - 36 36 36 36 @@ -66,26 +36,15 @@ Author: Romain Vigier top - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -93,89 +52,48 @@ Author: Romain Vigier 30 - True - False Switch backgrounds - - False - True - 0 - - True - True + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 0 - - True - False vertical 8 - True - False start Backgrounds - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -183,91 +101,53 @@ Author: Romain Vigier 30 - True - False Day background - - False - True - 0 - - True - False + 1 end - 8 - - True - False - end - center - image_filter - day_background_preview - False - Select your background image + + end + center + Choose... - - False - True - 0 - Clear - True - True - True + 1 - - False - True - 1 - + - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False - + - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -275,84 +155,43 @@ Author: Romain Vigier 30 - True - False Night background - - False - True - 0 - - True - False + 1 end - 8 - - True - False - end - center - image_filter - night_background_preview - False - Select your background image + + end + center + Choose... - - False - True - 0 - Clear - True - True - True + 1 - - False - True - 1 - + - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 1 - diff --git a/src/preferences/ui/commands.ui b/src/preferences/ui/commands.ui index fb12fdf..a837394 100644 --- a/src/preferences/ui/commands.ui +++ b/src/preferences/ui/commands.ui @@ -1,15 +1,10 @@ - - + 600 - True - False center start - 36 - 36 36 36 36 @@ -19,26 +14,15 @@ top - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -46,122 +30,68 @@ 30 - True - False vertical - True - False start Run commands - - False - True - 0 - - True - False + center start <small>You can set custom commands that will be run when the time of the day changes.</small> - True - True + 1 + 1 50 0 - - False - False - 1 - - - False - True - 0 - - True - True + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 0 - - True - False vertical 8 - True - False start Commands - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -169,93 +99,55 @@ 30 - True - False Sunrise command - - False - True - 0 - - True - False + 1 end - True - True end center 28 - True - notify-send "Hello sunshine!" + 1 + notify-send "Hello sunshine!" terminal - - False - True - 0 - Clear - True - True - True - - False - True - 1 - - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False - + - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -263,86 +155,45 @@ 30 - True - False Sunset command - - False - True - 0 - - True - False + 1 end - True - True end center 28 - True - notify-send "Hello moonshine!" + 1 + notify-send "Hello moonshine!" terminal - - False - True - 0 - Clear - True - True - True - - False - True - 1 - - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 1 - diff --git a/src/preferences/ui/cursor_theme.ui b/src/preferences/ui/cursor_theme.ui index 985e30e..cf9b6b6 100644 --- a/src/preferences/ui/cursor_theme.ui +++ b/src/preferences/ui/cursor_theme.ui @@ -1,40 +1,10 @@ - - - - - - + 600 - True - False center start - 36 - 36 36 36 36 @@ -44,26 +14,15 @@ Author: Romain Vigier top - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -71,90 +30,49 @@ Author: Romain Vigier 30 - True - False Switch cursor variants - - False - True - 0 - - True - True + 1 end center - True + 1 - - True - True - 1 - - + - - - - + - - False - True - 0 - - True - False vertical 8 - True - False start Variants - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -162,58 +80,35 @@ Author: Romain Vigier 30 - True - False Day variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False - + - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -221,51 +116,25 @@ Author: Romain Vigier 30 - True - False Night variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 1 - diff --git a/src/preferences/ui/gtk_theme.ui b/src/preferences/ui/gtk_theme.ui index 543fc37..d6ae1b2 100644 --- a/src/preferences/ui/gtk_theme.ui +++ b/src/preferences/ui/gtk_theme.ui @@ -1,40 +1,10 @@ - - - - - - + 600 - True - False center start - 36 - 36 36 36 36 @@ -44,26 +14,15 @@ Author: Romain Vigier top - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -71,68 +30,39 @@ Author: Romain Vigier 30 - True - False Switch GTK variants - - False - True - 0 - - True - True + 1 end center - True + 1 - - True - True - 1 - - + - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -140,122 +70,68 @@ Author: Romain Vigier 30 - True - False vertical - True - False start Manual variants - - False - True - 0 - - True - True + 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> - True - True + <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 - - False - False - 1 - - - False - True - 0 - - True - True + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 1 - - True - False vertical 8 - True - False start Manual variants - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -263,58 +139,35 @@ Author: Romain Vigier 30 - True - False Day variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False - + - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -322,51 +175,25 @@ Author: Romain Vigier 30 - True - False Night variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 2 - diff --git a/src/preferences/ui/headerbar.ui b/src/preferences/ui/headerbar.ui index f80753b..854474a 100644 --- a/src/preferences/ui/headerbar.ui +++ b/src/preferences/ui/headerbar.ui @@ -1,412 +1,205 @@ - - - - - - - + - True - False - True - True - False - True + 1 - - True - True - False - False - True - False + + 0 + 1 - True - False 4 4 vertical 4 - True - False nightthemeswitcher-schedule-symbolic - 2 + 1 - - False - True - 0 - - True - False Schedule - + - - False - True - 1 - - - False - True - 0 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-gtktheme-symbolic - 2 + 1 - - False - True - 0 - - True - False GTK theme - + - - False - True - 1 - - - False - True - 1 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-shelltheme-symbolic - 2 + 1 - - False - True - 0 - - True - False Shell theme - + - - False - True - 1 - - - False - True - 2 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-icontheme-symbolic - 2 + 1 - - False - True - 0 - - True - False Icon theme - + - - False - True - 1 - - - False - True - 3 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-cursortheme-symbolic - 2 + 1 - - False - True - 0 - - True - False Cursor theme - + - - False - True - 1 - - - False - True - 4 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-backgrounds-symbolic - 2 + 1 - - False - True - 0 - - True - False Backgrounds - + - - False - True - 1 - - - False - True - 5 - - - True - True - False - False - False + + 0 schedule_radio - True - False 4 4 vertical 4 - True - False nightthemeswitcher-commands-symbolic - 2 + 1 - - False - True - 0 - - True - False Commands - + - - False - True - 1 - - - False - True - 6 - - + + + + diff --git a/src/preferences/ui/schedule.ui b/src/preferences/ui/schedule.ui index 94761d2..1246c90 100644 --- a/src/preferences/ui/schedule.ui +++ b/src/preferences/ui/schedule.ui @@ -1,32 +1,6 @@ - - - - - - + 23 1 @@ -45,12 +19,9 @@ Author: Romain Vigier 600 - True - False + 0 center start - 36 - 36 36 36 36 @@ -60,26 +31,18 @@ Author: Romain Vigier top - True - False - 0 - + 0 + 600 - True - False + 0 none - True - True - False - + 0 + - True - False - 16 - 16 + 0 16 16 16 @@ -87,92 +50,61 @@ Author: Romain Vigier 30 - True - False + 0 vertical - True - False + 0 start Automatic time source - - False - True - 0 - - True - False + 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> - True - True + 1 + 1 50 0 - - False - False - 1 - - - False - True - 0 - - True - True + 1 end center - True + 1 - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False + 0 - + - True - True - False - + 0 + - True - False - 16 - 16 + 0 16 16 16 @@ -180,642 +112,391 @@ Author: Romain Vigier 30 - True - False + 0 vertical - True - False + 0 start Always show on-demand controls - - False - True - 0 - - True - False + center + 0 start <small>This allows you to override the current time when using a schedule.</small> - True - True + 1 + 1 50 0 - - False - False - 1 - - - False - True - 0 - - True - True + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 0 - - True - False + 0 vertical 8 - True - False + 0 start Manual time source - + - - False - True - 0 - 600 - True - False + 0 center - True + 1 - + Night Light - True - True - False - True - False + 1 - - False - True - 0 - - + Location Services - True - True - False - False manual_nightlight_radio - - False - True - 1 - - + Manual schedule - True - True - False - False manual_nightlight_radio - - False - True - 2 - - + On-demand - True - True - False - False manual_nightlight_radio - - False - True - 3 - - - False - True - 1 - - - False - True - 1 - - True - False - False + 0 + 0 crossfade - True + 1 - - True - False - vertical - - - - - + none No preferences - + + + 0 + vertical + + + - - True - False - vertical - - - True - False - start - Night Light - - - - - - False - True - 0 - - - - - True - False - 0 - - - 600 - True - False - none - - - True - True - False - - - True - False - 16 - 16 - 16 - 16 - 16 - 16 - 30 - - - True - False - vertical - - - True - False - start - Follow <i>Disable until tomorrow</i> - True - - - False - True - 0 - - - - - True - False - start - <small>When Night Light is temporarily disabled, the extension will switch to day variants.</small> - True - True - 50 - 0 - - - - False - False - 1 - - - - - False - True - 0 - - - - - True - True - end - center - - - True - True - 1 - - - - - - - - - - - - - - False - True - 1 - - - - + nightlight Night Light - 1 - - - - - 600 - True - False - vertical - 8 - - - True - False - start - Manual schedule times - - - - - - False - True - 0 - - - - - True - False - 0 + + + 0 + vertical + 8 - - 600 - True - False - none - - - True - True - False - - - True - False - 16 - 16 - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunrise - - - False - True - 0 - - - - - True - False - end - 8 - - - True - True - 2 - 2 - 0 - vertical - sunrise_hours_adjustment - True - True - - - False - True - 0 - - - - - True - False - : - - - False - True - 1 - - - - - True - True - 2 - 2 - 0 - vertical - sunrise_minutes_adjustment - True - True - - - False - True - 2 - - - - - True - True - 1 - - - - - - - - - True - True - False - False - - - True - False - - - - - - - True - True - False - - - True - False - 16 - 16 - 16 - 16 - 16 - 16 - 30 - - - True - False - Sunset - - - False - True - 0 - - - - - True - False - end - 8 - - - True - True - 2 - 2 - 0 - vertical - sunset_hours_adjustment - True - True - - - False - True - 0 - - - - - True - False - : - - - False - True - 1 - - - - - True - True - 2 - 2 - 0 - vertical - sunset_minutes_adjustment - True - True - - - False - True - 2 - - - - - True - True - 1 - - - - - - + + 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 + + + + + + + + + - - False - True - 1 - - + - - schedule_times - Manual schedule times - 2 - - + + 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 + + + + + + + + + + + + + + + - - False - True - 2 - - True - False + 0 vertical 8 - True - False + 0 start On-demand - + - - False - True - 0 - - True - False - 0 - + 0 + 600 - True - False + 0 none - True - True - False - + 0 + - True - False - 16 - 16 + 0 16 16 16 @@ -823,91 +504,58 @@ Author: Romain Vigier 30 - True - False + 0 Keyboard shortcut - - False - True - 0 - - True - False + 1 + end + 0 Choose - True - True - True + 1 end center - - False - True - 0 - Clear - True - True - True + 1 - - False - True - 1 - - - False - False - end - 1 - - + - True - True - False - False - + 0 + 0 + - True - False + 0 - + - True - True - False - + 0 + - True - False - 16 - 16 + 0 16 16 16 @@ -915,20 +563,14 @@ Author: Romain Vigier 30 - True - False + 0 Button location - - False - True - 0 - - True - False + 1 + 0 end 1 panel @@ -938,34 +580,16 @@ Author: Romain Vigier System menu - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 3 - diff --git a/src/preferences/ui/shell_theme.ui b/src/preferences/ui/shell_theme.ui index 73f68c2..005624b 100644 --- a/src/preferences/ui/shell_theme.ui +++ b/src/preferences/ui/shell_theme.ui @@ -1,40 +1,10 @@ - - - - - - + 600 - True - False center start - 36 - 36 36 36 36 @@ -44,26 +14,15 @@ Author: Romain Vigier top - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -71,68 +30,36 @@ Author: Romain Vigier 30 - True - False Switch Shell variants - - False - True - 0 - - True - True + 1 end center - True + 1 - - True - True - 1 - - + - - - - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -140,122 +67,68 @@ Author: Romain Vigier 30 - True - False vertical - True - False start Manual variants - - False - True - 0 - - True - True + 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> - True - True + <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 - - False - False - 1 - - - False - True - 0 - - True - True + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 1 - - True - False vertical 8 - True - False start Manual variants - + - - False - True - 0 - - True - False - 0 - + 600 - True - False none - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -263,58 +136,35 @@ Author: Romain Vigier 30 - True - False Day variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - True - True - False - False - + 0 + 0 + - True - False - + - True - True - False - + 0 + - True - False - 16 - 16 16 16 16 @@ -322,51 +172,25 @@ Author: Romain Vigier 30 - True - False Night variant - - False - True - 0 - - True - False + 1 end center - - True - True - 1 - - + - - - - + - - False - True - 1 - - - False - True - 2 - diff --git a/src/prefs.js b/src/prefs.js index 0cc7674..8042796 100644 --- a/src/prefs.js +++ b/src/prefs.js @@ -18,12 +18,12 @@ this program. If not, see . 'use strict'; -const { GLib, Gtk } = imports.gi; +const { Gdk, GLib, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const { compat, utils } = Me.imports; +const { utils } = Me.imports; const { Preferences } = Me.imports.preferences.Preferences; @@ -31,9 +31,9 @@ const { Preferences } = Me.imports.preferences.Preferences; * Initialize the preferences. */ function init() { - compat.initTranslations(Me.metadata.uuid); - const iconTheme = Gtk.IconTheme.get_default(); - iconTheme.append_search_path(GLib.build_filenamev([Me.path, 'icons'])); + extensionUtils.initTranslations(Me.metadata.uuid); + const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()); + iconTheme.add_search_path(GLib.build_filenamev([Me.path, 'icons'])); } /** @@ -42,8 +42,7 @@ function init() { function buildPrefsWidget() { const preferences = new Preferences(); GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { - const window = preferences.widget.get_toplevel(); - window.resize(600, 200); + const window = preferences.widget.get_root(); window.set_titlebar(preferences.headerbar); }); return preferences.widget; diff --git a/src/settings/Backgrounds.js b/src/settings/Backgrounds.js index 18f8a69..f1d2963 100644 --- a/src/settings/Backgrounds.js +++ b/src/settings/Backgrounds.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var BackgroundsSettings = class { constructor() { logDebug('Initializing backgrounds settings...'); - this.settings = compat.getSettings(getSettingsSchema('backgrounds')); + this.settings = extensionUtils.getSettings(getSettingsSchema('backgrounds')); logDebug('Backgrounds settings initialized.'); } diff --git a/src/settings/Commands.js b/src/settings/Commands.js index 925ab4c..ca7c484 100644 --- a/src/settings/Commands.js +++ b/src/settings/Commands.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var CommandsSettings = class { constructor() { logDebug('Initializing commands settings...'); - this.settings = compat.getSettings(getSettingsSchema('commands')); + this.settings = extensionUtils.getSettings(getSettingsSchema('commands')); logDebug('Commands settings initialized.'); } diff --git a/src/settings/CursorVariants.js b/src/settings/CursorVariants.js index 05bbdfd..64ed85a 100644 --- a/src/settings/CursorVariants.js +++ b/src/settings/CursorVariants.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var CursorVariantsSettings = class { constructor() { logDebug('Initializing cursor variants settings...'); - this.settings = compat.getSettings(getSettingsSchema('cursor-variants')); + this.settings = extensionUtils.getSettings(getSettingsSchema('cursor-variants')); logDebug('Cursor variants settings initialized.'); } diff --git a/src/settings/GtkVariants.js b/src/settings/GtkVariants.js index deb1874..2d87458 100644 --- a/src/settings/GtkVariants.js +++ b/src/settings/GtkVariants.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var GtkVariantsSettings = class { constructor() { logDebug('Initializing GTK variants settings...'); - this.settings = compat.getSettings(getSettingsSchema('gtk-variants')); + this.settings = extensionUtils.getSettings(getSettingsSchema('gtk-variants')); logDebug('GTK variants settings initialized.'); } diff --git a/src/settings/IconVariants.js b/src/settings/IconVariants.js index 986a536..5bdf17b 100644 --- a/src/settings/IconVariants.js +++ b/src/settings/IconVariants.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var IconVariantsSettings = class { constructor() { logDebug('Initializing icon variants settings...'); - this.settings = compat.getSettings(getSettingsSchema('icon-variants')); + this.settings = extensionUtils.getSettings(getSettingsSchema('icon-variants')); logDebug('Icon variants settings initialized.'); } diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 408694a..900f901 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -20,8 +20,6 @@ const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; - const { logDebug, notifyError, getSettingsSchema } = Me.imports.utils; const { BackgroundsSettings } = Me.imports.settings.Backgrounds; const { CommandsSettings } = Me.imports.settings.Commands; @@ -36,7 +34,7 @@ const { TimeSettings } = Me.imports.settings.Time; var Settings = class { constructor() { logDebug('Initializing settings...'); - this.extension = compat.getExtensionSettings(); + this.extension = extensionUtils.getSettings(); this.backgrounds = new BackgroundsSettings(); this.commands = new CommandsSettings(); this.cursorVariants = new CursorVariantsSettings(); diff --git a/src/settings/ShellVariants.js b/src/settings/ShellVariants.js index 4e1c4a9..cfb1bec 100644 --- a/src/settings/ShellVariants.js +++ b/src/settings/ShellVariants.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var ShellVariantsSettings = class { constructor() { logDebug('Initializing shell variants settings...'); - this.settings = compat.getSettings(getSettingsSchema('shell-variants')); + this.settings = extensionUtils.getSettings(getSettingsSchema('shell-variants')); logDebug('Shell variants settings initialized.'); } diff --git a/src/settings/System.js b/src/settings/System.js index 7d74d18..e7e0af2 100644 --- a/src/settings/System.js +++ b/src/settings/System.js @@ -22,7 +22,6 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getUserthemesExtension, getUserthemesSettings } = Me.imports.utils; diff --git a/src/settings/Time.js b/src/settings/Time.js index 22ae90d..0f31af9 100644 --- a/src/settings/Time.js +++ b/src/settings/Time.js @@ -21,14 +21,13 @@ const Signals = imports.signals; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const { logDebug, getSettingsSchema } = Me.imports.utils; var TimeSettings = class { constructor() { logDebug('Initializing time settings...'); - this.settings = compat.getSettings(getSettingsSchema('time')); + this.settings = extensionUtils.getSettings(getSettingsSchema('time')); logDebug('Time settings initialized.'); } diff --git a/src/settings/migrations/v0ToV1.js b/src/settings/migrations/v0ToV1.js index 4a9e5a5..1465fb7 100644 --- a/src/settings/migrations/v0ToV1.js +++ b/src/settings/migrations/v0ToV1.js @@ -20,8 +20,6 @@ const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; - const { getSettingsSchema } = Me.imports.utils; /** @@ -30,7 +28,7 @@ const { getSettingsSchema } = Me.imports.utils; * @param {Settings} settings The current settings. */ function migrate(settings) { - const oldSettings = compat.getSettings(getSettingsSchema('v0')); + const oldSettings = extensionUtils.getSettings(getSettingsSchema('v0')); settings.gtkVariants.enabled = oldSettings.get_boolean('gtk-variants-enabled'); settings.gtkVariants.day = oldSettings.get_string('gtk-variant-day'); diff --git a/src/utils.js b/src/utils.js index 3ea7822..0eecde0 100644 --- a/src/utils.js +++ b/src/utils.js @@ -20,7 +20,6 @@ const { Gdk, Gio, GLib, Gtk } = imports.gi; const { extensionUtils } = imports.misc; const Me = extensionUtils.getCurrentExtension(); -const compat = Me.imports.compat; const config = Me.imports.config; const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); @@ -177,7 +176,11 @@ function getInstalledCursorThemes() { * it isn't installed. */ function getUserthemesExtension() { - return compat.extensionManagerLookup('user-theme@gnome-shell-extensions.gcampax.github.com'); + try { + return imports.ui.main.extensionManager.lookup('user-theme@gnome-shell-extensions.gcampax.github.com'); + } catch (_e) { + return undefined; + } } /**