diff --git a/README.md b/README.md index 19baced7..9631df3c 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,15 @@ Also, check out my related [Google Earth View wallpaper extension](https://githu ## Features -* Fetches the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) and sets as both lock screen and desktop wallpaper +* Automatically sets the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) as both lock screen and desktop wallpapers * Only attempts to download wallpapers when they have been updated - doesn't poll continuously -* Optionally delete old images after a week, or keep them forever -* Optionally force a specific region (i.e. what Bing calls a "market", some Wallpapers may relate to local holidays or locations) +* Shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images) +* Image gallery to view, select and curate stored images +* Optionally delete old images after a week, or you can keep (and curate) them forever +* Override the lockscreen blur * Language support: 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 Japanese (ja) - a HUGE thanks to the translators * Image preview in menus & ability to manually set wallpapers individually or copy image to clipboard * A selection of different theme-aware indicator (tray) icons to choose (or hide it completely) -* Override the lockscreen blur -* NEW: shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images) -* NEW: image gallery to view, select and manage stored images #115 ## TODO @@ -36,7 +35,7 @@ Also, check out my related [Google Earth View wallpaper extension](https://githu ## Requirements -GNOME 3.28+ (Ubuntu Gnome 18.04+, Fedora 23+, older versions of the extension work with 3.18+, but are no longer supported). Blur control requires GNOME 3.36+, and may be unreliable on 3.36.3 or below. GNOME 40+ is still beta quality. +GNOME 3.36+ or 40+ (Ubuntu 20.04 LTS or later, older versions of the extension work with 3.18+, but are no longer supported). ## Install @@ -45,22 +44,16 @@ GNOME 3.28+ (Ubuntu Gnome 18.04+, Fedora 23+, older versions of the extension wo or install directly to your GNOME extensions directory (useful if you want to hack on it) ``` -git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git $HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com -``` - -or create a zip file by doing this - -``` +mkdir ~/Desktop/source +cd ~/Desktop/source git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git cd bing-wallpaper-gnome-extension -sh buildzip.sh +sh install.sh ``` -You can then install this file using the GNOME Tweak Tool. Please note to install an extension correctly the zip must have the metadata.json file in the base directory (not in a sub-directory), so you can't use the Github zip file to do this. - ## Enable debug logging -If you run into problems, you can enable debugging using dconf-editor with this command: +Enable debug logging through the exptension preferences 'Debug options' tab or if unable to open preferences you can enable debugging using dconf-editor with this command: ``` GSETTINGS_SCHEMA_DIR=$HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas dconf-editor /org/gnome/shell/extensions/bingwallpaper/ ``` @@ -69,16 +62,23 @@ Please include logs from your journal when submitting bug notices (make sure not ## Screenshots -Image gallery: +### Image gallery + ![Settings](/screenshot/settings5.png) -Preferences: -![Settings](/screenshot/settings.png)![Settings](/screenshot/settings2.png) -![Settings](/screenshot/settings3.png)![Settings](/screenshot/settings4.png) +### Preferences + +![Settings](/screenshot/settings.png) +![Settings](/screenshot/settings2.png) +![Settings](/screenshot/settings3.png) +![Settings](/screenshot/settings4.png) -Examples of adjustable blur on the lockscreen: -(from left to right: no blur/no dimming, slight blur/default dimming, default blur/default dimming) +### Lockscreen blur control +From left to right: +* no blur/no dimming +* slight blur/default dimming +* default blur/default dimming ![Blur example](/screenshot/blurexample.jpg) ## Toss a coin to your coder diff --git a/buildzip.sh b/buildzip.sh index c1faee93..c3f25ae7 100755 --- a/buildzip.sh +++ b/buildzip.sh @@ -5,7 +5,7 @@ intltool-extract --type=gettext/glade ui/Settings.ui intltool-extract --type=gettext/glade ui/Settings4.ui intltool-extract --type=gettext/glade ui/carousel.ui intltool-extract --type=gettext/glade ui/carousel4.ui -xgettext -k -k_ -kN_ -o locale/BingWallpaper.pot Settings.ui.h Settings4.ui.h extension.js prefs.js blur.js utils.js convenience.js carousel.ui carousel4.ui --from-code=UTF-8 +xgettext -k -k_ -kN_ -o locale/BingWallpaper.pot ui/Settings.ui.h ui/Settings4.ui.h ui/carousel.ui.h ui/carousel4.ui.h extension.js prefs.js blur.js utils.js convenience.js --from-code=UTF-8 echo "Translation status" > translations.txt for D in locale/*; do diff --git a/carousel.js b/carousel.js index 760375f3..c78c59ed 100644 --- a/carousel.js +++ b/carousel.js @@ -11,10 +11,9 @@ const { Gtk, Gdk, GdkPixbuf, Gio, GLib } = imports.gi; const Me = imports.misc.extensionUtils.getCurrentExtension(); const Utils = Me.imports.utils; -const Convenience = Me.imports.convenience; const Gettext = imports.gettext.domain('BingWallpaper'); const _ = Gettext.gettext; -const default_dimensions = [30, 30, 1500, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok +const default_dimensions = [30, 30, 1650, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok const GALLERY_THUMB_WIDTH = 320; const GALLERY_THUMB_HEIGHT = 180; @@ -22,11 +21,11 @@ const GALLERY_THUMB_HEIGHT = 180; var Carousel = class Carousel { constructor(settings, button = null, callbackfunc = null) { //create_gallery(widget, settings); - log('create carousel...'); this.settings = settings; this.button = button; this.callbackfunc = callbackfunc; - this.imageList = Utils.getImageList(this.settings).reverse(); // get images and reverse order + this.imageList = Utils.imageListSortByDate(Utils.getImageList(this.settings)).reverse(); // get images and reverse order + this.log('create carousel...'); // disable the button //if (this.button) // this.button.set_sensitive(false); @@ -65,25 +64,23 @@ var Carousel = class Carousel { } _create_gallery() { - let that = this; - Utils.randomIntervals.forEach(function (seconds, i) { - let item = that._create_random_item(seconds, Utils.randomIntervalsTitle[i]); + Utils.randomIntervals.forEach((seconds, i) => { + let item = this._create_random_item(seconds, Utils.randomIntervalsTitle[i]); if (Gtk.get_major_version() < 4) - that.flowBox.add(item); + this.flowBox.add(item); else - that.flowBox.insert(item, -1); + this.flowBox.insert(item, -1); }); - this.imageList.forEach(function (image) { - let item = that._create_gallery_item(image); + this.imageList.forEach((image) => { + let item = this._create_gallery_item(image); if (Gtk.get_major_version() < 4) - that.flowBox.add(item); + this.flowBox.add(item); else - that.flowBox.insert(item, -1); + this.flowBox.insert(item, -1); }); } _create_gallery_item(image) { - let that = this; let buildable = new Gtk.Builder(); if (Gtk.get_major_version() < 4) // grab appropriate object from UI file buildable.add_objects_from_file(Me.dir.get_path() + '/ui/carousel.ui', ["flowBoxChild"]); @@ -92,7 +89,9 @@ var Carousel = class Carousel { let galleryImage = buildable.get_object('galleryImage'); let imageLabel = buildable.get_object('imageLabel'); let filename = Utils.imageToFilename(this.settings, image); + let viewButton = buildable.get_object('viewButton'); let applyButton = buildable.get_object('applyButton'); + let infoButton = buildable.get_object('infoButton'); let deleteButton = buildable.get_object('deleteButton'); try { this._load_image(galleryImage, filename); @@ -105,25 +104,29 @@ var Carousel = class Carousel { galleryImage.set_from_icon_name('image-missing'); } galleryImage.set_icon_size = 2; // Gtk.GTK_ICON_SIZE_LARGE; - log('create_gallery_image: '+e); + this.log('create_gallery_image: '+e); } - galleryImage.set_tooltip_text(Utils.getImageTitle(image)); + galleryImage.set_tooltip_text(image.copyright); imageLabel.set_width_chars(60); imageLabel.set_label(Utils.shortenName(Utils.getImageTitle(image), 60)); - /*galleryImage.connect('clicked', function (widget) { + viewButton.connect('clicked', () => { Utils.openInSystemViewer(filename); - });*/ - applyButton.connect('clicked', function(widget) { - that.settings.set_string('selected-image', Utils.getImageUrlBase(image)); - log('gallery selected '+Utils.getImageUrlBase(image)); }); - deleteButton.connect('clicked', function(widget) { - log('Delete requested for '+filename); + applyButton.connect('clicked', () => { + this.settings.set_string('selected-image', Utils.getImageUrlBase(image)); + this.log('gallery selected '+Utils.getImageUrlBase(image)); + }); + infoButton.connect('clicked', () => { + Utils.openInSystemViewer(image.copyrightlink, false); + this.log('info page link opened '+image.copyrightlink); + }); + deleteButton.connect('clicked', (widget) => { + this.log('Delete requested for '+filename); Utils.deleteImage(filename); - Utils.cleanupImageList(that.settings); - widget.get_parent().get_parent().destroy(); // bit of a hack - if (that.callbackfunc) - that.callbackfunc(); + Utils.cleanupImageList(this.settings); + widget.get_parent().get_parent().set_visible(false); // bit of a hack + if (this.callbackfunc) + this.callbackfunc(); }); //deleteButton.set_sensitive(false); let item = buildable.get_object('flowBoxChild'); @@ -131,7 +134,6 @@ var Carousel = class Carousel { } _create_random_item(seconds, title) { - let that = this; let buildable = new Gtk.Builder(); if (Gtk.get_major_version() < 4) // grab appropriate object from UI file buildable.add_objects_from_file(Me.dir.get_path() + '/ui/carousel.ui', ["flowBoxRandom"]); @@ -142,10 +144,10 @@ var Carousel = class Carousel { let filename = 'random'; let applyButton = buildable.get_object('randomButton'); - applyButton.connect('clicked', function(widget) { - that.settings.set_string('selected-image', filename); - that.settings.set_int('random-interval', seconds); - log('gallery selected random with interval '+seconds); + applyButton.connect('clicked', (widget) => { + this.settings.set_string('selected-image', filename); + this.settings.set_int('random-interval', seconds); + this.log('gallery selected random with interval '+seconds); }); let item = buildable.get_object('flowBoxRandom'); return item; @@ -154,11 +156,11 @@ var Carousel = class Carousel { _load_image(galleryImage, filename) { let thumb_path = Utils.getWallpaperDir(this.settings)+'.thumbs/'; let thumb_dir = Gio.file_new_for_path(thumb_path); + let save_thumbs = !this.settings.get_boolean('delete-previous') && this.settings.get_boolean('create-thumbs'); // create thumbs only if not deleting previous and thumbs are enabled if (!thumb_dir.query_exists(null)) { thumb_dir.make_directory_with_parents(null); } let image_file = Gio.file_new_for_path(filename); - //log('thumbpath -> '+ thumb_path); if (!image_file.query_exists(null)){ this._set_blank_image(galleryImage); } @@ -170,9 +172,10 @@ var Carousel = class Carousel { if (image_thumb.query_exists(null)) { // use thumbnail if available pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_thumb_path); } - else { + else { // significantly speeds up gallery loading, but costs some addtional disk space pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, GALLERY_THUMB_WIDTH, GALLERY_THUMB_HEIGHT); - pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']); + if (save_thumbs) + pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']); } if (Gtk.get_major_version() < 4) { galleryImage.set_from_pixbuf(pixbuf); @@ -184,7 +187,7 @@ var Carousel = class Carousel { } catch (e) { this._set_blank_image(galleryImage); - log('create_gallery_image: '+e); + this.log('create_gallery_image: '+e); } } } @@ -200,4 +203,9 @@ var Carousel = class Carousel { } } + + log(msg) { + if (this.settings.get_boolean('debug-logging')) + print("BingWallpaper extension: " + msg); // disable to keep the noise down in journal + } }; diff --git a/convenience.js b/convenience.js index 7a21b570..15ff0e24 100644 --- a/convenience.js +++ b/convenience.js @@ -25,72 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -const Gettext = imports.gettext; -const Gio = imports.gi.Gio; - const Config = imports.misc.config; -const ExtensionUtils = imports.misc.extensionUtils; -const Local = ExtensionUtils.getCurrentExtension(); - -/** - * initTranslations: - * @domain: (optional): the gettext domain to use - * - * Initialize Gettext to load translations from extensionsdir/locale. - * If @domain is not provided, it will be taken from metadata['gettext-domain'] - */ -function initTranslations(domain) { - let extension = ExtensionUtils.getCurrentExtension(); - - domain = domain || extension.metadata['gettext-domain']; - - // check if this extension was built with "make zip-file", and thus - // has the locale files in a subfolder - // otherwise assume that extension has been installed in the - // same prefix as gnome-shell - let localeDir = extension.dir.get_child('locale'); - if (localeDir.query_exists(null)) - Gettext.bindtextdomain(domain, localeDir.get_path()); - else - Gettext.bindtextdomain(domain, Config.LOCALEDIR); -} - -/** - * getSettings: - * @schema: (optional): the GSettings schema id - * - * Builds and return a GSettings schema for @schema, using schema files - * in extensionsdir/schemas. If @schema is not provided, it is taken from - * metadata['settings-schema']. - */ -function getSettings(schema) { - let extension = ExtensionUtils.getCurrentExtension(); - - schema = schema || extension.metadata['settings-schema']; - - 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}); -} const versionArray = (v) => v.split(".").map(Number); @@ -149,8 +84,6 @@ function currentVersionSmallerEqual(v) { } var exports = { - initTranslations, - getSettings, currentVersion, currentVersionEqual, currentVersionGreater, diff --git a/extension.js b/extension.js index 4d13dcdd..82f494b3 100644 --- a/extension.js +++ b/extension.js @@ -25,8 +25,8 @@ const Gettext = imports.gettext.domain('BingWallpaper'); const _ = Gettext.gettext; const BingImageURL = Utils.BingImageURL; -const BingURL = "https://www.bing.com"; -const IndicatorName = "BingWallpaperIndicator"; +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'; @@ -34,10 +34,7 @@ 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 autores; // automatically selected resolution - let bingWallpaperIndicator = null; let blur = null; let blur_brightness = 0.55; @@ -46,11 +43,11 @@ let carousel = null; // 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')) - print("BingWallpaper extension: " + msg); // disable to keep the noise down in journal + print('BingWallpaper extension: ' + msg); // disable to keep the noise down in journal } function notifyError(msg) { @@ -62,7 +59,6 @@ function doSetBackground(uri, schema) { let prev = gsettings.get_string('picture-uri'); uri = 'file://' + uri; gsettings.set_string('picture-uri', uri); - gsettings.set_string('picture-options', 'zoom'); Gio.Settings.sync(); gsettings.apply(); return (prev != uri); // return true if background uri has changed @@ -95,14 +91,14 @@ class BingWallpaperIndicator extends PanelMenu.Button { blur.blur_brightness = 0.55; // take a variety of actions when the gsettings values are modified by prefs - this._settings = Utils.getSettings(); + this._settings = ExtensionUtils.getSettings(Utils.BING_SCHEMA); this.httpSession = new Soup.SessionAsync(); Soup.Session.prototype.add_feature.call(this.httpSession, new Soup.ProxyResolverDefault()); getActorCompat(this).visible = !this._settings.get_boolean('hide'); - // enable unsafe features on Wayland if the user overrides it + // enable testing potentially unsafe features on Wayland if the user overrides it if (!Utils.is_x11() && this._settings.get_boolean('override-unsafe-wayland')) { Utils.is_x11 = Utils.enabled_unsafe; } @@ -116,7 +112,6 @@ class BingWallpaperIndicator extends PanelMenu.Button { this.controlItem = new PopupMenu.PopupMenuItem(""); // blank this.copyrightItem = new PopupMenu.PopupMenuItem(_("Awaiting refresh...")); this._wrapLabelItem(this.copyrightItem); - this.separator = new PopupMenu.PopupSeparatorMenuItem(); this.clipboardImageItem = new PopupMenu.PopupMenuItem(_("Copy image to clipboard")); this.clipboardURLItem = new PopupMenu.PopupMenuItem(_("Copy image URL to clipboard")); this.folderItem = new PopupMenu.PopupMenuItem(_("Open image folder")); @@ -124,15 +119,10 @@ class BingWallpaperIndicator extends PanelMenu.Button { 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, now fixed - this.thumbnailItem = new PopupMenu.PopupBaseMenuItem(); - } - else { - this.thumbnailItem = new PopupMenu.PopupMenuItem(_("Thumbnail disabled on Wayland")); - log('X11 not detected, disabling some unsafe features'); - } + this.thumbnailItem = new PopupMenu.PopupBaseMenuItem(); this.menu.addMenuItem(this.refreshItem); this.menu.addMenuItem(this.refreshDueItem); + this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addMenuItem(this.explainItem); this.menu.addMenuItem(this.controlItem); this.prevBtn = this._newMenuIcon(ICON_PREVIOUS_BUTTON, this.controlItem, this._prevImage); @@ -142,33 +132,27 @@ class BingWallpaperIndicator extends PanelMenu.Button { this.menu.addMenuItem(this.thumbnailItem); this.menu.addMenuItem(this.titleItem); this.menu.addMenuItem(this.copyrightItem); - //this.menu.addMenuItem(this.showItem); - this.menu.addMenuItem(this.separator); - this._setConnections(); - 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(new PopupMenu.PopupSeparatorMenuItem()); + if (this.clipboard.clipboard) { // only if we have a clipboard this.menu.addMenuItem(this.clipboardImageItem); this.clipboardImageItem.connect('activate', this._copyImageToClipboard.bind(this)); this.menu.addMenuItem(this.clipboardURLItem); this.clipboardURLItem.connect('activate', this._copyURLToClipboard.bind(this)); } - this.menu.addMenuItem(this.folderItem); this.menu.addMenuItem(this.dwallpaperItem); - if (!Convenience.currentVersionGreaterEqual("3.36")) { // lockscreen and desktop wallpaper are the same in GNOME 3.36+ - this.menu.addMenuItem(this.swallpaperItem); - this.swallpaperItem.connect('activate', this._setBackgroundScreensaver.bind(this)); - } - + this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addMenuItem(this.settingsItem); this.explainItem.setSensitive(false); this.copyrightItem.setSensitive(false); this.refreshDueItem.setSensitive(false); this.thumbnailItem.setSensitive(false); + + this._setConnections(); this.thumbnailItem.connect('activate', this._openInSystemViewer.bind(this)); - this.titleItem.connect('activate', function() { + this.titleItem.connect('activate', () => { if (this.imageinfolink) - Util.spawn(["xdg-open", this.imageinfolink]); + Utils.openInSystemViewer(this.imageinfolink, false); }); this.folderItem.connect('activate', Utils.openImageFolder.bind(this, this._settings)); this.dwallpaperItem.connect('activate', this._setBackgroundDesktop.bind(this)); @@ -183,36 +167,31 @@ class BingWallpaperIndicator extends PanelMenu.Button { } } - // listen for configuration changes - _setConnections() { - this._settings.connect('changed::hide', function() { - getActorCompat(this).visible = !this._settings.get_boolean('hide'); - }); - this._setIcon(this._settings.get_string('icon-name')); - this._settings.connect('changed::icon-name', this._setIcon.bind(this, this._settings.get_string('icon-name'))); - this._settings.connect('changed::market', this._refresh.bind(this)); - this._settings.connect('changed::set-background', this._setBackground.bind(this)); - this._settings.connect('changed::set-lockscreen', this._setBackground.bind(this)); - this._settings.connect('changed::override-lockscreen-blur', this._setBlur.bind(this)); - this._settings.connect('changed::lockscreen-blur-strength', blur.set_blur_strength.bind(this, this._settings.get_int('lockscreen-blur-strength'))); - this._settings.connect('changed::lockscreen-blur-brightness', blur.set_blur_brightness.bind(this, this._settings.get_int('lockscreen-blur-brightness'))); - this._setBlur(); - this._settings.connect('changed::selected-image', this._setImage.bind(this)); - this._setImage(); - } - + // listen for configuration changes + _setConnections() { + this._settings.connect('changed::hide', () => { + getActorCompat(this).visible = !this._settings.get_boolean('hide'); + }); + this._setIcon(); + this._settings.connect('changed::icon-name', this._setIcon.bind(this)); + this._settings.connect('changed::market', this._refresh.bind(this)); + this._settings.connect('changed::set-background', this._setBackground.bind(this)); + this._settings.connect('changed::set-lockscreen', this._setBackground.bind(this)); + this._settings.connect('changed::override-lockscreen-blur', this._setBlur.bind(this)); + this._settings.connect('changed::lockscreen-blur-strength', blur.set_blur_strength.bind(this, this._settings.get_int('lockscreen-blur-strength'))); + this._settings.connect('changed::lockscreen-blur-brightness', blur.set_blur_brightness.bind(this, this._settings.get_int('lockscreen-blur-brightness'))); + this._setBlur(); + this._settings.connect('changed::selected-image', this._setImage.bind(this)); + this._setImage(); + this._settings.connect('changed::delete-previous', this._cleanUpImages.bind(this)); + this._settings.connect('changed::notify', this._notifyCurrentImage.bind(this)); + this._settings.connect('changed::always-export-bing-json', this._exportData.bind(this)); + this._settings.connect('changed::bing-json', this._exportData.bind(this)); + this._cleanUpImages(); + } _openPrefs() { - try { - ExtensionUtils.openPrefs(); - } - catch (e) { - log('Falling back to Util.spawn to launch extensions...'); - if (Convenience.currentVersionSmaller("3.36")) - Util.spawn(['gnome-shell-extension-prefs', Me.metadata.uuid]); // fall back for older gnome versions - else - Util.spawn(["gnome-extensions", "prefs", Me.metadata.uuid]); - } + ExtensionUtils.openPrefs(); } _openMenu() { @@ -244,11 +223,20 @@ class BingWallpaperIndicator extends PanelMenu.Button { this._selectImage(); } + _notifyCurrentImage() { + if (this._settings.get_boolean('notify')) { + let image = this._getCurrentImage(); + if (image) { + this._createNotification(image); + } + } + } + // set indicator icon (tray icon) - _setIcon(icon_name) { - //log('Icon set to : '+icon_name) + _setIcon() { Utils.validate_icon(this._settings); - let gicon = Gio.icon_new_for_string(Me.dir.get_child('icons').get_path() + "/" + icon_name + ".svg"); + let icon_name = this._settings.get_string('icon-name'); + 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'}); log('Replace icon set to : ' + icon_name); getActorCompat(this).remove_all_children(); @@ -257,13 +245,10 @@ class BingWallpaperIndicator extends PanelMenu.Button { // set backgrounds as requested and set preview image in menu _setBackground() { - if (this.filename == "") + if (this.filename == '') return; - if (Utils.is_x11()) { // wayland - only if we are sure it's safe to do so, we can't know if xwayland is running - this.thumbnail = new Thumbnail.Thumbnail(this.filename); - this._setThumbnailImage(); - } - + this.thumbnail = new Thumbnail.Thumbnail(this.filename); // historically thumbnails were a bit unsafe on Wayland, but now fixed + this._setThumbnailImage(); if (this._settings.get_boolean('set-background')) this._setBackgroundDesktop(); @@ -291,13 +276,10 @@ class BingWallpaperIndicator extends PanelMenu.Button { _restartTimeoutFromLongDate(longdate) { // 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); + let now = GLib.DateTime.new_now_local(); let difference = refreshDue.difference(now) / 1000000; - - log("Next refresh due @ " + refreshDue.format('%F %R %z') + " = " + difference + " seconds from now (" + now.format('%F %R %z') + ")"); - - if (difference < 60 || difference > 86400) // something wierd happened + log('Next refresh due ' + difference + ' seconds from now'); + if (difference < 60 || difference > 86400) // clamp to a reasonable range difference = 60; difference = difference + 300; // 5 minute fudge offset in case of inaccurate local clock @@ -318,8 +300,11 @@ class BingWallpaperIndicator extends PanelMenu.Button { } _wrapLabelItem(menuItem) { - menuItem.label.get_clutter_text().set_line_wrap(true); - menuItem.label.set_style("max-width: 350px;"); + let clutter_text = menuItem.label.get_clutter_text(); + clutter_text.set_line_wrap(true); + clutter_text.set_ellipsize(0); + clutter_text.set_max_length(0); + menuItem.label.set_style('max-width: 420px;'); } _newMenuIcon(icon_name, parent, fn) { @@ -338,7 +323,6 @@ class BingWallpaperIndicator extends PanelMenu.Button { x_expand: true, y_expand: true }); - getActorCompat(parent).add_child(iconBtn); iconBtn.connect('button-press-event', fn.bind(this)); return iconBtn; @@ -412,38 +396,40 @@ class BingWallpaperIndicator extends PanelMenu.Button { this._settings.set_string('selected-image', newImage.urlbase.replace('/th?id=OHR.', '')); } + _getCurrentImage() { + let imageList = Utils.getImageList(this._settings); + let curIndex = Utils.getCurrentImageIndex(imageList); + return Utils.getImageByIndex(imageList, curIndex); + } + // download Bing metadata _refresh() { - const that = this; if (this._updatePending) return; this._updatePending = true; - this._restartTimeout(); - let market = this._settings.get_string('market'); - log("market: " + market); - // create an http message - let request = Soup.Message.new('GET', BingImageURL + (market != 'auto' ? market : '')); // + market - log("fetching: " + BingImageURL + (market != 'auto' ? market : '')); + let url = BingImageURL + (market != 'auto' ? market : ''); + let request = Soup.Message.new('GET', url); + log('fetching: ' + url); // queue the http request - this.httpSession.queue_message(request, function(httpSession, message) { + this.httpSession.queue_message(request, (httpSession, message) => { if (message.status_code == 200) { let data = message.response_body.data; - log("Recieved " + data.length + " bytes "); - that._parseData(data); - if (that.selected_image != 'random' /*|| !forced*/) - that._selectImage(); + log('Recieved ' + data.length + ' bytes'); + this._parseData(data); + if (this.selected_image != 'random') + this._selectImage(); } else if (message.status_code == 403) { - log("Access denied: " + message.status_code); - that._updatePending = false; - that._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR); + log('Access denied: ' + message.status_code); + this._updatePending = false; + this._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR); } else { - log("Network error occured: " + message.status_code); - that._updatePending = false; - that._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR); + log('Network error occured: ' + message.status_code); + this._updatePending = false; + this._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR); } }); } @@ -455,8 +441,7 @@ class BingWallpaperIndicator extends PanelMenu.Button { if (seconds == null) seconds = TIMEOUT_SECONDS; this._timeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, seconds, this._refresh.bind(this)); - let timezone = GLib.TimeZone.new_local(); - let localTime = GLib.DateTime.new_now(timezone).add_seconds(seconds); + let localTime = GLib.DateTime.new_now_local().add_seconds(seconds); this.refreshdue = localTime; log('next check in ' + seconds + ' seconds @ local time ' + localTime.format('%F %R %z')); } @@ -470,6 +455,13 @@ class BingWallpaperIndicator extends PanelMenu.Button { log('next shuffle in ' + seconds + ' seconds'); } + // auto export Bing data to JSON file if requested + _exportData() { + if (this._settings.get_boolean('always-export-bing-json')) { // save copy of current JSON + Utils.exportBingJSON(this._settings); + } + } + // process Bing metadata _parseData(data) { try { @@ -479,16 +471,16 @@ class BingWallpaperIndicator extends PanelMenu.Button { 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.purgeImages(this._settings); // delete older images if enabled Utils.cleanupImageList(this._settings); if (newImages.length > 0 && this._settings.get_boolean('revert-to-current-image')) { // user wants to switch to the new image when it arrives this._settings.set_string('selected-image', 'current'); } if (this._settings.get_boolean('notify')) { - const that = this; - newImages.forEach(function(image, index) { + newImages.forEach((image, index) => { log('New image to notify: ' + Utils.getImageTitle(image)); - that._createNotification(image); + this._createNotification(image); }); } @@ -500,26 +492,23 @@ class BingWallpaperIndicator extends PanelMenu.Button { } } + _cleanUpImages() { + if (this._settings.get_boolean('delete-previous')) { + Utils.purgeImages(this._settings); + } + } + _createNotification(image) { // set notifications icon - let source = new MessageTray.Source("Bing Wallpaper", "preferences-desktop-wallpaper-symbolic"); + let source = new MessageTray.Source('Bing Wallpaper', 'preferences-desktop-wallpaper-symbolic'); Main.messageTray.add(source); - let msg = _("Bing Wallpaper of the Day for") + ' ' + this._localeDate(image.startdate); - let details = Utils.getImageTitle(image); //image.copyright.replace(/\s*\(.*?\)\s*/g, ""); + let msg = _('Bing Wallpaper of the Day for') + ' ' + this._localeDate(image.startdate); + let details = Utils.getImageTitle(image); let notification = new MessageTray.Notification(source, msg, details); notification.setTransient(this._settings.get_boolean('transient')); - // Add action to open Bing website with default browser, this is unfortunately very hacky - notification.addAction(_("More info on Bing.com"), this._notificationOpenLink().bind(this, notification)); source.showNotification(notification); } - _notificationOpenLink(notification) { - log("Open :" + notification.bannerBodyText); - let imageList = Utils.getImageList(this._settings); - let image = Utils.inImageListByTitle(imageList, notification.bannerBodyText); - Util.spawn(["xdg-open", image.copyrightlink]); - } - _selectImage() { let imageList = JSON.parse(this._settings.get_string('bing-json')); let image = null; @@ -527,12 +516,11 @@ class BingWallpaperIndicator extends PanelMenu.Button { if (this.selected_image == 'random') { image = imageList[Utils.getRandomInt(imageList.length)]; 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 { image = Utils.inImageList(imageList, this.selected_image); - log('_selectImage: ' + this.selected_image + ' = ' + image ? image.urlbase : "not found"); + log('_selectImage: ' + this.selected_image + ' = ' + image ? image.urlbase : 'not found'); if (!image) // if we didn't find it, try for current image = Utils.getCurrentImage(imageList); } @@ -540,14 +528,14 @@ class BingWallpaperIndicator extends PanelMenu.Button { return; // could force, image = imageList[0] or perhaps force refresh if (image.url != '') { - this.title = image.copyright.replace(/\s*[\(\(].*?[\)\)]\s*/g, ""); - this.explanation = _("Bing Wallpaper of the Day for") + ' ' + this._localeDate(image.startdate); + 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('\*\*', ''); // 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.imageURL = BingURL + image.urlbase + '_' + resolution + '.jpg'; // generate image url for user's resolution this.filename = toFilename(BingWallpaperDir, image.startdate, image.urlbase, resolution); let file = Gio.file_new_for_path(this.filename); @@ -561,11 +549,9 @@ class BingWallpaperIndicator extends PanelMenu.Button { } this._downloadImage(this.imageURL, file); } else { - log("Image already downloaded"); this._setBackground(); this._updatePending = false; } - //this._createNotification(image); // for testing } else { this.title = _("No wallpaper available"); @@ -628,68 +614,33 @@ class BingWallpaperIndicator extends PanelMenu.Button { // download and process new image // FIXME: improve error handling _downloadImage(url, file) { - const that = this; log("Downloading " + url + " to " + file.get_uri()); - // open the Gfile let fstream = file.replace(null, false, Gio.FileCreateFlags.NONE, null); - // create an http message let request = Soup.Message.new('GET', url); - // got_headers event - request.connect('got_headers', function(message) { - log("got_headers, status: " + message.status_code); - }); // got_chunk event - request.connect('got_chunk', function(message, chunk) { - //log("got_chuck, status: "+message.status_code); + request.connect('got_chunk', (message, chunk) => { if (message.status_code == 200) { // only save the data we want, not content of 301 redirect page fstream.write(chunk.get_data(), null); } - else { - log("got_chuck, status: " + message.status_code); - } }); // queue the http request - this.httpSession.queue_message(request, function(httpSession, message) { + this.httpSession.queue_message(request, (httpSession, message) => { // request completed fstream.close(null); - that._updatePending = false; + this._updatePending = false; if (message.status_code == 200) { log('Download successful'); - that._setBackground(); - that._addToPreviousQueue(that.filename); + this._setBackground(); } else { - log("Couldn't fetch image from " + url); + log('Couldn\'t fetch image from ' + url); file.delete(null); } }); } - // add image to persistant list so we can delete it later (in chronological order), delete the oldest image (if user wants this) - _addToPreviousQueue(filename) { - let rawimagelist = this._settings.get_string('previous'); - let imagelist = rawimagelist.split(','); - let maxpictures = this._settings.get_int('previous-days'); - let deletepictures = this._settings.get_boolean('delete-previous'); - - log("Settings: delete:" + (deletepictures ? "yes" : "no") + " max: " + maxpictures); - imagelist.push(filename); // add current to end of list - - 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 != '') { - Utils.deleteImage(to_delete); - } - } - - // put it back together and send back to settings - rawimagelist = imagelist.join(); - this._settings.set_string('previous', rawimagelist); - } - // open image in default image view _openInSystemViewer() { Utils.openInSystemViewer(this.filename); @@ -707,7 +658,7 @@ class BingWallpaperIndicator extends PanelMenu.Button { }); function init(extensionMeta) { - Convenience.initTranslations("BingWallpaper"); + ExtensionUtils.initTranslations("BingWallpaper"); } function enable() { @@ -725,6 +676,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/install.sh b/install.sh index 8d433a01..9fe4ca56 100755 --- a/install.sh +++ b/install.sh @@ -6,4 +6,6 @@ ZIP_NAME=BingWallpaper@ineffable-gmail.com.zip ./buildzip.sh +mkdir -p $INSTALL_PATH/$EXTENSION_NAME + unzip -o $ZIP_NAME -d $INSTALL_PATH/$EXTENSION_NAME/ diff --git a/locale/BingWallpaper.pot b/locale/BingWallpaper.pot index 0088deac..94358838 100644 --- a/locale/BingWallpaper.pot +++ b/locale/BingWallpaper.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-08-08 16:00+1000\n" +"POT-Creation-Date: 2021-12-14 18:32+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,288 +17,328 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: Settings.ui.h:1 Settings4.ui.h:2 +#: ui/Settings.ui.h:1 ui/Settings4.ui.h:2 msgid "Hide the indicator" msgstr "" -#: Settings.ui.h:2 Settings4.ui.h:3 +#: ui/Settings.ui.h:2 ui/Settings4.ui.h:3 msgid "Indicator icon" msgstr "" -#: Settings.ui.h:3 Settings4.ui.h:4 +#: ui/Settings.ui.h:3 ui/Settings4.ui.h:4 msgid "Enable desktop notifications" msgstr "" -#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:125 +#: ui/Settings.ui.h:4 ui/Settings4.ui.h:5 extension.js:118 msgid "Set background image" msgstr "" -#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:126 -msgid "Set lock screen image" +#: ui/Settings.ui.h:5 ui/Settings4.ui.h:6 +msgid "Background style option" msgstr "" -#: Settings.ui.h:6 Settings4.ui.h:7 +#: ui/Settings.ui.h:6 ui/Settings4.ui.h:7 msgid "Download folder" msgstr "" -#: Settings.ui.h:7 Settings4.ui.h:1 +#: ui/Settings.ui.h:7 ui/Settings4.ui.h:1 msgid "Bing Wallpaper pictures folder" msgstr "" -#: Settings.ui.h:8 Settings4.ui.h:8 +#: ui/Settings.ui.h:8 ui/Settings4.ui.h:8 msgid "Open folder" msgstr "" -#: Settings.ui.h:9 Settings4.ui.h:9 +#: ui/Settings.ui.h:9 ui/Settings4.ui.h:9 msgid "Delete previously downloaded wallpapers" msgstr "" -#: Settings.ui.h:10 Settings4.ui.h:10 +#: ui/Settings.ui.h:10 ui/Settings4.ui.h:10 msgid "Selected image" msgstr "" -#: Settings.ui.h:11 Settings4.ui.h:11 +#: ui/Settings.ui.h:11 ui/Settings4.ui.h:11 msgid "Select from image gallery" msgstr "" -#: Settings.ui.h:12 Settings4.ui.h:12 +#: ui/Settings.ui.h:12 ui/Settings4.ui.h:12 msgid "Bing locale" msgstr "" -#: Settings.ui.h:13 Settings4.ui.h:13 extension.js:128 +#: ui/Settings.ui.h:13 ui/Settings4.ui.h:13 extension.js:121 msgid "Settings" msgstr "" -#: Settings.ui.h:14 Settings4.ui.h:14 +#: ui/Settings.ui.h:14 ui/Settings4.ui.h:14 msgid "Use custom blur and brightness" msgstr "" -#: Settings.ui.h:15 Settings4.ui.h:15 +#: ui/Settings.ui.h:15 ui/Settings4.ui.h:15 msgid "Override GDM3 lockscreen effects" msgstr "" -#: Settings.ui.h:16 Settings4.ui.h:16 +#: ui/Settings.ui.h:16 ui/Settings4.ui.h:16 msgid "Blur can improve readability of login prompt" msgstr "" -#: Settings.ui.h:17 Settings4.ui.h:17 +#: ui/Settings.ui.h:17 ui/Settings4.ui.h:17 msgid "Background blur intensity" msgstr "" -#: Settings.ui.h:18 Settings4.ui.h:18 +#: ui/Settings.ui.h:18 ui/Settings4.ui.h:18 msgid "Can improve contrast of login prompt" msgstr "" -#: Settings.ui.h:19 Settings4.ui.h:19 +#: ui/Settings.ui.h:19 ui/Settings4.ui.h:19 msgid "Background brightness" msgstr "" -#: Settings.ui.h:20 Settings4.ui.h:20 +#: ui/Settings.ui.h:20 ui/Settings4.ui.h:20 msgid "Presets" msgstr "" -#: Settings.ui.h:21 Settings4.ui.h:21 +#: ui/Settings.ui.h:21 msgid "Commonly used presets" msgstr "" -#: Settings.ui.h:22 Settings4.ui.h:22 +#: ui/Settings.ui.h:22 ui/Settings4.ui.h:21 msgid "No blur, slight dim" msgstr "" -#: Settings.ui.h:23 Settings4.ui.h:23 +#: ui/Settings.ui.h:23 ui/Settings4.ui.h:22 msgid "GNOME default" msgstr "" -#: Settings.ui.h:24 Settings4.ui.h:24 +#: ui/Settings.ui.h:24 ui/Settings4.ui.h:23 msgid "Slight blur, slight dim" msgstr "" -#: Settings.ui.h:25 Settings4.ui.h:25 +#: ui/Settings.ui.h:25 ui/Settings4.ui.h:24 msgid "Lock Screen" msgstr "" -#: Settings.ui.h:26 Settings4.ui.h:27 +#: ui/Settings.ui.h:26 ui/Settings4.ui.h:26 msgid "Debug logging" msgstr "" -#: Settings.ui.h:27 Settings4.ui.h:26 +#: ui/Settings.ui.h:27 ui/Settings4.ui.h:25 msgid "Enable logging to system journal" msgstr "" -#: Settings.ui.h:28 Settings4.ui.h:29 +#: ui/Settings.ui.h:28 ui/Settings4.ui.h:28 msgid "Always show new images" msgstr "" -#: Settings.ui.h:29 Settings4.ui.h:28 +#: ui/Settings.ui.h:29 ui/Settings4.ui.h:27 msgid "Switch to new images when available (unless on random mode)" msgstr "" -#: Settings.ui.h:30 Settings4.ui.h:31 +#: ui/Settings.ui.h:30 ui/Settings4.ui.h:30 msgid "Enable all features on Wayland" msgstr "" -#: Settings.ui.h:31 Settings4.ui.h:30 +#: ui/Settings.ui.h:31 ui/Settings4.ui.h:29 msgid "Some newer features may be unstable on Wayland" msgstr "" -#: Settings.ui.h:32 Settings4.ui.h:32 +#: ui/Settings.ui.h:32 ui/Settings4.ui.h:31 msgid "Screen resolution" msgstr "" -#: Settings.ui.h:33 Settings4.ui.h:33 +#: ui/Settings.ui.h:33 ui/Settings4.ui.h:32 msgid "Override automatic resolution selection" msgstr "" -#: Settings.ui.h:34 Settings4.ui.h:34 +#: ui/Settings.ui.h:34 ui/Settings4.ui.h:33 +msgid "Manually adjust random interval (seconds)" +msgstr "" + +#: ui/Settings.ui.h:35 ui/Settings4.ui.h:34 +msgid "Random interval" +msgstr "" + +#: ui/Settings.ui.h:36 ui/Settings4.ui.h:35 +msgid "Import Bing Wallpaper data" +msgstr "" + +#: ui/Settings.ui.h:37 ui/Settings4.ui.h:36 +msgid "Import previously exported JSON data from wallpaper directory" +msgstr "" + +#: ui/Settings.ui.h:38 ui/Settings4.ui.h:37 +msgid "Import" +msgstr "" + +#: ui/Settings.ui.h:39 ui/Settings4.ui.h:38 +msgid "Export Bing Wallpaper data" +msgstr "" + +#: ui/Settings.ui.h:40 ui/Settings4.ui.h:39 +msgid "Export JSON data to wallpaper dir for backup or data migration" +msgstr "" + +#: ui/Settings.ui.h:41 ui/Settings4.ui.h:40 +msgid "Export" +msgstr "" + +#: ui/Settings.ui.h:42 ui/Settings4.ui.h:41 +msgid "Always export Bing data" +msgstr "" + +#: ui/Settings.ui.h:43 ui/Settings4.ui.h:42 +msgid "Export Bing JSON whenever data changes" +msgstr "" + +#: ui/Settings.ui.h:44 ui/Settings4.ui.h:43 msgid "Debug options" msgstr "" -#: Settings.ui.h:35 Settings4.ui.h:35 +#: ui/Settings.ui.h:45 ui/Settings4.ui.h:44 msgid "New wallpaper images everyday from Bing" msgstr "" -#: Settings.ui.h:36 Settings4.ui.h:36 +#: ui/Settings.ui.h:46 msgid "Gnome shell extension version " msgstr "" -#: Settings.ui.h:37 Settings4.ui.h:37 -msgid "https://github.com/neffo/bing-wallpaper-gnome-extension" -msgstr "" - -#: Settings.ui.h:38 Settings4.ui.h:38 +#: ui/Settings.ui.h:47 ui/Settings4.ui.h:46 msgid "Maintained by Michael Carroll" msgstr "" -#: Settings.ui.h:39 Settings4.ui.h:39 +#: ui/Settings.ui.h:48 ui/Settings4.ui.h:47 msgid "" "Show your support to the author on Flattr or Github " "Sponsors." msgstr "" -#: Settings.ui.h:40 Settings4.ui.h:40 +#: ui/Settings.ui.h:49 ui/Settings4.ui.h:48 msgid "Changes since last version" msgstr "" -#: Settings.ui.h:41 Settings4.ui.h:41 +#: ui/Settings.ui.h:50 ui/Settings4.ui.h:49 msgid "Based on NASA APOD Gnome shell extension by Elia Argentieri" msgstr "" -#: Settings.ui.h:42 Settings4.ui.h:42 +#: ui/Settings.ui.h:51 ui/Settings4.ui.h:50 msgid "" "This program comes with ABSOLUTELY NO WARRANTY.\n" "See the GNU General " "Public License, version 3 or later for details." msgstr "" -#: Settings.ui.h:44 Settings4.ui.h:44 +#: ui/Settings.ui.h:53 ui/Settings4.ui.h:52 msgid "About" msgstr "" -#: extension.js:111 +#: ui/Settings4.ui.h:45 +msgid "GNOME shell extension version " +msgstr "" + +#: ui/carousel.ui.h:1 ui/carousel4.ui.h:2 +msgid "Apply" +msgstr "" + +#: ui/carousel.ui.h:2 ui/carousel4.ui.h:3 +msgid "View" +msgstr "" + +#: ui/carousel.ui.h:3 ui/carousel4.ui.h:4 +msgid "Info" +msgstr "" + +#: ui/carousel.ui.h:4 ui/carousel4.ui.h:5 +msgid "Delete" +msgstr "" + +#: ui/carousel.ui.h:5 ui/carousel4.ui.h:6 +msgid "Set random mode" +msgstr "" + +#: ui/carousel4.ui.h:1 +msgid "" +msgstr "" + +#: extension.js:106 msgid "" msgstr "" -#: extension.js:113 extension.js:115 extension.js:118 +#: extension.js:108 extension.js:110 extension.js:113 msgid "Awaiting refresh..." msgstr "" -#: extension.js:121 +#: extension.js:115 msgid "Copy image to clipboard" msgstr "" -#: extension.js:122 +#: extension.js:116 msgid "Copy image URL to clipboard" msgstr "" -#: extension.js:123 +#: extension.js:117 msgid "Open image folder" msgstr "" -#: extension.js:124 -msgid "Open image gallery" +#: extension.js:119 +msgid "Set lock screen image" msgstr "" -#: extension.js:127 +#: extension.js:120 msgid "Refresh Now" msgstr "" -#: extension.js:133 -msgid "Thumbnail disabled on Wayland" -msgstr "" - -#: extension.js:235 +#: extension.js:209 msgid "Next refresh" msgstr "" -#: extension.js:512 extension.js:549 +#: extension.js:505 extension.js:532 msgid "Bing Wallpaper of the Day for" msgstr "" -#: extension.js:517 -msgid "More info on Bing.com" -msgstr "" - -#: extension.js:576 +#: extension.js:557 msgid "No wallpaper available" msgstr "" -#: extension.js:577 +#: extension.js:558 msgid "No picture for today 😞." msgstr "" -#: prefs.js:188 +#: prefs.js:202 msgid "Most recent image" msgstr "" -#: prefs.js:189 +#: prefs.js:203 msgid "Random image" msgstr "" -#: prefs.js:204 prefs.js:220 -msgid "Disabled on current GNOME version" -msgstr "" - -#: utils.js:144 +#: utils.js:118 msgid "Fetching data..." msgstr "" -#: utils.js:155 +#: utils.js:129 msgid "Market not available in your region" msgstr "" -#: utils.js:159 +#: utils.js:133 msgid "A network error occured" msgstr "" -#: utils.js:164 +#: utils.js:138 msgid "Too many requests in 5 seconds" msgstr "" -#: utils.js:191 +#: utils.js:163 msgid "No change log found for this release" msgstr "" -#: utils.js:389 utils.js:392 +#: utils.js:366 utils.js:369 msgid "minutes" msgstr "" -#: utils.js:395 +#: utils.js:372 msgid "days" msgstr "" -#: utils.js:398 +#: utils.js:375 msgid "hours" msgstr "" - -#: carousel.ui:87 carousel4.ui:50 -msgid "Set as wallpaper" -msgstr "" - -#: carousel.ui:99 carousel4.ui:60 -msgid "Delete image" -msgstr "" - -#: carousel4.ui:40 -msgid "" -msgstr "" diff --git a/locale/de/LC_MESSAGES/BingWallpaper.mo b/locale/de/LC_MESSAGES/BingWallpaper.mo index 1c578f02..e9d3c264 100644 Binary files a/locale/de/LC_MESSAGES/BingWallpaper.mo and b/locale/de/LC_MESSAGES/BingWallpaper.mo differ diff --git a/locale/de/LC_MESSAGES/BingWallpaper.po b/locale/de/LC_MESSAGES/BingWallpaper.po index 9527f5f5..b0007b34 100644 --- a/locale/de/LC_MESSAGES/BingWallpaper.po +++ b/locale/de/LC_MESSAGES/BingWallpaper.po @@ -7,15 +7,15 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-05-09 18:16+1000\n" -"PO-Revision-Date: 2021-05-10 07:34+1000\n" -"Last-Translator: Onno Giesmann \n" +"POT-Creation-Date: 2021-08-08 16:00+1000\n" +"PO-Revision-Date: 2021-12-02 22:11+0100\n" +"Last-Translator: Jannick Alexander Kuhr\n" "Language-Team: \n" "Language: de\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.2.4\n" #: Settings.ui.h:1 Settings4.ui.h:2 msgid "Hide the indicator" @@ -27,127 +27,149 @@ msgstr "Indikator-Symbol" #: Settings.ui.h:3 Settings4.ui.h:4 msgid "Enable desktop notifications" -msgstr "" +msgstr "Desktop-Benachrichtigungen aktivieren" -#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:129 +#: Settings.ui.h:4 Settings4.ui.h:5 extension.js:125 msgid "Set background image" -msgstr "Verwenden für Hintergrund" +msgstr "Als Hintergrundbild verwenden" -#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:130 +#: Settings.ui.h:5 Settings4.ui.h:6 extension.js:126 msgid "Set lock screen image" -msgstr "Verwenden für Sperrbildschirm" +msgstr "Für Sperrbildschirm verwenden" #: Settings.ui.h:6 Settings4.ui.h:7 msgid "Download folder" -msgstr "Downloadordner" +msgstr "Download-Ordner" #: Settings.ui.h:7 Settings4.ui.h:1 msgid "Bing Wallpaper pictures folder" -msgstr "Bilderordner für Bing-Hintergrundbilder" +msgstr "Ordner für Bing-Hintergrundbilder" -#: Settings.ui.h:8 Settings4.ui.h:9 -#, fuzzy -#| msgid "Delete previously downloaded wallpapers:" +#: Settings.ui.h:8 Settings4.ui.h:8 +msgid "Open folder" +msgstr "Download-Ordner" + +#: Settings.ui.h:9 Settings4.ui.h:9 msgid "Delete previously downloaded wallpapers" msgstr "Zuvor heruntergeladene Hintergrundbilder löschen" -#: Settings.ui.h:9 Settings4.ui.h:10 -msgid "Days to store wallpapers before deleting" -msgstr "Tage, bevor Hintergrundbilder wieder gelöscht werden" +#: Settings.ui.h:10 Settings4.ui.h:10 +msgid "Selected image" +msgstr "Ausgewähltes Bild" + +#: Settings.ui.h:11 Settings4.ui.h:11 +msgid "Select from image gallery" +msgstr "Aus Bildergalerie auswählen" -#: Settings.ui.h:10 Settings4.ui.h:11 +#: Settings.ui.h:12 Settings4.ui.h:12 msgid "Bing locale" msgstr "Bing-Region" -#: Settings.ui.h:11 Settings4.ui.h:12 -msgid "Default is English - United States" -msgstr "Vorgabe ist English - United States" - -#: Settings.ui.h:12 Settings4.ui.h:14 -msgid "Screen resolution" -msgstr "Bildschirmauflösung" - -#: Settings.ui.h:13 Settings4.ui.h:15 -msgid "Override automatic resolution selection" -msgstr "Überschreibt die automatische Auswahl der Auflösung" - -#: Settings.ui.h:14 Settings4.ui.h:13 -#, fuzzy -#| msgid "Set lock screen image" -msgid "Selected image" -msgstr "Verwenden für Sperrbildschirm" - -#: Settings.ui.h:15 Settings4.ui.h:16 extension.js:132 +#: Settings.ui.h:13 Settings4.ui.h:13 extension.js:128 msgid "Settings" msgstr "Einstellungen" -#: Settings.ui.h:16 Settings4.ui.h:17 +#: Settings.ui.h:14 Settings4.ui.h:14 msgid "Use custom blur and brightness" msgstr "Eigene Unschärfe und Helligkeit einstellen" -#: Settings.ui.h:17 Settings4.ui.h:18 +#: Settings.ui.h:15 Settings4.ui.h:15 msgid "Override GDM3 lockscreen effects" msgstr "Effekte des GDM3-Sperrbildschirms überschreiben" -#: 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 "Unschärfe kann die Lesbarkeit des Anmeldedialogs verbessern" -#: Settings.ui.h:19 Settings4.ui.h:20 +#: Settings.ui.h:17 Settings4.ui.h:17 msgid "Background blur intensity" msgstr "Intensität der Hintergrundunschärfe" -#: Settings.ui.h:20 Settings4.ui.h:21 +#: Settings.ui.h:18 Settings4.ui.h:18 msgid "Can improve contrast of login prompt" msgstr "Kann den Kontrast des Anmeldedialogs verbessern" -#: Settings.ui.h:21 Settings4.ui.h:22 +#: Settings.ui.h:19 Settings4.ui.h:19 msgid "Background brightness" msgstr "Hintergrundhelligkeit" -#: Settings.ui.h:22 Settings4.ui.h:23 +#: Settings.ui.h:20 Settings4.ui.h:20 msgid "Presets" msgstr "Voreinstellungen" -#: Settings.ui.h:23 Settings4.ui.h:24 +#: Settings.ui.h:21 Settings4.ui.h:21 msgid "Commonly used presets" msgstr "Häufig verwendete Voreinstellungen" -#: Settings.ui.h:24 Settings4.ui.h:25 +#: Settings.ui.h:22 Settings4.ui.h:22 msgid "No blur, slight dim" -msgstr "Keine Unschärfe, ein bisschen dimmen" +msgstr "Keine Unschärfe, leichtes Dimmen" -#: Settings.ui.h:25 Settings4.ui.h:26 +#: Settings.ui.h:23 Settings4.ui.h:23 msgid "GNOME default" msgstr "GNOME-Standard" -#: Settings.ui.h:26 Settings4.ui.h:27 +#: Settings.ui.h:24 Settings4.ui.h:24 msgid "Slight blur, slight dim" -msgstr "Etwas Unschärfe, ein bisschen dimmen" +msgstr "Etwas Unschärfe, leichtes Dimmen" -#: Settings.ui.h:27 Settings4.ui.h:28 +#: Settings.ui.h:25 Settings4.ui.h:25 msgid "Lock Screen" msgstr "Sperrbildschirm" +#: Settings.ui.h:26 Settings4.ui.h:27 +msgid "Debug logging" +msgstr "Debug-Protokollierung" + +#: Settings.ui.h:27 Settings4.ui.h:26 +msgid "Enable logging to system journal" +msgstr "Protokollierung in System-Journal aktivieren" + #: Settings.ui.h:28 Settings4.ui.h:29 +msgid "Always show new images" +msgstr "Neue Bilder immer anzeigen" + +#: Settings.ui.h:29 Settings4.ui.h:28 +msgid "Switch to new images when available (unless on random mode)" +msgstr "Zu verfügbaren neuen Bildern wechseln (sofern nicht im Zufallsmodus)" + +#: Settings.ui.h:30 Settings4.ui.h:31 +msgid "Enable all features on Wayland" +msgstr "Alle Features unter Wayland aktivieren" + +#: Settings.ui.h:31 Settings4.ui.h:30 +msgid "Some newer features may be unstable on Wayland" +msgstr "Einige neuere Features können unter Wayland instabil sein" + +#: Settings.ui.h:32 Settings4.ui.h:32 +msgid "Screen resolution" +msgstr "Bildschirmauflösung" + +#: Settings.ui.h:33 Settings4.ui.h:33 +msgid "Override automatic resolution selection" +msgstr "Automatische Auswahl der Auflösung überschreiben" + +#: Settings.ui.h:34 Settings4.ui.h:34 +msgid "Debug options" +msgstr "Debug-Einstellungen" + +#: Settings.ui.h:35 Settings4.ui.h:35 msgid "New wallpaper images everyday from Bing" msgstr "Jeden Tag neue Hintergrundbilder von Bing" -#: Settings.ui.h:29 Settings4.ui.h:30 -#, fuzzy -#| msgid "Gnome shell extension version: " +#: Settings.ui.h:36 Settings4.ui.h:36 msgid "Gnome shell extension version " -msgstr "Version dieser Gnome-Shell-Erweiterung: " +msgstr "Version dieser Gnome-Shell-Erweiterung " -#: 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 "Betreut von 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 " @@ -156,15 +178,15 @@ msgstr "" "Unterstützen Sie den Autor auf Flattr oder Github-Sponsoren." -#: Settings.ui.h:33 Settings4.ui.h:34 +#: Settings.ui.h:40 Settings4.ui.h:40 msgid "Changes since last version" msgstr "Änderungen seit der letzten Version" -#: 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 "Basiert auf der NASA APOD Gnome-Shell-Erweiterung von Elia Argentieri" -#: Settings.ui.h:35 Settings4.ui.h:36 +#: Settings.ui.h:42 Settings4.ui.h:42 msgid "" "This program comes with ABSOLUTELY NO WARRANTY.\n" "See the GNU General " @@ -175,114 +197,124 @@ msgstr "" "\">GNU General Public License, Version 3 oder später für weitere Details " "an." -#: Settings.ui.h:37 Settings4.ui.h:38 +#: Settings.ui.h:44 Settings4.ui.h:44 msgid "About" msgstr "Über" -#: Settings4.ui.h:8 -#, fuzzy -#| msgid "Download folder" -msgid "Open folder" -msgstr "Downloadordner" - -#: extension.js:117 +#: extension.js:111 msgid "" msgstr "" -#: extension.js:119 extension.js:121 extension.js:123 +#: extension.js:113 extension.js:115 extension.js:118 msgid "Awaiting refresh..." -msgstr "Warten auf Aktualisierung..." +msgstr "Warten auf Aktualisierung ..." -#: extension.js:126 +#: extension.js:121 msgid "Copy image to clipboard" msgstr "Bild in Zwischenablage kopieren" -#: extension.js:127 +#: extension.js:122 msgid "Copy image URL to clipboard" msgstr "Bildadresse in Zwischenablage kopieren" -#: extension.js:128 +#: extension.js:123 msgid "Open image folder" -msgstr "" +msgstr "Bilderordner öffnen" -#: extension.js:131 +#: extension.js:124 +msgid "Open image gallery" +msgstr "Bildergalerie öffnen" + +#: extension.js:127 msgid "Refresh Now" msgstr "Jetzt aktualisieren" -#: extension.js:137 +#: extension.js:133 msgid "Thumbnail disabled on Wayland" msgstr "Vorschaubild unter Wayland deaktiviert" -#: extension.js:203 +#: extension.js:235 msgid "Next refresh" msgstr "Nächste Aktualisierung" -#: extension.js:490 extension.js:527 +#: extension.js:512 extension.js:549 msgid "Bing Wallpaper of the Day for" msgstr "Bing-Hintergrundbild des Tages für" -#: extension.js:495 -#, fuzzy -#| msgid "Set desktop wallpaper" -msgid "Set as wallpaper" -msgstr "Schreibtisch-Hintergrund einstellen" - -#: extension.js:498 +#: extension.js:517 msgid "More info on Bing.com" -msgstr "" +msgstr "Mehr Informationen auf Bing.com" -#: extension.js:553 +#: extension.js:576 msgid "No wallpaper available" msgstr "Kein Hintergrundbild verfügbar" -#: extension.js:554 +#: extension.js:577 msgid "No picture for today 😞." msgstr "Heute kein Bild 😞." -#: prefs.js:173 +#: prefs.js:188 msgid "Most recent image" -msgstr "" +msgstr "Aktuellstes Bild" -#: prefs.js:174 +#: prefs.js:189 msgid "Random image" -msgstr "" +msgstr "Zufälliges Bild" -#: prefs.js:190 prefs.js:206 +#: prefs.js:204 prefs.js:220 msgid "Disabled on current GNOME version" -msgstr "" +msgstr "Auf aktueller GNOME-Version deaktiviert" -#: utils.js:139 +#: utils.js:144 msgid "Fetching data..." msgstr "Daten werden abgerufen..." -#: utils.js:150 +#: utils.js:155 msgid "Market not available in your region" -msgstr "Bing Bild in Ihrer Region nicht verfügbar" +msgstr "Bing-Bilder in Ihrer Region nicht verfügbar" -#: utils.js:154 +#: utils.js:159 msgid "A network error occured" msgstr "Ein Netzwerkfehler ist aufgetreten" -#: utils.js:159 +#: utils.js:164 msgid "Too many requests in 5 seconds" -msgstr "" +msgstr "Zu viele Anfragen in 5 Sekunden" -#: utils.js:186 +#: utils.js:191 msgid "No change log found for this release" msgstr "Kein Änderungsverlauf gefunden für diese Version" -#: utils.js:366 utils.js:369 +#: utils.js:389 utils.js:392 msgid "minutes" msgstr "Minuten" -#: utils.js:372 +#: utils.js:395 msgid "days" msgstr "Tage" -#: utils.js:375 +#: utils.js:398 msgid "hours" msgstr "Stunden" +#: carousel.ui:87 carousel4.ui:50 +msgid "Set as wallpaper" +msgstr "Als Hintergrundbild verwenden" + +#: carousel.ui:99 carousel4.ui:60 +msgid "Delete image" +msgstr "Bild löschen" + +#: carousel4.ui:40 +msgid "" +msgstr "" + +#~ msgid "Days to store wallpapers before deleting" +#~ msgstr "Tage, bevor Hintergrundbilder gelöscht werden" + +#~ msgid "Default is English - United States" +#~ msgstr "Vorgabe ist English - United States" + #~ msgid "" #~ "Changes your wallpaper daily to the Bing picture of the day for your " #~ "region. Displays the picture description and copyright information." diff --git a/locale/sv/LC_MESSAGES/BingWallpaper.mo b/locale/sv/LC_MESSAGES/BingWallpaper.mo index cc1e0d45..bee87afb 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 f0d8f500..b0dd3a53 100644 --- a/locale/sv/LC_MESSAGES/BingWallpaper.po +++ b/locale/sv/LC_MESSAGES/BingWallpaper.po @@ -8,15 +8,15 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \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" +"PO-Revision-Date: 2021-10-17 08:37+0200\n" +"Last-Translator: Isak Bergdahl \n" +"Language-Team: Swedish <>\n" "Language: sv\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" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Gtranslator 40.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" #: Settings.ui.h:1 Settings4.ui.h:2 msgid "Hide the indicator" @@ -47,7 +47,6 @@ msgid "Bing Wallpaper pictures folder" msgstr "Bing Wallpaper nedladdningsmapp" #: Settings.ui.h:8 Settings4.ui.h:8 -#, fuzzy #| msgid "Download folder" msgid "Open folder" msgstr "Öppna mapp" @@ -122,29 +121,29 @@ msgstr "Låsskärm" #: Settings.ui.h:26 Settings4.ui.h:27 msgid "Debug logging" -msgstr "" +msgstr "Felsökningsloggning" #: Settings.ui.h:27 Settings4.ui.h:26 msgid "Enable logging to system journal" -msgstr "" +msgstr "Aktiva loggning till systemets journal" #: Settings.ui.h:28 Settings4.ui.h:29 msgid "Always show new images" -msgstr "" +msgstr "Visa alltid nya bilder" #: Settings.ui.h:29 Settings4.ui.h:28 msgid "Switch to new images when available (unless on random mode)" msgstr "" +"Byt till nya bilder så snart de är tillgängliga (utom i slumpmässigt läge)" #: 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" +msgstr "Aktivera alla funktioner med Wayland" #: Settings.ui.h:31 Settings4.ui.h:30 msgid "Some newer features may be unstable on Wayland" -msgstr "" +msgstr "Vissa nyare funktioner kan vara ostabila med Wayland" #: Settings.ui.h:32 Settings4.ui.h:32 msgid "Screen resolution" @@ -156,7 +155,7 @@ msgstr "Åsidosätt automatiskt skärmupplösningsval" #: Settings.ui.h:34 Settings4.ui.h:34 msgid "Debug options" -msgstr "" +msgstr "Felsökningsalternativ" #: Settings.ui.h:35 Settings4.ui.h:35 msgid "New wallpaper images everyday from Bing" @@ -189,7 +188,7 @@ msgstr "Nyheter sedan förra versionen" #: 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" +msgstr "Baserat på NASA APOD Gnome shell extensions av Elia Argentieri" #: Settings.ui.h:42 Settings4.ui.h:42 msgid "" @@ -222,7 +221,6 @@ msgid "Copy image URL to clipboard" msgstr "Kopiera bildlänk till urklipp" #: extension.js:128 -#, fuzzy msgid "Open image folder" msgstr "Öppna bildmapp" @@ -244,7 +242,7 @@ msgstr "Bings dagliga bakgrundsbild för" #: extension.js:525 msgid "More info on Bing.com" -msgstr "" +msgstr "Mer information på Bing.com" #: extension.js:579 msgid "No wallpaper available" @@ -252,7 +250,7 @@ msgstr "Inga skrivbordsbakgrunder tillgängliga" #: extension.js:580 msgid "No picture for today 😞." -msgstr "Inga nya bilder idag 😞." +msgstr "Ingen ny bild idag 😞." #: prefs.js:181 msgid "Most recent image" diff --git a/metadata.json b/metadata.json index 95a53177..e523dfc0 100644 --- a/metadata.json +++ b/metadata.json @@ -1,9 +1,9 @@ { "uuid": "BingWallpaper@ineffable-gmail.com", - "shell-version": ["3.28", "3.30", "3.32", "3.34", "3.36", "3.38", "40", "41"], + "shell-version": ["3.36", "3.38", "40", "41"], "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 *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": "36", + "version": "37", "url": "https://github.com/neffo/bing-wallpaper-gnome-extension" } diff --git a/prefs.js b/prefs.js index 2168a2a0..8953fe90 100644 --- a/prefs.js +++ b/prefs.js @@ -10,7 +10,8 @@ imports.gi.versions.Soup = '2.4'; const {Gtk, Gdk, GdkPixbuf, Gio, GLib, Soup} = imports.gi; -const Me = imports.misc.extensionUtils.getCurrentExtension(); +const ExtensionUtils = imports.misc.extensionUtils; +const Me = ExtensionUtils.getCurrentExtension(); const Utils = Me.imports.utils; const Convenience = Me.imports.convenience; const Gettext = imports.gettext.domain('BingWallpaper'); @@ -18,6 +19,7 @@ const _ = Gettext.gettext; const Carousel = Me.imports.carousel; let settings; +let desktop_settings; let marketDescription = null; let icon_image = null; @@ -29,8 +31,10 @@ let httpSession = null; const BingImageURL = Utils.BingImageURL; +var DESKTOP_SCHEMA = 'org.gnome.desktop.background'; + function init() { - Convenience.initTranslations("BingWallpaper"); + ExtensionUtils.initTranslations("BingWallpaper"); // this is now included in ExtensionUtils, but we still need it for now (for older GNOME versions) } function buildPrefsWidget() { @@ -58,7 +62,7 @@ function buildPrefsWidget() { let iconEntry = buildable.get_object('icon'); let notifySwitch = buildable.get_object('notify'); let bgSwitch = buildable.get_object('background'); - let lsSwitch = buildable.get_object('lock_screen'); + let styleEntry = buildable.get_object('background_style'); let fileChooserBtn = buildable.get_object('download_folder'); let fileChooser = buildable.get_object('file_chooser'); // this should only exist on Gtk4 let folderOpenBtn = buildable.get_object('button_open_download_folder'); @@ -81,8 +85,12 @@ function buildPrefsWidget() { let buttonGDMdefault = buildable.get_object('button_default_gnome'); let buttonnoblur = buildable.get_object('button_no_blur'); let buttonslightblur = buildable.get_object('button_slight_blur'); + let buttonImportData = buildable.get_object('button_json_import'); + let buttonExportData = buildable.get_object('button_json_export'); + let switchAlwaysExport = buildable.get_object('always_export_switch'); - settings = Utils.getSettings(Me); + settings = ExtensionUtils.getSettings(Utils.BING_SCHEMA); + desktop_settings = ExtensionUtils.getSettings(Utils.DESKTOP_SCHEMA); httpSession = new Soup.SessionAsync(); Soup.Session.prototype.add_feature.call(httpSession, new Soup.ProxyResolverDefault()); @@ -95,41 +103,47 @@ function buildPrefsWidget() { settings.bind('hide', hideSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind('notify', notifySwitch, 'active', Gio.SettingsBindFlags.DEFAULT); - Utils.icon_list.forEach(function (iconname, index) { // add markets to dropdown list (aka a GtkComboText) + Utils.icon_list.forEach((iconname, index) => { // add markets to dropdown list (aka a GtkComboText) iconEntry.append(iconname, iconname); }); settings.bind('icon-name', iconEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT); - settings.connect('changed::icon-name', function() { + settings.connect('changed::icon-name', () => { Utils.validate_icon(settings, icon_image); }); iconEntry.set_active_id(settings.get_string('icon-name')); settings.bind('set-background', bgSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); - settings.bind('set-lock-screen', lsSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind('debug-logging', debugSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind('revert-to-current-image', revertSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind('override-unsafe-wayland', unsafeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); settings.bind('random-interval', randomIntervalEntry, 'value', Gio.SettingsBindFlags.DEFAULT); + settings.bind('always-export-bing-json', switchAlwaysExport, 'active', Gio.SettingsBindFlags.DEFAULT); - folderOpenBtn.connect('clicked', function(widget) { + folderOpenBtn.connect('clicked', (widget) => { Utils.openImageFolder(settings); }); - galleryButton.connect('clicked', function(widget) { + galleryButton.connect('clicked', (widget) => { carousel = new Carousel.Carousel(settings, widget); }); + buttonImportData.connect('clicked', () => { + Utils.importBingJSON(settings); + }); + buttonExportData.connect('clicked', () => { + Utils.exportBingJSON(settings); + }); //download folder if (Gtk.get_major_version() == 4) { // we need to use native file choosers in Gtk4 fileChooserBtn.set_label(settings.get_string('download-folder')); fileChooser.set_current_folder(Gio.File.new_for_path(Utils.getWallpaperDir(settings)).get_parent()); - fileChooserBtn.connect('clicked', function(widget) { + fileChooserBtn.connect('clicked', (widget) => { let parent = widget.get_root(); fileChooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER); fileChooser.set_transient_for(parent); fileChooser.show(); }); - fileChooser.connect('response', function(widget, response) { + fileChooser.connect('response', (widget, response) => { if (response !== Gtk.ResponseType.ACCEPT) { return; } @@ -144,12 +158,12 @@ function buildPrefsWidget() { marketEntry = Gtk.DropDown.new_from_strings(Utils.marketName); marketEntry.set_selected(Utils.markets.indexOf(settings.get_string('market'))); market_grid.attach(marketEntry, 1, 0, 1, 2); - marketEntry.connect('notify::selected-item', function() { + marketEntry.connect('notify::selected-item', () => { let id = marketEntry.get_selected(); settings.set_string('market', Utils.markets[id]); log('dropdown selected '+id+' = '+Utils.markets[id]+" - "+Utils.marketName[id]); }); - settings.connect('changed::market', function() { + settings.connect('changed::market', () => { Utils.validate_market(settings, marketDescription, lastreq); lastreq = GLib.DateTime.new_now_utc(); marketEntry.set_selected(Utils.markets.indexOf(settings.get_string('market'))); @@ -159,28 +173,27 @@ function buildPrefsWidget() { fileChooserBtn.set_filename(Utils.getWallpaperDir(settings)); log("fileChooser filename/dirname set to '"+fileChooserBtn.get_filename()+"' setting is '"+settings.get_string('download-folder')+"'"); fileChooserBtn.add_shortcut_folder_uri("file://" + GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)+"/BingWallpaper"); - fileChooserBtn.connect('file-set', function(widget) { + fileChooserBtn.connect('file-set', (widget) => { Utils.moveImagesToNewFolder(settings, settings.get_string('download-folder'), widget.get_filename()); settings.set_string('download-folder', widget.get_filename()); }); - Utils.markets.forEach(function (bingmarket, index) { // add markets to dropdown list (aka a GtkComboText) + Utils.markets.forEach((bingmarket, index) => { // add markets to dropdown list (aka a GtkComboText) marketEntry.append(bingmarket, bingmarket+": "+Utils.marketName[index]); }); - //marketEntry.set_active_id(settings.get_string('market')); // set to current settings.bind('market', marketEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT); - settings.connect('changed::market', function() { + settings.connect('changed::market', () => { Utils.validate_market(settings, marketDescription, lastreq); lastreq = GLib.DateTime.new_now_utc(); }); } // Resolution - Utils.resolutions.forEach(function (res) { // add res to dropdown list (aka a GtkComboText) + Utils.resolutions.forEach((res) => { // add res to dropdown list (aka a GtkComboText) resolutionEntry.append(res, res); }); settings.bind('resolution', resolutionEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT); - settings.connect('changed::resolution', function() { + settings.connect('changed::resolution', () => { Utils.validate_resolution(settings); }); @@ -188,44 +201,35 @@ function buildPrefsWidget() { let imageList = Utils.getImageList(settings); historyEntry.append('current', _('Most recent image')); historyEntry.append('random', _('Random image')); - imageList.forEach(function (image) { + imageList.forEach((image) => { 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() { + settings.connect('changed::selected-image', () => { Utils.validate_imagename(settings); }); - + + // background styles (e.g. zoom or span) + Utils.backgroundStyle.forEach((style) => { + styleEntry.append(style, style); + }); + desktop_settings.bind('picture-options', styleEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT); settings.bind('delete-previous', deleteSwitch, 'active', Gio.SettingsBindFlags.DEFAULT); - - if (Convenience.currentVersionGreaterEqual("3.36")) { - // lockscreen and desktop wallpaper are shared in GNOME 3.36+ - lsSwitch.set_sensitive(false); - buildable.get_object('lock_screen_listboxrow').set_tooltip_text(_("Disabled on current GNOME version")); - // GDM3 lockscreen blur override - 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) { - Utils.set_blur_preset(settings, Utils.PRESET_GNOME_DEFAULT); - }); - buttonnoblur.connect('clicked', function(widget) { - Utils.set_blur_preset(settings, Utils.PRESET_NO_BLUR); - }); - buttonslightblur.connect('clicked', function(widget) { - Utils.set_blur_preset(settings, Utils.PRESET_SLIGHT_BLUR); - }); - } else { - // older version of GNOME - buildable.get_object('lockscreen_box').set_tooltip_text(_("Disabled on current GNOME version")); - overrideSwitch.set_sensitive(false); - strengthEntry.set_sensitive(false); - brightnessEntry.set_sensitive(false); - buttonGDMdefault.set_sensitive(false); - buttonnoblur.set_sensitive(false); - buttonslightblur.set_sensitive(false); - } + + // GDM3 lockscreen blur override + 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', (widget) => { + Utils.set_blur_preset(settings, Utils.PRESET_GNOME_DEFAULT); + }); + buttonnoblur.connect('clicked', (widget) => { + Utils.set_blur_preset(settings, Utils.PRESET_NO_BLUR); + }); + buttonslightblur.connect('clicked', (widget) => { + Utils.set_blur_preset(settings, Utils.PRESET_SLIGHT_BLUR); + }); // not required in GTK4 as widgets are displayed by default if (Gtk.get_major_version() < 4) diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index c0a61471..fb1f3319 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 683a4a6a..8d99dd72 100644 --- a/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml +++ b/schemas/org.gnome.shell.extensions.bingwallpaper.gschema.xml @@ -63,12 +63,6 @@ Save disk space - - "" - Previous wallpapers - Used to delete wallpapers after a set number of days - - 8 Number of days to keep wallpapers @@ -150,5 +144,47 @@ Enables features which may or may not be unstable or untested in all cases + + true + Create thumbnails to speed up image gallery loading + Speeds up subsequent loads, but requires some additional disk space + + + + false + Save backup copy of Bing JSON to wallpaper directory + Enables migration to new install or restoration from back up + + + + diff --git a/screenshot/settings5.png b/screenshot/settings5.png index edfefe54..2277a7b4 100644 Binary files a/screenshot/settings5.png and b/screenshot/settings5.png differ diff --git a/ui/Settings.ui b/ui/Settings.ui index 377000e1..d1f0c474 100644 --- a/ui/Settings.ui +++ b/ui/Settings.ui @@ -151,7 +151,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll False end True - icons/bing-symbolic.svg + ../icons/bing-symbolic.svg 1 @@ -266,11 +266,11 @@ Bing Wallpaper GNOME extension by: Michael Carroll - + True True - + True False 12 @@ -279,10 +279,13 @@ Bing Wallpaper GNOME extension by: Michael Carroll 12 32 - + True False - Set lock screen image + start + True + Background style option + True 0 @@ -290,11 +293,9 @@ Bing Wallpaper GNOME extension by: Michael Carroll - + True - True - end - True + False 1 @@ -483,7 +484,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll 1 0 - 1 @@ -564,7 +564,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll 1 0 - 2 @@ -679,8 +678,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -743,8 +740,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -807,8 +802,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -1066,8 +1059,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -1129,8 +1120,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -1179,7 +1168,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll 1 0 - 2 @@ -1188,8 +1176,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 True True @@ -1250,6 +1236,185 @@ Bing Wallpaper GNOME extension by: Michael Carroll + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + start + True + Import Bing Wallpaper data + True + + + 0 + 0 + + + + + True + False + start + True + Import previously exported JSON data from wallpaper directory + + + + 0 + 1 + + + + + Import + True + True + True + + + 1 + 1 + + + + + + + + + + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + start + True + Export Bing Wallpaper data + True + + + 0 + 0 + + + + + True + False + start + True + Export JSON data to wallpaper dir for backup or data migration + + + + 0 + 1 + + + + + Export + True + True + True + + + 1 + 1 + + + + + + + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + start + True + Always export Bing data + True + + + 0 + 0 + + + + + True + False + start + True + Export Bing JSON whenever data changes + + + + 0 + 1 + + + + + True + True + end + + + 1 + 1 + + + + + + @@ -1289,7 +1454,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll True vertical 5 - + True @@ -1370,7 +1536,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll - https://github.com/neffo/bing-wallpaper-gnome-extension + https://github.com/neffo/bing-wallpaper-gnome-extension True False True diff --git a/ui/Settings4.ui b/ui/Settings4.ui index 6ca010ec..3829d075 100644 --- a/ui/Settings4.ui +++ b/ui/Settings4.ui @@ -148,7 +148,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll 0 end 1 - icons/bing-symbolic.svg + ../icons/bing-symbolic.svg 1 0 @@ -244,9 +244,10 @@ Bing Wallpaper GNOME extension by: Michael Carroll - + + 0 - + 0 12 12 @@ -254,9 +255,12 @@ Bing Wallpaper GNOME extension by: Michael Carroll 12 32 - + 0 - Set lock screen image + start + 1 + Background style option + 1 0 0 @@ -264,12 +268,11 @@ Bing Wallpaper GNOME extension by: Michael Carroll - - end - 1 + 1 0 + 1 @@ -418,7 +421,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll Select from image gallery 1 - 1 + 2 1 @@ -499,8 +502,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll - - + @@ -525,7 +527,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll 12 - 1 + 0 0 @@ -588,8 +590,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -645,8 +645,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -702,8 +700,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -725,28 +721,13 @@ Bing Wallpaper GNOME extension by: Michael Carroll - - - 0 - start - 1 - Commonly used presets - - - 0 - 1 - - - No blur, slight dim 1 - 1 - 1 + 0 + 2 @@ -756,7 +737,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll 1 1 - 0 + 2 @@ -765,7 +746,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll Slight blur, slight dim 1 - 1 + 2 2 @@ -808,7 +789,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll 12 - 1 + 0 0 @@ -871,8 +852,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -927,8 +906,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -1034,8 +1011,6 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 100 - 80 0 @@ -1089,6 +1064,171 @@ Bing Wallpaper GNOME extension by: Michael Carroll + + + + + 0 + 12 + 12 + 12 + 12 + 32 + + + 0 + start + 1 + Import Bing Wallpaper data + 1 + + 0 + 0 + + + + + + 0 + start + 1 + Import previously exported JSON data from wallpaper directory + + + 0 + 1 + + + + + + Import + 1 + + 1 + 1 + + + + + + + + + + + + + + + 0 + 12 + 12 + 12 + 12 + 32 + + + 0 + start + 1 + Export Bing Wallpaper data + 1 + + 0 + 0 + + + + + + 0 + start + 1 + Export JSON data to wallpaper dir for backup or data migration + + + 0 + 1 + + + + + + Export + 1 + + 1 + 1 + + + + + + + + + + + + + + + 0 + 12 + 12 + 12 + 12 + 32 + + + 0 + start + 1 + Always export Bing data + 1 + + 0 + 0 + + + + + + 0 + start + 1 + Export Bing JSON whenever data changes + + + + 0 + 1 + + + + + + end + + 1 + 1 + + + + + + + + + + @@ -1149,16 +1289,14 @@ Bing Wallpaper GNOME extension by: Michael Carroll center 12 - - 0 + 0 end - Gnome shell extension version + GNOME shell extension version - 0 0 start ... @@ -1168,7 +1306,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll - https://github.com/neffo/bing-wallpaper-gnome-extension + https://github.com/neffo/bing-wallpaper-gnome-extension 0 1 center @@ -1183,14 +1321,12 @@ Bing Wallpaper GNOME extension by: Michael Carroll 5 - 0 0 Maintained by Michael Carroll - 0 0 ineffable@gmail.com 1 @@ -1235,7 +1371,7 @@ Bing Wallpaper GNOME extension by: Michael Carroll - 1 + 0 0 end <span size="small">This program comes with ABSOLUTELY NO WARRANTY. diff --git a/ui/carousel.ui b/ui/carousel.ui index c8f4dfb5..9f251155 100644 --- a/ui/carousel.ui +++ b/ui/carousel.ui @@ -67,7 +67,7 @@ Author: Michael Carroll 0 0 - 2 + 4 @@ -79,7 +79,7 @@ Author: Michael Carroll 0 1 - 2 + 4 @@ -94,6 +94,30 @@ Author: Michael Carroll 2 + + + View + True + True + True + + + 1 + 2 + + + + + Info + True + True + True + + + 2 + 2 + + Delete @@ -102,7 +126,7 @@ Author: Michael Carroll True - 1 + 3 2 diff --git a/ui/carousel4.ui b/ui/carousel4.ui index 06165928..a07a2f7e 100644 --- a/ui/carousel4.ui +++ b/ui/carousel4.ui @@ -56,7 +56,7 @@ Author: Michael Carroll 0 0 - 2 + 4 @@ -65,9 +65,10 @@ Author: Michael Carroll 0 <image name here> + 0 1 - 2 + 4 @@ -83,6 +84,30 @@ Author: Michael Carroll + + + View + 1 + 0 + center + + 1 + 2 + + + + + + Info + 1 + 0 + center + + 2 + 2 + + + Delete @@ -90,7 +115,7 @@ Author: Michael Carroll 0 center - 1 + 3 2 diff --git a/utils.js b/utils.js index f68a36f5..02dde854 100644 --- a/utils.js +++ b/utils.js @@ -16,11 +16,13 @@ const Config = imports.misc.config; const Convenience = Me.imports.convenience; const Gettext = imports.gettext.domain('BingWallpaper'); const _ = Gettext.gettext; +const ByteArray = imports.byteArray; var PRESET_GNOME_DEFAULT = { blur: 60, dim: 55 }; // as at GNOME 40 var PRESET_NO_BLUR = { blur: 0, dim: 60 }; var PRESET_SLIGHT_BLUR = { blur: 2, dim: 60 }; +var BING_SCHEMA = 'org.gnome.shell.extensions.bingwallpaper'; var DESKTOP_SCHEMA = 'org.gnome.desktop.background'; var LOCKSCREEN_SCHEMA = 'org.gnome.desktop.screensaver'; @@ -31,11 +33,12 @@ var shellVersionPoint = parseInt(imports.misc.config.PACKAGE_VERSION.split('.')[ var vertical_blur = null; var horizontal_blur = null; -let debug = true; +let gitreleaseurl = 'https://api.github.com/repos/neffo/bing-wallpaper-gnome-extension/releases/tags/'; +let debug = false; // 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']; @@ -46,59 +49,30 @@ var markets = ['auto', 'ar-XA', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'en-AU', 'en '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 = [ - "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)", - "українська (Україна)", "中文(中国)", "中文(中國香港特別行政區)", "中文(台灣)" + '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 backgroundStyle = ['none', 'wallpaper', 'centered', 'scaled', 'stretched', 'zoom', 'spanned']; var randomIntervals = [300, 3600, 86400]; var randomIntervalsTitle = ['00:05:00', '01:00:00', '24:00:00']; -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 ' + - extension.metadata.uuid + '. Please check your installation.'); - } - - return new Gio.Settings({settings_schema: schemaObj}); -} +var BingImageURL = 'https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=8&mbl=1&mkt='; 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) { + if (icon_name == '' || icon_list.indexOf(icon_name) == -1) { settings.reset('icon-name'); icon_name = settings.get_string('icon-name'); } @@ -112,7 +86,7 @@ function validate_icon(settings, icon_image = null) { function validate_resolution(settings) { let resolution = settings.get_string('resolution'); - if (resolution == "" || resolutions.indexOf(resolution) == -1) // if not a valid resolution + if (resolution == '' || resolutions.indexOf(resolution) == -1) // if not a valid resolution settings.reset('resolution'); } @@ -124,12 +98,13 @@ function validate_imagename(settings) { if (!inImageList(getImageList(settings), filename)) { log('invalid image selected'); //settings.reset('selected-image'); + settings.set_string('selected-image', 'current'); } } function validate_market(settings, marketDescription = null, lastreq = null, httpSession) { let market = settings.get_string('market'); - if (market == "" || markets.indexOf(market) == -1) { // if not a valid market + if (market == '' || markets.indexOf(market) == -1) { // if not a valid market settings.reset('market'); } // only run this check if called from prefs @@ -170,8 +145,6 @@ function get_current_bg(schema) { return (cur); } -let gitreleaseurl = 'https://api.github.com/repos/neffo/bing-wallpaper-gnome-extension/releases/tags/'; - function fetch_change_log(version, label, httpSession) { // create an http message let url = gitreleaseurl + "v" + version; @@ -203,7 +176,7 @@ function is_x11() { } function enabled_unsafe() { - log("User override, enabling unsafe Wayland functionality"); + //log("User override, enabling unsafe Wayland functionality"); return true; } @@ -248,7 +221,7 @@ function setImageList(settings, 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) { @@ -306,7 +279,7 @@ function mergeImageLists(settings, imageList) { newList.unshift(x); } }); - setImageList(settings, curList); + setImageList(settings, imageListSortByDate(curList)); // sort then save back to settings return newList; // return this to caller for notifications } @@ -342,7 +315,7 @@ 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/"; + BingWallpaperDir = userPicturesDir + '/BingWallpaper/'; settings.set_string('download-folder', BingWallpaperDir); } else if (!BingWallpaperDir.endsWith('/')) { @@ -359,20 +332,25 @@ function getWallpaperDir(settings) { function imageToFilename(settings, image, resolution = null) { return getWallpaperDir(settings) + image.startdate + '-' + - image.urlbase.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '') + "_" - + (resolution ? resolution : getResolution(settings, image)) + ".jpg"; + image.urlbase.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '') + '_' + + (resolution ? resolution : getResolution(settings, image)) + '.jpg'; } function getRandomInt(max) { return Math.floor(Math.random() * max); } -function dump(object) { +// Utility function +function dump(object, level = 0) { let output = ''; for (let property in object) { - output += property + ': ' + object[property] + '; '; + output += ' - '.repeat(level)+property + ': ' + object[property]+'\n '; + if ( typeof object[property] === 'object' ) + output += dump(object[property], level+1); } - log(output); + if (level == 0) + log(output); + return(output); } function friendly_time_diff(time, short = true) { @@ -401,9 +379,9 @@ function friendly_time_diff(time, short = true) { 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 - settings.get_string('resolution') == "auto" ) { + settings.get_string('resolution') == 'auto' ) { // resolution invalid, animated background or autoselected - resolution = "UHD"; + resolution = 'UHD'; } return resolution; } @@ -428,11 +406,10 @@ function shortenName(string, limit) { } 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 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); @@ -444,7 +421,7 @@ function moveImagesToNewFolder(settings, oldPath, newPath) { 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"); }); + cur.move(dest, Gio.FileCopyFlags.OVERWRITE, null, function () { log ('...moved'); }); } } // fix filenames in previous queue @@ -452,7 +429,7 @@ function moveImagesToNewFolder(settings, 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")) + if (settings.get_boolean('set-lock-screen') && Convenience.currentVersionSmaller('3.36')) moveBackground(oldPath, newPath, LOCKSCREEN_SCHEMA); } @@ -492,8 +469,69 @@ function deleteImage(to_delete) { } } -function openInSystemViewer(filename) { - const context = global.create_app_launch_context(0, -1); - Gio.AppInfo.launch_default_for_uri('file://' + filename, context); +// add image to persistant list so we can delete it later (in chronological order), delete the oldest image (if user wants this) +function purgeImages(settings) { + let deletepictures = settings.get_boolean('delete-previous'); + if (deletepictures === false) + return; + let imagelist = imageListSortByDate(getImageList(settings)); + let maxpictures = settings.get_int('previous-days'); + let origlength = imagelist.length; + while (imagelist.length > maxpictures) { + var to_delete = imagelist.shift(); // get the first (oldest item from the list) + if (deletepictures && to_delete != '') { + let imageFilename = imageToFilename(settings, to_delete); + log('deleting '+imageFilename); + deleteImage(imageFilename); + } + } + log('cleaned up image list, count was '+origlength+' now '+imagelist.length); + cleanupImageList(settings); + validate_imagename(settings); // if we deleted our current image, we want to reset it to something valid +} + +function openInSystemViewer(filename, is_file = true) { + let context; + try { + context = global.create_app_launch_context(0, -1); + } + catch (error) { + context = null; + } + if (is_file) + filename = 'file://'+filename; + Gio.AppInfo.launch_default_for_uri(filename, context); +} + +function exportBingJSON(settings) { + let json = settings.get_string('bing-json'); + let filepath = getWallpaperDir(settings) + 'bing.json'; + let file = Gio.file_new_for_path(filepath); + let [success, error] = file.replace_contents(json, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null); + if (!success) { + log('error saving bing-json from '+filepath+': '+error); + } +} + +function importBingJSON(settings) { + + let filepath = getWallpaperDir(settings) + 'bing.json'; + let file = Gio.file_new_for_path(filepath); + if (file.query_exists(null)) { + let [success, contents, etag_out] = file.load_contents(null); + if (!success) { + log('error loading bing-json '+filepath+' - '+etag_out); + } + else { + log('JSON import success'); + let parsed = JSON.parse(ByteArray.toString(contents)); // FIXME: triggers GJS warning without the conversion, need to investigate + // need to implement some checks for validity here + mergeImageLists(settings, parsed); + cleanupImageList(settings); // remove the older missing images + } + } + else { + log('JSON import file not found'); + } } \ No newline at end of file