Skip to content

Commit

Permalink
add notifications for file errors
Browse files Browse the repository at this point in the history
  • Loading branch information
neffo committed Sep 24, 2024
1 parent df8805a commit ea3a5ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class BingWallpaperIndicator extends Button {

let toggles = [ /*{key: 'set-background', toggle: this.toggleSetBackground},*/
{key: 'revert-to-current-image', toggle: this.toggleSelectNew},
{key: 'notify', toggle: this.toggleNotifications},
/*{key: 'notify', toggle: this.toggleNotifications},*/
/*{key: 'show-count-in-image-title', toggle: this.toggleImageCount},*/
{key: 'random-mode-enabled', toggle: this.toggleShuffle},
{key: 'random-mode-include-only-favourites', toggle: this.toggleShuffleOnlyFaves},
Expand Down Expand Up @@ -317,17 +317,17 @@ class BingWallpaperIndicator extends Button {

_setBooleanSetting(key, state) {
let success = this._settings.set_boolean(key, state);
log('key '+key+' set to ' + (state?'true':'false') + ' returned ' + (success?'true':'false'));
log('key '+key+' set to ' + (state?'true':'false') + ' (returned ' + (success?'true':'false')+')');
}

_setStringSetting(key, value) {
let success = this._settings.set_string(key, value);
log('key '+key+' set to ' + value + ' returned ' + (success?'true':'false'));
log('key '+key+' set to ' + value + ' (returned ' + (success?'true':'false')+')');
}

_setIntSetting(key, value) {
let success = this._settings.set_int(key, value);
log('key '+key+' set to ' + value + ' returned ' + (success?'true':'false'));
log('key '+key+' set to ' + value + ' (returned ' + (success?'true':'false')+')');
}

_onDestroy() {
Expand Down Expand Up @@ -1063,7 +1063,9 @@ class BingWallpaperIndicator extends Button {
let BingWallpaperDir = Utils.getWallpaperDir(this._settings);
let dir = Gio.file_new_for_path(BingWallpaperDir);
if (!dir.query_exists(null)) {
dir.make_directory_with_parents(null);
//dir.make_directory_with_parents(null);
notifyError('Download folder '+BingWallpaperDir+' does not exist or is not writable');
return;
}
log("Downloading " + url + " to " + file.get_uri());
let request = Soup.Message.new('GET', url);
Expand Down Expand Up @@ -1107,6 +1109,7 @@ class BingWallpaperIndicator extends Button {
}
catch(e) {
log('Error writing file: ' + e);
notifyError('Image '+file+' is not writable, check directory permissions '+e);
}
}
);
Expand Down
5 changes: 4 additions & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ export function getWallpaperDir(settings) {
dir.make_directory_with_parents(null);
}
//FIXME: test if dir is good and writable
return BingWallpaperDir;
if (dir.query_exists(null))
return BingWallpaperDir;
else
return null;
}

export function setWallpaperDir(settings, uri) {
Expand Down

0 comments on commit ea3a5ec

Please sign in to comment.