Search code examples
gnomevalagtk3

Dialogues do not close in Vala


For some reason, dialogue boxes don't close in my program, even though shown by standard dialog.run() call. They show and they return codes, but buttons don't close them. Here's some code with which this happens:

//Inside constructor for my window class
load_dlg = new FileChooserDialog("Select file to open...", this,
FileChooserAction.OPEN,
Gtk.Stock.CANCEL, ResponseType.CANCEL,
Gtk.Stock.OPEN, ResponseType.ACCEPT, null);
//...
//Inside an event handler method
if(load_dlg.run() == Gtk.ResponseType.ACCEPT){
    image_backend = new Pixbuf.from_file(load_dlg.get_filename()); // This works, and it's in a try clause.

And everything is fine except that the dialogue just won't close after returning a code. Same with AboutDialog. Everything works just fine in Python, though.


Solution

  • You can just load_dlg.hide() after load_dlg.run() has returned.