[polari] urlPreview: Explicitly load pixbuf
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] urlPreview: Explicitly load pixbuf
- Date: Fri, 3 Sep 2021 09:45:13 +0000 (UTC)
commit 4e52e1e6f8e156a30db52d767c98efaeb2402e99
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Aug 25 00:32:25 2021 +0200
urlPreview: Explicitly load pixbuf
We currently let GtkImage load the thumbnail file, then access its
:pixbuf property to look up the tEXt::Title attribute.
In GTK4 GtkImage is no longer backed by a pixbuf, so this will stop
working. Instead, load the pixbuf and set the image from that.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/225>
src/urlPreview.js | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/urlPreview.js b/src/urlPreview.js
index a673f519..328d3f03 100644
--- a/src/urlPreview.js
+++ b/src/urlPreview.js
@@ -1,3 +1,4 @@
+import GdkPixbuf from 'gi://GdkPixbuf';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
@@ -157,9 +158,13 @@ export default GObject.registerClass({
});
const thumbnailer = Thumbnailer.getDefault();
+ let title;
try {
const filename = await thumbnailer.getThumbnail(this.uri);
- this._image.set_from_file(filename);
+ const pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename);
+
+ title = pixbuf.get_option('tEXt::Title');
+ this._image.set_from_pixbuf(pixbuf);
this._image.get_style_context().remove_class('dim-label');
} catch (e) {
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NETWORK_UNREACHABLE)) {
@@ -174,10 +179,6 @@ export default GObject.registerClass({
});
}
- let title = null;
- if (this._image.pixbuf)
- title = this._image.pixbuf.get_option('tEXt::Title');
-
if (title) {
this._label.set_label(title);
this.tooltip_text = title;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]