From 8147edfa060cba45dbebeae2c196694dda7fe11b Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Fri, 18 Aug 2023 06:13:39 +0200 Subject: [PATCH] :beetle: Fix config import --- prefs.js | 41 ++++++++++++++++++++++++++++++++++++++++- src/utils.js | 44 -------------------------------------------- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/prefs.js b/prefs.js index 5c893a1..3d96505 100644 --- a/prefs.js +++ b/prefs.js @@ -20,7 +20,7 @@ import GLib from 'gi://GLib'; import Gdk from 'gi://Gdk'; import Adw from 'gi://Adw'; -import {getUIDir, getStringResource, shellVersionIsAtLeast} from './src/utils.js'; +import {getStringResource} from './src/utils.js'; import {ProfileManager} from './src/ProfileManager.js'; import Apparition from './src/effects/Apparition.js'; @@ -46,6 +46,45 @@ import TVGlitch from './src/effects/TVGlitch.js'; import Wisps from './src/effects/Wisps.js'; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; +import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js'; + +const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion); + +// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3, +// -2, and -1 are returned respectively. +function toNumericVersion(x) { + switch (x) { + case 'alpha': + return -3; + case 'beta': + return -2; + case 'rc': + return -1; + } + return x; +} + +// Currently, the extension supports only one set of UI files. In the past, there were +// three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the +// current UI directory. It's still here since it might be useful in the future. +function getUIDir() { + return 'adw'; +} + +// This method returns true if the current GNOME Shell version is at least as high as the +// given arguments. Supports "alpha" and "beta" for the minor version number. +function shellVersionIsAtLeast(major, minor) { + if (GS_MAJOR > major) { + return true; + } + + if (GS_MAJOR == major) { + return GS_MINOR >= toNumericVersion(minor); + } + + return false; +} + ////////////////////////////////////////////////////////////////////////////////////////// // The preferences dialog is organized in pages, each of which is loaded from a // diff --git a/src/utils.js b/src/utils.js index 6742f8c..85d7ed5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -17,23 +17,6 @@ import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; -// Returns the given argument, except for "alpha", "beta", and "rc". In these cases -3, -// -2, and -1 are returned respectively. -function toNumericVersion(x) { - switch (x) { - case 'alpha': - return -3; - case 'beta': - return -2; - case 'rc': - return -1; - } - return x; -} - -const Config = imports.misc.config; -const [GS_MAJOR, GS_MINOR] = Config.PACKAGE_VERSION.split('.').map(toNumericVersion); - // This method can be used to write a message to GNOME Shell's log. This is enhances // the standard log() functionality by prepending the extension's name and the location // where the message was logged. As the extensions name is part of the location, you @@ -48,33 +31,6 @@ export function debug(message) { log('[' + stack[0] + '] ' + message); } -// Currently, the extension supports only one set of UI files. In the past, there were -// three different sets for GTK3, GTK4, and Adwaita. This method returns the name of the -// current UI directory. It's still here since it might be useful in the future. -export function getUIDir() { - return 'adw'; -} - -// This method returns true if the current GNOME Shell version matches the given -// arguments. -export function shellVersionIs(major, minor) { - return GS_MAJOR == major && GS_MINOR == toNumericVersion(minor); -} - -// This method returns true if the current GNOME Shell version is at least as high as the -// given arguments. Supports "alpha" and "beta" for the minor version number. -export function shellVersionIsAtLeast(major, minor) { - if (GS_MAJOR > major) { - return true; - } - - if (GS_MAJOR == major) { - return GS_MINOR >= toNumericVersion(minor); - } - - return false; -} - // Reads the contents of a file contained in the global resources archive. The data // is returned as a string. export function getStringResource(path) {