diff --git a/BWClipboard.js b/BWClipboard.js
index b92c8a42..9a78fbc5 100644
--- a/BWClipboard.js
+++ b/BWClipboard.js
@@ -8,31 +8,26 @@
const St = imports.gi.St;
const CLIPBOARD_TYPE = St.ClipboardType.CLIPBOARD;
-/*const Gdk = imports.gi.Gdk;
-const Gtk = imports.gi.Gtk;*/
+const Gio = imports.gi.Gio;
var BWClipboard = class BWClipboard {
constructor() {
- /*
- this.display = Gdk.Display.get_default();
- this.clipboard = this.display ? Gtk.Clipboard.get_default(this.display) : null;*/
this.clipboard = St.Clipboard.get_default();
}
- // non functional, getting this to function would likely involve using Gtk, which seems to be a bit unsafe on Wayland
setImage(filename) {
try {
let file = Gio.File.new_for_path(filename);
let [success, image_data] = file.load_contents(null);
//log('error: '+success);
- this.clipboard.set_content(CLIPBOARD_TYPE, 'image/jpeg', image_data);
+ if (success)
+ this.clipboard.set_content(CLIPBOARD_TYPE, 'image/jpeg', image_data);
} catch (err) {
log('unable to set clipboard to data in '+filename);
}
}
setText(text) {
- /*this.clipboard.set_text(text, -1);*/
this.clipboard.set_text(CLIPBOARD_TYPE, text);
}
-}
+};
diff --git a/README.md b/README.md
index dddef953..51735e35 100644
--- a/README.md
+++ b/README.md
@@ -76,6 +76,7 @@ Please include logs from your journal when submitting bug notices (make sure not
![Settings](/screenshot/settings.png)
![Settings](/screenshot/settings2.png)
![Settings](/screenshot/settings3.png)
+![Settings](/screenshot/settings4.png)
Examples of adjustable blur on the lockscreen:
diff --git a/Settings.ui b/Settings.ui
index 670d193d..6cd4dc8a 100644
--- a/Settings.ui
+++ b/Settings.ui
@@ -528,7 +528,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll
False
start
False
- Default is English - United States
+
diff --git a/Settings4.ui b/Settings4.ui
index 4a3299f9..9441d8f9 100644
--- a/Settings4.ui
+++ b/Settings4.ui
@@ -463,7 +463,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll
0
start
0
- Default is English - United States
+
diff --git a/blur.js b/blur.js
index 0403fc20..613e301c 100644
--- a/blur.js
+++ b/blur.js
@@ -60,8 +60,8 @@ var Blur = class Blur {
this._backgroundGroup.add_child(widget);
const themeContext = St.ThemeContext.get_for_stage(global.stage);
log("blur strength: " + blur_strength +" blur brightness: "+blur_brightness);
- let effect = new Shell.BlurEffect({ brightness: blur_brightness * 0.01, sigma: blur_strength * themeContext.scale_factor / 5 });
- this._scaleChangedId = themeContext.connect('notify::scale-factor', () => { effect.sigma = SIGMA_VALUE * themeContext.scale_factor; });
+ let effect = new Shell.BlurEffect({ brightness: blur_brightness * 0.01, sigma: blur_strength * themeContext.scale_factor / 5 }); // fix me, should this be /5?
+ this._scaleChangedId = themeContext.connect('notify::scale-factor', () => { effect.sigma = blur_strength * themeContext.scale_factor / 5; });
widget.add_effect(effect);
}
@@ -130,7 +130,7 @@ var Blur = class Blur {
log("shell version too old, no overriding");
}
}
-}
+};
function whichVersion() {
if ((shellVersionMajor == 3 && shellVersionMinor >= 36) || shellVersionMajor == 40) {
@@ -138,7 +138,7 @@ function whichVersion() {
return 1;
}
else {
- return 2
+ return 2;
}
}
else {
diff --git a/convenience.js b/convenience.js
index 1b28ebd0..7a21b570 100644
--- a/convenience.js
+++ b/convenience.js
@@ -89,7 +89,7 @@ function getSettings(schema) {
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});
}
const versionArray = (v) => v.split(".").map(Number);
@@ -104,58 +104,58 @@ const zip = function(a, b, defaultValue) {
};
function versionEqual(a, b) {
- return zip(versionArray(a), versionArray(b), 0).reduce(
- (prev, [a, b]) => prev && (a === b)
- , true);
+ return zip(versionArray(a), versionArray(b), 0).reduce(
+ (prev, [a, b]) => prev && (a === b)
+ , true);
}
function versionGreater(a, b) {
- const diff = zip(versionArray(a), versionArray(b), 0).find(([a, b]) => a !== b);
- if (!diff) {
- return false;
- }
- const [x, y] = diff;
- return x > y;
+ const diff = zip(versionArray(a), versionArray(b), 0).find(([a, b]) => a !== b);
+ if (!diff) {
+ return false;
+ }
+ const [x, y] = diff;
+ return x > y;
}
function versionSmaller(a, b) {
- return (!versionEqual(a, b)) && (!versionGreater(a, b));
+ return (!versionEqual(a, b)) && (!versionGreater(a, b));
}
function currentVersion() {
- return Config.PACKAGE_VERSION;
+ return Config.PACKAGE_VERSION;
}
function currentVersionEqual(v) {
- return versionEqual(currentVersion(), v);
+ return versionEqual(currentVersion(), v);
}
function currentVersionGreater(v) {
- return versionGreater(currentVersion(), v);
+ return versionGreater(currentVersion(), v);
}
function currentVersionGreaterEqual(v) {
- return versionEqual(currentVersion(), v)
+ return versionEqual(currentVersion(), v)
|| versionGreater(currentVersion(), v);
}
function currentVersionSmaller(v) {
- return versionSmaller(currentVersion(), v);
+ return versionSmaller(currentVersion(), v);
}
function currentVersionSmallerEqual(v) {
- return versionEqual(currentVersion(), v)
+ return versionEqual(currentVersion(), v)
&& (!versionGreater(currentVersion(), v));
}
var exports = {
-initTranslations,
-getSettings,
-currentVersion,
-currentVersionEqual,
-currentVersionGreater,
-currentVersionGreaterEqual,
-currentVersionSmaller,
-currentVersionSmallerEqual
+ initTranslations,
+ getSettings,
+ currentVersion,
+ currentVersionEqual,
+ currentVersionGreater,
+ currentVersionGreaterEqual,
+ currentVersionSmaller,
+ currentVersionSmallerEqual
};
diff --git a/extension.js b/extension.js
index 92aed4ec..f8def9ff 100644
--- a/extension.js
+++ b/extension.js
@@ -40,8 +40,12 @@ const BingURL = "https://www.bing.com";
const IndicatorName = "BingWallpaperIndicator";
const TIMEOUT_SECONDS = 24 * 3600; // FIXME: this should use the end data from the json data
const TIMEOUT_SECONDS_ON_HTTP_ERROR = 1 * 3600; // retry in one hour if there is a http error
+const ICON_PREVIOUS_BUTTON = 'media-seek-backward-symbolic';
+const ICON_SHUFFLE_BUTTON = 'media-playlist-shuffle-symbolic';
+const ICON_NEXT_BUTTON = 'media-seek-forward-symbolic';
+const ICON_CURRENT_BUTTON = 'media-skip-forward-symbolic';
-let validresolutions = [ '800x600' , '1024x768', '1280x720', '1280x768', '1366x768', '1920x1080', '1920x1200', 'UHD'];
+let validresolutions = ['800x600', '1024x768', '1280x720', '1280x768', '1366x768', '1920x1080', '1920x1200', 'UHD'];
let autores; // automatically selected resolution
@@ -52,7 +56,7 @@ let blur_strength=30;
// remove this when dropping support for < 3.33, see https://github.com/OttoAllmendinger/
const getActorCompat = (obj) =>
- Convenience.currentVersionGreaterEqual("3.33") ? obj : obj.actor;
+ Convenience.currentVersionGreaterEqual("3.33") ? obj : obj.actor;
function log(msg) {
if (bingWallpaperIndicator==null || bingWallpaperIndicator._settings.get_boolean('debug-logging'))
@@ -91,6 +95,7 @@ const BingWallpaperIndicator = new Lang.Class({
this.version = "0.1";
this._updatePending = false;
this._timeout = null;
+ this._shuffleTimeout = null;
this.longstartdate = null;
this.imageURL= ""; // link to image itself
this.imageinfolink = ""; // link to Bing photo info page
@@ -110,7 +115,7 @@ const BingWallpaperIndicator = new Lang.Class({
getActorCompat(this).visible = !this._settings.get_boolean('hide');
// enable unsafe features on Wayland if the user overrides it
- if (this._settings.get_boolean('override-unsafe-wayland')) {
+ if (!Utils.is_x11() && this._settings.get_boolean('override-unsafe-wayland')) {
Utils.is_x11 = Utils.enabled_unsafe;
}
@@ -120,6 +125,7 @@ const BingWallpaperIndicator = new Lang.Class({
this._wrapLabelItem(this.titleItem);
this.explainItem = new PopupMenu.PopupMenuItem(_("Awaiting refresh..."));
this._wrapLabelItem(this.explainItem);
+ this.controlItem = new PopupMenu.PopupMenuItem(""); // blank
this.copyrightItem = new PopupMenu.PopupMenuItem(_("Awaiting refresh..."));
this._wrapLabelItem(this.copyrightItem);
this.separator = new PopupMenu.PopupSeparatorMenuItem();
@@ -130,8 +136,8 @@ const BingWallpaperIndicator = new Lang.Class({
this.swallpaperItem = new PopupMenu.PopupMenuItem(_("Set lock screen image"));
this.refreshItem = new PopupMenu.PopupMenuItem(_("Refresh Now"));
this.settingsItem = new PopupMenu.PopupMenuItem(_("Settings"));
- if (Utils.is_x11()) { // causes crashes when XWayland is not available, ref github #82
- this.thumbnailItem = new PopupMenu.PopupBaseMenuItem(); // new Gtk.AspectFrame('Preview',0.5, 0.5, 1.77, false);
+ if (Utils.is_x11()) { // causes crashes when XWayland is not available, ref github #82, now fixed
+ this.thumbnailItem = new PopupMenu.PopupBaseMenuItem();
}
else {
this.thumbnailItem = new PopupMenu.PopupMenuItem(_("Thumbnail disabled on Wayland"));
@@ -140,9 +146,11 @@ const BingWallpaperIndicator = new Lang.Class({
this.menu.addMenuItem(this.refreshItem);
this.menu.addMenuItem(this.refreshDueItem);
this.menu.addMenuItem(this.explainItem);
- this.prevBtn = this._newMenuIcon('go-previous-symbolic', this.explainItem, this._prevImage);
- this.randomBtn = this._newMenuIcon('media-playlist-shuffle-symbolic', this.explainItem, this._setRandom);
- this.nextBtn = this._newMenuIcon('go-next-symbolic', this.explainItem, this._nextImage);
+ this.menu.addMenuItem(this.controlItem);
+ this.prevBtn = this._newMenuIcon(ICON_PREVIOUS_BUTTON, this.controlItem, this._prevImage);
+ this.randomBtn = this._newMenuIcon(ICON_SHUFFLE_BUTTON, this.controlItem, this._setRandom);
+ this.nextBtn = this._newMenuIcon(ICON_NEXT_BUTTON, this.controlItem, this._nextImage);
+ this.curBtn = this._newMenuIcon(ICON_CURRENT_BUTTON, this.controlItem, this._curImage);
this.menu.addMenuItem(this.thumbnailItem);
this.menu.addMenuItem(this.titleItem);
this.menu.addMenuItem(this.copyrightItem);
@@ -150,8 +158,8 @@ const BingWallpaperIndicator = new Lang.Class({
this.menu.addMenuItem(this.separator);
if (Utils.is_x11() && this.clipboard.clipboard) { // these may not work on Wayland atm, check to see if it's working
// currently non functional
- /*this.menu.addMenuItem(this.clipboardImageItem);
- this.clipboardImageItem.connect('activate', Lang.bind(this, this._copyImageToClipboard));*/
+ this.menu.addMenuItem(this.clipboardImageItem);
+ this.clipboardImageItem.connect('activate', Lang.bind(this, this._copyImageToClipboard));
this.menu.addMenuItem(this.clipboardURLItem);
this.clipboardURLItem.connect('activate', Lang.bind(this, this._copyURLToClipboard));
}
@@ -174,7 +182,7 @@ const BingWallpaperIndicator = new Lang.Class({
}));
this.titleItem.connect('activate', Lang.bind(this, function() {
if (this.imageinfolink)
- Util.spawn(["xdg-open", this.imageinfolink]);
+ Util.spawn(["xdg-open", this.imageinfolink]);
}));
this.folderItem.connect('activate', Lang.bind(this, function() {
Utils.openImageFolder(this._settings);
@@ -182,7 +190,7 @@ const BingWallpaperIndicator = new Lang.Class({
this.dwallpaperItem.connect('activate', Lang.bind(this, this._setBackgroundDesktop));
this.refreshItem.connect('activate', Lang.bind(this, this._refresh));
- this.settingsItem.connect('activate', function() {
+ this.settingsItem.connect('activate', Lang.bind(this, () => {
try {
ExtensionUtils.openPrefs();
}
@@ -193,7 +201,7 @@ const BingWallpaperIndicator = new Lang.Class({
else
Util.spawn(["gnome-extensions", "prefs", Me.metadata.uuid]);
}
- });
+ }));
getActorCompat(this).connect('button-press-event', Lang.bind(this, function () {
// Grey out menu items if an update is pending
@@ -201,13 +209,13 @@ const BingWallpaperIndicator = new Lang.Class({
if (Utils.is_x11()) {
this.clipboardImageItem.setSensitive(!this._updatePending && this.imageURL != "");
this.clipboardURLItem.setSensitive(!this._updatePending && this.imageURL != "");
- }
+ }
this.thumbnailItem.setSensitive(!this._updatePending && this.imageURL != "");
//this.showItem.setSensitive(!this._updatePending && this.title != "" && this.explanation != "");
this.dwallpaperItem.setSensitive(!this._updatePending && this.filename != "");
this.swallpaperItem.setSensitive(!this._updatePending && this.filename != "");
this.titleItem.setSensitive(!this._updatePending && this.imageinfolink != "");
- this.refreshduetext = _("Next refresh") + ": " + this.refreshdue.format("%X") + " (" + Utils.friendly_time_diff(this.refreshdue) + ")";
+ this.refreshduetext = _("Next refresh") + ": " + (this.refreshdue? this.refreshdue.format("%X"):'-') + " (" + Utils.friendly_time_diff(this.refreshdue) + ")";
this.refreshDueItem.label.set_text(this.refreshduetext); //
}));
if (this._settings.get_string('state') != '[]') {
@@ -219,7 +227,7 @@ const BingWallpaperIndicator = new Lang.Class({
},
// listen for configuration changes
- _setConnections: function(){
+ _setConnections: function() {
this._settings.connect('changed::hide', Lang.bind(this, function() {
getActorCompat(this).visible = !this._settings.get_boolean('hide');
}));
@@ -265,15 +273,9 @@ const BingWallpaperIndicator = new Lang.Class({
Utils.validate_icon(this._settings);
let gicon = Gio.icon_new_for_string(Me.dir.get_child('icons').get_path() + "/" + icon_name + ".svg");
this.icon = new St.Icon({gicon: gicon, style_class: 'system-status-icon'});
- if (!this.icon.get_parent() && 0) {
- log('New icon set to : '+icon_name);
- getActorCompat(this).add_child(this.icon);
- }
- else {
- log('Replace icon set to : '+icon_name);
- getActorCompat(this).remove_all_children();
- getActorCompat(this).add_child(this.icon);
- }
+ log('Replace icon set to : '+icon_name);
+ getActorCompat(this).remove_all_children();
+ getActorCompat(this).add_child(this.icon);
},
// set backgrounds as requested and set preview image in menu
@@ -321,9 +323,18 @@ const BingWallpaperIndicator = new Lang.Class({
log('next check in '+seconds+' seconds @ local time '+localTime.format('%F %R %z'));
},
+ _restartShuffleTimeout: function (seconds = null) {
+ if (this._shuffleTimeout)
+ Mainloop.source_remove(this._shuffleTimeout);
+ if (seconds == null)
+ seconds = this._settings.get_int('random-interval');
+ this._shuffleTimeout = Mainloop.timeout_add_seconds(seconds, Lang.bind(this, this._selectImage));
+ log('next shuffle in '+seconds+' seconds');
+ },
+
// set a timer on when the current image is going to expire
_restartTimeoutFromLongDate: function (longdate) {
- // all bing times are in UTC (+0)
+ // all bing times are in UTC (+0)
let refreshDue = Utils.dateFromLongDate(longdate, 86400);
let timezone = GLib.TimeZone.new_local();
let now = GLib.DateTime.new_now(timezone);
@@ -340,8 +351,8 @@ const BingWallpaperIndicator = new Lang.Class({
// convert shortdate format into human friendly format
_localeDate: function (shortdate) {
- let date = Utils.dateFromShortDate(shortdate);
- return date.format('%Y-%m-%d'); // ISO 8601 - https://xkcd.com/1179/
+ let date = Utils.dateFromShortDate(shortdate);
+ return date.format('%Y-%m-%d'); // ISO 8601 - https://xkcd.com/1179/
},
// set menu text in lieu of a notification/popup
@@ -374,9 +385,7 @@ const BingWallpaperIndicator = new Lang.Class({
});
getActorCompat(parent).add_child(iconBtn);
- iconBtn.connect('button-press-event',
- Lang.bind(this, fn)
- );
+ iconBtn.connect('button-press-event', Lang.bind(this, fn));
return iconBtn;
},
@@ -416,11 +425,15 @@ const BingWallpaperIndicator = new Lang.Class({
this._gotoImage(-1);
},
+ _curImage: function () {
+ this._settings.set_string('selected-image', 'current');
+ this._gotoImage(0);
+ },
+
_setRandom: function () {
- if (this._settings.get_string('selected-image')=='random') {
+ if (this._settings.get_string('selected-image') == 'random') {
// already set to random, so just roll the dice once more
this._selectImage();
- this._restartTimeout(this._settings.get_int('random-interval'));
}
else {
// setting this will force a new image selection
@@ -445,7 +458,7 @@ const BingWallpaperIndicator = new Lang.Class({
},
// download Bing metadata
- _refresh: function() {
+ _refresh: function(forced = false) {
if (this._updatePending)
return;
this._updatePending = true;
@@ -456,8 +469,8 @@ const BingWallpaperIndicator = new Lang.Class({
log("market: " + market);
// create an http message
- let request = Soup.Message.new('GET', BingImageURL+market); // + market
- log("fetching: " + BingImageURL+market);
+ let request = Soup.Message.new('GET', BingImageURL + (market != 'auto' ? market : '')); // + market
+ log("fetching: " + BingImageURL + (market != 'auto' ? market : ''));
// queue the http request
httpSession.queue_message(request, Lang.bind(this, function(httpSession, message) {
@@ -465,7 +478,8 @@ const BingWallpaperIndicator = new Lang.Class({
let data = message.response_body.data;
log("Recieved "+data.length+" bytes");
this._parseData(data);
- this._selectImage();
+ if (this.selected_image != 'random' /*|| !forced*/)
+ this._selectImage();
} else if (message.status_code == 403) {
log("Access denied: "+message.status_code);
this._updatePending = false;
@@ -484,7 +498,8 @@ const BingWallpaperIndicator = new Lang.Class({
let parsed = JSON.parse(data);
let datamarket = parsed.market.mkt;
let prefmarket = this._settings.get_string('market');
- // FIXME: we need to handle this better, including storing longer history & removing duplicates
+ if (datamarket != prefmarket && prefmarket != 'auto')
+ log('WARNING: Bing returning market data for '+datamarket+' rather than selected '+prefmarket);
let newImages = Utils.mergeImageLists(this._settings, parsed.images);
Utils.cleanupImageList(this._settings);
if (newImages.length > 0 && this._settings.get_boolean('revert-to-current-image')) {
@@ -531,12 +546,13 @@ const BingWallpaperIndicator = new Lang.Class({
},
_selectImage: function() {
- imageList = JSON.parse(this._settings.get_string('bing-json'));
+ let imageList = JSON.parse(this._settings.get_string('bing-json'));
let image = null;
// special values, 'current' is most recent (default mode), 'random' picks one at random, anything else should be filename
if (this.selected_image == 'random') {
image = imageList[Utils.getRandomInt(imageList.length)];
- this._restartTimeout(this._settings.get_int('random-interval')); // we update image every hour by default
+ this._restartShuffleTimeout();
+ //this._restartTimeout(this._settings.get_int('random-interval')); // we update image every hour by default
} else if (this.selected_image == 'current') {
image = Utils.getCurrentImage(imageList);
} else {
@@ -549,19 +565,19 @@ const BingWallpaperIndicator = new Lang.Class({
return; // could force, image = imageList[0] or perhaps force refresh
if (image.url != '') {
- this.title = image.copyright.replace(/\s*\(.*?\)\s*/g, "");
+ this.title = image.copyright.replace(/\s*[\(\(].*?[\)\)]\s*/g, "");
this.explanation = _("Bing Wallpaper of the Day for")+' '+this._localeDate(image.startdate);
- this.copyright = image.copyright.match(/\(([^)]+)\)/)[1].replace('\*\*','');
+ this.copyright = image.copyright.match(/[\(\(]([^)]+)[\)\)]/)[1].replace('\*\*', ''); // Japan locale uses () rather than ()
this.longstartdate = image.fullstartdate;
this.imageinfolink = image.copyrightlink.replace(/^http:\/\//i, 'https://');
let resolution = Utils.getResolution(this._settings, image);
let BingWallpaperDir = Utils.getWallpaperDir(this._settings);
this.imageURL = BingURL+image.urlbase+"_"+resolution+".jpg"; // generate image url for user's resolution
- this.filename = BingWallpaperDir+image.startdate+'-'+this.imageURL.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '');
+ this.filename = toFilename(BingWallpaperDir, image.startdate, image.urlbase, resolution);
let file = Gio.file_new_for_path(this.filename);
let file_exists = file.query_exists(null);
- let file_info = file_exists ? file.query_info ('*',Gio.FileQueryInfoFlags.NONE,null): 0;
+ let file_info = file_exists ? file.query_info ('*', Gio.FileQueryInfoFlags.NONE, null): 0;
if (!file_exists || file_info.get_size () == 0) { // file doesn't exist or is empty (probably due to a network error)
let dir = Gio.file_new_for_path(BingWallpaperDir);
@@ -571,7 +587,7 @@ const BingWallpaperIndicator = new Lang.Class({
this._downloadImage(this.imageURL, file);
} else {
log("Image already downloaded");
- let changed = this._setBackground();
+ this._setBackground();
this._updatePending = false;
}
//this._createNotification(image); // for testing
@@ -600,10 +616,11 @@ const BingWallpaperIndicator = new Lang.Class({
_reStoreState: function() {
try {
+ log('restoring state...');
let stateJSON = this._settings.get_string('state');
let state = JSON.parse(stateJSON);
let maxLongDate = null;
- maxLongdate = state.maxlongdate? state.maxlongdate: null;
+ maxLongDate = state.maxlongdate? state.maxlongdate: null;
this.title = state.title;
this.explanation = state.explanation;
this.copyright = state.copyright;
@@ -611,13 +628,16 @@ const BingWallpaperIndicator = new Lang.Class({
this.imageinfolink = state.imageinfolink;
this.imageURL = state.imageURL;
this.filename = state.filename;
+ this._selected_image = this._settings.get_string('selected-image');
this._setMenuText();
this._setBackground();
if (!maxLongDate) {
this._restartTimeout(60);
+ return;
}
- else if (this.selected_image == 'random') {
- this._restartTimeout(this._settings.get_int('random-interval'));
+ if (this.selected_image == 'random') {
+ this._setRandom();
+ this._restartTimeoutFromLongDate(maxLongDate);
}
else {
this._restartTimeoutFromLongDate(maxLongDate);
@@ -640,12 +660,12 @@ const BingWallpaperIndicator = new Lang.Class({
// create an http message
let request = Soup.Message.new('GET', url);
// got_headers event
- request.connect('got_headers', Lang.bind(this, function(message){
+ request.connect('got_headers', Lang.bind(this, function(message) {
log("got_headers, status: "+message.status_code);
}));
// got_chunk event
- request.connect('got_chunk', Lang.bind(this, function(message, chunk){
+ request.connect('got_chunk', Lang.bind(this, function(message, chunk) {
//log("got_chuck, status: "+message.status_code);
if (message.status_code == 200) { // only save the data we want, not content of 301 redirect page
fstream.write(chunk.get_data(), null);
@@ -681,7 +701,7 @@ const BingWallpaperIndicator = new Lang.Class({
log("Settings: delete:"+(deletepictures?"yes":"no")+" max: "+maxpictures);
imagelist.push(filename); // add current to end of list
- while(imagelist.length > maxpictures+1) {
+ while (imagelist.length > maxpictures+1) {
var to_delete = imagelist.shift(); // get the first (oldest item from the list)
log("image: "+to_delete);
if (deletepictures && to_delete != '') {
@@ -712,7 +732,10 @@ const BingWallpaperIndicator = new Lang.Class({
stop: function () {
if (this._timeout)
Mainloop.source_remove(this._timeout);
+ if (this._shuffleTimeout)
+ Mainloop.source_remove(this._shuffleTimeout);
this._timeout = undefined;
+ this._shuffleTimeout = undefined;
this.menu.removeAll();
}
});
@@ -727,9 +750,7 @@ function enable() {
autores = "UHD"; // remove monitor size checks
}
-function disable() {
- if (this._timeout)
- Mainloop.source_remove(this._timeout);
+function disable() {
bingWallpaperIndicator.stop();
bingWallpaperIndicator.destroy();
bingWallpaperIndicator = null;
@@ -738,6 +759,6 @@ function disable() {
}
function toFilename(wallpaperDir, startdate, imageURL, resolution) {
- return wallpaperDir+startdate+'-'+imageURL.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '')+"_"+resolution+".jpg";;
+ return wallpaperDir+startdate+'-'+imageURL.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '')+"_"+resolution+".jpg";
}
diff --git a/locale/pt/LC_MESSAGES/BingWallpaper.mo b/locale/pt/LC_MESSAGES/BingWallpaper.mo
index 3eaab72c..ff25d1c2 100644
Binary files a/locale/pt/LC_MESSAGES/BingWallpaper.mo and b/locale/pt/LC_MESSAGES/BingWallpaper.mo differ
diff --git a/locale/pt/LC_MESSAGES/BingWallpaper.po b/locale/pt/LC_MESSAGES/BingWallpaper.po
index 90add9f7..c7c84106 100644
--- a/locale/pt/LC_MESSAGES/BingWallpaper.po
+++ b/locale/pt/LC_MESSAGES/BingWallpaper.po
@@ -2,20 +2,21 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
+# Juliano de Souza Camargo , 2021.
#
msgid ""
msgstr ""
-"Project-Id-Version: \n"
+"Project-Id-Version: unnamed project\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-05-09 13:10+1000\n"
-"PO-Revision-Date: 2021-05-09 17:43+1000\n"
-"Last-Translator: \n"
-"Language-Team: \n"
+"POT-Creation-Date: 2021-06-06 14:27+1000\n"
+"PO-Revision-Date: 2021-06-07 23:29+1000\n"
+"Last-Translator: Juliano de Souza Camargo \n"
+"Language-Team: Portuguese < >\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Poedit 2.4.1\n"
+"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: Settings.ui.h:1 Settings4.ui.h:2
@@ -28,141 +29,167 @@ msgstr "Indicador"
#: Settings.ui.h:3 Settings4.ui.h:4
msgid "Enable desktop notifications"
-msgstr ""
+msgstr "Ativar as notificações na área de trabalho"
-#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:129
+#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:135
msgid "Set background image"
-msgstr "Definir como imagem de fundo"
+msgstr "Definir a imagem como fundo da área de trabalho"
-#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:130
+#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:136
msgid "Set lock screen image"
-msgstr "Definir imagem na tela de bloqueio"
+msgstr "Definir a imagem como fundo do ecrã de bloqueio"
#: Settings.ui.h:6 Settings4.ui.h:7
msgid "Download folder"
-msgstr "Pasta de download"
+msgstr "Pasta de transferências"
#: Settings.ui.h:7 Settings4.ui.h:1
msgid "Bing Wallpaper pictures folder"
-msgstr "Pasta de imagens do Bing Wallpaper"
+msgstr "Pasta de imagens de fundo do Bing"
+
+#: Settings.ui.h:8 Settings4.ui.h:8
+msgid "Open folder"
+msgstr "Abrir pasta"
-#: Settings.ui.h:8 Settings4.ui.h:9
+#: Settings.ui.h:9 Settings4.ui.h:9
msgid "Delete previously downloaded wallpapers"
-msgstr "Excluir os wallpapers baixados anteriormente"
+msgstr "Eliminar os fundos descarregados anteriormente"
-#: Settings.ui.h:9 Settings4.ui.h:10
-msgid "Days to store wallpapers before deleting"
-msgstr "Dias para armazenar os wallpapers antes de excluir"
+#: Settings.ui.h:10 Settings4.ui.h:10
+msgid "Selected image"
+msgstr "Imagem selecionada"
-#: Settings.ui.h:10 Settings4.ui.h:11
+#: Settings.ui.h:11 Settings4.ui.h:11
msgid "Bing locale"
-msgstr "Local do Bing"
+msgstr "Localização do Bing"
-#: Settings.ui.h:11 Settings4.ui.h:12
+#: Settings.ui.h:12 Settings4.ui.h:12
msgid "Default is English - United States"
-msgstr "Padrão é Inglês - Estados Unidos"
+msgstr "A predefinição é Inglês - Estados Unidos"
-#: Settings.ui.h:12 Settings4.ui.h:14
-msgid "Screen resolution"
-msgstr "Resolução da Tela"
-
-#: Settings.ui.h:13 Settings4.ui.h:15
-msgid "Override automatic resolution selection"
-msgstr "Sobrescreve a seleção automática da resolução"
-
-#: Settings.ui.h:14 Settings4.ui.h:13
-msgid "Selected image"
-msgstr ""
-
-#: Settings.ui.h:15 Settings4.ui.h:16 extension.js:132
+#: Settings.ui.h:13 Settings4.ui.h:13 extension.js:138
msgid "Settings"
-msgstr "Configurações"
+msgstr "Definições"
-#: Settings.ui.h:16 Settings4.ui.h:17
+#: Settings.ui.h:14 Settings4.ui.h:14
msgid "Use custom blur and brightness"
-msgstr ""
+msgstr "Utilizar brilho e desfoque personalizados"
-#: Settings.ui.h:17 Settings4.ui.h:18
+#: Settings.ui.h:15 Settings4.ui.h:15
msgid "Override GDM3 lockscreen effects"
-msgstr ""
+msgstr "Sobrescrever os efeitos do ecrã de bloqueio do GDM3"
-#: Settings.ui.h:18 Settings4.ui.h:19
+#: Settings.ui.h:16 Settings4.ui.h:16
msgid "Blur can improve readability of login prompt"
-msgstr ""
+msgstr "O desfoque pode tornar o ecrã de início de sessão mais legível"
-#: Settings.ui.h:19 Settings4.ui.h:20
+#: Settings.ui.h:17 Settings4.ui.h:17
msgid "Background blur intensity"
-msgstr ""
+msgstr "Intensidade de desfoque do fundo"
-#: Settings.ui.h:20 Settings4.ui.h:21
+#: Settings.ui.h:18 Settings4.ui.h:18
msgid "Can improve contrast of login prompt"
-msgstr ""
+msgstr "Pode melhorar o contraste do ecrã de início de sessão"
-#: Settings.ui.h:21 Settings4.ui.h:22
+#: Settings.ui.h:19 Settings4.ui.h:19
msgid "Background brightness"
-msgstr ""
+msgstr "Brilho do fundo"
-#: Settings.ui.h:22 Settings4.ui.h:23
+#: Settings.ui.h:20 Settings4.ui.h:20
msgid "Presets"
-msgstr ""
+msgstr "Predefinições"
-#: Settings.ui.h:23 Settings4.ui.h:24
+#: Settings.ui.h:21 Settings4.ui.h:21
msgid "Commonly used presets"
-msgstr ""
+msgstr "Predefinições mais utilizadas"
-#: Settings.ui.h:24 Settings4.ui.h:25
+#: Settings.ui.h:22 Settings4.ui.h:22
msgid "No blur, slight dim"
-msgstr ""
+msgstr "Sem desfoque e ligeiramente escurecido"
-#: Settings.ui.h:25 Settings4.ui.h:26
+#: Settings.ui.h:23 Settings4.ui.h:23
msgid "GNOME default"
-msgstr ""
+msgstr "Predefinição GNOME"
-#: Settings.ui.h:26 Settings4.ui.h:27
+#: Settings.ui.h:24 Settings4.ui.h:24
msgid "Slight blur, slight dim"
-msgstr ""
+msgstr "Ligeiramente desfocado e escurecido"
-#: Settings.ui.h:27 Settings4.ui.h:28
+#: Settings.ui.h:25 Settings4.ui.h:25
msgid "Lock Screen"
-msgstr ""
+msgstr "Ecrã de bloqueio"
+
+#: Settings.ui.h:26 Settings4.ui.h:27
+msgid "Debug logging"
+msgstr "Registo de depuração"
+
+#: Settings.ui.h:27 Settings4.ui.h:26
+msgid "Enable logging to system journal"
+msgstr "Ativar o registo no diário do sistema"
#: Settings.ui.h:28 Settings4.ui.h:29
-msgid "New wallpaper images everyday from Bing"
+msgid "Always show new images"
+msgstr "Mostrar sempre novas imagens"
+
+#: Settings.ui.h:29 Settings4.ui.h:28
+msgid "Switch to new images when available (unless on random mode)"
msgstr ""
+"Mudar para novas imagens quando disponíveis (a menos que em modo aleatório)"
-#: Settings.ui.h:29 Settings4.ui.h:30
+#: Settings.ui.h:30 Settings4.ui.h:31
+msgid "Enable all features on Wayland"
+msgstr "Ativar todas as funcionalidades no Wayland"
+
+#: Settings.ui.h:31 Settings4.ui.h:30
+msgid "Some newer features may be unstable on Wayland"
+msgstr "Algumas novas funcionalidades podem ser instáveis no Wayland"
+
+#: Settings.ui.h:32 Settings4.ui.h:32
+msgid "Screen resolution"
+msgstr "Resolução do ecrã"
+
+#: Settings.ui.h:33 Settings4.ui.h:33
+msgid "Override automatic resolution selection"
+msgstr "Sobrescreve automaticamente a resolução selecionada"
+
+#: Settings.ui.h:34 Settings4.ui.h:34
+msgid "Debug options"
+msgstr "Opções de depuração"
+
+#: Settings.ui.h:35 Settings4.ui.h:35
+msgid "New wallpaper images everyday from Bing"
+msgstr "Novos fundos diariamente através do Bing"
+
+#: Settings.ui.h:36 Settings4.ui.h:36
msgid "Gnome shell extension version "
-msgstr "Versão da extensão do Gnome shell "
+msgstr "Versão da extensão na consola Gnome "
-#: Settings.ui.h:30 Settings4.ui.h:31
+#: Settings.ui.h:37 Settings4.ui.h:37
msgid "https://github.com/neffo/bing-wallpaper-gnome-extension"
msgstr "https://github.com/neffo/bing-wallpaper-gnome-extension"
-#: Settings.ui.h:31 Settings4.ui.h:32
+#: Settings.ui.h:38 Settings4.ui.h:38
msgid "Maintained by Michael Carroll"
msgstr "Mantido por Michael Carroll"
-#: Settings.ui.h:32 Settings4.ui.h:33
+#: Settings.ui.h:39 Settings4.ui.h:39
msgid ""
"Show your support to the author on Flattr or Github "
"Sponsors."
msgstr ""
+"Dê seu apoio ao autor em Flattr ou "
+"Github Sponsors."
-#: Settings.ui.h:33 Settings4.ui.h:34
+#: Settings.ui.h:40 Settings4.ui.h:40
msgid "Changes since last version"
-msgstr ""
+msgstr "Alterações desde a última versão"
-#: Settings.ui.h:34 Settings4.ui.h:35
+#: Settings.ui.h:41 Settings4.ui.h:41
msgid "Based on NASA APOD Gnome shell extension by Elia Argentieri"
-msgstr "Baseado na extensão do Gnome shell NASA APOD por Elia Argentieri"
-
-#: Settings.ui.h:35 Settings4.ui.h:36
-#, fuzzy
-#| msgid ""
-#| "This program comes with ABSOLUTELY NO WARRANTY.\n"
-#| "See the GNU General Public License, version 3 or later for details."
+msgstr "Baseado na extensão da consola Gnome NASA APOD de Elia Argentieri"
+
+#: Settings.ui.h:42 Settings4.ui.h:42
msgid ""
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"See the GNU General "
@@ -172,144 +199,98 @@ msgstr ""
"Veja a Licença Pública Geral GNU, versão 3 ou superior para detalhes."
-#: Settings.ui.h:37 Settings4.ui.h:38
+#: Settings.ui.h:44 Settings4.ui.h:44
msgid "About"
-msgstr "Sobre"
-
-#: Settings4.ui.h:8
-msgid "Open folder"
-msgstr ""
+msgstr "Acerca"
-#: extension.js:117
+#: extension.js:122
msgid ""
msgstr ""
-#: extension.js:119 extension.js:121 extension.js:123
+#: extension.js:124 extension.js:126 extension.js:129
msgid "Awaiting refresh..."
-msgstr "Esperando por atualização..."
+msgstr "Em espera por atualização..."
-#: extension.js:126
-#, fuzzy
+#: extension.js:132
msgid "Copy image to clipboard"
-msgstr "Copiar imagem para a área de transferência"
+msgstr "Copiar a imagem para a área de transferência"
-#: extension.js:127
+#: extension.js:133
msgid "Copy image URL to clipboard"
-msgstr "Copiar URL da imagem para a área de transferência"
+msgstr "Copiar a URL da imagem para a área de transferência"
-#: extension.js:128
+#: extension.js:134
msgid "Open image folder"
-msgstr ""
+msgstr "Abrir a pasta da imagem"
-#: extension.js:131
+#: extension.js:137
msgid "Refresh Now"
msgstr "Atualizar agora"
-#: extension.js:137
+#: extension.js:143
msgid "Thumbnail disabled on Wayland"
-msgstr ""
+msgstr "Miniaturas desativadas no Wayland"
-#: extension.js:203
+#: extension.js:218
msgid "Next refresh"
msgstr "Próxima atualização"
-#: extension.js:490 extension.js:527
+#: extension.js:533 extension.js:573
msgid "Bing Wallpaper of the Day for"
-msgstr "Wallpaper do dia para"
+msgstr "Fundo atual do Bing para"
-#: extension.js:495
-#, fuzzy
-#| msgid "Set wallpaper"
-msgid "Set as wallpaper"
-msgstr "Definir wallpaper"
-
-#: extension.js:498
+#: extension.js:538
msgid "More info on Bing.com"
-msgstr ""
+msgstr "Mais informação em Bing.com"
-#: extension.js:553
+#: extension.js:600
msgid "No wallpaper available"
-msgstr "Nenhum wallpaper disponível"
+msgstr "Nenhum fundo disponível"
-#: extension.js:554
+#: extension.js:601
msgid "No picture for today 😞."
-msgstr "Nenhuma imagem para hoje 😞."
+msgstr "Nenhum fundo por hoje 😞."
-#: prefs.js:173
+#: prefs.js:181
msgid "Most recent image"
-msgstr ""
+msgstr "Imagens recentes"
-#: prefs.js:174
+#: prefs.js:182
msgid "Random image"
-msgstr ""
+msgstr "Imagens aleatórias"
-#: prefs.js:190 prefs.js:206
+#: prefs.js:197 prefs.js:213
msgid "Disabled on current GNOME version"
-msgstr ""
+msgstr "Desativado na versão atual do GNOME"
-#: utils.js:139
+#: utils.js:146
msgid "Fetching data..."
-msgstr "Buscando dados..."
+msgstr "A obter dados..."
-#: utils.js:150
+#: utils.js:157
msgid "Market not available in your region"
-msgstr "Local não disponível em sua região"
+msgstr "Loja não disponível em sua região"
-#: utils.js:154
+#: utils.js:161
msgid "A network error occured"
msgstr "Ocorreu um erro de rede"
-#: utils.js:159
+#: utils.js:166
msgid "Too many requests in 5 seconds"
-msgstr ""
+msgstr "Demasiadas requisições em 5 segundos"
-#: utils.js:186
+#: utils.js:193
msgid "No change log found for this release"
-msgstr ""
+msgstr "Sem registo de alterações nesta versão"
-#: utils.js:366 utils.js:369
+#: utils.js:388 utils.js:391
msgid "minutes"
msgstr "minutos"
-#: utils.js:372
+#: utils.js:394
msgid "days"
msgstr "dia"
-#: utils.js:375
+#: utils.js:397
msgid "hours"
msgstr "horas"
-
-#~ msgid ""
-#~ "Changes your wallpaper daily to the Bing picture of the day for your "
-#~ "region. Displays the picture description and copyright information."
-#~ msgstr ""
-#~ "Altera o seu wallpaper diariamente para a imagem do dia do Bing da sua "
-#~ "região. Cria uma notificação para a descrição da imagem e informações "
-#~ "sobre direitos autorais."
-
-#~ msgid "Send a notification with explanation when a new image is downloaded."
-#~ msgstr ""
-#~ "Enviar uma notificação com explicações quando uma nova imagem for baixada."
-
-#~ msgid "Notifications"
-#~ msgstr "Notificações"
-
-#~ msgid "Use transient notifications (auto dismiss)"
-#~ msgstr "Usar notificações transitórias (auto descartar)"
-
-#~ msgid "Show description"
-#~ msgstr "Exibir descrição"
-
-#~ msgid "Open extension settings"
-#~ msgstr "Abrir as configurações da extensão"
-
-#~ msgid "Bing website"
-#~ msgstr "Site do Bing"
-
-#~ msgid ""
-#~ "The selected market is not available in your country or geographic "
-#~ "region.\n"
-#~ msgstr "O local selecionado não está disponível em seu país ou região.\n"
-
-#~ msgid "This market is not available in your region"
-#~ msgstr "Este local não está disponível em sua região"
diff --git a/locale/sv/LC_MESSAGES/BingWallpaper.mo b/locale/sv/LC_MESSAGES/BingWallpaper.mo
index 4356313c..cc1e0d45 100644
Binary files a/locale/sv/LC_MESSAGES/BingWallpaper.mo and b/locale/sv/LC_MESSAGES/BingWallpaper.mo differ
diff --git a/locale/sv/LC_MESSAGES/BingWallpaper.po b/locale/sv/LC_MESSAGES/BingWallpaper.po
index c67a7660..f0d8f500 100644
--- a/locale/sv/LC_MESSAGES/BingWallpaper.po
+++ b/locale/sv/LC_MESSAGES/BingWallpaper.po
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-05-22 18:34+1000\n"
-"PO-Revision-Date: 2021-05-30 14:15+1000\n"
+"POT-Creation-Date: 2021-06-01 22:23+1000\n"
+"PO-Revision-Date: 2021-06-03 23:11+1000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: sv\n"
@@ -28,11 +28,11 @@ msgstr "Indikatorikon"
#: Settings.ui.h:3 Settings4.ui.h:4
msgid "Enable desktop notifications"
-msgstr ""
+msgstr "Aktivera aviseringar"
#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:129
msgid "Set background image"
-msgstr "Välj backgrundsbild"
+msgstr "Välj bakgrundsbild"
#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:130
msgid "Set lock screen image"
@@ -46,99 +46,135 @@ msgstr "Nedladdningsmapp"
msgid "Bing Wallpaper pictures folder"
msgstr "Bing Wallpaper nedladdningsmapp"
-#: Settings.ui.h:8 Settings4.ui.h:9
+#: Settings.ui.h:8 Settings4.ui.h:8
+#, fuzzy
+#| msgid "Download folder"
+msgid "Open folder"
+msgstr "Öppna mapp"
+
+#: Settings.ui.h:9 Settings4.ui.h:9
msgid "Delete previously downloaded wallpapers"
msgstr "Radera tidigare nedladdade bakgrundsbilder"
-#: Settings.ui.h:9 Settings4.ui.h:10
+#: Settings.ui.h:10 Settings4.ui.h:10
+msgid "Selected image"
+msgstr "Vald bild"
+
+#: Settings.ui.h:11 Settings4.ui.h:11
msgid "Bing locale"
msgstr "Bing språkvariant"
-#: Settings.ui.h:10 Settings4.ui.h:11
+#: Settings.ui.h:12 Settings4.ui.h:12
msgid "Default is English - United States"
msgstr "Standardspråk är Engelska (United States)"
-#: Settings.ui.h:11 Settings4.ui.h:13
-msgid "Screen resolution"
-msgstr "Skärmupplösning"
-
-#: Settings.ui.h:12 Settings4.ui.h:14
-msgid "Override automatic resolution selection"
-msgstr "Välj manuell skärmupplösning"
-
-#: Settings.ui.h:13 Settings4.ui.h:12
-msgid "Selected image"
-msgstr ""
-
-#: Settings.ui.h:14 Settings4.ui.h:15 extension.js:132
+#: Settings.ui.h:13 Settings4.ui.h:13 extension.js:132
msgid "Settings"
msgstr "Inställningar"
-#: Settings.ui.h:15 Settings4.ui.h:16
+#: Settings.ui.h:14 Settings4.ui.h:14
msgid "Use custom blur and brightness"
-msgstr "Välj egna inställningar för oskärpa och belysning"
+msgstr "Välj egna inställningar för oskärpa och ljusstyrka"
-#: Settings.ui.h:16 Settings4.ui.h:17
+#: Settings.ui.h:15 Settings4.ui.h:15
msgid "Override GDM3 lockscreen effects"
msgstr "Åsidosätt GDM3s låsskärmseffekter"
-#: Settings.ui.h:17 Settings4.ui.h:18
+#: Settings.ui.h:16 Settings4.ui.h:16
msgid "Blur can improve readability of login prompt"
msgstr "Oskärpa kan förbättra läsbarheten för inloggningsfältet"
-#: Settings.ui.h:18 Settings4.ui.h:19
+#: Settings.ui.h:17 Settings4.ui.h:17
msgid "Background blur intensity"
msgstr "Bakgrundsoskärpa"
-#: Settings.ui.h:19 Settings4.ui.h:20
+#: Settings.ui.h:18 Settings4.ui.h:18
msgid "Can improve contrast of login prompt"
msgstr "Kan förbättra läsbarheten för inloggningsfältet"
-#: Settings.ui.h:20 Settings4.ui.h:21
+#: Settings.ui.h:19 Settings4.ui.h:19
msgid "Background brightness"
-msgstr "Bakgrundsbelysning"
+msgstr "Bakgrundens ljusstyrka"
-#: Settings.ui.h:21 Settings4.ui.h:22
+#: Settings.ui.h:20 Settings4.ui.h:20
msgid "Presets"
msgstr "Förinställningar"
-#: Settings.ui.h:22 Settings4.ui.h:23
+#: Settings.ui.h:21 Settings4.ui.h:21
msgid "Commonly used presets"
-msgstr "Vanliga inställningar"
+msgstr "Vanliga förinställningar"
-#: Settings.ui.h:23 Settings4.ui.h:24
+#: Settings.ui.h:22 Settings4.ui.h:22
msgid "No blur, slight dim"
-msgstr "Endast dimrat"
+msgstr "Ingen oskärpa, svag neddimning"
-#: Settings.ui.h:24 Settings4.ui.h:25
+#: Settings.ui.h:23 Settings4.ui.h:23
msgid "GNOME default"
msgstr "GNOME-standard"
-#: Settings.ui.h:25 Settings4.ui.h:26
+#: Settings.ui.h:24 Settings4.ui.h:24
msgid "Slight blur, slight dim"
-msgstr "Något oskarpt och dimrat"
+msgstr "Svag oskärpa, svag neddimning"
-#: Settings.ui.h:26 Settings4.ui.h:27
+#: Settings.ui.h:25 Settings4.ui.h:25
msgid "Lock Screen"
msgstr "Låsskärm"
-#: Settings.ui.h:27 Settings4.ui.h:28
-msgid "New wallpaper images everyday from Bing"
-msgstr "Nya skrivbordsbakgrundsbilder dagligen från Bing"
+#: Settings.ui.h:26 Settings4.ui.h:27
+msgid "Debug logging"
+msgstr ""
+
+#: Settings.ui.h:27 Settings4.ui.h:26
+msgid "Enable logging to system journal"
+msgstr ""
#: Settings.ui.h:28 Settings4.ui.h:29
+msgid "Always show new images"
+msgstr ""
+
+#: Settings.ui.h:29 Settings4.ui.h:28
+msgid "Switch to new images when available (unless on random mode)"
+msgstr ""
+
+#: Settings.ui.h:30 Settings4.ui.h:31
+#, fuzzy
+#| msgid "Thumbnail disabled on Wayland"
+msgid "Enable all features on Wayland"
+msgstr "Miniatyrbild är inaktiverad på Wayland"
+
+#: Settings.ui.h:31 Settings4.ui.h:30
+msgid "Some newer features may be unstable on Wayland"
+msgstr ""
+
+#: Settings.ui.h:32 Settings4.ui.h:32
+msgid "Screen resolution"
+msgstr "Skärmupplösning"
+
+#: Settings.ui.h:33 Settings4.ui.h:33
+msgid "Override automatic resolution selection"
+msgstr "Åsidosätt automatiskt skärmupplösningsval"
+
+#: Settings.ui.h:34 Settings4.ui.h:34
+msgid "Debug options"
+msgstr ""
+
+#: Settings.ui.h:35 Settings4.ui.h:35
+msgid "New wallpaper images everyday from Bing"
+msgstr "Dagliga nya skrivbordsbakgrundsbilder från Bing"
+
+#: Settings.ui.h:36 Settings4.ui.h:36
msgid "Gnome shell extension version "
msgstr "GNOME shell-tillägg version "
-#: Settings.ui.h:29 Settings4.ui.h:30
+#: Settings.ui.h:37 Settings4.ui.h:37
msgid "https://github.com/neffo/bing-wallpaper-gnome-extension"
msgstr "https://github.com/neffo/bing-wallpaper-gnome-extension"
-#: Settings.ui.h:30 Settings4.ui.h:31
+#: Settings.ui.h:38 Settings4.ui.h:38
msgid "Maintained by Michael Carroll"
msgstr "Underhålls av Michael Carroll"
-#: Settings.ui.h:31 Settings4.ui.h:32
+#: Settings.ui.h:39 Settings4.ui.h:39
msgid ""
"Show your support to the author on Flattr or Github "
@@ -147,15 +183,15 @@ msgstr ""
"Stöd tillägget genom Flattr eller "
"Github Sponsors."
-#: Settings.ui.h:32 Settings4.ui.h:33
+#: Settings.ui.h:40 Settings4.ui.h:40
msgid "Changes since last version"
-msgstr "Nyheter"
+msgstr "Nyheter sedan förra versionen"
-#: Settings.ui.h:33 Settings4.ui.h:34
+#: Settings.ui.h:41 Settings4.ui.h:41
msgid "Based on NASA APOD Gnome shell extension by Elia Argentieri"
msgstr "Baserat på \\\"NASA APOD Gnome shell extensions\\\" av Elia Argentieri"
-#: Settings.ui.h:34 Settings4.ui.h:35
+#: Settings.ui.h:42 Settings4.ui.h:42
msgid ""
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"See the GNU General "
@@ -165,16 +201,10 @@ msgstr ""
"Se GNU General Public "
"License, version 3 eller senare för detaljer."
-#: Settings.ui.h:36 Settings4.ui.h:37
+#: Settings.ui.h:44 Settings4.ui.h:44
msgid "About"
msgstr "Om"
-#: Settings4.ui.h:8
-#, fuzzy
-#| msgid "Download folder"
-msgid "Open folder"
-msgstr "Nedladdningsmapp"
-
#: extension.js:117
msgid ""
msgstr ""
@@ -185,83 +215,87 @@ msgstr "Uppdaterar..."
#: extension.js:126
msgid "Copy image to clipboard"
-msgstr "Kopiera bild till urklippet"
+msgstr "Kopiera bild till urklipp"
#: extension.js:127
msgid "Copy image URL to clipboard"
-msgstr "Kopiera bildlänk till urklippet"
+msgstr "Kopiera bildlänk till urklipp"
#: extension.js:128
#, fuzzy
msgid "Open image folder"
-msgstr "Nedladdningsmapp"
+msgstr "Öppna bildmapp"
#: extension.js:131
msgid "Refresh Now"
-msgstr "Uppdatera"
+msgstr "Uppdatera nu"
#: extension.js:137
msgid "Thumbnail disabled on Wayland"
msgstr "Miniatyrbild är inaktiverad på Wayland"
-#: extension.js:204
+#: extension.js:210
msgid "Next refresh"
msgstr "Nästa uppdatering"
-#: extension.js:505 extension.js:543
+#: extension.js:515 extension.js:552
msgid "Bing Wallpaper of the Day for"
msgstr "Bings dagliga bakgrundsbild för"
-#: extension.js:570
+#: extension.js:525
+msgid "More info on Bing.com"
+msgstr ""
+
+#: extension.js:579
msgid "No wallpaper available"
msgstr "Inga skrivbordsbakgrunder tillgängliga"
-#: extension.js:571
+#: extension.js:580
msgid "No picture for today 😞."
msgstr "Inga nya bilder idag 😞."
-#: prefs.js:172
+#: prefs.js:181
msgid "Most recent image"
-msgstr ""
+msgstr "Den senaste bilden"
-#: prefs.js:173
+#: prefs.js:182
msgid "Random image"
-msgstr ""
+msgstr "Slumpmässig bild"
-#: prefs.js:188 prefs.js:204
+#: prefs.js:197 prefs.js:213
#, fuzzy
msgid "Disabled on current GNOME version"
-msgstr "Miniatyrbild är inaktiverad"
+msgstr "Inaktiverad i denna GNOME-version"
-#: utils.js:141
+#: utils.js:146
msgid "Fetching data..."
msgstr "Hämtar data..."
-#: utils.js:152
+#: utils.js:157
msgid "Market not available in your region"
msgstr "Marknaden är inte tillgänglig för din region"
-#: utils.js:156
+#: utils.js:161
msgid "A network error occured"
msgstr "Ett nätverksproblem inträffade"
-#: utils.js:161
+#: utils.js:166
msgid "Too many requests in 5 seconds"
-msgstr ""
+msgstr "För många förfrågningar under fem sekunder"
-#: utils.js:188
+#: utils.js:193
msgid "No change log found for this release"
-msgstr "Nyheter saknas för denna version"
+msgstr "Förändringslogg saknas för denna version"
-#: utils.js:369 utils.js:372
+#: utils.js:388 utils.js:391
msgid "minutes"
msgstr "minuter"
-#: utils.js:375
+#: utils.js:394
msgid "days"
msgstr "dagar"
-#: utils.js:378
+#: utils.js:397
msgid "hours"
msgstr "timmar"
diff --git a/metadata.json b/metadata.json
index bc04d5fe..3bbe1497 100644
--- a/metadata.json
+++ b/metadata.json
@@ -3,7 +3,7 @@
"shell-version": ["3.28", "3.30", "3.32", "3.34", "3.36", "3.38", "40"],
"name": "Bing Wallpaper",
"settings-schema": "org.gnome.shell.extensions.bingwallpaper",
- "description": "Lightweight GNOME shell extension to set your wallpaper to today's Microsoft Bing image of the day (the image you see when you visit Bing.com).\n\n *Disclaimer*: this extension is unofficial and not affiliated with Bing or Microsoft in any way. Images are protected by copyright and are licensed only for use as wallpapers.\n\nThis extension is based extensively on the NASA APOD extension by Elinvention (https://github.com/Elinvention) and inspired by Bing Desktop Wallpaper Changer by Utkarsh Gupta (https://github.com/UtkarshGpta).\n\nFeatures:\n* Fetches Bing wallpaper of the day and sets as both lock screen and desktop wallpaper (user selectable on GNOME versions that support it)\n* Optionally force a specific region (i.e. locale)\n* UHD supported resolutions\n* Only attempts to download wallpapers when they have been updated\n* Doesn't poll continuously - only once per day and on startup (schedules a refresh when Bing is due to update)\n* English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN), French (fr_FR), Portuguese (pt, pt_BR), Russian (ru_RU), Spanish (es), Korean (ko, ko_KR, ko_KP), Indonesian (id), Catalan (ca), Norwegian Bokmål (nb) & Nynorsk (ni), Swedish (sv), Arabic (ar), Hungarian (hu) and Finnish (fi_FI) - a HUGE thanks to the translators\n\nPlease report bugs to the GitHub page below:",
- "version": "33",
+ "description": "Lightweight GNOME shell extension to set your wallpaper to today's Microsoft Bing image of the day (the image you see when you visit Bing.com).\n\n *Disclaimer*: this extension is unofficial and not affiliated with Bing or Microsoft in any way. Images are protected by copyright and are licensed only for use as wallpapers.\n\nThis extension is based extensively on the NASA APOD extension by Elinvention (https://github.com/Elinvention) and inspired by Bing Desktop Wallpaper Changer by Utkarsh Gupta (https://github.com/UtkarshGpta).\n\nFeatures:\n* Fetches Bing wallpaper of the day and sets as both lock screen and desktop wallpaper (user selectable on GNOME versions that support it)\n* Optionally force a specific region (i.e. locale)\n* UHD supported resolutions\n* Only attempts to download wallpapers when they have been updated\n* Doesn't poll continuously - only once per day and on startup (schedules a refresh when Bing is due to update)\n *NEW: random mode\n *NEW: select wallpaper from previously downloaded images\n* English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN), French (fr_FR), Portuguese (pt, pt_BR), Russian (ru_RU), Spanish (es), Korean (ko, ko_KR, ko_KP), Indonesian (id), Catalan (ca), Norwegian Bokmål (nb) & Nynorsk (ni), Swedish (sv), Arabic (ar), Hungarian (hu) and Finnish (fi_FI) - a HUGE thanks to the translators\n\nAlways restart GNOME after manually updating extensions. Please report bugs to the GitHub page below:",
+ "version": "34",
"url": "https://github.com/neffo/bing-wallpaper-gnome-extension"
}
diff --git a/package.json b/package.json
new file mode 100644
index 00000000..00602a79
--- /dev/null
+++ b/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "Bing Wallpaper",
+ "description": "Bing Wallpaper eslint check",
+ "devDependencies": {
+ "eslint": "^5.16.0"
+ },
+ "scripts": {
+ "lint": "eslint *.js"
+ }
+}
\ No newline at end of file
diff --git a/prefs.js b/prefs.js
index c079e3ea..43ba1ff6 100644
--- a/prefs.js
+++ b/prefs.js
@@ -34,7 +34,7 @@ function init() {
Convenience.initTranslations("BingWallpaper");
}
-function buildPrefsWidget(){
+function buildPrefsWidget() {
// Prepare labels and controls
let buildable = new Gtk.Builder();
if (Gtk.get_major_version() == 4) { // GTK4 removes some properties, and builder breaks when it sees them
@@ -125,7 +125,7 @@ function buildPrefsWidget(){
if (response !== Gtk.ResponseType.ACCEPT) {
return;
}
- let fileURI = fileChooser.get_file().get_uri().replace('file://','');
+ let fileURI = fileChooser.get_file().get_uri().replace('file://', '');
log("fileChooser returned: "+fileURI);
fileChooserBtn.set_label(fileURI);
Utils.moveImagesToNewFolder(settings, settings.get_string('download-folder'), fileURI);
@@ -138,7 +138,7 @@ function buildPrefsWidget(){
market_grid.attach(marketEntry, 1, 0, 1, 2);
marketEntry.connect('notify::selected-item', function() {
let id = marketEntry.get_selected();
- settings.set_string('market',Utils.markets[id]);
+ settings.set_string('market', Utils.markets[id]);
log('dropdown selected '+id+' = '+Utils.markets[id]+" - "+Utils.marketName[id]);
});
settings.connect('changed::market', function() {
@@ -178,10 +178,10 @@ function buildPrefsWidget(){
// History
let imageList = Utils.getImageList(settings);
- historyEntry.append('current',_('Most recent image'));
- historyEntry.append('random',_('Random image'));
+ historyEntry.append('current', _('Most recent image'));
+ historyEntry.append('random', _('Random image'));
imageList.forEach(function (image) {
- historyEntry.append(image.urlbase.replace('/th?id=OHR.', ''), Utils.shortenName(Utils.getImageTitle(image),50));
+ historyEntry.append(image.urlbase.replace('/th?id=OHR.', ''), Utils.shortenName(Utils.getImageTitle(image), 50));
});
settings.bind('selected-image', historyEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::selected-image', function() {
@@ -199,13 +199,13 @@ function buildPrefsWidget(){
settings.bind('override-lockscreen-blur', overrideSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('lockscreen-blur-strength', strengthEntry, 'value', Gio.SettingsBindFlags.DEFAULT);
settings.bind('lockscreen-blur-brightness', brightnessEntry, 'value', Gio.SettingsBindFlags.DEFAULT);
- buttonGDMdefault.connect('clicked',function(widget) {
+ buttonGDMdefault.connect('clicked', function(widget) {
Utils.set_blur_preset(settings, Utils.PRESET_GNOME_DEFAULT);
});
- buttonnoblur.connect('clicked',function(widget) {
+ buttonnoblur.connect('clicked', function(widget) {
Utils.set_blur_preset(settings, Utils.PRESET_NO_BLUR);
});
- buttonslightblur.connect('clicked',function(widget) {
+ buttonslightblur.connect('clicked', function(widget) {
Utils.set_blur_preset(settings, Utils.PRESET_SLIGHT_BLUR);
});
} else {
diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled
index 5aa8bd59..2543ef23 100644
Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ
diff --git a/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml b/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml
index 45b74bae..5a8782a7 100644
--- a/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml
@@ -40,7 +40,7 @@
- "en-US"
+ "auto"
Default Market for Bing
diff --git a/screenshot/notification.png b/screenshot/notification.png
index 3e6f5529..894a6855 100644
Binary files a/screenshot/notification.png and b/screenshot/notification.png differ
diff --git a/screenshot/popup.png b/screenshot/popup.png
index 0e5b23b6..86e91653 100644
Binary files a/screenshot/popup.png and b/screenshot/popup.png differ
diff --git a/screenshot/settings.png b/screenshot/settings.png
index d0c5557d..2060ad88 100644
Binary files a/screenshot/settings.png and b/screenshot/settings.png differ
diff --git a/screenshot/settings2.png b/screenshot/settings2.png
index b294e8ee..b64a6797 100644
Binary files a/screenshot/settings2.png and b/screenshot/settings2.png differ
diff --git a/screenshot/settings3.png b/screenshot/settings3.png
index 9a669b48..7a762aab 100644
Binary files a/screenshot/settings3.png and b/screenshot/settings3.png differ
diff --git a/screenshot/settings4.png b/screenshot/settings4.png
new file mode 100644
index 00000000..134f06d2
Binary files /dev/null and b/screenshot/settings4.png differ
diff --git a/thumbnail.js b/thumbnail.js
index edb89b46..c054e637 100644
--- a/thumbnail.js
+++ b/thumbnail.js
@@ -17,9 +17,8 @@ var Thumbnail = class Thumbnail {
try {
this.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filePath, 480, 270);
this.srcFile = Gio.File.new_for_path(filePath);
- }
- catch (err) {
+ } catch (err) {
log('Unable to create thumbnail for corrupt or incomplete file: ' + filePath + ' err: ' + err);
}
}
-}
+};
diff --git a/utils.js b/utils.js
index 567b610f..e340142a 100644
--- a/utils.js
+++ b/utils.js
@@ -41,336 +41,336 @@ let debug = true;
// remove this when dropping support for < 3.33, see https://github.com/OttoAllmendinger/
var getActorCompat = (obj) =>
- Convenience.currentVersionGreaterEqual("3.33") ? obj : obj.actor;
+ Convenience.currentVersionGreaterEqual("3.33") ? obj : obj.actor;
var icon_list = ['bing-symbolic', 'brick-symbolic', 'high-frame-symbolic', 'mid-frame-symbolic', 'low-frame-symbolic'];
var resolutions = ['auto', 'UHD', '1920x1200', '1920x1080', '1366x768', '1280x720', '1024x768', '800x600'];
-var markets = ['ar-XA', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'en-AU', 'en-CA', 'en-GB',
- 'en-ID', 'en-IE', 'en-IN', 'en-MY', 'en-NZ', 'en-PH', 'en-SG', 'en-US', 'en-WW', 'en-XA', 'en-ZA', 'es-AR',
- 'es-CL', 'es-ES', 'es-MX', 'es-US', 'es-XL', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR',
- 'he-IL', 'hr-HR', 'hu-HU', 'it-IT', 'ja-JP', 'ko-KR', 'lt-LT', 'lv-LV', 'nb-NO', 'nl-BE', 'nl-NL',
- 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sl-SL', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA',
- 'zh-CN', 'zh-HK', 'zh-TW'];
+var markets = ['auto', 'ar-XA', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'en-AU', 'en-CA', 'en-GB',
+ 'en-ID', 'en-IE', 'en-IN', 'en-MY', 'en-NZ', 'en-PH', 'en-SG', 'en-US', 'en-WW', 'en-XA', 'en-ZA', 'es-AR',
+ 'es-CL', 'es-ES', 'es-MX', 'es-US', 'es-XL', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR',
+ 'he-IL', 'hr-HR', 'hu-HU', 'it-IT', 'ja-JP', 'ko-KR', 'lt-LT', 'lv-LV', 'nb-NO', 'nl-BE', 'nl-NL',
+ 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sl-SL', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA',
+ 'zh-CN', 'zh-HK', 'zh-TW'];
var marketName = [
- "(شبه الجزيرة العربية) العربية", "dansk (Danmark)", "Deutsch (Österreich)",
- "Deutsch (Schweiz)", "Deutsch (Deutschland)", "English (Australia)", "English (Canada)",
- "English (United Kingdom)", "English (Indonesia)", "English (Ireland)", "English (India)", "English (Malaysia)",
- "English (New Zealand)", "English (Philippines)", "English (Singapore)", "English (United States)",
- "English (International)", "English (Arabia)", "English (South Africa)", "español (Argentina)", "español (Chile)",
- "español (España)", "español (México)", "español (Estados Unidos)", "español (Latinoamérica)", "eesti (Eesti)",
- "suomi (Suomi)", "français (Belgique)", "français (Canada)", "français (Suisse)", "français (France)",
- "(עברית (ישראל", "hrvatski (Hrvatska)", "magyar (Magyarország)", "italiano (Italia)", "日本語 (日本)", "한국어(대한민국)",
- "lietuvių (Lietuva)", "latviešu (Latvija)", "norsk bokmål (Norge)", "Nederlands (België)", "Nederlands (Nederland)",
- "polski (Polska)", "português (Brasil)", "português (Portugal)", "română (România)", "русский (Россия)",
- "slovenčina (Slovensko)", "slovenščina (Slovenija)", "svenska (Sverige)", "ไทย (ไทย)", "Türkçe (Türkiye)",
- "українська (Україна)", "中文(中国)", "中文(中國香港特別行政區)", "中文(台灣)"
+ "auto", "(شبه الجزيرة العربية) العربية", "dansk (Danmark)", "Deutsch (Österreich)",
+ "Deutsch (Schweiz)", "Deutsch (Deutschland)", "English (Australia)", "English (Canada)",
+ "English (United Kingdom)", "English (Indonesia)", "English (Ireland)", "English (India)", "English (Malaysia)",
+ "English (New Zealand)", "English (Philippines)", "English (Singapore)", "English (United States)",
+ "English (International)", "English (Arabia)", "English (South Africa)", "español (Argentina)", "español (Chile)",
+ "español (España)", "español (México)", "español (Estados Unidos)", "español (Latinoamérica)", "eesti (Eesti)",
+ "suomi (Suomi)", "français (Belgique)", "français (Canada)", "français (Suisse)", "français (France)",
+ "(עברית (ישראל", "hrvatski (Hrvatska)", "magyar (Magyarország)", "italiano (Italia)", "日本語 (日本)", "한국어(대한민국)",
+ "lietuvių (Lietuva)", "latviešu (Latvija)", "norsk bokmål (Norge)", "Nederlands (België)", "Nederlands (Nederland)",
+ "polski (Polska)", "português (Brasil)", "português (Portugal)", "română (România)", "русский (Россия)",
+ "slovenčina (Slovensko)", "slovenščina (Slovenija)", "svenska (Sverige)", "ไทย (ไทย)", "Türkçe (Türkiye)",
+ "українська (Україна)", "中文(中国)", "中文(中國香港特別行政區)", "中文(台灣)"
];
var BingImageURL = "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=8&mbl=1&mkt=";
function getSettings() {
- let extension = ExtensionUtils.getCurrentExtension();
- let schema = 'org.gnome.shell.extensions.bingwallpaper';
-
- 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();
- }
-
- let schemaObj = schemaSource.lookup(schema, true);
- if (!schemaObj) {
- throw new Error('Schema ' + schema + ' could not be found for extension ' +
+ let extension = ExtensionUtils.getCurrentExtension();
+ let schema = 'org.gnome.shell.extensions.bingwallpaper';
+
+ 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();
+ }
+
+ 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});
}
function validate_icon(settings, icon_image = null) {
- log('validate_icon()');
- let icon_name = settings.get_string('icon-name');
- if (icon_name == "" || icon_list.indexOf(icon_name) == -1) {
- settings.reset('icon-name');
- icon_name = settings.get_string('icon-name');
- }
- // if called from prefs
- if (icon_image) {
- log('set icon to: ' + Me.dir.get_path() + '/icons/' + icon_name + '.svg');
- let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(Me.dir.get_path() + '/icons/' + icon_name + '.svg', 32, 32);
- icon_image.set_from_pixbuf(pixbuf);
- }
+ log('validate_icon()');
+ let icon_name = settings.get_string('icon-name');
+ if (icon_name == "" || icon_list.indexOf(icon_name) == -1) {
+ settings.reset('icon-name');
+ icon_name = settings.get_string('icon-name');
+ }
+ // if called from prefs
+ if (icon_image) {
+ log('set icon to: ' + Me.dir.get_path() + '/icons/' + icon_name + '.svg');
+ let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(Me.dir.get_path() + '/icons/' + icon_name + '.svg', 32, 32);
+ icon_image.set_from_pixbuf(pixbuf);
+ }
}
function validate_resolution(settings) {
- let resolution = settings.get_string('resolution');
- if (resolution == "" || resolutions.indexOf(resolution) == -1) // if not a valid resolution
- settings.reset('resolution');
+ let resolution = settings.get_string('resolution');
+ if (resolution == "" || resolutions.indexOf(resolution) == -1) // if not a valid resolution
+ settings.reset('resolution');
}
// FIXME: needs work
function validate_imagename(settings) {
- let filename = settings.get_string('selected-image');
- if (filename !='current' || filename != 'random')
- return;
- if (!inImageList(getImageList(settings), filename)) {
- log('invalid image selected');
- //settings.reset('selected-image');
- }
+ let filename = settings.get_string('selected-image');
+ if (filename != 'current' || filename != 'random')
+ return;
+ if (!inImageList(getImageList(settings), filename)) {
+ log('invalid image selected');
+ //settings.reset('selected-image');
+ }
}
function validate_market(settings, marketDescription = null, lastreq = null) {
- let market = settings.get_string('market');
- if (market == "" || markets.indexOf(market) == -1) { // if not a valid market
- settings.reset('market');
- }
- // only run this check if called from prefs
- let lastReqDiff = lastreq ? GLib.DateTime.new_now_utc().difference(lastreq): null; // time diff in *micro*seconds
- log("last check was " + lastReqDiff+" us ago");
-
- if ((marketDescription && lastreq === null) || (lastReqDiff && lastReqDiff>5000000)) { // rate limit no more than 1 request per 5 seconds
- let request = Soup.Message.new('GET', BingImageURL + market); // + market
- log("fetching: " + BingImageURL + market);
+ let market = settings.get_string('market');
+ if (market == "" || markets.indexOf(market) == -1) { // if not a valid market
+ settings.reset('market');
+ }
+ // only run this check if called from prefs
+ let lastReqDiff = lastreq ? GLib.DateTime.new_now_utc().difference(lastreq) : null; // time diff in *micro*seconds
+ log("last check was " + lastReqDiff + " us ago");
+
+ if ((marketDescription && lastreq === null) || (lastReqDiff && lastReqDiff > 5000000)) { // rate limit no more than 1 request per 5 seconds
+ let request = Soup.Message.new('GET', BingImageURL + (market != 'auto' ? market : '')); // + market
+ log("fetching: " + BingImageURL + (market != 'auto' ? market : ''));
- marketDescription.set_label(_("Fetching data..."));
- // queue the http request
- httpSession.queue_message(request, Lang.bind(this, function (httpSession, message) {
- if (message.status_code == 200) {
- let data = message.response_body.data;
- log("Recieved " + data.length + " bytes");
- let checkData = JSON.parse(data);
- let checkStatus = checkData.market.mkt;
- if (checkStatus == market) {
- marketDescription.set_label('Data OK, ' + data.length + ' bytes recieved');
- } else {
- marketDescription.set_label(_("Market not available in your region"));
- }
- } else {
- log("Network error occured: " + message.status_code);
- marketDescription.set_label(_("A network error occured") + ": " + message.status_code);
- }
- }));
- }
- else {
- marketDescription.set_label(_("Too many requests in 5 seconds"));
- }
+ marketDescription.set_label(_("Fetching data..."));
+ // queue the http request
+ httpSession.queue_message(request, Lang.bind(this, function (httpSession, message) {
+ if (message.status_code == 200) {
+ let data = message.response_body.data;
+ log("Recieved " + data.length + " bytes");
+ let checkData = JSON.parse(data);
+ let checkStatus = checkData.market.mkt;
+ if (market == 'auto' || checkStatus == market) {
+ marketDescription.set_label('Data OK, ' + data.length + ' bytes recieved');
+ } else {
+ marketDescription.set_label(_("Market not available in your region"));
+ }
+ } else {
+ log("Network error occured: " + message.status_code);
+ marketDescription.set_label(_("A network error occured") + ": " + message.status_code);
+ }
+ }));
+ }
+ else {
+ marketDescription.set_label(_("Too many requests in 5 seconds"));
+ }
}
function get_current_bg(schema) {
- let gsettings = new Gio.Settings({ schema: schema });
- let cur = gsettings.get_string('picture-uri');
- return (cur);
+ let gsettings = new Gio.Settings({ schema: schema });
+ let cur = gsettings.get_string('picture-uri');
+ return (cur);
}
let gitreleaseurl = 'https://api.github.com/repos/neffo/bing-wallpaper-gnome-extension/releases/tags/';
function fetch_change_log(version, label) {
- // create an http message
- let url = gitreleaseurl + "v" + version;
- let request = Soup.Message.new('GET', url);
- httpSession.user_agent = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:'+version+') BingWallpaper Gnome Extension';
- log("Fetching "+url);
- // queue the http request
- httpSession.queue_message(request, Lang.bind(this, function (httpSession, message) {
- if (message.status_code == 200) {
- let data = message.response_body.data;
- text = JSON.parse(data).body;
- label.set_label(text);
- }
- else {
- log("Change log not found: " + message.status_code + "\n" + message.response_body.data);
- label.set_label(_("No change log found for this release") + ": " + message.status_code);
- }
- }));
+ // create an http message
+ let url = gitreleaseurl + "v" + version;
+ let request = Soup.Message.new('GET', url);
+ httpSession.user_agent = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:' + version + ') BingWallpaper Gnome Extension';
+ log("Fetching " + url);
+ // queue the http request
+ httpSession.queue_message(request, Lang.bind(this, function (httpSession, message) {
+ if (message.status_code == 200) {
+ let data = message.response_body.data;
+ let text = JSON.parse(data).body;
+ label.set_label(text);
+ }
+ else {
+ log("Change log not found: " + message.status_code + "\n" + message.response_body.data);
+ label.set_label(_("No change log found for this release") + ": " + message.status_code);
+ }
+ }));
}
function set_blur_preset(settings, preset) {
settings.set_int('lockscreen-blur-strength', preset.blur);
- settings.set_int('lockscreen-blur-brightness', preset.dim);
- log("Set blur preset to "+preset.blur+" brightness to "+preset.dim);
+ settings.set_int('lockscreen-blur-brightness', preset.dim);
+ log("Set blur preset to " + preset.blur + " brightness to " + preset.dim);
}
function is_x11() {
- return GLib.getenv('XDG_SESSION_TYPE') == 'x11'; // don't do wayland unsafe things if set
+ return GLib.getenv('XDG_SESSION_TYPE') == 'x11'; // don't do wayland unsafe things if set
}
function enabled_unsafe() {
- log("User override, enabling unsafe Wayland functionality");
- return true;
+ log("User override, enabling unsafe Wayland functionality");
+ return true;
}
function gnome_major_version() {
- let [major] = Config.PACKAGE_VERSION.split('.');
- let shellVersion = Number.parseInt(major);
+ let [major] = Config.PACKAGE_VERSION.split('.');
+ let shellVersion = Number.parseInt(major);
- return shellVersion;
+ return shellVersion;
}
function imageHasBasename(image_item, i, b) {
- log("imageHasBasename : "+image_item.urlbase+ " =? "+this);
- if (this && this.search(image_item.urlbase.replace('th?id=OHR.', '')))
- return true;
- return false;
+ log("imageHasBasename : " + image_item.urlbase + " =? " + this);
+ if (this && this.search(image_item.urlbase.replace('th?id=OHR.', '')))
+ return true;
+ return false;
}
function dateFromLongDate(longdate, add_seconds) {
- return GLib.DateTime.new(GLib.TimeZone.new_utc(),
- parseInt(longdate.substr(0,4)), // year
- parseInt(longdate.substr(4,2)), // month
- parseInt(longdate.substr(6,2)), // day
- parseInt(longdate.substr(8,2)), // hour
- parseInt(longdate.substr(10,2)), // mins
- 0 ).add_seconds(add_seconds); // seconds
+ return GLib.DateTime.new(GLib.TimeZone.new_utc(),
+ parseInt(longdate.substr(0, 4)), // year
+ parseInt(longdate.substr(4, 2)), // month
+ parseInt(longdate.substr(6, 2)), // day
+ parseInt(longdate.substr(8, 2)), // hour
+ parseInt(longdate.substr(10, 2)), // mins
+ 0 ).add_seconds(add_seconds); // seconds
}
function dateFromShortDate(shortdate) {
- return GLib.DateTime.new(GLib.TimeZone.new_utc(),
- parseInt(shortdate.substr(0,4)), // year
- parseInt(shortdate.substr(4,2)), // month
- parseInt(shortdate.substr(6,2)), // day
- 0, 0, 0 );
+ return GLib.DateTime.new(GLib.TimeZone.new_utc(),
+ parseInt(shortdate.substr(0, 4)), // year
+ parseInt(shortdate.substr(4, 2)), // month
+ parseInt(shortdate.substr(6, 2)), // day
+ 0, 0, 0 );
}
function getImageList(settings) {
- return JSON.parse(settings.get_string('bing-json'));
+ return JSON.parse(settings.get_string('bing-json'));
}
function setImageList(settings, imageList) {
- settings.set_string('bing-json', JSON.stringify(imageList));
+ settings.set_string('bing-json', JSON.stringify(imageList));
}
function getImageTitle(image_data) {
- return image_data.copyright.replace(/\s*\(.*?\)\s*/g, "");
+ return image_data.copyright.replace(/\s*\(.*?\)\s*/g, "");
}
function getImageUrlBase(image_data) {
- return image_data.urlbase.replace('/th?id=OHR.', '');
+ return image_data.urlbase.replace('/th?id=OHR.', '');
}
function getMaxLongDate(settings) {
- imageList = getImageList(settings);
- return Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }))
+ let imageList = getImageList(settings);
+ return Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }));
}
function getCurrentImageIndex (imageList) {
- if (!imageList)
- return -1;
- let maxLongDate = Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }));
- let index = imageList.map(p => parseInt(p.fullstartdate)).indexOf(maxLongDate);
- log('getCurrentImageIndex for '+maxLongDate+': '+index)
- return index;
+ if (!imageList)
+ return -1;
+ let maxLongDate = Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }));
+ let index = imageList.map(p => parseInt(p.fullstartdate)).indexOf(maxLongDate);
+ log('getCurrentImageIndex for ' + maxLongDate + ': ' + index);
+ return index;
}
function getCurrentImage(imageList) {
- if (!imageList || imageList.length == 0)
- return null;
- let index = getCurrentImageIndex(imageList);
- if (index == -1)
- return imageList[0]; // give something sensible
- return imageList[index];
+ if (!imageList || imageList.length == 0)
+ return null;
+ let index = getCurrentImageIndex(imageList);
+ if (index == -1)
+ return imageList[0]; // give something sensible
+ return imageList[index];
}
function inImageList(imageList, urlbase) {
- let image = null;
- imageList.forEach(function(x, i) {
- if (urlbase.replace('/th?id=OHR.', '') == x.urlbase.replace('/th?id=OHR.', ''))
- image = x;
- });
- return image;
+ let image = null;
+ imageList.forEach(function(x, i) {
+ if (urlbase.replace('/th?id=OHR.', '') == x.urlbase.replace('/th?id=OHR.', ''))
+ image = x;
+ });
+ return image;
}
function inImageListByTitle(imageList, title) {
- let image = null;
- imageList.forEach(function(x, i) {
- log('inImageListbyTitle(): '+title+' == '+getImageTitle(x));
- if (getImageTitle(x) == title)
- image = x;
- });
- return image;
+ let image = null;
+ imageList.forEach(function(x, i) {
+ log('inImageListbyTitle(): ' + title + ' == ' + getImageTitle(x));
+ if (getImageTitle(x) == title)
+ image = x;
+ });
+ return image;
}
function mergeImageLists(settings, imageList) {
- let curList = getImageList(settings);
- let newList = []; // list of only new images (for future notifications)
- imageList.forEach(function(x, i) {
- if (!inImageList(curList, x.urlbase)) {// if not in the list, add it
- curList.unshift(x); // use unshift to maintain reverse chronological order
- newList.unshift(x);
- }
- });
- setImageList(settings, curList);
- return newList; // return this to caller for notifications
+ let curList = getImageList(settings);
+ let newList = []; // list of only new images (for future notifications)
+ imageList.forEach(function(x, i) {
+ if (!inImageList(curList, x.urlbase)) {// if not in the list, add it
+ curList.unshift(x); // use unshift to maintain reverse chronological order
+ newList.unshift(x);
+ }
+ });
+ setImageList(settings, curList);
+ return newList; // return this to caller for notifications
}
function imageIndex(imageList, urlbase) {
- return imageList.map(p => p.urlbase.replace('/th?id=OHR.', '')).indexOf(urlbase.replace('/th?id=OHR.', ''));
+ return imageList.map(p => p.urlbase.replace('/th?id=OHR.', '')).indexOf(urlbase.replace('/th?id=OHR.', ''));
}
function getImageByIndex(imageList, index) {
- if (imageList.length == 0 || index < 0 || index > imageList.length-1)
- return null;
- return imageList[index];
+ if (imageList.length == 0 || index < 0 || index > imageList.length - 1)
+ return null;
+ return imageList[index];
}
function cleanupImageList(settings) {
- let curList = imageListSortByDate(getImageList(settings));
- let cutOff = GLib.DateTime.new_now_utc().add_days(-8); // 8 days ago
- let newList = [];
- curList.forEach( function (x, i) {
- let filename = imageToFilename(settings, x);
- let diff = dateFromLongDate(x.fullstartdate,0).difference(cutOff);
- // image is still downloadable (< 8 days old) or still on disk, so we keep
- if (diff > 0 || Gio.file_new_for_path(filename).query_exists(null)) {
- newList.push(x);
- }
- });
- setImageList(settings, newList);
+ let curList = imageListSortByDate(getImageList(settings));
+ let cutOff = GLib.DateTime.new_now_utc().add_days(-8); // 8 days ago
+ let newList = [];
+ curList.forEach( function (x, i) {
+ let filename = imageToFilename(settings, x);
+ let diff = dateFromLongDate(x.fullstartdate, 0).difference(cutOff);
+ // image is still downloadable (< 8 days old) or still on disk, so we keep
+ if (diff > 0 || Gio.file_new_for_path(filename).query_exists(null)) {
+ newList.push(x);
+ }
+ });
+ setImageList(settings, newList);
}
function getWallpaperDir(settings) {
- let BingWallpaperDir = settings.get_string('download-folder');
- let userPicturesDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
- if (BingWallpaperDir == '') {
- BingWallpaperDir = userPicturesDir + "/BingWallpaper/";
- settings.set_string('download-folder', BingWallpaperDir);
- }
- else if (!BingWallpaperDir.endsWith('/')) {
- BingWallpaperDir += '/';
- }
-
- let dir = Gio.file_new_for_path(BingWallpaperDir);
- if (!dir.query_exists(null)) {
- dir.make_directory_with_parents(null);
- }
- //FIXME: test if dir is good and writable
- return BingWallpaperDir;
+ let BingWallpaperDir = settings.get_string('download-folder');
+ let userPicturesDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
+ if (BingWallpaperDir == '') {
+ BingWallpaperDir = userPicturesDir + "/BingWallpaper/";
+ settings.set_string('download-folder', BingWallpaperDir);
+ }
+ else if (!BingWallpaperDir.endsWith('/')) {
+ BingWallpaperDir += '/';
+ }
+
+ let dir = Gio.file_new_for_path(BingWallpaperDir);
+ if (!dir.query_exists(null)) {
+ dir.make_directory_with_parents(null);
+ }
+ //FIXME: test if dir is good and writable
+ return BingWallpaperDir;
}
function imageToFilename(settings, image, resolution = null) {
- return getWallpaperDir(settings)+image.startdate+'-'+
- image.urlbase.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '')+"_"
- +(resolution? resolution : getResolution(settings, image))+".jpg";
+ return getWallpaperDir(settings) + image.startdate + '-' +
+ image.urlbase.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '') + "_"
+ + (resolution ? resolution : getResolution(settings, image)) + ".jpg";
}
function getRandomInt(max) {
- return Math.floor(Math.random() * max);
+ return Math.floor(Math.random() * max);
}
function dump(object) {
let output = '';
for (let property in object) {
- output += property + ': ' + object[property]+'; ';
+ output += property + ': ' + object[property] + '; ';
}
log(output);
}
@@ -385,85 +385,85 @@ function friendly_time_diff(time, short = true) {
return "now";
}
else if (seconds < 60) {
- return "< 1 "+(short?"m":_("minutes"));
+ return "< 1 " + (short ? "m" : _("minutes"));
}
else if (seconds < 3600) {
- return Math.round(seconds/60)+" "+(short?"m":_("minutes"));
+ return Math.round(seconds / 60) + " " + (short ? "m" : _("minutes"));
}
else if (seconds > 86400) {
- return Math.round(seconds/86400)+" "+(short?"d":_("days"));
+ return Math.round(seconds / 86400) + " " + (short ? "d" : _("days"));
}
else {
- return Math.round(seconds/3600)+" "+(short?"h":_("hours"));
+ return Math.round(seconds / 3600) + " " + (short ? "h" : _("hours"));
}
}
function getResolution(settings, image) {
- let resolution = settings.get_string('resolution');
- if (resolutions.indexOf(resolution) == -1 || (image ? image.wp == false:true) || // wp == false when background is animated
+ let resolution = settings.get_string('resolution');
+ if (resolutions.indexOf(resolution) == -1 || (image ? image.wp == false : true) || // wp == false when background is animated
settings.get_string('resolution') == "auto" ) {
- // resolution invalid, animated background or autoselected
- resolution = "UHD";
- }
- return resolution;
+ // resolution invalid, animated background or autoselected
+ resolution = "UHD";
+ }
+ return resolution;
}
function openImageFolder(settings) {
- //const context = global?global.create_app_launch_context(0, -1):null;
- Gio.AppInfo.launch_default_for_uri('file://'+getWallpaperDir(settings), null);
+ //const context = global?global.create_app_launch_context(0, -1):null;
+ Gio.AppInfo.launch_default_for_uri('file://' + getWallpaperDir(settings), null);
}
function imageListSortByDate(imageList) {
- return imageList.sort(function(a, b) {
+ return imageList.sort(function(a, b) {
var x = parseInt(a.fullstartdate); var y = parseInt(b.fullstartdate);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
function shortenName(string, limit) {
- if (string.length > limit) {
- string = string.substr(0, limit-4) + '...';
- }
- return string;
+ if (string.length > limit) {
+ string = string.substr(0, limit - 4) + '...';
+ }
+ return string;
}
function moveImagesToNewFolder(settings, oldPath, newPath) {
- log('moveImagesToNewFolder(): stub function');
- // possible race condition here, need to think about how to fix it
- //let BingWallpaperDir = settings.get_string('download-folder');
- let dir = Gio.file_new_for_path(oldPath);
- let dirIter = dir.enumerate_children("", Gio.FileQueryInfoFlags.NONE, null );
- let newDir = Gio.file_new_for_path(newPath);
- if (!newDir.query_exists(null)) {
- newDir.make_directory_with_parents(null);
- }
- let file = null;
- while (file = dirIter.next_file(null)) {
- let filename = file.get_name(); // we only want to move files that we think we own
- if (filename.match(/\d{8}\-.+\.jpg/i)) {
- log('file: '+slash(oldPath)+filename+' -> '+slash(newPath)+filename);
- let cur = Gio.file_new_for_path(slash(oldPath)+filename);
- let dest = Gio.file_new_for_path(slash(newPath)+filename);
- cur.move(dest, Gio.FileCopyFlags.OVERWRITE, null, function () { log ("...moved"); });
- }
- }
- // fix filenames in previous queue
- settings.set_string('previous', settings.get_string('previous').replaceAll(oldPath,newPath));
- // correct filenames for GNOME backgrounds
- if (this._settings.get_boolean('set-background'))
- moveBackground(oldPath, newPath, DESKTOP_SCHEMA);
- if (this._settings.get_boolean('set-lock-screen') && Convenience.currentVersionSmaller("3.36"))
- moveBackground(oldPath, newPath, LOCKSCREEN_SCHEMA);
+ log('moveImagesToNewFolder(): stub function');
+ // possible race condition here, need to think about how to fix it
+ //let BingWallpaperDir = settings.get_string('download-folder');
+ let dir = Gio.file_new_for_path(oldPath);
+ let dirIter = dir.enumerate_children("", Gio.FileQueryInfoFlags.NONE, null );
+ let newDir = Gio.file_new_for_path(newPath);
+ if (!newDir.query_exists(null)) {
+ newDir.make_directory_with_parents(null);
+ }
+ let file = null;
+ while (file = dirIter.next_file(null)) {
+ let filename = file.get_name(); // we only want to move files that we think we own
+ if (filename.match(/\d{8}\-.+\.jpg/i)) {
+ log('file: ' + slash(oldPath) + filename + ' -> ' + slash(newPath) + filename);
+ let cur = Gio.file_new_for_path(slash(oldPath) + filename);
+ let dest = Gio.file_new_for_path(slash(newPath) + filename);
+ cur.move(dest, Gio.FileCopyFlags.OVERWRITE, null, function () { log ("...moved"); });
+ }
+ }
+ // fix filenames in previous queue
+ settings.set_string('previous', settings.get_string('previous').replaceAll(oldPath, newPath));
+ // correct filenames for GNOME backgrounds
+ if (settings.get_boolean('set-background'))
+ moveBackground(oldPath, newPath, DESKTOP_SCHEMA);
+ if (settings.get_boolean('set-lock-screen') && Convenience.currentVersionSmaller("3.36"))
+ moveBackground(oldPath, newPath, LOCKSCREEN_SCHEMA);
}
function dirname(path) {
- return path.match(/.*\//);
+ return path.match(/.*\//);
}
function slash(path) {
- if (!path.endsWith('/'))
- return path += '/';
- return path;
+ if (!path.endsWith('/'))
+ return path += '/';
+ return path;
}
function moveBackground(oldPath, newPath, schema) {