spk121 / guile-gi

Bindings for GObject Introspection and libgirepository for Guile
GNU General Public License v3.0
58 stars 7 forks source link

icon-theme:get-default how to use? <Help> #124

Closed zedth2 closed 2 years ago

zedth2 commented 2 years ago

When I try to run icon-theme:get-default I get an error message.

scheme@(guile-user)> (icon-theme:get-default)

(process:9201): Gtk-CRITICAL **: 08:00:44.346: gtk_icon_theme_get_for_screen: assertion 'GDK_IS_SCREEN (screen)' failed
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure %object-arg->scm: cannot convert a NULL pointer to an object of type "GtkIconTheme"

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

I'm not really sure the what GDK_IS_SCREEN is. I'm also not really sure how to pass a pointer in Guile. I tried using the (use-modules (system foreign)) to pass a pointer that didn't really work either. Pass an already built GtkIconTheme resulted in the following.

scheme@(guile-user)> (define m (gi:make <GtkIconTheme>))
scheme@(guile-user)> (icon-theme:get-default m)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
No applicable method for #<<generic> icon-theme:get-default (1)> in call (icon-theme:get-default #<<GtkIconTheme> 7f7e6fdb5030>)

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 

Which just makes me think I'm just not doing it right.

Someone please let me know the right way to use that function. I haven't dug into the C code which I might do now to see if I can't figure it out. Unfortunately I greping hasn't shown me where the function is defined so I'm assuming there's a lot of abstraction going on so I'm guessing this is gonna take me a while.

LordYuuma commented 2 years ago

I'm pretty sure you need to call Gtk's init function before you can access the screen (since Gio and Gtk both provide init, make sure to prefix it with e.g gtk: so that it is bound to gtk:init!). You might even need to run icon-theme:get-default in an application's activation hook after having created a window, though I'm not too sure about that one.

zedth2 commented 2 years ago

Yeah I think I missed that.