From f12d6cf11cb4b1876774456e28663516e7f3298d Mon Sep 17 00:00:00 2001 From: Julien Pinsonneau Date: Fri, 13 Jun 2025 10:01:56 +0200 Subject: [PATCH 1/2] gnome 48 support --- src/historyMenuElements.ts | 2 +- src/metadata.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/historyMenuElements.ts b/src/historyMenuElements.ts index 20781ec..a2f1877 100644 --- a/src/historyMenuElements.ts +++ b/src/historyMenuElements.ts @@ -82,7 +82,7 @@ class PreviewWidget extends St.Bin { const height = pixbuf.get_height(); const width = pixbuf.get_width(); - const image = new Clutter.Image(); + const image = new St.ImageContent(); const pixelFormat = pixbuf.get_has_alpha() ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888; image.set_data( pixbuf.get_pixels(), diff --git a/src/metadata.json b/src/metadata.json index 2e4bc29..b643aa7 100644 --- a/src/metadata.json +++ b/src/metadata.json @@ -1,5 +1,5 @@ { - "shell-version": [ "45", "46", "47" ], + "shell-version": [ "45", "46", "47", "48" ], "uuid": "randomwallpaper@iflow.space", "settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper", "name": "Random Wallpaper", From 51cab9f7cdb809a8e4f44592f179b6912b2eeb19 Mon Sep 17 00:00:00 2001 From: Julien Pinsonneau Date: Mon, 30 Jun 2025 09:40:13 +0200 Subject: [PATCH 2/2] hide preview for gnome 48+ --- src/historyMenuElements.ts | 2 +- src/randomWallpaperMenu.ts | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/historyMenuElements.ts b/src/historyMenuElements.ts index a2f1877..f1f77fe 100644 --- a/src/historyMenuElements.ts +++ b/src/historyMenuElements.ts @@ -74,7 +74,7 @@ class PreviewWidget extends St.Bin { * @param {string} path Path to the image to preview */ preview(path: string | null): void { - if (!path) + if (!path || MAJOR >= 48) return; try { diff --git a/src/randomWallpaperMenu.ts b/src/randomWallpaperMenu.ts index 303e8bc..8311e25 100644 --- a/src/randomWallpaperMenu.ts +++ b/src/randomWallpaperMenu.ts @@ -20,6 +20,9 @@ import {Logger} from './logger.js'; import {WallpaperController} from './wallpaperController.js'; import {HistoryEntry} from './history.js'; +import * as Config from 'resource:///org/gnome/shell/misc/config.js'; +const [MAJOR, unused_MINOR] = Config.PACKAGE_VERSION.split('.').map(s => Number(s)); + /** * PanelMenu for this extension. */ @@ -35,7 +38,7 @@ class RandomWallpaperMenu { private previewSection = new PopupMenu.PopupMenuSection(); private previewSeparator = new PopupMenu.PopupSeparatorMenuItem(); - private previewWidget: CustomElements.PreviewWidget; + private previewWidget: CustomElements.PreviewWidget | undefined; /** * Create a new PanelMenu. @@ -62,10 +65,13 @@ class RandomWallpaperMenu { this._panelMenu.menu.actor.set_width(350); // Preview widget showing the current wallpaper - this._panelMenu.menu.addMenuItem(this.previewSection); - this.previewWidget = new CustomElements.PreviewWidget(this._panelMenu.menu.actor.width); - this.previewSection.actor.add_child(this.previewWidget); - this._panelMenu.menu.addMenuItem(this.previewSeparator); + // only supported on previous shell versions due to girs breaking changes + if (MAJOR < 48) { + this._panelMenu.menu.addMenuItem(this.previewSection); + this.previewWidget = new CustomElements.PreviewWidget(this._panelMenu.menu.actor.width); + this.previewSection.actor.add_child(this.previewWidget); + this._panelMenu.menu.addMenuItem(this.previewSeparator); + } // history section this._historySection = new CustomElements.HistorySection(); @@ -218,7 +224,7 @@ class RandomWallpaperMenu { */ const onLeave = (_entry: HistoryEntry): void => { if (history.length > 0) - this.previewWidget.preview(history[0].path); + this.previewWidget?.preview(history[0].path); this._wallpaperController.resetPreview(); }; @@ -229,7 +235,7 @@ class RandomWallpaperMenu { * @param {HistoryEntry} entry The hovered/focused history entry */ const onEnter = (entry: HistoryEntry): void => { - this.previewWidget.preview(entry.path); + this.previewWidget?.preview(entry.path); this._wallpaperController.previewWallpaper(entry.id); }; @@ -250,8 +256,8 @@ class RandomWallpaperMenu { this._historySection.updateList(history, onEnter, onLeave, onSelect); - this.previewWidget.preview(history[0].path); - this.previewWidget.show(); + this.previewWidget?.preview(history[0].path); + this.previewWidget?.show(); this.previewSeparator.show(); } @@ -259,7 +265,7 @@ class RandomWallpaperMenu { * Remove the history section */ clearHistoryList(): void { - this.previewWidget.hide(); + this.previewWidget?.hide(); this.previewSeparator.hide(); this._historySection.clear(); }