diff --git a/blur.js b/blur.js index 7f950713..fcf090b4 100644 --- a/blur.js +++ b/blur.js @@ -10,17 +10,11 @@ // and https://github.com/sunwxg/gnome-shell-extension-unlockDialogBackground import St from 'gi://St'; -import Shell from 'gi://Shell'; -import * as Main from 'resource:///org/gnome/shell/ui/main.js'; -import * as Background from 'resource:///org/gnome/shell/ui/background.js'; -import * as ScreenShield from 'resource:///org/gnome/shell/ui/screenShield.js'; import * as UnlockDialog from 'resource:///org/gnome/shell/ui/unlockDialog.js'; import * as Config from 'resource:///org/gnome/shell/misc/config.js'; -import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; var _updateBackgroundEffects = UnlockDialog.UnlockDialog.prototype._updateBackgroundEffects; var _showClock = UnlockDialog.UnlockDialog.prototype._showClock; var _showPrompt = UnlockDialog.UnlockDialog.prototype._showPrompt; -import * as Utils from './utils.js'; var shellVersionMajor = parseInt(Config.PACKAGE_VERSION.split('.')[0]); var shellVersionMinor = parseInt(Config.PACKAGE_VERSION.split('.')[1]); diff --git a/buildzip.sh b/buildzip.sh index a4b9085e..f5e88b60 100755 --- a/buildzip.sh +++ b/buildzip.sh @@ -7,7 +7,7 @@ glib-compile-schemas schemas/ intltool-extract --type=gettext/glade ui/Settings4.ui intltool-extract --type=gettext/glade ui/carousel4.ui -xgettext -k -k_ -kN_ --omit-header -o locale/BingWallpaper.pot ui/Settings4.ui.h ui/carousel4.ui.h ui/intervals.utils.js.h extension.js prefs.js blur.js utils.js convenience.js --from-code=UTF-8 +xgettext -k -k_ -kN_ --omit-header -o locale/BingWallpaper.pot ui/Settings4.ui.h ui/carousel4.ui.h ui/intervals.utils.js.h extension.js prefs.js blur.js utils.js --from-code=UTF-8 DATE=`date +"%F"` echo "# Translation status of statements as at $DATE:" > translations.txt diff --git a/carousel.js b/carousel.js index d7092498..3685ea7b 100644 --- a/carousel.js +++ b/carousel.js @@ -8,12 +8,10 @@ // Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod import Gtk from 'gi://Gtk'; -import Gdk from 'gi://Gdk'; import GdkPixbuf from 'gi://GdkPixbuf'; import Gio from 'gi://Gio'; -import GLib from 'gi://GLib'; import * as Utils from './utils.js'; -import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; +import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; const default_dimensions = [30, 30, 1650, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok @@ -21,7 +19,7 @@ const GALLERY_THUMB_WIDTH = 320; const GALLERY_THUMB_HEIGHT = 180; export default class Carousel { - constructor(settings, button = null, callbackfunc = null, prefs_flowbox = null) { + constructor(settings, button = null, callbackfunc = null, prefs_flowbox = null, extensionPath = null) { //create_gallery(widget, settings); this.settings = settings; this.button = button; @@ -30,27 +28,12 @@ export default class Carousel { this.window = null; this.imageList = Utils.imageListSortByDate(Utils.getImageList(this.settings)).reverse(); // get images and reverse order this.searchEntry = null; - this.extensionPath = ExtensionPreferences.lookupByUUID('BingWallpaper@ineffable-gmail.com').path + this.extensionPath = extensionPath this.log('create carousel...'); - if (!prefs_flowbox) { - [this.window, this.flowBox] = this._create_gallery_window(_('Bing Wallpaper Gallery'), default_dimensions); - if (Gtk.get_major_version() < 4) - this.window.show_all(); - else - this.window.show(); - //this.window.connect('destroy', this._enable_button); - } - else { - this.flowBox = prefs_flowbox; - } - if (Gtk.get_major_version() < 4) { - this._create_gallery(); - } - else { - this.flowBox.insert(this._create_placeholder_item(), -1); - } + this.flowBox = prefs_flowbox; + this.flowBox.insert(this._create_placeholder_item(), -1); } _enable_button() { @@ -59,20 +42,6 @@ export default class Carousel { } } - _create_gallery_window(title, dimensions) { - let buildable = new Gtk.Builder(); - let win = new Gtk.Window(); - let flowBox; - - win.set_default_size(dimensions[2], dimensions[3]); - win.set_title(title); - - buildable.add_objects_from_file(this.extensionPath + '/ui/carousel4.ui', ['carouselViewPort']); - flowBox = buildable.get_object('carouselFlowBox'); - win.set_child(buildable.get_object('carouselScrollable')); - return [win, flowBox]; - } - _create_gallery() { Utils.randomIntervals.forEach((x) => { let item = this._create_random_item(x.value, _(x.title)); diff --git a/convenience.js b/convenience.js deleted file mode 100644 index bcb6f4d3..00000000 --- a/convenience.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* - Copyright (c) 2011-2012, Giovanni Campagna - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the GNOME nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - -const versionArray = (v) => v.split(".").map(Number); - -const zip = function(a, b, defaultValue) { - if (a.length === 0 && b.length === 0) { - return []; - } - const headA = (a.length > 0) ? a.shift() : defaultValue; - const headB = (b.length > 0) ? b.shift() : defaultValue; - return [[headA, headB]].concat(zip(a, b, defaultValue)); -}; - -function versionEqual(a, b) { - return zip(versionArray(a), versionArray(b), 0).reduce( - (prev, [a, b]) => prev && (a === b) - , true); -} - -export function versionGreater(a, b) { - const diff = zip(versionArray(a), versionArray(b), 0).find(([a, b]) => a !== b); - if (!diff) { - return false; - } - const [x, y] = diff; - return x > y; -} - -export function versionGreaterEqual(a,b) { - return versionEqual(a, b) || versionGreater(a, b); -} - -function versionSmaller(a, b) { - return (!versionEqual(a, b)) && (!versionGreater(a, b)); -} \ No newline at end of file diff --git a/extension.js b/extension.js index 7e7c58ed..9164ffe5 100644 --- a/extension.js +++ b/extension.js @@ -14,22 +14,18 @@ import GObject from 'gi://GObject'; import GLib from 'gi://GLib'; import Clutter from 'gi://Clutter'; import Cogl from 'gi://Cogl'; -import Gdk from 'gi://Gdk'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; -import * as Util from 'resource:///org/gnome/shell/misc/util.js'; import {Button} from 'resource:///org/gnome/shell/ui/panelMenu.js'; import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js'; import * as Config from 'resource:///org/gnome/shell/misc/config.js'; -const ByteArray = imports.byteArray; import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; import * as Utils from './utils.js'; import Blur from './blur.js'; import Thumbnail from './thumbnail.js'; import BWClipboard from './BWClipboard.js'; -import * as Convenience from './convenience.js'; const BingImageURL = Utils.BingImageURL; const BingURL = 'https://www.bing.com'; @@ -1017,14 +1013,6 @@ export default class BingWallpaperExtension extends Extension { bingWallpaperIndicator.stop(); bingWallpaperIndicator.destroy(); bingWallpaperIndicator = null; - - // *** NOTE for EGO reviewers *** - // blur.js remains active during lockscreen, while the rest of the extension is disabled - // this code ONLY modifies the background blur effects for the lockscreen no web connectivity - if (!Main.sessionMode.isLocked) { - blur._disable(); // disable blur (blur.js) override and cleanup - blur = null; - } } } diff --git a/locale/de/LC_MESSAGES/BingWallpaper.mo b/locale/de/LC_MESSAGES/BingWallpaper.mo index c6402e25..88428849 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 10117b1e..6ebae71d 100644 --- a/locale/de/LC_MESSAGES/BingWallpaper.po +++ b/locale/de/LC_MESSAGES/BingWallpaper.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-12-14 18:32+1000\n" -"PO-Revision-Date: 2023-10-22 10:31+0200\n" +"PO-Revision-Date: 2023-10-23 08:47+0200\n" "Last-Translator: Sebastian Kessler\n" "Language-Team: \n" "Language: de\n" @@ -325,7 +325,7 @@ msgstr "Shuffle-Modus für Bilder" #: extension.js:162 msgid "Image shuffle only favourites" -msgstr "Shuffle-Modus nur Bilder" +msgstr "Shuffle-Modus nur Favoriten" #: extension.js:164 msgid "Show image count" diff --git a/metadata.json b/metadata.json index f1dd9e35..cf2d7374 100644 --- a/metadata.json +++ b/metadata.json @@ -4,7 +4,7 @@ "name": "Bing Wallpaper", "settings-schema": "org.gnome.shell.extensions.bingwallpaper", "description": "Sync 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\nFeatures:\n* UHD resolution wallpapers\n* Automatically fetches current Bing wallpaper of the day and sets as both lock screen and desktop wallpaper (user selectable on GNOME versions that support it)\n* Doesn't poll continuously - only once per day and on startup (schedules a refresh when Bing is due to update)\n * random mode (from previously downloaded wallpapers)\n *NEW: select/cycle wallpaper through previously downloaded images\n* Language support: English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN, zh_TW), French (fr), Portuguese (pt), Ukrainian (uk), Russian (ru_RU), Spanish (es), Korean (ko), 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\n\nThis extension was forked from 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\nAlways restart GNOME after manually updating extensions. Please report bugs to the GitHub page below:", - "version": "46", + "version": "47", "url": "https://github.com/neffo/bing-wallpaper-gnome-extension", "gettext-domain": "BingWallpaper" } diff --git a/prefs.js b/prefs.js index 7957d3cb..a23424b1 100644 --- a/prefs.js +++ b/prefs.js @@ -9,15 +9,12 @@ import Gtk from 'gi://Gtk'; import Gdk from 'gi://Gdk'; -import GdkPixbuf from 'gi://GdkPixbuf'; import Gio from 'gi://Gio'; -import GLib from 'gi://GLib'; import Soup from 'gi://Soup'; import Adw from 'gi://Adw'; import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js'; import * as Utils from './utils.js'; -import * as Convenience from './convenience.js'; import Carousel from './carousel.js'; const BingImageURL = Utils.BingImageURL; @@ -137,7 +134,7 @@ export default class BingWallpaperExtensionPreferences extends ExtensionPreferen }); // we populate the tab (gtk4+, gnome 40+), this was previously a button to open a new window in gtk3 - carousel = new Carousel(settings, null, null, carouselFlowBox); // auto load carousel + carousel = new Carousel(settings, null, null, carouselFlowBox, this.dir.get_path()); // auto load carousel // this is intended for migrating image folders between computers (or even sharing) or backups // we export the Bing JSON data to the image directory, so this folder becomes portable diff --git a/utils.js b/utils.js index 1d51723a..b2c8d91e 100644 --- a/utils.js +++ b/utils.js @@ -11,8 +11,6 @@ import Gio from 'gi://Gio'; import GLib from 'gi://GLib'; import Soup from 'gi://Soup'; import GdkPixbuf from 'gi://GdkPixbuf'; -import * as Convenience from './convenience.js'; -//import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; export var PRESET_GNOME_DEFAULT = { blur: 60, dim: 55 }; // as at GNOME 40 export var PRESET_NO_BLUR = { blur: 0, dim: 60 }; @@ -137,10 +135,6 @@ export function set_blur_preset(settings, preset) { BingLog("Set blur preset to " + preset.blur + " brightness to " + preset.dim); } -export function is_x11(settings) { - return settings.get_boolean('override-unsafe-wayland') || GLib.getenv('XDG_SESSION_TYPE') == 'x11'; // don't do wayland unsafe things if set -} - export function imageHasBasename(image_item, i, b) { //log("imageHasBasename : " + image_item.urlbase + " =? " + this); if (this && this.search(image_item.urlbase.replace('th?id=OHR.', ''))) @@ -196,7 +190,6 @@ export function setImageList(settings, imageList) { } export function setImageHiddenStatus(settings, hide_image_list, hide_status) { - // stub // get current image list let image_list = getImageList(settings); image_list.forEach( (x, i) => { @@ -255,21 +248,6 @@ export function getCurrentImage(imageList) { return imageList[index]; } -function getFetchableImageList(settings) { - let imageList = getImageList(settings); - let cutOff = GLib.DateTime.new_now_utc().add_days(-8); // 8 days ago - let dlList = []; - imageList.forEach( function (x, i) { - let diff = dateFromLongDate(x.fullstartdate, 0).difference(cutOff); - let filename = imageToFilename(settings, x); - // image is still downloadable (< 8 days old) but not on disk - if (diff > 0 && !Gio.file_new_for_path(filename).query_exists(null)) { - dlList.push(x); - } - }); - return dlList; -} - export function inImageList(imageList, urlbase) { let image = null; imageList.forEach(function(x, i) { @@ -423,7 +401,7 @@ export function friendly_time_diff(time, short = true) { } } -function seconds_until(until) { +export function seconds_until(until) { let now = GLib.DateTime.new_now_local(); let end, day; if (until == 'hourly') {