Re: filechooserwidget
Matthieu Dubuget <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Jacques Garrigue a écrit : > From: Matthieu Dubuget <[email protected]> > > >> I'm trying to get access to a GFile.chooser_widget from a .glade file. >> >> For this, I would need to convert the >> >> Gtk.widget Gtk.obj >> >> returned by >> >> Glade.get_widget ~name:"filechooserwidget" xmldata >> >> into a >> >> ([> `filechooser | `gtk | `widget ] as 'a) Gtk.obj >> >> >> But I really don't know how to do this. >> > > The standard way to do this is to use the function > GtkFile.FileChooser.cast, which checks that your widget is really a > file chooser. Unfortunately, there seems to be a bug, and the returned > type is not correct (it contains only `filechooser, not `gtk and > `widget), so you will have to call also Gobject.unsafe_cast. > > The whole command would look like > > let fcw = GtkFile.FileChooser.cast > (Glade.get_widget ~name:"filechooserwidget" xmldata) in > new GFile.chooser_widget (Gobject.unsafe_cast fcw) > > Jacques > Thanks a lot Jacques. It works now with: let fcw = Glade.get_widget ~name:"filechooserwidget" xmldata in new GFile.chooser_widget (Gobject.unsafe_cast fcw) Salutations Matt