Philipp Hörist pushed to branch gtk4 at gajim / gajim
Commits:
83d64c13 by Philipp Hörist at 2024-11-02T21:32:39+01:00
fix: Fix transport icons
- - - - -
1 changed file:
- gajim/gtk/util.py
Changes:
=====================================
gajim/gtk/util.py
=====================================
@@ -8,6 +8,7 @@
from __future__ import annotations
from typing import Any
+from typing import cast
import datetime
import logging
@@ -25,6 +26,7 @@
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
+from gi.repository import Gsk
from gi.repository import Gtk
from gi.repository import GtkSource
from gi.repository import Pango
@@ -86,17 +88,24 @@ def load_icon_surface(
icon = icon_theme.lookup_icon(
icon_name, None, size, scale, Gtk.TextDirection.NONE, 0) # pyright:
ignore
- surface = cairo.ImageSurface(cairo.Format.ARGB32, size, size)
- surface.set_device_scale(scale, scale)
-
- context = cairo.Context(surface)
-
snapshot = Gtk.Snapshot()
icon.snapshot(snapshot, size, size)
- node = snapshot.to_node()
+ node = cast(Gsk.TextureNode, snapshot.to_node())
assert node is not None
- node.draw(context)
- context.paint()
+
+ texture = node.get_texture()
+ downloader = Gdk.TextureDownloader.new(texture)
+ gbytes, stride = downloader.download_bytes()
+ bytes_ = gbytes.get_data()
+ assert bytes_ is not None
+ array = bytearray(bytes_)
+
+ surface = cairo.ImageSurface.create_for_data(
+ array, # pyright: ignore
+ cairo.Format.ARGB32,
+ texture.get_width(),
+ texture.get_height(),
+ stride)
return surface
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/83d64c137d9cf7f7ac3c3f3ea8ee4b491110b5f1
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/83d64c137d9cf7f7ac3c3f3ea8ee4b491110b5f1
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]