How to go about loading an image from the internet using Gtk3 with javascript?
I tried using
var image = new Image();
image.src(url);
But this gives an error -> JS ERROR: ReferenceError: Image is not defined
Any helps?
Thanks.
//Update Since their was not enough information available above, I`ll post it down here ->
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
let app = new Gtk.Application({ application_id: 'org.gtk.ExampleApp' });
app.connect("activate", ()=>{
let win = new Gtk.Window({application : app});
let img = new Gtk.Image();
let url = 'https://spotlightreport.net/wp-content/uploads/2020/10/AC-DC-SHOT-IN-THE-DARK-PACK-SHOT-1920x1920.jpg';
let input_stream = Gio.MemoryInputStream.new_from_data(url, null);
let pixbuf = Gdk.GdkPixbuf.Pixbuf.new_from_stream(input_stream);
img.set_from_pixbuf(pixbuf);
win.connect('destroy', ()=>{win.close();});
win.set_default_size(450,250);
win.show_all();
});
app.run([]);
I actually want to load the image from url directly i.e. without downloading it. And i came across a post to fetch data using javascript functions but it didn`t work. How do i fetch the image and show it? I actually tried to do this -> Post