diff --git a/randomwallpaper@iflow.space/prefs.js b/randomwallpaper@iflow.space/prefs.js
index 4fbd998..b00abcc 100644
--- a/randomwallpaper@iflow.space/prefs.js
+++ b/randomwallpaper@iflow.space/prefs.js
@@ -120,6 +120,10 @@ const RandomWallpaperSettings = new Lang.Class({
this._builder.get_object('af-switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
+ this._settings.bind('change-lock-screen',
+ this._builder.get_object('change-lock-screen'),
+ 'active',
+ Gio.SettingsBindFlags.DEFAULT);
},
_toggleAfSliders: function () {
diff --git a/randomwallpaper@iflow.space/schemas/gschemas.compiled b/randomwallpaper@iflow.space/schemas/gschemas.compiled
index bfc7a76..4ee1798 100644
Binary files a/randomwallpaper@iflow.space/schemas/gschemas.compiled and b/randomwallpaper@iflow.space/schemas/gschemas.compiled differ
diff --git a/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml b/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml
index 715a32b..ec17645 100644
--- a/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml
+++ b/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml
@@ -55,6 +55,12 @@
The time that already elapsed.
+
+ false
+ Change lock screen
+ Weather the gnome lock screen should also be set to the new wallpaper.
+
+
15
15
vertical
+ 10
-
-
-
- False
- False
1
@@ -285,15 +273,97 @@
-
diff --git a/randomwallpaper@iflow.space/wallpaperController.js b/randomwallpaper@iflow.space/wallpaperController.js
index a4c015c..86a0c7f 100644
--- a/randomwallpaper@iflow.space/wallpaperController.js
+++ b/randomwallpaper@iflow.space/wallpaperController.js
@@ -29,7 +29,7 @@ let WallpaperController = new Lang.Class({
imageSourceAdapter: null,
_timer: null,
- _autoFetch : {
+ _autoFetch: {
active: false,
duration: 30,
},
@@ -39,7 +39,7 @@ let WallpaperController = new Lang.Class({
// functions will be called when loading a new wallpaper stopped. If an error occured then the error will be passed as parameter.
_stopLoadingHooks: [],
- _init: function(extensionMeta){
+ _init: function (extensionMeta) {
this.extensionMeta = extensionMeta;
this.wallpaperlocation = this.extensionMeta.path + '/wallpapers/';
@@ -64,11 +64,11 @@ let WallpaperController = new Lang.Class({
this.logger = new LoggerModule.Logger('RWG3', 'WallpaperController');
},
- _updateHistory: function() {
+ _updateHistory: function () {
this._historyController.load();
},
- _updateAutoFetching: function() {
+ _updateAutoFetching: function () {
let duration = 0;
duration += this._settings.get('minutes', 'int');
duration += this._settings.get('hours', 'int') * 60;
@@ -84,37 +84,39 @@ let WallpaperController = new Lang.Class({
},
/*
- forwards the request to the adapter
- */
- _requestRandomImageFromAdapter: function(callback){
+ forwards the request to the adapter
+ */
+ _requestRandomImageFromAdapter: function (callback) {
this.imageSourceAdapter = this._desktopperAdapter;
switch (this._settings.get('source', 'enum')) {
- case 0:
- this.imageSourceAdapter = this._desktopperAdapter;
- break;
- case 1:
- this.imageSourceAdapter = this._unsplashAdapter;
- break;
- case 2:
- this.imageSourceAdapter = this._wallheavenAdapter;
- break;
- default:
- this.imageSourceAdapter = this._desktopperAdapter;
- break;
+ case 0:
+ this.imageSourceAdapter = this._desktopperAdapter;
+ break;
+ case 1:
+ this.imageSourceAdapter = this._unsplashAdapter;
+ break;
+ case 2:
+ this.imageSourceAdapter = this._wallheavenAdapter;
+ break;
+ default:
+ this.imageSourceAdapter = this._desktopperAdapter;
+ break;
}
this.imageSourceAdapter.requestRandomImage(callback);
},
- /*
- copy file from uri to local wallpaper direcotry and calls
- the given callback with the name and the full filepath of
- the written file as parameter.
- */
- _fetchFile: function(uri, callback){
+ /**
+ * copy file from uri to local wallpaper directory and calls the given callback with the name and the full filepath
+ * of the written file as parameter.
+ * @param uri
+ * @param callback
+ * @private
+ */
+ _fetchFile: function (uri, callback) {
//extract the name from the url and
let date = new Date();
- let name = date.getTime()+'_'+this.imageSourceAdapter.fileName(uri); // timestamp ensures uniqueness
+ let name = date.getTime() + '_' + this.imageSourceAdapter.fileName(uri); // timestamp ensures uniqueness
let output_file = Gio.file_new_for_path(this.wallpaperlocation + String(name));
let output_stream = output_file.create(0, null);
@@ -132,56 +134,91 @@ let WallpaperController = new Lang.Class({
});
},
- _setBackground: function(path, callback){
+ /**
+ * Sets the wallpaper and the lockscreen when enabled to the given path. Executes the callback on success.
+ * @param path
+ * @param callback
+ * @private
+ */
+ _setBackground: function (path, callback) {
let background_setting = new Gio.Settings({schema: "org.gnome.desktop.background"});
+ path = "file://" + path;
- /*
- inspired from:
- https://bitbucket.org/LukasKnuth/backslide/src/7e36a49fc5e1439fa9ed21e39b09b61eca8df41a/backslide@codeisland.org/settings.js?at=master
- */
- // Set:
- if (background_setting.is_writable("picture-uri")){
- // Set a new Background-Image (should show up immediately):
- if (background_setting.set_string("picture-uri", "file://"+path) ){
- Gio.Settings.sync(); // Necessary: http://stackoverflow.com/questions/9985140
+ this._setPictureUriOfSettingsObject(background_setting, path, () => {
+ if (this._settings.get('change-lock-screen', 'boolean')) {
+ let screensaver_setting = new Gio.Settings({schema: "org.gnome.desktop.screensaver"});
+
+ this._setPictureUriOfSettingsObject(screensaver_setting, path, () => {
+ // call callback if given
+ if (callback) {
+ callback();
+ }
+ });
+ } else {
// call callback if given
if (callback) {
callback();
}
+ }
+ });
+ },
+
+ /**
+ * Set the picture-uri property of the given settings object to the path.
+ * Precondition: the settings object has to be a valid Gio settings object with the picture-uri property.
+ * @param settings
+ * @param path
+ * @param callback
+ * @private
+ */
+ _setPictureUriOfSettingsObject: function(settings, path, callback) {
+ /*
+ inspired from:
+ https://bitbucket.org/LukasKnuth/backslide/src/7e36a49fc5e1439fa9ed21e39b09b61eca8df41a/backslide@codeisland.org/settings.js?at=master
+ */
+ if (settings.is_writable("picture-uri")) {
+ // Set a new Background-Image (should show up immediately):
+ if (settings.set_string("picture-uri", path)) {
+ Gio.Settings.sync(); // Necessary: http://stackoverflow.com/questions/9985140
+
+ // call callback if given
+ if (callback) {
+ callback();
+ }
+
} else {
// TODO: error handling
}
} else {
// TODO: error handling
}
-
},
- _getCurrentWallpaper: function() {
+ _getCurrentWallpaper: function () {
let background_setting = new Gio.Settings({schema: "org.gnome.desktop.background"});
return background_setting.get_string("picture-uri").replace(/^(file:\/\/)/, "");
},
- setWallpaper: function(historyId) {
+ setWallpaper: function (historyId) {
let historyElement = this._historyController.get(historyId);
- if(this._historyController.promoteToActive(historyElement.id)) {
+ if (this._historyController.promoteToActive(historyElement.id)) {
this._setBackground(historyElement.path);
this.currentWallpaper = this._getCurrentWallpaper();
} else {
- this.logger.warn("The history id ("+historyElement.id+") could not be found.")
+ this.logger.warn("The history id (" + historyElement.id + ") could not be found.")
// TODO: Error handling history id not found.
}
},
- fetchNewWallpaper: function(callback) {
+ fetchNewWallpaper: function (callback) {
this._startLoadingHooks.forEach((element) => {
element();
});
this._timer.begin(); // reset timer
this._requestRandomImageFromAdapter((historyElement) => {
- this.logger.info("Requesting image: "+historyElement.source.imageUrl);
+ this.logger.info("Requesting image: " + historyElement.source.imageUrl);
this._fetchFile(historyElement.source.imageUrl, (historyId, path) => {
historyElement.path = path;
@@ -203,7 +240,7 @@ let WallpaperController = new Lang.Class({
});
},
- _backgroundTimout: function(delay) {
+ _backgroundTimout: function (delay) {
if (this.timeout) {
return;
}
@@ -222,37 +259,37 @@ let WallpaperController = new Lang.Class({
});
},
- previewWallpaper: function(historyid, delay) {
+ previewWallpaper: function (historyid, delay) {
this.previewId = historyid;
this._resetWallpaper = false;
this._backgroundTimout(delay);
},
- resetWallpaper: function() {
+ resetWallpaper: function () {
this._resetWallpaper = true;
this._backgroundTimout();
},
- getHistoryController: function() {
+ getHistoryController: function () {
return this._historyController;
},
- deleteHistory: function() {
+ deleteHistory: function () {
this._historyController.clear();
},
- menuShowHook: function() {
+ menuShowHook: function () {
this.currentWallpaper = this._getCurrentWallpaper();
},
- registerStartLoadingHook: function(fn) {
+ registerStartLoadingHook: function (fn) {
if (typeof fn === "function") {
this._startLoadingHooks.push(fn)
}
},
- registerStopLoadingHook: function(fn) {
+ registerStopLoadingHook: function (fn) {
if (typeof fn === "function") {
this._stopLoadingHooks.push(fn)
}