From 38ab10bb84e543b8699b53a052479197399fe4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gayot?= Date: Fri, 12 Apr 2019 11:32:08 +0200 Subject: [PATCH] :bug: Update for Gnome 3.32 --- .gitignore | 1 + Random_Walls@Antares/assets/pictureChooser.js | 862 +++++++++--------- Random_Walls@Antares/assets/timeout.js | 73 +- Random_Walls@Antares/assets/wallpapers.js | 492 +++++----- Random_Walls@Antares/extension.js | 613 ++++++------- 5 files changed, 1006 insertions(+), 1035 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62c8935 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/Random_Walls@Antares/assets/pictureChooser.js b/Random_Walls@Antares/assets/pictureChooser.js index 6109d11..07d96a0 100644 --- a/Random_Walls@Antares/assets/pictureChooser.js +++ b/Random_Walls@Antares/assets/pictureChooser.js @@ -20,450 +20,442 @@ const NEXT_LOCK = 3; var THUMB_WIDTH = 200; //Change on stylesheet.css too!! const NUM_COLS_TABLE = 4; -let _settings=Convenience.getSettings(); +let _settings = Convenience.getSettings(); -var ThumbIcon = new Lang.Class({ - Name: 'ThumbIcon', - actor: {}, - _icon: {}, - _callback: null, +var ThumbIcon = class ThumbIcon { - _init: function(gicon,callback) { - this._icon = new St.Icon({ - gicon: gicon, - icon_size: THUMB_WIDTH, - style_class: 'wall-preview' - }); + constructor(gicon, callback) { + this._icon = new St.Icon({ + gicon: gicon, + icon_size: THUMB_WIDTH, + style_class: 'wall-preview' + }); + + this.actor = new St.Button({ + child: this._icon, + x_expand: true + }); + + this._icon.set_height(THUMB_WIDTH * Wallpapers.getScreenAspectRatio()); - this.actor = new St.Button({ - child: this._icon, - x_expand: true - }); + this.actor.connect('clicked', Lang.bind(this, this._callback_internal)); + if (callback != undefined || callback != null) { + this._callback = callback; + } + + this.actor.connect('enter_event', Lang.bind(this, this.start_hover)); + this.actor.connect('leave_event', Lang.bind(this, this.stop_hover)); - this._icon.set_height(THUMB_WIDTH*Wallpapers.getScreenAspectRatio()); + } - this.actor.connect('clicked', Lang.bind(this,this._callback_internal)); - if (callback != undefined || callback != null){ - this._callback = callback; + _callback_internal(object) { + this.stop_hover(); + if (this._callback != undefined || this._callback != null) { + this._callback(); + } + } + + setCallback(callback) { + if (callback === undefined || callback === null || typeof callback !== "function") { + throw TypeError("'callback' needs to be a function."); + } + this._callback = callback; + } + + start_hover() { + this._icon.set_style_class_name("wall-preview-hover"); + } + + stop_hover() { + this._icon.set_style_class_name("wall-preview"); + } + + set_style(style) { + this.actor.set_style(style); + } + + set_gicon(icon) { + this._icon.set_gicon(icon); + } + + set_style_class(styleClass) { + this._icon.set_style_class(styleClass); + } +}; + +const PictureChooser = class PictureChooser extends ModalDialog.ModalDialog { + constructor(whoami, wallutils) { + super({destroyOnClose: false}); + this._wallUtils = wallutils; + this._whoami = whoami; + + this._dialogLayout = + typeof this.dialogLayout === "undefined" + ? this._dialogLayout + : this.dialogLayout; + + this._dialogLayout.set_style_class_name('picture-chooser-box'); + this._dialogLayout.connect('key_press_event', Lang.bind(this, this._on_key_press_event)); + this._createLayout(); + } + + _on_key_press_event(o, e) { + if (e.get_key_symbol() == Clutter.KEY_Escape) + this.close(); + } + + _createLayout() { + //CLOSE BUTTON + this.contentLayout.add(this._create_close_button(), { + x_fill: false, + x_align: St.Align.END, + y_fill: false, + y_align: St.Align.START + }); + //SEARCH + this.contentLayout.add(this._create_search_bar(), {x_fill: false}); + + //THUMBS TABLE + let thumbsTable = this._create_thumbs_table(); + this.contentLayout.add(thumbsTable); + + } + + _create_search_bar() { + this._search_box = new St.BoxLayout({ + vertical: false, + width: THUMB_WIDTH * 2, + style_class: 'modal-search-bar', + margin_bottom: 10 + }); + + let icon = new St.Icon({ + icon_name: 'edit-find-symbolic', + icon_size: 18, + }); + + this._search_icon = new St.Button({ + reactive: false, + name: 'search-icon', + style_class: 'modal-search-icon', + }); + + this._search_icon.add_actor(icon); + + this._search_bar = new St.Entry({ + width: THUMB_WIDTH * 2 - 40, + y_align: St.Align.MIDDLE, + hint_text: _("Search image"), + style_class: "hint-text" + }); + + this._search_bar.clutter_text.connect('text-changed', Lang.bind(this, this.redraw)); + this._search_bar.clutter_text.connect('key_focus_in', Lang.bind(this, function () { + this._search_icon.add_style_class_name("search-icon-focus"); + 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}) + return this._search_box; + } + + _search_file() { + this._search_bar.remove_style_class_name('hint-text'); + let text = this._search_bar.get_text(); + if (text.length == 0) + return null; + //set to true to know the user wrote something on the search bar + this._searched = true; + let paths = this._wallUtils.getDirs(); + + let results = []; + for (var i = 0; i < paths.length; i++) { + let path = paths[i]; + let file = Gio.File.new_for_path(path); + let fileEnum = file.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE, null); + let info; + if (fileEnum !== null) { + while ((info = fileEnum.next_file(null))) { + let name = info.get_name(); + let nameNoExt = name.slice(0, name.lastIndexOf('.')); + //if(name.slice(0,text.length) == text) { + if (nameNoExt.toLowerCase().search(text.toLowerCase()) != -1) { + let child = fileEnum.get_child(info); + results.push(child.get_parse_name()); + } } + } + } + + if (!results.length) + return null; + else + return results; + } + + _create_searched_thumbs_table(images) { + let scroll = new St.ScrollView({ + style_class: 'chooser-box-table', + name: 'thumbs-box', + }); + + scroll.set_height(700); + this._super_box = new St.BoxLayout({ + y_expand: true, + x_expand: true, + vertical: true + }); + this._super_box.set_width(THUMB_WIDTH * (NUM_COLS_TABLE + 1) - 35); + + if (!images) { + scroll.add_actor(this._super_box); + return scroll; + } - this.actor.connect('enter_event',Lang.bind(this,this.start_hover)); - this.actor.connect('leave_event',Lang.bind(this,this.stop_hover)); - - }, - - _callback_internal: function(object){ - this.stop_hover(); - if (this._callback != undefined || this._callback != null){ - this._callback(); - } - }, - - setCallback: function(callback) { - if (callback === undefined || callback === null || typeof callback !== "function"){ - throw TypeError("'callback' needs to be a function."); - } - this._callback = callback; - }, - - start_hover: function() { - this._icon.set_style_class_name("wall-preview-hover"); - }, - - stop_hover: function() { - this._icon.set_style_class_name("wall-preview"); - }, - - set_style: function(style) { - this.actor.set_style(style); - }, - - set_gicon: function(icon) { - this._icon.set_gicon(icon); - }, - - set_style_class: function(styleClass) { - this._icon.set_style_class(styleClass); - } -}); - -const PictureChooser = new Lang.Class ({ - Name: 'PictureChooser', - Extends: ModalDialog.ModalDialog, - _whoami: null, - _wallUtils: null, - _searched: false, - - _init: function(whoami,wallutils) { - this.parent({destroyOnClose: false}); - this._wallUtils = wallutils; - this._whoami = whoami; - - this._dialogLayout = - typeof this.dialogLayout === "undefined" - ? this._dialogLayout - : this.dialogLayout; - - this._dialogLayout.set_style_class_name('picture-chooser-box'); - this._dialogLayout.connect('key_press_event', Lang.bind(this,this._on_key_press_event)); - this._createLayout(); - }, - - _on_key_press_event: function(o,e) { - if(e.get_key_symbol() == Clutter.KEY_Escape) - this.close(); - }, - - _createLayout: function() { - //CLOSE BUTTON - this.contentLayout.add(this._create_close_button(), { - x_fill: false, - x_align: St.Align.END, - y_fill: false, - y_align: St.Align.START - }); - //SEARCH - this.contentLayout.add(this._create_search_bar(),{x_fill:false}); - - //THUMBS TABLE - let thumbsTable = this._create_thumbs_table(); - this.contentLayout.add(thumbsTable); - - }, - - _create_search_bar: function() { - this._search_box = new St.BoxLayout({ - vertical: false, - width: THUMB_WIDTH*2, - style_class: 'modal-search-bar', - margin_bottom: 10 - }); - - let icon = new St.Icon({ - icon_name: 'edit-find-symbolic', - icon_size: 18, - }); - - this._search_icon = new St.Button({ - reactive: false, - name: 'search-icon', - style_class: 'modal-search-icon', - }); - - this._search_icon.add_actor(icon); - - this._search_bar = new St.Entry({ - width: THUMB_WIDTH*2-40, - y_align: St.Align.MIDDLE, - hint_text: _("Search image"), - style_class: "hint-text" - }); - - this._search_bar.clutter_text.connect('text-changed',Lang.bind(this,this.redraw)); - this._search_bar.clutter_text.connect('key_focus_in', Lang.bind(this,function(){ - this._search_icon.add_style_class_name("search-icon-focus"); - 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}) - return this._search_box; - }, - - _search_file: function(){ - this._search_bar.remove_style_class_name('hint-text'); - let text = this._search_bar.get_text(); - if(text.length == 0) - return null; - //set to true to know the user wrote something on the search bar - this._searched = true; - let paths = this._wallUtils.getDirs(); - - let results = []; - for(var i=0;i= 1) && (newValue <= 3000)) { + this._timeout = newValue * 60000; + this.start(); + } + })); + } - _settings: {}, - _timeout: 0, - _callback: null, - _timerId: null, - - _init: function() { - this._settings = Convenience.getSettings(); - this._timeout = this._settings.get_int(SETTINGS_TIMEOUT)*60000; - // 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); - if((this._timeout != newValue) && (newValue >= 1) && (newValue <= 3000)) { - this._timeout = newValue*60000; - this.start(); - } - })); - }, - - setCallback: function(callback) { - if (callback === undefined || callback === null || typeof callback !== "function"){ - throw TypeError("'callback' needs to be a function."); - } - this._callback = callback; - }, - - start: function() { - this.stop(); - this._timerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,this._timeout, this._callback); - }, - - stop: function() { - //If timerId is not set we don't do anything - if (this._timerId !== null) { - GLib.source_remove(this._timerId); - this._timerId = null; - } - }, -}); + setCallback(callback) { + if (callback === undefined || callback === null || typeof callback !== "function") { + throw TypeError("'callback' needs to be a function."); + } + this._callback = callback; + } + + start() { + this.stop(); + this._timerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._timeout, this._callback); + } + + stop() { + //If timerId is not set we don't do anything + if (this._timerId !== null) { + GLib.source_remove(this._timerId); + this._timerId = null; + } + } +} diff --git a/Random_Walls@Antares/assets/wallpapers.js b/Random_Walls@Antares/assets/wallpapers.js index 8384699..c078a9b 100644 --- a/Random_Walls@Antares/assets/wallpapers.js +++ b/Random_Walls@Antares/assets/wallpapers.js @@ -8,254 +8,246 @@ const SETTINGS_LOCK_URI = 'picture-uri'; const SETTINGS_FOLDER_LIST = 'folder-list'; const SETTINGS_BACKGROUND_MODE = 'picture-options'; -var WallUtils = new Lang.Class({ - Name: 'WallUtils', - - _settings: null, - _nextWall: null, - _nextLock: null, - _indicator: null, - _dirs: null, - - _init: function(settings,indicator) { - this._settings = settings; - this._dirs = this.initValidDirs(); - if (this._dirs != null) { - this._nextWall = this.getRandomPicture(); - this._nextLock = this.getRandomPicture(); - } - }, - - setIndicator: function(indicator) { - this._indicator = indicator; - }, - - getDirs: function() { - return this._dirs; - }, - - getNumValidImages: function() { - let numFiles = 0; - for (let i = 0; i < this._dirs.length; i++) { - let dir = Gio.File.new_for_path(this._dirs[i]); - - let fileEnum; - try { - fileEnum = dir.enumerate_children('standard::name,standard::type', - Gio.FileQueryInfoFlags.NONE, - null); - } catch (e) { - fileEnum = null; - } - - let info, child; - if (fileEnum !== null) { - while ((info = fileEnum.next_file(null)) != null) { - let child = fileEnum.get_child(info); - //Check if is a regular file, and is an image - if (info.get_file_type() == Gio.FileType.REGULAR && - /.*\.[jpg|jpeg|png]/i.test(child.get_parse_name())) { - numFiles++; - } - } - } - } - - return numFiles; - }, - - getCurrentWall: function() { - 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)}); - }, - - getCurrentLockWall: function() { - 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)}); - }, - - getGiconFromPath: function(path) { - return new Gio.FileIcon({file: Gio.File.new_for_path(path)}); - }, - - getNextWall: function() { - return new Gio.FileIcon({file: Gio.File.new_for_path(this._nextWall)}); - }, - - getNextLockWall: function() { - return new Gio.FileIcon({file: Gio.File.new_for_path(this._nextLock)}); - }, - - setWall: function(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('/')); - }, - - setLockWall: function(picture) { - let lockbackground_setting = new Gio.Settings({schema: 'org.gnome.desktop.screensaver'}); - lockbackground_setting.set_string(SETTINGS_WALLS_URI, - 'file://' + picture.split('/').map(c => encodeURIComponent(c)).join('/')); - }, - - setNextLockWall: function(picture) { - this._nextLock = picture; - }, - - setNextWall: function(picture) { - this._nextWall = picture; - }, - - getRandomPicture: function() { - //Get list of dirs with images and select one randomly - //let listDirs = this._settings.get_strv(SETTINGS_FOLDER_LIST); - let randDir = Math.floor((Math.random() * this._dirs.length)); - let dir = Gio.File.new_for_path(this._dirs[randDir]); - let randPic = null; - - let fileEnum; - try { - fileEnum = dir.enumerate_children('standard::name,standard::type', - Gio.FileQueryInfoFlags.NONE, - null); - } catch (e) { - fileEnum = null; - } - //Make list of valid files - let validFiles = []; - if (fileEnum !== null) { - let info, child; - while ((info = fileEnum.next_file(null)) != null) { - let child = fileEnum.get_child(info); - //Check if is a regular file, and is an image - if (info.get_file_type() == Gio.FileType.REGULAR && - /.*\.[jpg|jpeg|png]/i.test(child.get_parse_name())) { - validFiles.push(child.get_parse_name()); - } - } - - if (validFiles.length > 0) { - let randomPic = Math.floor((Math.random() * validFiles.length)); - randPic = validFiles[randomPic]; - } - } - - return randPic; - }, - - changeWallpapers: function() { - let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); - //DESKTOP CHANGE: Always except if we are in lockscreen mode - if (currentMode != 'lockscreen') - this.setWall(this._nextWall); - - //LOCKSCREEN CHANGE: If we are in 'same' mode set the desktop wall - // If we are in 'lockscreen' or 'different' change randomly - if (currentMode != 'desktop') { - if (currentMode == 'same') - this.setLockWall(this._nextWall); - else - this.setLockWall(this._nextLock); - } - //Get new nextWalls - this._nextWall = this.getRandomPicture(); - this._nextLock = this.getRandomPicture(); - //updateThumbs - this.refreshThumbs(); - }, - - refreshThumbs: function() { - let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); - //DESKTOP THUMBS UPDATE: only if not in lockscreen mode - if (currentMode != 'lockscreen') { - this._indicator.currentThumbs.setWallThumb(); - this._indicator.nextThumbs.setWallThumb(); - } - //LOCKSCREEN THUMBS: only if not in desktop or same mode - if (currentMode != 'desktop' && currentMode != 'same') { - this._indicator.currentThumbs.setLockThumb(); - this._indicator.nextThumbs.setLockThumb(); - } - }, - - setNewNextAndRefresh: function() { - let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); - - this._nextWall = this.getRandomPicture(); - this._nextLock = (currentMode=='same')?this._nextWall:this.getRandomPicture(); - - if (currentMode != 'lockscreen') - this._indicator.nextThumbs.setWallThumb(); - - if (currentMode != 'desktop' && currentMode != 'same') - this._indicator.nextThumbs.setLockThumb(); - - }, - - checkFolder: function(dirpath,validDirs) { - let dir = Gio.File.new_for_path(dirpath); - - let fileEnum; - try { - fileEnum = dir.enumerate_children('standard::name,standard::type,standard::content-type', - Gio.FileQueryInfoFlags.NONE, - null); - } catch (e) { - fileEnum = null; - } - if (fileEnum !== null) { - let info, child; - while ((info = fileEnum.next_file(null)) != null) { - 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, and be careful with loops - if (info.get_content_type().match(/^image\//i) && validDirs.indexOf(dirpath) == -1) { - validDirs.push(dirpath); - } - } else if (info.get_file_type() == Gio.FileType.DIRECTORY) { - this.checkFolder(child.get_parse_name(),validDirs); - } - } - } - - return validDirs; - - }, - - initValidDirs: function() { - let validDirs = []; - let listDirs = this._settings.get_strv(SETTINGS_FOLDER_LIST); - if (listDirs.length > 0) { - for (let i = 0; i < listDirs.length; i++) { - let dirpath = listDirs[i]; - this.checkFolder(dirpath,validDirs); - } - - if (validDirs.length > 0) - return validDirs; - } - - return null; - }, - - isEmpty: function() { - return this._dirs == null; - } - - -}); - -var getScreenAspectRatio = function() { - 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(); - } else { - let screen = Gdk.Screen.get_default(); - let monitor = screen.get_monitor_geometry(screen.get_primary_monitor()); - return monitor.height / monitor.width; - } +var WallUtils = class WallUtils { + constructor(settings, indicator) { + this._settings = settings; + this._dirs = this.initValidDirs(); + if (this._dirs != null) { + this._nextWall = this.getRandomPicture(); + this._nextLock = this.getRandomPicture(); + } + } + + setIndicator(indicator) { + this._indicator = indicator; + } + + getDirs() { + return this._dirs; + } + + getNumValidImages() { + let numFiles = 0; + for (let i = 0; i < this._dirs.length; i++) { + let dir = Gio.File.new_for_path(this._dirs[i]); + + let fileEnum; + try { + fileEnum = dir.enumerate_children('standard::name,standard::type', + Gio.FileQueryInfoFlags.NONE, + null); + } catch (e) { + fileEnum = null; + } + + let info, child; + if (fileEnum !== null) { + while ((info = fileEnum.next_file(null)) != null) { + let child = fileEnum.get_child(info); + //Check if is a regular file, and is an image + if (info.get_file_type() == Gio.FileType.REGULAR && + /.*\.[jpg|jpeg|png]/i.test(child.get_parse_name())) { + numFiles++; + } + } + } + } + + return numFiles; + } + + 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)}); + } + + 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)}); + } + + getGiconFromPath(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)}); + } + + getNextLockWall() { + 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('/')); + } + + setLockWall(picture) { + let lockbackground_setting = new Gio.Settings({schema: 'org.gnome.desktop.screensaver'}); + lockbackground_setting.set_string(SETTINGS_WALLS_URI, + 'file://' + picture.split('/').map(c => encodeURIComponent(c)).join('/')); + } + + setNextLockWall(picture) { + this._nextLock = picture; + } + + setNextWall(picture) { + this._nextWall = picture; + } + + getRandomPicture() { + //Get list of dirs with images and select one randomly + //let listDirs = this._settings.get_strv(SETTINGS_FOLDER_LIST); + let randDir = Math.floor((Math.random() * this._dirs.length)); + let dir = Gio.File.new_for_path(this._dirs[randDir]); + let randPic = null; + + let fileEnum; + try { + fileEnum = dir.enumerate_children('standard::name,standard::type', + Gio.FileQueryInfoFlags.NONE, + null); + } catch (e) { + fileEnum = null; + } + //Make list of valid files + let validFiles = []; + if (fileEnum !== null) { + let info, child; + while ((info = fileEnum.next_file(null)) != null) { + let child = fileEnum.get_child(info); + //Check if is a regular file, and is an image + if (info.get_file_type() == Gio.FileType.REGULAR && + /.*\.[jpg|jpeg|png]/i.test(child.get_parse_name())) { + validFiles.push(child.get_parse_name()); + } + } + + if (validFiles.length > 0) { + let randomPic = Math.floor((Math.random() * validFiles.length)); + randPic = validFiles[randomPic]; + } + } + + return randPic; + } + + changeWallpapers() { + let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); + //DESKTOP CHANGE: Always except if we are in lockscreen mode + if (currentMode != 'lockscreen') + this.setWall(this._nextWall); + + //LOCKSCREEN CHANGE: If we are in 'same' mode set the desktop wall + // If we are in 'lockscreen' or 'different' change randomly + if (currentMode != 'desktop') { + if (currentMode == 'same') + this.setLockWall(this._nextWall); + else + this.setLockWall(this._nextLock); + } + //Get new nextWalls + this._nextWall = this.getRandomPicture(); + this._nextLock = this.getRandomPicture(); + //updateThumbs + this.refreshThumbs(); + } + + refreshThumbs() { + let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); + //DESKTOP THUMBS UPDATE: only if not in lockscreen mode + if (currentMode != 'lockscreen') { + this._indicator.currentThumbs.setWallThumb(); + this._indicator.nextThumbs.setWallThumb(); + } + //LOCKSCREEN THUMBS: only if not in desktop or same mode + if (currentMode != 'desktop' && currentMode != 'same') { + this._indicator.currentThumbs.setLockThumb(); + this._indicator.nextThumbs.setLockThumb(); + } + } + + setNewNextAndRefresh() { + let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE); + + this._nextWall = this.getRandomPicture(); + this._nextLock = (currentMode == 'same') ? this._nextWall : this.getRandomPicture(); + + if (currentMode != 'lockscreen') + this._indicator.nextThumbs.setWallThumb(); + + if (currentMode != 'desktop' && currentMode != 'same') + this._indicator.nextThumbs.setLockThumb(); + + } + + checkFolder(dirpath, validDirs) { + let dir = Gio.File.new_for_path(dirpath); + + let fileEnum; + try { + fileEnum = dir.enumerate_children('standard::name,standard::type,standard::content-type', + Gio.FileQueryInfoFlags.NONE, + null); + } catch (e) { + fileEnum = null; + } + if (fileEnum !== null) { + let info, child; + while ((info = fileEnum.next_file(null)) != null) { + 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, and be careful with loops + if (info.get_content_type().match(/^image\//i) && validDirs.indexOf(dirpath) == -1) { + validDirs.push(dirpath); + } + } else if (info.get_file_type() == Gio.FileType.DIRECTORY) { + this.checkFolder(child.get_parse_name(), validDirs); + } + } + } + + return validDirs; + + } + + initValidDirs() { + let validDirs = []; + let listDirs = this._settings.get_strv(SETTINGS_FOLDER_LIST); + if (listDirs.length > 0) { + for (let i = 0; i < listDirs.length; i++) { + let dirpath = listDirs[i]; + this.checkFolder(dirpath, validDirs); + } + + if (validDirs.length > 0) + return validDirs; + } + + return null; + } + + isEmpty() { + return this._dirs == null; + } + + +} + +var getScreenAspectRatio = function () { + 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(); + } else { + let screen = Gdk.Screen.get_default(); + let monitor = screen.get_monitor_geometry(screen.get_primary_monitor()); + return monitor.height / monitor.width; + } }; diff --git a/Random_Walls@Antares/extension.js b/Random_Walls@Antares/extension.js index 15db2b2..ac0545e 100644 --- a/Random_Walls@Antares/extension.js +++ b/Random_Walls@Antares/extension.js @@ -1,4 +1,4 @@ -const St = imports.gi.St; +const { GObject, Shell, St } = imports.gi; const Main = imports.ui.main; const Me = imports.misc.extensionUtils.getCurrentExtension(); const Convenience = Me.imports.convenience; @@ -8,7 +8,7 @@ const Chooser = Me.imports.assets.pictureChooser; const MyConfig = Me.imports.prefs; const Lang = imports.lang; const Tweener = imports.ui.tweener; -const Shell = imports.gi.Shell; + const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; @@ -26,342 +26,335 @@ const CURRENT_LOCK = 1; const NEXT_DESK = 2; const NEXT_LOCK = 3; - let metadata = Me.metadata; let settings; var MyTimer; let wallUtils; -const LabelWidget = new Lang.Class({ - Name: "LabelWidget", - Extends: PopupMenu.PopupBaseMenuItem, +const LabelWidget = class LabelWidget extends PopupMenu.PopupBaseMenuItem { + constructor(text, type) { + super({ + reactive: false + }); - _init: function(text,type){ - this.parent({ - reactive: false - }); + this._label = new St.Label({ + text: text, + style_class: "labels" + }); + //Add type to stylesheet.css if you want different styles + this._label.add_style_class_name(type); - this._label = new St.Label({ - text: text, - style_class: "labels" - }); - //Add type to stylesheet.css if you want different styles - this._label.add_style_class_name(type); - - this.actor.add_child(this._label); - }, - - setText: function(text){ - this._label.text = text; + this.actor.add_child(this._label); + } + + setText(text) { + this._label.text = text; + } +}; + + +const ControlButton = class ControlButton { + constructor(icon, callback) { + this.icon = new St.Icon({ + icon_name: icon + "-symbolic", // Get the symbol-icons. + icon_size: 20 + }); + + this.actor = new St.Button({ + style_class: 'notification-icon-button control-button', // buttons styled like in Rhythmbox-notifications + child: this.icon + }); + this.icon.set_style('padding: 0px'); + this.actor.set_style('padding: 8px'); // Put less space between buttons + + if (callback != undefined || callback != null) { + this.actor.connect('clicked', callback); } -}); + } -const ControlButton = new Lang.Class({ - Name: 'ControlButton', - actor: {}, + setIcon(icon) { + this.icon.icon_name = icon + '-symbolic'; + } +}; - _init: function(icon, callback){ - this.icon = new St.Icon({ - icon_name: icon + "-symbolic", // Get the symbol-icons. - icon_size: 20 - }); +const ConfigControls = class ConfigControls extends PopupMenu.PopupBaseMenuItem { + + constructor() { + super({ + reactive: false + }); + + this.box = new St.BoxLayout({ + style_class: "controls", + }); + + this.actor.add(this.box, {expand: true}); + this.box.add_actor(new ControlButton("list-add", this._openConfigWidget).actor); + + } + + _openConfigWidget() { + let _appSys = Shell.AppSystem.get_default(); + let _gsmPrefs = _appSys.lookup_app('gnome-shell-extension-prefs.desktop'); + if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING) { + _gsmPrefs.activate(); + } else { + let info = _gsmPrefs.get_app_info(); + let timestamp = global.display.get_current_time_roundtrip(); + info.launch_uris([metadata.uuid], global.create_app_launch_context(timestamp, -1)); + } + } +}; + +const NextWallControls = class NextWallControls extends PopupMenu.PopupBaseMenuItem { + constructor() { + + super({ + reactive: false + }); + + this.box = new St.BoxLayout({ + style_class: "controls", + }); + + let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); + if (currentMode == "different") { + this.box.set_style("padding-left: " + (Chooser.THUMB_WIDTH - 30) + "px;"); + } 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.box.add_actor(new ControlButton("media-playback-start", this._changeWalls).actor); + this.box.add_actor(new ControlButton("media-playlist-shuffle", this._newNextWalls).actor); - this.actor = new St.Button({ - style_class: 'notification-icon-button control-button', // buttons styled like in Rhythmbox-notifications - child: this.icon + } + + _changeWalls() { + if (wallUtils != null) + wallUtils.changeWallpapers(); + } + + _newNextWalls() { + if (wallUtils != null) + wallUtils.setNewNextAndRefresh(); + } +}; + +const thumbPreviews = class thumbPreviews extends PopupMenu.PopupBaseMenuItem { + constructor(isNextThumbs) { + super(); + this._isNextThumbs = isNextThumbs; + //Main Box + let MainBox = new St.BoxLayout({vertical: false}); + //Label + Icon Desktop Wallpaper Box + let desktopBox = new St.BoxLayout({vertical: true}); + let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); + let textLabel, whoami; + /* 1st step: Label and identifier */ + switch (currentMode) { + case "different": + case "desktop": + textLabel = _("Desktop"); + whoami = (this._isNextThumbs) ? NEXT_DESK : CURRENT_DESK; + break; + case "same": + textLabel = _("Desktop & Lockscreen"); + whoami = (this._isNextThumbs) ? NEXT_DESK : CURRENT_DESK; + break; + case "lockscreen": + textLabel = _("Lockscreen"); + whoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK; + break; + } + 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)*/ + if (currentMode != "lockscreen") { + let filewall = wallUtils.getCurrentWall(); + this.wallIcon = new Chooser.ThumbIcon(filewall, function () { + _indicator.close(); + new Chooser.PictureChooser(whoami, wallUtils).open(); + }); + desktopBox.add_actor(this.wallIcon.actor); + MainBox.add_child(desktopBox); + MainBox.add_child(new St.Icon({width: 20})); + } + /* End 2nd step */ + + /* 3rd step: Create lockIcon (only in "different" and "lockscreen" mode*/ + let lockwhoami = whoami; + switch (currentMode) { + case "different": + //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 lockwall = wallUtils.getCurrentLockWall(); + this.lockIcon = new Chooser.ThumbIcon(lockwall, function () { + _indicator.close(); + new Chooser.PictureChooser(lockwhoami, wallUtils).open(); }); - this.icon.set_style('padding: 0px'); - this.actor.set_style('padding: 8px'); // Put less space between buttons + lockBox.add_child(this.lockIcon.actor); + MainBox.add_child(lockBox); + break; + } + /* End 3nd step*/ + // Add everything to the mainbox + this.actor.add_actor(MainBox); + } + + setWallThumb() { + let newIcon = null; + if (this._isNextThumbs) + newIcon = wallUtils.getNextWall(); + else + newIcon = wallUtils.getCurrentWall(); + Tweener.addTween(this.wallIcon.actor, { + opacity: 0, + time: 1, + transition: 'easeOutQuad', + onCompleteParams: [this.wallIcon, newIcon], + onComplete: function (thumb, icon) { + thumb.set_gicon(icon); + } + }); + Tweener.addTween(this.wallIcon.actor, {opacity: 255, delay: 1.3, time: 1, transition: 'easeOutQuad'}); + } + + + setLockThumb() { + let lockIcon = null; + if (this._isNextThumbs) + lockIcon = wallUtils.getNextLockWall(); + else + lockIcon = wallUtils.getCurrentLockWall(); + Tweener.addTween(this.lockIcon.actor, { + opacity: 0, + time: 1, + transition: 'easeOutQuad', + onCompleteParams: [this.lockIcon, lockIcon], + onComplete: function (thumb, icon) { + thumb.set_gicon(icon); + } + }); + Tweener.addTween(this.lockIcon.actor, {opacity: 255, delay: 1.3, time: 1, transition: 'easeOutQuad'}); + } +}; - if (callback != undefined || callback != null){ - this.actor.connect('clicked', callback); - } - }, +const RandWallMenu = GObject.registerClass( + class RandWallMenu extends PanelMenu.Button { + _init() { + super._init(0.0, "randwall"); + // this.mainButton = new PanelMenu.Button(0.0, "randwall"); + // this.menu = this.mainButton.menu; + // this.actor = this.mainButton.actor; + let hbox = new St.BoxLayout({style_class: 'panel-status-menu-box'}); + let icon = new St.Icon({ + style_class: 'system-status-icon randwall-icon', + icon_name: 'randwall-symbolic' + }); + hbox.add_child(icon); + hbox.add_child(PopupMenu.arrowIcon(St.Side.BOTTOM)); + this.actor.add_actor(hbox); + + if (!wallUtils.isEmpty()) { + //Label current wallpapers + this.menu.addMenuItem(new LabelWidget(_("CURRENT"), "info")); + // Current Walls thumbs + this.currentThumbs = new thumbPreviews(false); + this.menu.addMenuItem(this.currentThumbs); + // Separator + this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); + //Label current wallpapers + this.menu.addMenuItem(new LabelWidget(_("NEXT"), "info")); + // Next Walls thumbs + this.nextThumbs = new thumbPreviews(true); + this.menu.addMenuItem(this.nextThumbs); + // Separator + this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); + //Controles + let control = new NextWallControls(); + this.menu.addMenuItem(control); + } else { + this.menu.addMenuItem(new LabelWidget(_("No images found!"), "error")); + this.menu.addMenuItem(new LabelWidget(_("Please, add some folders with images"), "info")); + this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); + this.menu.addMenuItem(new ConfigControls()); + } - setIcon: function(icon){ - this.icon.icon_name = icon+'-symbolic'; } -}); - -const ConfigControls = new Lang.Class({ - Name: "ConfigControls", - Extends: PopupMenu.PopupBaseMenuItem, - - _init: function() { - - this.parent({ - reactive: false - }); - - this.box = new St.BoxLayout({ - style_class: "controls", - }); - - this.actor.add(this.box,{expand:true}); - this.box.add_actor(new ControlButton("list-add",this._openConfigWidget).actor ); - - }, - - _openConfigWidget: function() { - let _appSys = Shell.AppSystem.get_default(); - let _gsmPrefs = _appSys.lookup_app('gnome-shell-extension-prefs.desktop'); - if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING){ - _gsmPrefs.activate(); - } else { - let info = _gsmPrefs.get_app_info(); - let timestamp = global.display.get_current_time_roundtrip(); - info.launch_uris([metadata.uuid], global.create_app_launch_context(timestamp, -1)); - } - } - -}); - -const NextWallControls = new Lang.Class({ - Name: "NextWallControls", - Extends: PopupMenu.PopupBaseMenuItem, - - _init: function() { - - this.parent({ - reactive: false - }); - - this.box = new St.BoxLayout({ - style_class: "controls", - }); - - let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); - if(currentMode == "different") { - this.box.set_style("padding-left: " + (Chooser.THUMB_WIDTH - 30) + "px;"); - } 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.box.add_actor(new ControlButton("media-playback-start",this._changeWalls ).actor ); - this.box.add_actor(new ControlButton("media-playlist-shuffle", this._newNextWalls).actor ); - - }, - - _changeWalls: function() { - if(wallUtils != null) - wallUtils.changeWallpapers(); - }, - - _newNextWalls: function() { - if(wallUtils != null) - wallUtils.setNewNextAndRefresh(); - } - -}); - -const thumbPreviews = new Lang.Class({ - Name: 'thumbPreviews', - Extends: PopupMenu.PopupBaseMenuItem, - - _isNextThumbs: false, - - _init: function(isNextThumbs) { - this.parent(); - this._isNextThumbs = isNextThumbs; - //Main Box - let MainBox = new St.BoxLayout({vertical: false}); - //Label + Icon Desktop Wallpaper Box - let desktopBox = new St.BoxLayout({vertical: true}); - let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE); - let textLabel,whoami; - /* 1st step: Label and identifier */ - switch(currentMode){ - case "different": - case "desktop": - textLabel = _("Desktop"); - whoami = (this._isNextThumbs)?NEXT_DESK:CURRENT_DESK; - break; - case "same": - textLabel = _("Desktop & Lockscreen"); - whoami = (this._isNextThumbs)?NEXT_DESK:CURRENT_DESK; - break; - case "lockscreen": - textLabel = _("Lockscreen"); - whoami = (this._isNextThumbs)?NEXT_LOCK:CURRENT_LOCK; - break; - } - 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)*/ - if(currentMode != "lockscreen") { - let filewall = wallUtils.getCurrentWall(); - this.wallIcon = new Chooser.ThumbIcon(filewall,function(){ - _indicator.close(); - new Chooser.PictureChooser(whoami,wallUtils).open(); - }); - desktopBox.add_actor(this.wallIcon.actor); - MainBox.add_child(desktopBox); - MainBox.add_child(new St.Icon({width:20})); - } - /* End 2nd step */ - - /* 3rd step: Create lockIcon (only in "different" and "lockscreen" mode*/ - let lockwhoami = whoami; - switch(currentMode) { - case "different": - //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 lockwall = wallUtils.getCurrentLockWall(); - this.lockIcon = new Chooser.ThumbIcon(lockwall,function(){ - _indicator.close(); - new Chooser.PictureChooser(lockwhoami,wallUtils).open(); - }); - lockBox.add_child(this.lockIcon.actor); - MainBox.add_child(lockBox); - break; - } - /* End 3nd step*/ - // Add everything to the mainbox - this.actor.add_actor(MainBox); - }, - - setWallThumb: function() { - let newIcon = null; - if(this._isNextThumbs) - newIcon = wallUtils.getNextWall(); - else - newIcon = wallUtils.getCurrentWall(); - Tweener.addTween(this.wallIcon.actor, {opacity:0,time:1,transition: 'easeOutQuad',onCompleteParams:[this.wallIcon,newIcon], onComplete:function(thumb,icon){ - thumb.set_gicon(icon); - }}); - Tweener.addTween(this.wallIcon.actor, {opacity:255,delay:1.3, time:1,transition: 'easeOutQuad'}); - }, - - - setLockThumb: function() { - let lockIcon = null; - if(this._isNextThumbs) - lockIcon = wallUtils.getNextLockWall(); - else - lockIcon = wallUtils.getCurrentLockWall(); - Tweener.addTween(this.lockIcon.actor, {opacity:0,time:1,transition: 'easeOutQuad', onCompleteParams:[this.lockIcon,lockIcon], onComplete:function(thumb,icon){ - thumb.set_gicon(icon); - }}); - Tweener.addTween(this.lockIcon.actor, {opacity:255,delay:1.3, time:1,transition: 'easeOutQuad'}); - } - -}); - -const RandWallMenu = new Lang.Class({ - Name: 'RandWallMenu.RandWallMenu', - Extends: PanelMenu.Button, - - _init: function() { - this.parent(0.0,"randwall"); - let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); - let icon = new St.Icon({style_class: 'system-status-icon randwall-icon', - icon_name: 'randwall-symbolic'}); - hbox.add_child(icon); - hbox.add_child(PopupMenu.arrowIcon(St.Side.BOTTOM)); - this.actor.add_actor(hbox); - - if(!wallUtils.isEmpty()) { - //Label current wallpapers - this.menu.addMenuItem(new LabelWidget(_("CURRENT"),"info")); - // Current Walls thumbs - this.currentThumbs = new thumbPreviews(false); - this.menu.addMenuItem(this.currentThumbs); - // Separator - this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - //Label current wallpapers - this.menu.addMenuItem(new LabelWidget(_("NEXT"),"info")); - // Next Walls thumbs - this.nextThumbs = new thumbPreviews(true); - this.menu.addMenuItem(this.nextThumbs); - // Separator - this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - //Controles - let control = new NextWallControls(); - this.menu.addMenuItem(control); - } else { - this.menu.addMenuItem(new LabelWidget(_("No images found!"),"error")); - this.menu.addMenuItem(new LabelWidget(_("Please, add some folders with images"),"info")); - this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - this.menu.addMenuItem(new ConfigControls()); - } - - - }, - - destroy: function() { - this.parent(); - }, - - _changeBackgrounds: function() { - wallUtils.changeWallpapers(); - //update thumbs - this.refreshThumbs(); - }, - - close: function() { - this.menu.close(); - } - -}); + destroy() { + this.menu.destroy(); + } -function init(metadata) { - _settings=Convenience.getSettings(); - Convenience.initTranslations(); - wallUtils = new Wallpapers.WallUtils(_settings); - if(!wallUtils.isEmpty()) { - this.MyTimer = new Interval.MyTimer(); - this.MyTimer.setCallback(function() { - // WARNING! Without the return true the timer will stop after the first run - if(_settings.get_int(SETTINGS_TIMEOUT) != 0) { - wallUtils.changeWallpapers(); - return true; - } - else - return false; - }); + _changeBackgrounds() { + wallUtils.changeWallpapers(); + //update thumbs + this.refreshThumbs(); + } + + close() { + this.menu.close(); } - let theme = imports.gi.Gtk.IconTheme.get_default(); - theme.append_search_path(metadata.path + "/icons"); + }); + + +function init(metadata) { + _settings = Convenience.getSettings(); + Convenience.initTranslations(); + wallUtils = new Wallpapers.WallUtils(_settings); + if (!wallUtils.isEmpty()) { + this.MyTimer = new Interval.MyTimer(); + this.MyTimer.setCallback(function () { + // WARNING! Without the return true the timer will stop after the first run + if (_settings.get_int(SETTINGS_TIMEOUT) != 0) { + wallUtils.changeWallpapers(); + return true; + } else + return false; + }); + } + let theme = imports.gi.Gtk.IconTheme.get_default(); + theme.append_search_path(metadata.path + "/icons"); } let _indicator; let _settings; function enable() { - _indicator = new RandWallMenu(_settings); - wallUtils.setIndicator(_indicator); - if(!wallUtils.isEmpty() && this.MyTimer && _settings.get_int(SETTINGS_TIMEOUT) != 0) { - wallUtils.changeWallpapers(); - this.MyTimer.start(); - } - let hideIcon = _settings.get_boolean(SETTINGS_HIDE_ICON); - if(!hideIcon) - Main.panel.addToStatusArea('randwall',_indicator,1,'right'); - _settings.connect('changed::' + SETTINGS_HIDE_ICON,Lang.bind(this,applyChanges)); - _settings.connect('changed::' + SETTINGS_CHANGE_MODE,Lang.bind(this,applyChanges)); - _settings.connect('changed::' + SETTINGS_FOLDER_LIST,Lang.bind(this,applyChanges)); + _indicator = new RandWallMenu(_settings); + + wallUtils.setIndicator(_indicator); + if (!wallUtils.isEmpty() && this.MyTimer && _settings.get_int(SETTINGS_TIMEOUT) != 0) { + wallUtils.changeWallpapers(); + this.MyTimer.start(); + } + let hideIcon = _settings.get_boolean(SETTINGS_HIDE_ICON); + if (!hideIcon) + Main.panel.addToStatusArea('randwall', _indicator, 1, 'right'); + _settings.connect('changed::' + SETTINGS_HIDE_ICON, Lang.bind(this, applyChanges)); + _settings.connect('changed::' + SETTINGS_CHANGE_MODE, Lang.bind(this, applyChanges)); + _settings.connect('changed::' + SETTINGS_FOLDER_LIST, Lang.bind(this, applyChanges)); } function applyChanges() { - if(!_indicator || !wallUtils || !_settings) - return; - - _indicator.destroy(); - wallUtils = new Wallpapers.WallUtils(_settings); - _indicator = new RandWallMenu(_settings); - wallUtils.setIndicator(_indicator); - let hideIcon = _settings.get_boolean(SETTINGS_HIDE_ICON); - if(!hideIcon) - Main.panel.addToStatusArea('randwall',_indicator,1,'right'); - wallUtils.setNewNextAndRefresh(); + if (!_indicator || !wallUtils || !_settings) + return; + + _indicator.destroy(); + wallUtils = new Wallpapers.WallUtils(_settings); + _indicator = new RandWallMenu(_settings); + wallUtils.setIndicator(_indicator); + let hideIcon = _settings.get_boolean(SETTINGS_HIDE_ICON); + if (!hideIcon) + Main.panel.addToStatusArea('randwall', _indicator, 1, 'right'); + wallUtils.setNewNextAndRefresh(); } function disable() { - _indicator.destroy(); - this.MyTimer.stop(); + _indicator.destroy(); + this.MyTimer.stop(); }