diff --git a/Random_Walls@Antares/assets/menu.js b/Random_Walls@Antares/assets/menu.js index 9c7ac92..9c867ff 100644 --- a/Random_Walls@Antares/assets/menu.js +++ b/Random_Walls@Antares/assets/menu.js @@ -100,7 +100,10 @@ var ConfigControls = GObject.registerClass( _openConfigWidget() { let _appSys = Shell.AppSystem.get_default(); let _gsmPrefs = _appSys.lookup_app("org.gnome.Extensions.desktop"); - if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING) { + // The proper value is Shell.AppState.RUNNING; Not sure what the other value is, but it's kept + // in as that was there previously + // See: (https://gjs-docs.gnome.org/shell01~0.1_api/shell.appstate) + if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING || Shell.AppState.RUNNING) { _gsmPrefs.activate(); } else { let info = _gsmPrefs.get_app_info(); @@ -154,9 +157,9 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu. this._isNextThumbs = isNextThumbs; this._wallUtils = wallUtils; //Main Box - let MainBox = new St.BoxLayout({vertical: false}); + let MainBox = new St.BoxLayout({ vertical: false }); //Label + Icon Desktop Wallpaper Box - let desktopBox = new St.BoxLayout({vertical: true}); + let desktopBox = new St.BoxLayout({ vertical: true }); let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); let textLabel, whoami; /* 1st step: Label and identifier */ @@ -175,7 +178,7 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu. whoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK; break; } - desktopBox.add_child(new St.Label({text: textLabel, style_class: "label-thumb"})); + desktopBox.add_child(new St.Label({ text: textLabel, style_class: "label-thumb" })); /* End 1st step */ /* 2nd step: Create wallIcon (only if not in lockscreen mode)*/ @@ -187,7 +190,7 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu. }); desktopBox.add_actor(this.wallIcon); MainBox.add_child(desktopBox); - MainBox.add_child(new St.Icon({width: 20})); + MainBox.add_child(new St.Icon({ width: 20 })); } /* End 2nd step */ @@ -198,8 +201,8 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu. //whoami was NEXT or CURRENT desktop on the 1st step. Now is NEXT or CURRENT lock lockwhoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK; case "lockscreen": - let lockBox = new St.BoxLayout({vertical: true}); - lockBox.add_child(new St.Label({text: _("Lockscreen"), style_class: "label-thumb"})); + let lockBox = new St.BoxLayout({ vertical: true }); + lockBox.add_child(new St.Label({ text: _("Lockscreen"), style_class: "label-thumb" })); let lockwall = wallUtils.getCurrentLockWall(); this.lockIcon = new Chooser.ThumbIcon(lockwall, function () { indicator.close(); @@ -245,7 +248,7 @@ var RandWallMenu = GObject.registerClass( this._wallUtils = wallUtils; - let hbox = new St.BoxLayout({style_class: 'panel-status-menu-box'}); + let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); let gicon = imports.gi.Gio.icon_new_for_string(Me.path + "/icons/randwall-symbolic.symbolic.png"); let icon = new St.Icon({ style_class: 'system-status-icon randwall-icon', diff --git a/Random_Walls@Antares/assets/pictureChooser.js b/Random_Walls@Antares/assets/pictureChooser.js index 4806933..51209e9 100644 --- a/Random_Walls@Antares/assets/pictureChooser.js +++ b/Random_Walls@Antares/assets/pictureChooser.js @@ -79,7 +79,7 @@ var ThumbIcon = GObject.registerClass(class ThumbIcon extends St.Button { var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDialog.ModalDialog { _init(whoami, wallutils) { - super._init({destroyOnClose: false}); + super._init({ destroyOnClose: false }); this._wallUtils = wallutils; this._whoami = whoami; @@ -212,8 +212,9 @@ var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDia let table_col = 0; let table; for (var i = 0; i < images.length; i++) { - if (table_col == 0) - table = new St.BoxLayout({x_expand: true, style_class: "chooser-row-box-table"}); + if (table_col == 0) { + table = new St.BoxLayout({ x_expand: true, style_class: "chooser-row-box-table" }); + } //create a icon with the current image let imagepath = images[i]; @@ -301,12 +302,12 @@ var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDia let child = fileEnum.get_child(info); //Check if is a regular file if (info.get_file_type() == Gio.FileType.REGULAR) - //Check if file is a valid image + //Check if file is a valid image if (info.get_content_type().match(/^image\//i)) { let imagepath = child.get_parse_name(); //For every row create a table if (table_col == 0) - table = new St.BoxLayout({x_expand: true, vertical: false, style_class: "chooser-row-box-table"}); + table = new St.BoxLayout({ x_expand: true, vertical: false, style_class: "chooser-row-box-table" }); //create a icon with the current image let image = new ThumbIcon(this._wallUtils.getGiconFromPath(imagepath), null); diff --git a/Random_Walls@Antares/assets/settings.js b/Random_Walls@Antares/assets/settings.js new file mode 100644 index 0000000..440eddf --- /dev/null +++ b/Random_Walls@Antares/assets/settings.js @@ -0,0 +1,259 @@ +const { Gio, GObject, Gtk } = imports.gi; +const Lang = imports.lang; +const Config = imports.misc.config; + +const ExtensionUtils = imports.misc.extensionUtils; +const Me = ExtensionUtils.getCurrentExtension(); +const Convenience = Me.imports.convenience; + +const Gettext = imports.gettext.domain('randwall'); +const _ = Gettext.gettext; + +const Columns = { + FOLDER_NAME: 0 +}; + +const SETTINGS_FOLDER_LIST = 'folder-list'; +const SETTINGS_CHANGE_TIME = "change-time"; +const SETTINGS_CHANGE_MODE = "change-mode"; +const SETTINGS_HIDE_ICON = "hide-icon"; + +const margins = { + margin_top: 10, + margin_bottom: 10, + margin_start: 10, + margin_end: 10 +}; + +function horizSeparator() { + return new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL }); +} + +function horizBox() { + return new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, spacing: 20, ...margins + }); +} + +const FILE_REGEX = /^file:\/\//; + +var RandWallSettingsWidget = GObject.registerClass({ + GTypeName: 'RandWallSettingsWidget', +}, class RandWallSettingsWidget extends Gtk.Box { + + _init(params = {}) { + super._init(); + this.set_size_request(-1, 500); + this.set_orientation(Gtk.Orientation.VERTICAL); + + this._settings = Convenience.getSettings(); + this._settings.connect('changed', Lang.bind(this, this._refresh)); + this._changedPermitted = false; + + this._store = new Gtk.ListStore(); + this._store.set_column_types([GObject.TYPE_STRING]); + //Change Mode + this.append(horizSeparator()); + + let gHBoxMode = horizBox(); + + gHBoxMode.append(new Gtk.Label({ + label: _("Change mode"), halign: 1, + })); + + let modeLabels = { + 'different': _("Change both desktop and lockscreen"), + 'same': _("Change desktop and lockscreen using the same image"), + 'desktop': _("Change only desktop wallpaper"), + 'lockscreen': _("Change only Lockscreen wallpaper") + }; + + let radio = null; + let range = this._settings.get_range(SETTINGS_CHANGE_MODE); + let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); + let modes = range.deep_unpack()[1].deep_unpack(); + + let grid = new Gtk.Grid({ + orientation: Gtk.Orientation.VERTICAL, row_spacing: 6, column_spacing: 6, + margin_top: 6, margin_start: 20 + }); + + for (let i = 0; i < modes.length; i++) { + let mode = modes[i]; + let label = modeLabels[mode]; + + if (!label) { + log('Unhandled option "%s" for lock-mode'.format(mode)); + continue; + } + + radio = new Gtk.ToggleButton({ + active: currentMode == mode, label: label, group: radio + }); + + grid.attach(radio, 0, i, 1, 1); + + if (currentMode === mode) { + radio.set_active(true); + } + + radio.connect('toggled', Lang.bind(this, function (button) { + if (button.active) + this._settings.set_string(SETTINGS_CHANGE_MODE, mode); + })); + } + + gHBoxMode.append(grid); + + this.append(gHBoxMode); + this.append(horizSeparator()); + + //Hide Icon + let gHBoxHideIcon = horizBox(); + + gHBoxHideIcon.append(new Gtk.Label({ + halign: 1, hexpand: true, label: _("Hide Icon") + })); + + let iconSwitch = new Gtk.Switch({ + active: this._settings.get_boolean(SETTINGS_HIDE_ICON), + }); + + gHBoxHideIcon.append(iconSwitch); + + this.append(gHBoxHideIcon); + this.append(horizSeparator()); + + this._settings.bind(SETTINGS_HIDE_ICON, iconSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); + + //Change time + let gHBoxTimer = horizBox(); + + let gLabelTimer = new Gtk.Label({ + label: _("Interval (in minutes)"), halign: 1, hexpand: true + }); + gHBoxTimer.append(gLabelTimer); + + this._interval = Gtk.SpinButton.new_with_range(0, 3000, 1); + gHBoxTimer.append(this._interval); + this._settings.bind(SETTINGS_CHANGE_TIME, this._interval, 'value', Gio.SettingsBindFlags.DEFAULT); + + // this._interval.connect('changed',Lang.bind(this,this._changeInterval)); + this.append(gHBoxTimer); + + //Scroll list + let scrolled = new Gtk.ScrolledWindow(); + scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); + this.append(scrolled); + + //Folder tree view + this._treeView = new Gtk.TreeView({ + model: this._store, hexpand: true, vexpand: true + }); + this._treeView.get_selection().set_mode(Gtk.SelectionMode.SINGLE); + + let folderColumn = new Gtk.TreeViewColumn({ + expand: true, sort_column_id: Columns.FOLDER_NAME, title: _("Image Folders") + }); + + let nameRenderer = new Gtk.CellRendererText; + folderColumn.pack_start(nameRenderer, true); + folderColumn.add_attribute(nameRenderer, "text", Columns.FOLDER_NAME); + this._treeView.append_column(folderColumn); + scrolled.set_child(this._treeView); + + //Toolbar + let toolbar = horizBox(); + this.append(toolbar); + + let newButtonBox = horizBox(); + newButtonBox.append(new Gtk.Label({ label: _("Add Folder") })); + newButtonBox.append(new Gtk.Image({ icon_name: "bookmark-new-symbolic" })); + + //add Button + this._newButton = new Gtk.Button(); + this._newButton.set_child(newButtonBox); + + + this._newButton.connect('clicked', Lang.bind(this, this._createFolderDialog)); + toolbar.append(this._newButton); + + //delete button + let delButton = new Gtk.Button({ icon_name: 'edit-delete-symbolic' }); + delButton.connect('clicked', Lang.bind(this, this._deleteSelected)); + toolbar.append(delButton); + + let selection = this._treeView.get_selection(); + selection.connect('changed', function () { + delButton.sensitive = selection.count_selected_rows() > 0; + }); + delButton.sensitive = selection.count_selected_rows() > 0; + + let currentInterval = this._settings.get_int(SETTINGS_CHANGE_TIME); + this._interval.set_value(currentInterval); + + this._changedPermitted = true; + this._refresh(); + } + + + _createFolderDialog() { + let folderDialog = new Gtk.FileChooserNative({ + title: _("Select a folder"), + modal: true, + action: Gtk.FileChooserAction.SELECT_FOLDER + }); + + folderDialog.set_transient_for(this._newButton.get_root()); + + folderDialog.connect('response', Lang.bind(this, function (dialog, id) { + log(id); + if (id != Gtk.ResponseType.ACCEPT) { + dialog.destroy(); + } else { + let filename = dialog.get_file().get_uri().replace(FILE_REGEX, ""); + + let items = this._settings.get_strv(SETTINGS_FOLDER_LIST); + let exists = items.indexOf(filename); + if (exists == -1) { + items.push(filename); + this._settings.set_strv(SETTINGS_FOLDER_LIST, items); + } + dialog.destroy(); + } + })); + + folderDialog.show(); + } + + _deleteSelected() { + let [any, model, iter] = this._treeView.get_selection().get_selected(); + if (any) { + let folderName = this._store.get_value(iter, Columns.FOLDER_NAME); + this._changedPermitted = false; + let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); + let index = currentItems.indexOf(folderName); + if (index < 0) { + return; + } + currentItems.splice(index, 1); + this._settings.set_strv(SETTINGS_FOLDER_LIST, currentItems); + this._changedPermitted = true; + this._store.remove(iter); + this._refresh; + } + + } + + _refresh() { + if (!this._changedPermitted) + return; + + this._store.clear(); + let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); + for (var i = 0; i < currentItems.length; i++) { + let iter = this._store.append(); + this._store.set(iter, [Columns.FOLDER_NAME], [currentItems[i]]); + } + } +}); \ No newline at end of file diff --git a/Random_Walls@Antares/assets/timeout.js b/Random_Walls@Antares/assets/timeout.js index dfaf70a..e202e31 100644 --- a/Random_Walls@Antares/assets/timeout.js +++ b/Random_Walls@Antares/assets/timeout.js @@ -12,7 +12,7 @@ var MyTimer = class MyTimer { this._timeout = this._settings.get_int(SETTINGS_TIMEOUT) * 60000; this._timerId = null; this._changed = false; - + // Listen to changes and restart with new timeout. this._settings.connect('changed::' + SETTINGS_TIMEOUT, Lang.bind(this, function (value) { let newValue = value.get_int(SETTINGS_TIMEOUT); diff --git a/Random_Walls@Antares/assets/wallpapers.js b/Random_Walls@Antares/assets/wallpapers.js index 29830c2..0040b81 100644 --- a/Random_Walls@Antares/assets/wallpapers.js +++ b/Random_Walls@Antares/assets/wallpapers.js @@ -2,9 +2,17 @@ const Gio = imports.gi.Gio; const Gdk = imports.gi.Gdk; const Lang = imports.lang; +const Config = imports.misc.config; + +let shellMajorVersion = parseInt(Config.PACKAGE_VERSION.split('.')[0]); + +const PICTURE_URIS = shellMajorVersion >= 42 ? + ["picture-uri", "picture-uri-dark"] : + ["picture-uri"]; + const SETTINGS_CHANGE_MODE = 'change-mode'; -const SETTINGS_WALLS_URI = 'picture-uri'; -const SETTINGS_LOCK_URI = 'picture-uri'; +// const SETTINGS_WALLS_URI = 'picture-uri'; +// const SETTINGS_LOCK_URI = 'picture-uri'; const SETTINGS_FOLDER_LIST = 'folder-list'; const SETTINGS_BACKGROUND_MODE = 'picture-options'; @@ -57,38 +65,42 @@ var WallUtils = class WallUtils { } getCurrentWall() { - let background_setting = new Gio.Settings({schema: 'org.gnome.desktop.background'}); - let pathFromURI = decodeURIComponent(background_setting.get_string(SETTINGS_WALLS_URI)).replace(/^file:\/\//g, ''); - return new Gio.FileIcon({file: Gio.File.new_for_path(pathFromURI)}); + let background_setting = new Gio.Settings({ schema: 'org.gnome.desktop.background' }); + let pathFromURI = decodeURIComponent(background_setting.get_string(PICTURE_URIS[0])).replace(/^file:\/\//g, ''); + return new Gio.FileIcon({ file: Gio.File.new_for_path(pathFromURI) }); } getCurrentLockWall() { - let lockbackground_setting = new Gio.Settings({schema: 'org.gnome.desktop.screensaver'}); - let pathFromURI = decodeURIComponent(lockbackground_setting.get_string(SETTINGS_LOCK_URI)).replace(/^file:\/\//g, ''); - return new Gio.FileIcon({file: Gio.File.new_for_path(pathFromURI)}); + let lockbackground_setting = new Gio.Settings({ schema: 'org.gnome.desktop.screensaver' }); + let pathFromURI = decodeURIComponent(lockbackground_setting.get_string(PICTURE_URIS[0])).replace(/^file:\/\//g, ''); + return new Gio.FileIcon({ file: Gio.File.new_for_path(pathFromURI) }); } getGiconFromPath(path) { - return new Gio.FileIcon({file: Gio.File.new_for_path(path)}); + return new Gio.FileIcon({ file: Gio.File.new_for_path(path) }); } getNextWall() { - return new Gio.FileIcon({file: Gio.File.new_for_path(this._nextWall)}); + return new Gio.FileIcon({ file: Gio.File.new_for_path(this._nextWall) }); } getNextLockWall() { - return new Gio.FileIcon({file: Gio.File.new_for_path(this._nextLock)}); + return new Gio.FileIcon({ file: Gio.File.new_for_path(this._nextLock) }); } setWall(picture) { - let background_setting = new Gio.Settings({schema: 'org.gnome.desktop.background'}); - background_setting.set_string(SETTINGS_WALLS_URI, - 'file://' + picture.split('/').map(c => encodeURIComponent(c)).join('/')); + let background_setting = new Gio.Settings({ schema: 'org.gnome.desktop.background' }); + + for (let i = 0; i < PICTURE_URIS.length; i++) { + background_setting.set_string(PICTURE_URIS[i], + 'file://' + picture.split('/').map(c => encodeURIComponent(c)).join('/')); + } } setLockWall(picture) { - let lockbackground_setting = new Gio.Settings({schema: 'org.gnome.desktop.screensaver'}); - lockbackground_setting.set_string(SETTINGS_WALLS_URI, + let lockbackground_setting = new Gio.Settings({ schema: 'org.gnome.desktop.screensaver' }); + + lockbackground_setting.set_string(PICTURE_URIS[0], 'file://' + picture.split('/').map(c => encodeURIComponent(c)).join('/')); } @@ -249,7 +261,7 @@ var WallUtils = class WallUtils { } var getScreenAspectRatio = function () { - let background_setting = new Gio.Settings({schema: 'org.gnome.desktop.background'}); + let background_setting = new Gio.Settings({ schema: 'org.gnome.desktop.background' }); let background_mode = background_setting.get_string(SETTINGS_BACKGROUND_MODE); if (background_mode == 'spanned') { return Gdk.Screen.height() / Gdk.Screen.width(); diff --git a/Random_Walls@Antares/convenience.js b/Random_Walls@Antares/convenience.js index bbc8608..5b93add 100644 --- a/Random_Walls@Antares/convenience.js +++ b/Random_Walls@Antares/convenience.js @@ -1,4 +1,4 @@ -/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* -*- mode: js; js-basic-offset: 2; indent-tabs-mode: nil -*- */ /* Copyright (c) 2011-2012, Giovanni Campagna @@ -39,19 +39,19 @@ const ExtensionUtils = imports.misc.extensionUtils; * If @domain is not provided, it will be taken from metadata['gettext-domain'] */ function initTranslations(domain) { - let extension = ExtensionUtils.getCurrentExtension(); + let extension = ExtensionUtils.getCurrentExtension(); - domain = domain || extension.metadata['gettext-domain']; + 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); + // 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); } /** @@ -63,31 +63,31 @@ function initTranslations(domain) { * metadata['settings-schema']. */ function getSettings(schema) { - let extension = ExtensionUtils.getCurrentExtension(); + let extension = ExtensionUtils.getCurrentExtension(); - schema = schema || extension.metadata['settings-schema']; + schema = schema || extension.metadata['settings-schema']; - const GioSSS = Gio.SettingsSchemaSource; + 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(); + // 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.'); + 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 }); + return new Gio.Settings({ settings_schema: schemaObj }); } - + diff --git a/Random_Walls@Antares/extension.js b/Random_Walls@Antares/extension.js index 452fdfe..4856c93 100644 --- a/Random_Walls@Antares/extension.js +++ b/Random_Walls@Antares/extension.js @@ -7,12 +7,13 @@ const Wallpapers = Me.imports.assets.wallpapers; const Lang = imports.lang; const Config = imports.misc.config; +let shellMajorVersion = parseInt(Config.PACKAGE_VERSION.split('.')[0]); let shellMinorVersion = parseInt(Config.PACKAGE_VERSION.split('.')[1]); let RandWallMenu; let wallUtils; -if (shellMinorVersion > 30) { +if (shellMajorVersion >= 40 || shellMinorVersion > 30) { RandWallMenu = Me.imports.assets.menu.RandWallMenu; } else { RandWallMenu = Me.imports.legacy.menu.RandWallMenu @@ -21,11 +22,11 @@ if (shellMinorVersion > 30) { const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; -const SETTINGS_FOLDER_LIST = "folder-list"; -const SETTINGS_CHANGE_MODE = "change-mode"; -const SETTINGS_HIDE_ICON = "hide-icon"; -const SETTINGS_TIMEOUT = "change-time"; -const SETTINGS_CHANGE_TIMESTAMP = "change-timestamp"; +var SETTINGS_FOLDER_LIST = "folder-list"; +var SETTINGS_CHANGE_MODE = "change-mode"; +var SETTINGS_HIDE_ICON = "hide-icon"; +var SETTINGS_TIMEOUT = "change-time"; +var SETTINGS_CHANGE_TIMESTAMP = "change-timestamp"; function init(metadata) { _settings = Convenience.getSettings(); @@ -70,7 +71,7 @@ function enable() { } else { const timer = MyTimer; - _wait_timer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, expected_change_time - now, function() { + _wait_timer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, expected_change_time - now, function () { // if the timeout was changed (even if it is the same value now), do not start a second time if (!timer.changed()) { wallUtils.changeWallpapers(); diff --git a/Random_Walls@Antares/legacy/menu.js b/Random_Walls@Antares/legacy/menu.js index be3d6bc..8bb9a7a 100644 --- a/Random_Walls@Antares/legacy/menu.js +++ b/Random_Walls@Antares/legacy/menu.js @@ -83,7 +83,7 @@ const ConfigControls = class ConfigControls extends PopupMenu.PopupBaseMenuItem style_class: "controls", }); - this.actor.add(this.box, {expand: true}); + this.actor.add(this.box, { expand: true }); this.box.add_actor(new ControlButton("list-add", this._openConfigWidget).actor); } @@ -119,7 +119,7 @@ var NextWallControls = class NextWallControls extends PopupMenu.PopupBaseMenuIte } else this.box.set_style("padding-left: " + ((Chooser.THUMB_WIDTH / 2) - 36) + "px;"); //36 = button_size*2 + padding*2 - this.actor.add(this.box, {expand: true}); + this.actor.add(this.box, { expand: true }); this.box.add_actor(new ControlButton("media-playback-start", Lang.bind(this, this._changeWalls)).actor); this.box.add_actor(new ControlButton("media-playlist-shuffle", Lang.bind(this, this._newNextWalls)).actor); @@ -143,9 +143,9 @@ var thumbPreviews = class thumbPreviews extends PopupMenu.PopupBaseMenuItem { this._wallUtils = wallUtils; //Main Box - let MainBox = new St.BoxLayout({vertical: false}); + let MainBox = new St.BoxLayout({ vertical: false }); //Label + Icon Desktop Wallpaper Box - let desktopBox = new St.BoxLayout({vertical: true}); + let desktopBox = new St.BoxLayout({ vertical: true }); let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); let textLabel, whoami; /* 1st step: Label and identifier */ @@ -164,7 +164,7 @@ var thumbPreviews = class thumbPreviews extends PopupMenu.PopupBaseMenuItem { whoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK; break; } - desktopBox.add_child(new St.Label({text: textLabel, style_class: "label-thumb"})); + desktopBox.add_child(new St.Label({ text: textLabel, style_class: "label-thumb" })); /* End 1st step */ /* 2nd step: Create wallIcon (only if not in lockscreen mode)*/ @@ -176,7 +176,7 @@ var thumbPreviews = class thumbPreviews extends PopupMenu.PopupBaseMenuItem { }); desktopBox.add_actor(this.wallIcon.actor); MainBox.add_child(desktopBox); - MainBox.add_child(new St.Icon({width: 20})); + MainBox.add_child(new St.Icon({ width: 20 })); } /* End 2nd step */ @@ -187,8 +187,8 @@ var thumbPreviews = class thumbPreviews extends PopupMenu.PopupBaseMenuItem { //whoami was NEXT or CURRENT desktop on the 1st step. Now is NEXT or CURRENT lock lockwhoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK; case "lockscreen": - let lockBox = new St.BoxLayout({vertical: true}); - lockBox.add_child(new St.Label({text: _("Lockscreen"), style_class: "label-thumb"})); + let lockBox = new St.BoxLayout({ vertical: true }); + lockBox.add_child(new St.Label({ text: _("Lockscreen"), style_class: "label-thumb" })); let lockwall = wallUtils.getCurrentLockWall(); this.lockIcon = new Chooser.ThumbIcon(lockwall, function () { indicator.close(); @@ -231,7 +231,7 @@ var RandWallMenu = class RandWallMenu extends PanelMenu.Button { this._wallUtils = wallUtils; - let hbox = new St.BoxLayout({style_class: 'panel-status-menu-box'}); + let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); let gicon = imports.gi.Gio.icon_new_for_string(Me.path + "/icons/randwall-symbolic.symbolic.png"); let icon = new St.Icon({ style_class: 'system-status-icon randwall-icon', diff --git a/Random_Walls@Antares/legacy/pictureChooser.js b/Random_Walls@Antares/legacy/pictureChooser.js index 947573b..17aca40 100644 --- a/Random_Walls@Antares/legacy/pictureChooser.js +++ b/Random_Walls@Antares/legacy/pictureChooser.js @@ -83,7 +83,7 @@ var ThumbIcon = class ThumbIcon { var PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { constructor(whoami, wallutils) { - super({destroyOnClose: false}); + super({ destroyOnClose: false }); this._wallUtils = wallutils; this._whoami = whoami; @@ -111,7 +111,7 @@ var PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { y_align: St.Align.START }); //SEARCH - this.contentLayout.add(this._create_search_bar(), {x_fill: false}); + this.contentLayout.add(this._create_search_bar(), { x_fill: false }); //THUMBS TABLE let thumbsTable = this._create_thumbs_table(); @@ -152,8 +152,8 @@ var PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { this._search_box.add_style_class_name("modal-search-bar-focus"); })); - this._search_box.add(this._search_icon, {y_align: St.Align.MIDDLE}); - this._search_box.add(this._search_bar, {y_align: St.Align.MIDDLE, y_fill: false, x_expand: true}) + this._search_box.add(this._search_icon, { y_align: St.Align.MIDDLE }); + this._search_box.add(this._search_bar, { y_align: St.Align.MIDDLE, y_fill: false, x_expand: true }) return this._search_box; } @@ -215,7 +215,7 @@ var PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { let table; for (var i = 0; i < images.length; i++) { if (table_col == 0) - table = new St.BoxLayout({x_expand: true, style_class: "chooser-row-box-table"}); + table = new St.BoxLayout({ x_expand: true, style_class: "chooser-row-box-table" }); //create a icon with the current image let imagepath = images[i]; @@ -302,12 +302,12 @@ var PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { let child = fileEnum.get_child(info); //Check if is a regular file if (info.get_file_type() == Gio.FileType.REGULAR) - //Check if file is a valid image + //Check if file is a valid image if (info.get_content_type().match(/^image\//i)) { let imagepath = child.get_parse_name(); //For every row create a table if (table_col == 0) - table = new St.BoxLayout({x_expand: true, vertical: false, style_class: "chooser-row-box-table"}); + table = new St.BoxLayout({ x_expand: true, vertical: false, style_class: "chooser-row-box-table" }); //create a icon with the current image let image = new ThumbIcon(this._wallUtils.getGiconFromPath(imagepath), null); //set the callback diff --git a/Random_Walls@Antares/legacy/settings.js b/Random_Walls@Antares/legacy/settings.js new file mode 100644 index 0000000..2b0cd5b --- /dev/null +++ b/Random_Walls@Antares/legacy/settings.js @@ -0,0 +1,218 @@ +const { Gio, GObject, Gtk } = imports.gi; +const Lang = imports.lang; +const Config = imports.misc.config; + +const ExtensionUtils = imports.misc.extensionUtils; +const Me = ExtensionUtils.getCurrentExtension(); +const Convenience = Me.imports.convenience; + +const Gettext = imports.gettext.domain('randwall'); +const _ = Gettext.gettext; + +const SETTINGS_FOLDER_LIST = 'folder-list'; +const SETTINGS_CHANGE_TIME = "change-time"; +const SETTINGS_CHANGE_MODE = "change-mode"; +const SETTINGS_HIDE_ICON = "hide-icon"; + + +const Columns = { + FOLDER_NAME: 0 +}; + +const RandWallSettingsWidget = new GObject.Class({ + Name: 'RandWall.prefs.RandWallSettingsWidget', + GTypeName: 'RandWallSettingsWidget', + Extends: Gtk.Grid, + + _init: function (params) { + this.parent(params); + this.set_size_request(-1, 500); + this.set_orientation(Gtk.Orientation.VERTICAL); + + this._settings = Convenience.getSettings(); + this._settings.connect('changed', Lang.bind(this, this._refresh)); + this._changedPermitted = false; + + this._store = new Gtk.ListStore(); + this._store.set_column_types([GObject.TYPE_STRING]); + //Change Mode + this.add(new Gtk.HSeparator()); + this.add(new Gtk.Label({ label: _("Change mode"), halign: Gtk.Align.START, margin: 10 })); + let modeLabels = { + 'different': _("Change both desktop and lockscreen"), + 'same': _("Change desktop and lockscreen using the same image"), + 'desktop': _("Change only desktop wallpaper"), + 'lockscreen': _("Change only Lockscreen wallpaper") + }; + let radio = null; + let range = this._settings.get_range(SETTINGS_CHANGE_MODE); + let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); + let modes = range.deep_unpack()[1].deep_unpack(); + + let grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL, row_spacing: 6, column_spacing: 6, margin_top: 6, margin_left: 20 }); + for (let i = 0; i < modes.length; i++) { + let mode = modes[i]; + let label = modeLabels[mode]; + + if (!label) { + log('Unhandled option "%s" for lock-mode'.format(mode)); + continue; + } + + radio = new Gtk.RadioButton({ + active: currentMode == mode, label: label, group: radio + }); + + grid.add(radio); + + if (currentMode === mode) { + radio.set_active(true); + } + + radio.connect('toggled', Lang.bind(this, function (button) { + if (button.active) + this._settings.set_string(SETTINGS_CHANGE_MODE, mode); + })); + + } + + this.add(grid); + this.add(new Gtk.HSeparator()); + + //Hide Icon + let gHBoxHideIcon = new Gtk.HBox({ margin: 10, spacing: 20 }); + gHBoxHideIcon.add(new Gtk.Label({ + halign: 1, hexpand: true, label: _("Hide Icon") + })); + let iconSwitch = new Gtk.Switch({ + active: this._settings.get_boolean(SETTINGS_HIDE_ICON), + }); + gHBoxHideIcon.add(iconSwitch); + this.add(gHBoxHideIcon); + this.add(new Gtk.HSeparator()); + this._settings.bind(SETTINGS_HIDE_ICON, iconSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); + + //Change time + let gHBoxTimer = new Gtk.HBox({ margin: 10, spacing: 20, hexpand: true }); + let gLabelTimer = new Gtk.Label({ label: _("Interval (in minutes)"), halign: Gtk.Align.START }); + gHBoxTimer.add(gLabelTimer); + this._interval = Gtk.SpinButton.new_with_range(0, 3000, 1); + gHBoxTimer.add(this._interval); + this._interval.connect('changed', Lang.bind(this, this._changeInterval)); + this.add(gHBoxTimer); + + //Scroll list + let scrolled = new Gtk.ScrolledWindow({ shadow_type: Gtk.ShadowType.IN }); + scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); + this.add(scrolled); + + //Folder tree view + this._treeView = new Gtk.TreeView({ model: this._store, hexpand: true, vexpand: true }); + this._treeView.get_selection().set_mode(Gtk.SelectionMode.SINGLE); + + let folderColumn = new Gtk.TreeViewColumn({ expand: true, sort_column_id: Columns.FOLDER_NAME, title: _("Image Folders") }); + let nameRenderer = new Gtk.CellRendererText; + folderColumn.pack_start(nameRenderer, true); + folderColumn.add_attribute(nameRenderer, "text", Columns.FOLDER_NAME); + this._treeView.append_column(folderColumn); + scrolled.add(this._treeView); + + //Toolbar + let toolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.SMALL_TOOLBAR }); + toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR); + this.add(toolbar); + + //add Button + let newButton = new Gtk.ToolButton({ + icon_name: 'bookmark-new-symbolic', + label: _("Add Folder"), + is_important: true + }); + + + newButton.connect('clicked', Lang.bind(this, this._createFolderDialog)); + toolbar.add(newButton); + //delete button + let delButton = new Gtk.ToolButton({ icon_name: 'edit-delete-symbolic' }); + delButton.connect('clicked', Lang.bind(this, this._deleteSelected)); + toolbar.add(delButton); + + let selection = this._treeView.get_selection(); + selection.connect('changed', function () { + delButton.sensitive = selection.count_selected_rows() > 0; + }); + delButton.sensitive = selection.count_selected_rows() > 0; + + + this._changedPermitted = true; + this._refresh(); + }, + + + _createFolderDialog: function () { + let folderDialog = new Gtk.FileChooserDialog({ + title: _("Select a folder"), + modal: true, + action: Gtk.FileChooserAction.SELECT_FOLDER + }); + folderDialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL); + folderDialog.add_button(Gtk.STOCK_ADD, Gtk.ResponseType.OK); + + folderDialog.connect('response', Lang.bind(this, function (dialog, id) { + if (id != Gtk.ResponseType.OK) { + dialog.destroy(); + } else { + let items = this._settings.get_strv(SETTINGS_FOLDER_LIST); + let exists = items.indexOf(dialog.get_filename()); + if (exists == -1) { + items.push(dialog.get_filename()); + this._settings.set_strv(SETTINGS_FOLDER_LIST, items); + } + dialog.destroy(); + } + + })); + + folderDialog.run(); + }, + + _deleteSelected: function () { + let [any, model, iter] = this._treeView.get_selection().get_selected(); + if (any) { + let folderName = this._store.get_value(iter, Columns.FOLDER_NAME); + this._changedPermitted = false; + let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); + let index = currentItems.indexOf(folderName); + if (index < 0) { + return; + } + currentItems.splice(index, 1); + this._settings.set_strv(SETTINGS_FOLDER_LIST, currentItems); + this._changedPermitted = true; + this._store.remove(iter); + this._refresh; + } + + }, + + _changeInterval: function () { + let currentValue = this._interval.get_value(); + //this._spawn_sync(Me.path + "/scripts/", ["randwallcron", Me.path], null); + this._settings.set_int(SETTINGS_CHANGE_TIME, currentValue); + }, + + _refresh: function () { + if (!this._changedPermitted) + return; + + let currentInterval = this._settings.get_int(SETTINGS_CHANGE_TIME); + this._interval.set_value(currentInterval); + + this._store.clear(); + let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); + for (var i = 0; i < currentItems.length; i++) { + let iter = this._store.append(); + this._store.set(iter, [Columns.FOLDER_NAME], [currentItems[i]]); + } + } +}); \ No newline at end of file diff --git a/Random_Walls@Antares/metadata.json b/Random_Walls@Antares/metadata.json old mode 100644 new mode 100755 index 4a10649..5b45e25 --- a/Random_Walls@Antares/metadata.json +++ b/Random_Walls@Antares/metadata.json @@ -1,9 +1,22 @@ { - "shell-version": ["3.14","3.16","3.18","3.20","3.22", "3.30", "3.32", "3.34", "3.36", "3.38"], + "shell-version": [ + "3.14", + "3.16", + "3.18", + "3.20", + "3.22", + "3.30", + "3.32", + "3.34", + "3.36", + "3.38", + "40", + "42" + ], "uuid": "Random_Walls@Antares", "url": "https://github.com/rodakorn/randwall", "settings-schema": "org.gnome.shell.extensions.randwall", - "gettext-domain" : "randwall", + "gettext-domain": "randwall", "name": "Random Walls", "description": "Change desktop and lockscreen wallpapers randomly" } \ No newline at end of file diff --git a/Random_Walls@Antares/prefs.js b/Random_Walls@Antares/prefs.js index 12cd2e2..adf1dd3 100644 --- a/Random_Walls@Antares/prefs.js +++ b/Random_Walls@Antares/prefs.js @@ -1,237 +1,30 @@ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ - -const Gio = imports.gi.Gio; -const Gtk = imports.gi.Gtk; -const GObject = imports.gi.GObject; -const Lang = imports.lang; - +const Config = imports.misc.config; const ExtensionUtils = imports.misc.extensionUtils; + const Me = ExtensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; -const Gettext = imports.gettext.domain('randwall'); -const _ = Gettext.gettext; - -const Columns = { - FOLDER_NAME : 0 -}; - -const SETTINGS_FOLDER_LIST = 'folder-list'; -const SETTINGS_CHANGE_TIME = "change-time"; -const SETTINGS_CHANGE_MODE = "change-mode"; -const SETTINGS_HIDE_ICON = "hide-icon"; - -/*const SettingsWidget = new GObject.Class({ - Name: "SettingsWidget", - Extends: Gtk.Widget, - - _init: function(params) { - this.parent(params); - this.grid = new RandWallSettingsWidget(); - this.add(this.grid); - } - -});*/ - -const RandWallSettingsWidget = new GObject.Class({ - Name: 'RandWall.prefs.RandWallSettingsWidget', - GTypeName: 'RandWallSettingsWidget', - Extends: Gtk.Grid, - - _init : function(params) { - this.parent(params); - this.set_size_request(-1,500); - this.set_orientation(Gtk.Orientation.VERTICAL); - - this._settings = Convenience.getSettings(); - this._settings.connect('changed', Lang.bind(this, this._refresh)); - this._changedPermitted = false; - - this._store = new Gtk.ListStore(); - this._store.set_column_types([GObject.TYPE_STRING]); - //Change Mode - this.add(new Gtk.HSeparator()); - this.add(new Gtk.Label({label: _("Change mode"),halign: Gtk.Align.START, margin: 10})); - let modeLabels = { - 'different': _("Change both desktop and lockscreen"), - 'same': _("Change desktop and lockscreen using the same image"), - 'desktop': _("Change only desktop wallpaper"), - 'lockscreen': _("Change only Lockscreen wallpaper") - }; - let radio = null; - let range = this._settings.get_range(SETTINGS_CHANGE_MODE); - let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); - let modes = range.deep_unpack()[1].deep_unpack(); - - let grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,row_spacing: 6,column_spacing: 6,margin_top: 6, margin_left: 20 }); - for (let i = 0; i < modes.length; i++) { - let mode = modes[i]; - let label = modeLabels[mode]; - if (!label) { - log('Unhandled option "%s" for lock-mode'.format(mode)); - continue; - } - radio = new Gtk.RadioButton({ active: currentMode == mode, - label: label, - group: radio }); - - grid.add(radio); - - if (currentMode === mode) { - radio.set_active(true); - } - - radio.connect('toggled', Lang.bind(this, function(button) { - if (button.active) - this._settings.set_string(SETTINGS_CHANGE_MODE, mode); - })); +let shellMajorVersion = parseInt(Config.PACKAGE_VERSION.split('.')[0]); - } - - this.add(grid); - this.add(new Gtk.HSeparator()); - - //Hide Icon - let gHBoxHideIcon = new Gtk.HBox({margin:10, spacing: 20, hexpand: true}); - gHBoxHideIcon.add(new Gtk.Label({label: _("Hide Icon"),halign: Gtk.Align.START, margin: 10})); - let iconSwitch = new Gtk.Switch({ - active: this._settings.get_boolean(SETTINGS_HIDE_ICON), - halign: Gtk.Align.END - }); - gHBoxHideIcon.add(iconSwitch); - this.add(gHBoxHideIcon); - this.add(new Gtk.HSeparator()); - this._settings.bind(SETTINGS_HIDE_ICON, iconSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); - - //Change time - let gHBoxTimer = new Gtk.HBox({margin:10, spacing: 20, hexpand: true}); - let gLabelTimer = new Gtk.Label({label: _("Interval (in minutes)"),halign: Gtk.Align.START}); - gHBoxTimer.add(gLabelTimer); - this._interval = Gtk.SpinButton.new_with_range (0, 3000, 1); - gHBoxTimer.add(this._interval); - this._interval.connect('changed',Lang.bind(this,this._changeInterval)); - this.add(gHBoxTimer); - - //Scroll list - let scrolled = new Gtk.ScrolledWindow({ shadow_type: Gtk.ShadowType.IN}); - scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); - this.add(scrolled); - - //Folder tree view - this._treeView = new Gtk.TreeView({ model: this._store, hexpand: true, vexpand: true }); - this._treeView.get_selection().set_mode(Gtk.SelectionMode.SINGLE); - - let folderColumn = new Gtk.TreeViewColumn({ expand: true, sort_column_id: Columns.FOLDER_NAME, title: _("Image Folders") }); - let nameRenderer = new Gtk.CellRendererText; - folderColumn.pack_start(nameRenderer,true); - folderColumn.add_attribute(nameRenderer,"text",Columns.FOLDER_NAME); - this._treeView.append_column(folderColumn); - scrolled.add(this._treeView); - - //Toolbar - let toolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.SMALL_TOOLBAR }); - toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR); - this.add(toolbar); - - //add Button - let newButton = new Gtk.ToolButton({ icon_name: 'bookmark-new-symbolic', - label: _("Add Folder"), - is_important: true }); - - - newButton.connect('clicked',Lang.bind(this,this._createFolderDialog)); - toolbar.add(newButton); - //delete button - let delButton = new Gtk.ToolButton({ icon_name: 'edit-delete-symbolic' }); - delButton.connect('clicked',Lang.bind(this, this._deleteSelected)); - toolbar.add(delButton); - - let selection = this._treeView.get_selection(); - selection.connect('changed', function(){ - delButton.sensitive = selection.count_selected_rows() > 0; - }); - delButton.sensitive = selection.count_selected_rows() > 0; - - - this._changedPermitted = true; - this._refresh(); - }, - - - _createFolderDialog: function() { - let folderDialog = new Gtk.FileChooserDialog({ title: _("Select a folder"), - modal: true, - action: Gtk.FileChooserAction.SELECT_FOLDER }); - folderDialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL); - folderDialog.add_button(Gtk.STOCK_ADD, Gtk.ResponseType.OK); - - folderDialog.connect('response', Lang.bind(this,function(dialog,id){ - if(id != Gtk.ResponseType.OK){ - dialog.destroy(); - } else { - let items = this._settings.get_strv(SETTINGS_FOLDER_LIST); - let exists = items.indexOf(dialog.get_filename()); - if (exists == -1 ) { - items.push(dialog.get_filename()); - this._settings.set_strv(SETTINGS_FOLDER_LIST, items); - } - dialog.destroy(); - } - - })); - - folderDialog.run(); - }, - - _deleteSelected: function() { - let [any, model, iter] = this._treeView.get_selection().get_selected(); - if (any) { - let folderName = this._store.get_value(iter,Columns.FOLDER_NAME); - this._changedPermitted = false; - let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); - let index = currentItems.indexOf(folderName); - if(index < 0) { - return; - } - currentItems.splice(index,1); - this._settings.set_strv(SETTINGS_FOLDER_LIST, currentItems); - this._changedPermitted = true; - this._store.remove(iter); - this._refresh; - } - - }, - - _changeInterval: function() { - let currentValue = this._interval.get_value(); - //this._spawn_sync(Me.path + "/scripts/", ["randwallcron", Me.path], null); - this._settings.set_int(SETTINGS_CHANGE_TIME,currentValue); - }, +let RandWallSettingsWidget; - _refresh: function() { - if(!this._changedPermitted) - return; - - let currentInterval = this._settings.get_int(SETTINGS_CHANGE_TIME); - this._interval.set_value(currentInterval); - - this._store.clear(); - let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST); - for (var i = 0; i < currentItems.length; i++) { - let iter = this._store.append(); - this._store.set(iter,[Columns.FOLDER_NAME],[currentItems[i]]); - } - } - -}); +if (shellMajorVersion >= 40) { + RandWallSettingsWidget = Me.imports.assets.settings.RandWallSettingsWidget; +} else { + RandWallSettingsWidget = Me.imports.legacy.settings.RandWallSettingsWidget; +} function init() { Convenience.initTranslations(); } function buildPrefsWidget() { - let widget = new RandWallSettingsWidget({ margin: 12 }); - widget.show_all(); + let widget = new RandWallSettingsWidget(); + + if (shellMajorVersion < 40) { + widget.show_all(); + } return widget; }