Accessing filenames from file choosers
- From: Ross Clement <rclement dmu ac uk>
- To: gtk-app-devel-list gnome org
- Subject: Accessing filenames from file choosers
- Date: Tue, 11 Apr 2006 11:48:17 +0100
I should have known my previous good progress would get stuck on some
seemingly minor point.
I create a few file chooser dialogs. These were set up in glade. I can
make the dialogs appear, use them, and then make them disappear again.
What I can't do is fetch the selected filename from the dialog.
Looking around it seems that I should use the function
to get fs in the callback for the open button being clicked, I can use
the lookup_widget function.
fs = lookup_widget((GtkWidget *)button,"fileselection1");
(using a different name for my own GtkFileChooser)
But this doesn't work. I get an error message saying that:
Gtk-CRITICAL **: gtk_file_selection_get_filename: assertion
`GTK_IS_FILE_SELECTION (filesel)' failed
OK, so I conclude that I need to access the GtkFileSelection widget. But
how do I get access to this. I return to Glade and view the widget tree,
expecting that in the tree for my file dialog I'll find a widget for a
GtkFileSelection and can then lookup_widget() on that name. But I can't
find any such widget.
I then look through all the properties of the GtkFileChooser object in
glade, looking to see if I could make the GtkFileSelection widget
visible to the outside world, but I can't see anything. I then add a
file activated callback to the GtkFileChooser expecting that it will
have a GtkFileSelection object as an argument, but no dice. And in any
case file activated callbacks only seem to happen when double clicking
on the filename, not when clicking on the open button.
I've searched on the web for solutions to this, but none of the glade
tutorials that I've found seem to cover how to fetch the filename from
the File Chooser dialog, and the gtk tutorials that do assume interface
code that glade does not generate.
I would much prefer not to have to give up using glade to build the
interface. And there *MUST* be a way of making file choosers work with
Could someone please put me out of my misery?
Thanks in anticipation,
] [Thread Prev