Load Gtk.Image from resource in GJS

752 views Asked by At

I am trying to load a Gtk.Image from a resource but I can't figure it out what I am doing wrong.

I have the png in my gresource.xml

<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/com/mydomain/MyApp">
    <file preprocess="xml-stripblanks">app-menu.ui</file>
    <file preprocess="xml-stripblanks">main.ui</file>
    <file>application.css</file>
    <file>logo.svg.png</file>
  </gresource>
</gresources>

And I am trying to load that png like this:

let imgWidget = new Gtk.Image();
imgWidget.set_from_resource('resource:///com/mydomain/MyApp/logo.svg.png');

But I always get a broken image.

1

There are 1 answers

0
codiaf On BEST ANSWER

As niyasc pointed out, I had to remove the resource:// prefix