tags:

views:

404

answers:

1

I'm trying hard to find out how to use the file chooser button properly. Reading the reference manual on GtkFileChooserButton, GtkFileChooserDialog and GtkFileChooser didn't help so far. I've tried connecting to the undocumented signal file-set of GtkFileChooserButton and calling get_filename() from here, but it seems to behave quite unreliably. When the user clicks the button and selects a file, it works fine so far.

But, if after clicking on the same button (which already has a filename set), the user changes his mind and closes the "open file" dialog, get_filename() returns None (a Python type, i write it using pygtk) while the file remains set. Even more weird, if i call get_filename() on that button later from within another signal handler, the filename returns to what it previously had been set by the user. By the way, only closing the dialog box seems to cause the problem, pressing "cancel" works just fine.

A: 

Unclear question:

if you mean how to distinct between a valid chosen file: if you call Run you will get a reponse: Gtk::RESPONSE_ACCEPT if the user selected a file and accepted this file (clicked ok)

So only get the filename when the file is accepted.

if you mean how to reset filepath: see gtk FileChooser -> set_ current_folder(filename) (without the space)

PoweRoy
Sorry, but i don't call Run on the dialog myself. I just put FileChooserButton on my window and it calls the dialog when clicked.
RommeDeSerieux