Philipp Hörist pushed to branch gtk4 at gajim / gajim


Commits:
1bf553de by Philipp Hörist at 2024-11-02T21:40:53+01:00
refactor: Add conversion method

- - - - -


1 changed file:

- gajim/gtk/util.py


Changes:

=====================================
gajim/gtk/util.py
=====================================
@@ -94,20 +94,7 @@ def load_icon_surface(
     assert node is not None
 
     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
+    return convert_texture_to_surface(texture)
 
 
 def get_status_icon_name(name: str) -> str:
@@ -885,6 +872,22 @@ def convert_surface_to_texture(surface: 
cairo.ImageSurface) -> Gdk.Texture:
     )
 
 
+def convert_texture_to_surface(texture: Gdk.Texture) -> cairo.ImageSurface:
+    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
+
+
 def convert_py_to_glib_datetime(dt: datetime.datetime | datetime.date) -> 
GLib.DateTime:
     if type(dt) is datetime.date:
         dt = datetime.datetime(



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/1bf553de933d61440075dc4be0badbc29a3a64eb

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/1bf553de933d61440075dc4be0badbc29a3a64eb
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]

Reply via email to