Skip to content

Commit 10f56b3

Browse files
committed
port: HTTP Image
1 parent 10990d0 commit 10f56b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/HTTP Image/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import GLib from "gi://GLib";
22
import Gdk from "gi://Gdk?version=4.0";
33
import Gio from "gi://Gio";
4+
import Gtk from "gi://Gtk?version=4.0";
45
import Soup from "gi://Soup";
56

67
// https://picsum.photos/
@@ -14,19 +15,20 @@ Gio._promisify(
1415

1516
const image_bytes = await getImageBytes(IMAGE_URL);
1617
const texture = Gdk.Texture.new_from_bytes(image_bytes);
17-
workbench.builder.get_object("picture").set_paintable(texture);
18+
workbench.builder.get_object<Gtk.Picture>("picture").set_paintable(texture);
1819

1920
async function getImageBytes(url) {
2021
const session = new Soup.Session();
2122
const message = new Soup.Message({
2223
method: "GET",
2324
uri: GLib.Uri.parse(url, GLib.UriFlags.NONE),
2425
});
26+
// @ts-expect-error undetected async function
2527
const bytes = await session.send_and_read_async(
2628
message,
2729
GLib.PRIORITY_DEFAULT,
2830
null,
29-
);
31+
) as GLib.Bytes;
3032
const status = message.get_status();
3133
if (status !== Soup.Status.OK) {
3234
throw new Error(`Got ${status}, ${message.reason_phrase}`);

0 commit comments

Comments
 (0)