Move all old shell versions compatibility code to a single file

This commit is contained in:
Romain Vigier
2020-07-28 12:10:53 +02:00
parent 4e70a11624
commit c6f35255b2
12 changed files with 72 additions and 118 deletions
+4 -9
View File
@@ -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');
+4 -9
View File
@@ -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)}"`)
+4 -9
View File
@@ -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));
+5 -10
View File
@@ -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 <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. 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));
+4 -9
View File
@@ -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));
+6 -11
View File
@@ -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,
+5 -10
View File
@@ -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 <a href="https://gitlab.com/rmnvgr/nightthemeswitcher-gnome-shell-extension/-/issues">submit a request</a>. 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)));