diff --git a/src/compat.js b/src/compat.js
index a3cf22b..1704bae 100644
--- a/src/compat.js
+++ b/src/compat.js
@@ -16,27 +16,44 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see .
*/
-const Meta = imports.gi.Meta;
+const { extensionUtils } = imports.misc;
+const Me = extensionUtils.getCurrentExtension();
const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
+function init_translations(domain) {
+ if ( shell_minor_version <= 30 ) return Me.imports.convenience.initTranslations(domain);
+ else return extensionUtils.initTranslations(domain);
+}
+
+
+function extension_manager_initialized() {
+ if ( shell_minor_version > 32 ) return imports.ui.main.extensionManager._initialized;
+ else return imports.ui.extensionSystem.initted;
+}
+
+
+function extension_manager_lookup(uuid) {
+ if ( shell_minor_version > 32 ) return imports.ui.main.extensionManager.lookup(uuid);
+ else return extensionUtils.extensions[uuid] || null;
+}
+
+
+function get_extension_settings() {
+ if ( shell_minor_version <= 30 ) return Me.imports.convenience.getSettings();
+ else return extensionUtils.getSettings();
+}
+
+
function key_binding_auto_repeat() {
// if version is less then 3.30 the keybinding flags are NONE
- if (shell_minor_version < 30) {
- return Meta.KeyBindingFlags.NONE;
- }
- else {
- return Meta.KeyBindingFlags.IGNORE_AUTOREPEAT;
- }
+ if (shell_minor_version < 30) return imports.gi.Meta.KeyBindingFlags.NONE;
+ else return imports.gi.Meta.KeyBindingFlags.IGNORE_AUTOREPEAT;
};
function get_actor(subject) {
- if (shell_minor_version > 34) {
- return subject;
- }
- else {
- return subject.actor;
- }
+ if (shell_minor_version > 34) return subject;
+ else return subject.actor;
};
diff --git a/src/extension.js b/src/extension.js
index fc7d8d0..d2b0e8a 100644
--- a/src/extension.js
+++ b/src/extension.js
@@ -23,6 +23,7 @@ const { main } = imports.ui;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { log_debug } = Me.imports.utils;
const { SettingsManager } = Me.imports.modules.SettingsManager;
const { Timer } = Me.imports.modules.Timer;
@@ -34,12 +35,6 @@ const { Backgrounder } = Me.imports.modules.Backgrounder;
const { Commander } = Me.imports.modules.Commander;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.initTranslations = Me.imports.convenience.initTranslations;
-}
-
-
var enabled = false;
var settingsManager = null;
var timer = null;
@@ -53,7 +48,7 @@ var commander = null;
function init() {
log_debug('Initializing extension...');
- extensionUtils.initTranslations(Me.metadata.uuid);
+ compat.init_translations(Me.metadata.uuid);
log_debug('Extension initialized.');
}
@@ -109,16 +104,8 @@ function disable() {
async function _await_extensionManager_init() {
log_debug('Waiting for the Extension Manager to be initialized...');
- if ( shell_minor_version > 32 ) {
- while ( true ) {
- if ( main.extensionManager._initialized ) return;
- await null;
- }
- }
- else {
- while ( true ) {
- if ( imports.ui.extensionSystem.initted ) return;
- await null;
- }
+ while ( true ) {
+ if ( compat.extension_manager_initialized() ) return;
+ await null;
}
}
diff --git a/src/modules/TimerNightlight.js b/src/modules/TimerNightlight.js
index 24cbb41..9ab52ea 100644
--- a/src/modules/TimerNightlight.js
+++ b/src/modules/TimerNightlight.js
@@ -17,7 +17,7 @@ this program. If not, see .
*/
const { Gio, GLib } = imports.gi;
-const { extensionUtils, fileUtils } = imports.misc;
+const { extensionUtils } = imports.misc;
const Signals = imports.signals;
const Me = extensionUtils.getCurrentExtension();
@@ -25,12 +25,6 @@ const Me = extensionUtils.getCurrentExtension();
const { log_debug } = Me.imports.utils;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- fileUtils.loadInterfaceXML = Me.imports.convenience.loadInterfaceXML;
-}
-
-
const COLOR_INTERFACE = `
diff --git a/src/preferences/Backgrounds.js b/src/preferences/Backgrounds.js
index aea4070..1ddb89d 100644
--- a/src/preferences/Backgrounds.js
+++ b/src/preferences/Backgrounds.js
@@ -21,22 +21,17 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var BackgroundsPreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Backgrounds');
const description = _('You can set different backgrounds for day and night.');
@@ -71,7 +66,7 @@ var BackgroundsPreferences = class {
class BackgroundsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('backgrounds-enabled')
});
@@ -90,7 +85,7 @@ class BackgroundsEnabledControl {
class TimeBackgroundControl {
constructor(time) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const filter = new Gtk.FileFilter();
filter.add_mime_type('image/jpeg');
diff --git a/src/preferences/Commands.js b/src/preferences/Commands.js
index 2b3d61f..6f27f54 100644
--- a/src/preferences/Commands.js
+++ b/src/preferences/Commands.js
@@ -21,22 +21,17 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var CommandsPreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Commands');
const description = _('You can set custom commands that will be run when the time of the day changes.');
@@ -71,7 +66,7 @@ var CommandsPreferences = class {
class CommandsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('commands-enabled')
});
@@ -94,7 +89,7 @@ class SuntimeCommandControl {
['sunrise', _('Hello sunshine!')],
['sunset', _('Hello moonshine!')]
]);
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const entry = new Gtk.Entry({
width_request: 300,
placeholder_text: _(`notify-send "${message.get(suntime)}"`)
diff --git a/src/preferences/CursorTheme.js b/src/preferences/CursorTheme.js
index 05ad438..1b85db2 100644
--- a/src/preferences/CursorTheme.js
+++ b/src/preferences/CursorTheme.js
@@ -21,6 +21,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_cursor_themes } = Me.imports.utils;
@@ -28,16 +29,10 @@ const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var CursorThemePreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Cursor theme');
const description = _('You can set different cursor themes for day and night.');
@@ -72,7 +67,7 @@ var CursorThemePreferences = class {
class CursorVariantsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('cursor-variants-enabled')
});
@@ -91,7 +86,7 @@ class CursorVariantsEnabledControl {
class TimeCursorVariantControl {
constructor(time) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_cursor_themes()).sort();
themes.forEach(theme => combo.append(theme, theme));
diff --git a/src/preferences/GtkTheme.js b/src/preferences/GtkTheme.js
index 94f7d6d..d056fdb 100644
--- a/src/preferences/GtkTheme.js
+++ b/src/preferences/GtkTheme.js
@@ -21,6 +21,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_gtk_themes } = Me.imports.utils;
@@ -28,16 +29,10 @@ const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var GtkThemePreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('GTK theme');
const description = _('The extension will try to automatically detect the day and night variants of your GTK theme.\n\nIf the theme you use isn\'t supported, please submit a request. You can also manually set variants.');
@@ -77,7 +72,7 @@ var GtkThemePreferences = class {
class GtkVariantsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('gtk-variants-enabled')
});
@@ -96,7 +91,7 @@ class GtkVariantsEnabledControl {
class ManualGtkVariantsControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: false
});
@@ -115,7 +110,7 @@ class ManualGtkVariantsControl {
class TimeGtkVariantControl {
constructor(time) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_gtk_themes()).sort();
themes.forEach(theme => combo.append(theme, theme));
diff --git a/src/preferences/IconTheme.js b/src/preferences/IconTheme.js
index f4d747b..5267cb4 100644
--- a/src/preferences/IconTheme.js
+++ b/src/preferences/IconTheme.js
@@ -21,6 +21,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_icon_themes } = Me.imports.utils;
@@ -28,16 +29,10 @@ const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var IconThemePreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Icon theme');
const description = _('You can set different icon themes for day and night.');
@@ -72,7 +67,7 @@ var IconThemePreferences = class {
class IconVariantsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('icon-variants-enabled')
});
@@ -91,7 +86,7 @@ class IconVariantsEnabledControl {
class TimeIconVariantControl {
constructor(time) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_icon_themes()).sort();
themes.forEach(theme => combo.append(theme, theme));
diff --git a/src/preferences/Schedule.js b/src/preferences/Schedule.js
index 725a46b..81349b1 100644
--- a/src/preferences/Schedule.js
+++ b/src/preferences/Schedule.js
@@ -21,22 +21,17 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var SchedulePreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Schedule');
const description = _('The extension will try to use Night Light or Location Services to automatically set your current sunrise and sunset times if they are enabled.\n\nIf you prefer, you can manually choose a time source.');
@@ -82,7 +77,7 @@ var SchedulePreferences = class {
class ManualTimeSourceControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: false
});
@@ -101,7 +96,7 @@ class ManualTimeSourceControl {
class TimeSourceControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const colorSettings = new Gio.Settings({ schema: 'org.gnome.settings-daemon.plugins.color' });
const locationSettings = new Gio.Settings({ schema: 'org.gnome.system.location' });
@@ -189,7 +184,7 @@ class TimeSourceControl {
class KeyBindingControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const KEYBINDING_KEY = 'nightthemeswitcher-ondemand-keybinding';
const COLUMN_KEY = 0;
const COLUMN_MODS = 1;
@@ -239,7 +234,7 @@ class KeyBindingControl {
class SuntimeControl {
constructor(suntime) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const box = new Gtk.Box({
spacing: 8,
orientation: Gtk.Orientation.HORIZONTAL,
diff --git a/src/preferences/ShellTheme.js b/src/preferences/ShellTheme.js
index 5d39342..152af64 100644
--- a/src/preferences/ShellTheme.js
+++ b/src/preferences/ShellTheme.js
@@ -21,6 +21,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { SettingsPage, SettingsList, SettingsListRow } = Me.imports.preferences.bases;
const { get_installed_shell_themes } = Me.imports.utils;
@@ -28,16 +29,10 @@ const Gettext = imports.gettext.domain(Me.metadata.uuid);
const _ = Gettext.gettext;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.getSettings = Me.imports.convenience.getSettings;
-}
-
-
var ShellThemePreferences = class {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const label = _('Shell theme');
const description = _('The extension will try to automatically detect the day and night variants of your GNOME Shell theme.\n\nIf the theme you use isn\'t supported, please submit a request. You can also manually set variants.');
@@ -77,7 +72,7 @@ var ShellThemePreferences = class {
class ShellVariantsEnabledControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: settings.get_boolean('shell-variants-enabled')
});
@@ -96,7 +91,7 @@ class ShellVariantsEnabledControl {
class ManualShellVariantsControl {
constructor() {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const toggle = new Gtk.Switch({
active: false
});
@@ -115,7 +110,7 @@ class ManualShellVariantsControl {
class TimeShellVariantControl {
constructor(time) {
- const settings = extensionUtils.getSettings();
+ const settings = compat.get_extension_settings();
const combo = new Gtk.ComboBoxText();
const themes = Array.from(get_installed_shell_themes()).sort();
themes.forEach(theme => combo.append(theme, (theme === '' ? _('Default') : theme)));
diff --git a/src/prefs.js b/src/prefs.js
index 3e9515d..7fd287d 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -23,6 +23,7 @@ const { extensionUtils } = imports.misc;
const Me = extensionUtils.getCurrentExtension();
+const compat = Me.imports.compat;
const { BackgroundsPreferences } = Me.imports.preferences.Backgrounds;
const { CommandsPreferences } = Me.imports.preferences.Commands;
const { CursorThemePreferences } = Me.imports.preferences.CursorTheme;
@@ -32,14 +33,8 @@ const { SchedulePreferences } = Me.imports.preferences.Schedule;
const { ShellThemePreferences } = Me.imports.preferences.ShellTheme;
-const shell_minor_version = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[1]);
-if ( shell_minor_version <= 30 ) {
- extensionUtils.initTranslations = Me.imports.convenience.initTranslations;
-}
-
-
function init() {
- extensionUtils.initTranslations(Me.metadata.uuid);
+ compat.init_translations(Me.metadata.uuid);
}
function buildPrefsWidget() {
diff --git a/src/utils.js b/src/utils.js
index 3c41523..e21d47f 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,6 +20,7 @@ const { 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.uuid);
@@ -178,12 +179,7 @@ function get_installed_cursor_themes() {
* it isn't installed.
*/
function get_userthemes_extension() {
- if ( shell_minor_version > 32 ) {
- return imports.ui.main.extensionManager.lookup('user-theme@gnome-shell-extensions.gcampax.github.com');
- }
- else {
- return extensionUtils.extensions['user-theme@gnome-shell-extensions.gcampax.github.com'] || null;
- }
+ return compat.extension_manager_lookup('user-theme@gnome-shell-extensions.gcampax.github.com');
}
/**