Re: How to close FileChooserDialog immediately after selection of file?
- From: "Milosz Derezynski" <internalerror gmail com>
- To: argnu <wzhsascha web de>
- Cc: gtkmm-list gnome org
- Subject: Re: How to close FileChooserDialog immediately after selection of file?
- Date: Tue, 18 Nov 2008 05:36:33 +0100
Not sure why you need the sleep() statement (i'm always somewhat suspicious about sleep()), but try this:
fcd1->hide();
while (Gtk::Main::pending())
Gtk::Main::iteration();
I suspect that after hiding and before the sleep there is no time for Gtk+ to actually perform the hiding.
On Mon, Nov 17, 2008 at 10:00 PM, argnu
<wzhsascha web de> wrote:
In my program a file gets chosen and then a routine taking this file as
parameter starts which takes some time.
My problem is: the FileChooserDialog closes only _after_ the routine has
finished.
I want the Dialog to be closed _before_ the routine starts.
I have tried it with FileChooserButton and with a separate Button which
calls a FileChooserDialog. For the last version I posted a Code Snippet. in
void on_button3_clicked() I would expect (and like to have) that
fcd1->hide(); //should close the dialog
works before the
sleep(3)-statement in switch(res),
however the hide() statement which should close the dialog comes into effect
after the sleep(3);
sleep(3); stands for the routine which takes some time.
do you have any suggestions?
With best argnu
// ------------------------------------------
Gtk::Window *win=NULL;
Gtk::Label *resultlabel=NULL;
Gtk::Toolbar *toolbar1=NULL;
std::string gladefile="/home/binder/tmp/bla/bla.glade";
Glib::RefPtr<Gnome::Glade::Xml> refXml;
void on_button3_clicked()
{
toolbar1->freeze_child_notify();
Gtk::FileChooserDialog *fcd1=NULL;
refXml->get_widget("filechooserdialog1", fcd1);
fcd1->show();
int res=fcd1->run();
std::string filename = fcd1->get_filename();
fcd1->hide();
std::cout << "after hide "<<std::endl;
fcd1=NULL;
switch(res)
{
case(Gtk::RESPONSE_OK):
{
std::cout << "Open clicked." << std::endl;
std::cout << "File selected: " << filename << std::endl;
std::cout << "sleeping 3"<<std::endl;
sleep(3);
std::cout << "FINISHED sleeping 3"<<std::endl;
break;
}
case(Gtk::RESPONSE_CANCEL):
case(Gtk::RESPONSE_DELETE_EVENT):
{
std::cout << "Cancel or X clicked." << std::endl;
break;
}
default:
{
std::cout << "Unexpected button clicked." << std::endl;
break;
}
}
toolbar1->thaw_child_notify();
}
int main(int argc, char **argv)
{
Gtk::Main kit(argc, argv);
refXml = Gnome::Glade::Xml::create(gladefile);
//toolbar1 and resultlabel is init'ed here,too, its not a leak
...
Gtk::Button* pButton = NULL;
refXml->get_widget("button3", pButton);
pButton->signal_clicked().connect( sigc::ptr_fun(on_button3_clicked) );
refXml->get_widget("window1", win);
kit.run(*win);
}
--
View this message in context: http://www.nabble.com/How-to-close-FileChooserDialog-immediately-after-selection-of-file--tp20548033p20548033.html
Sent from the Gtkmm mailing list archive at Nabble.com.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
--
Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.
[Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge
jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]