non-modal dialogs



hi

I have searching for a way to do non-modal dialogs. In my application I
want to have multiple message boxes, that times out and destroys
themselves when done.

I have made a class that extends the ordinary MessageDialog class, and
overloads run() and on_delete_event. Code at the bottom.

It works. When I have one of these timeout dialog running, the main
window functions properly and everything works as intended.

The problem arises when I have multiple timeout windows. Only one will
show itself at any given time.
I do something like this:
             GtkTimeoutWindow *ToW;	// using pointer so it is not
deleted at the end of the current scope
             ToW = new GtkTimeoutWindow( *this );
             Tow->set_message( " blabla" );
             Tow->run( 15 );	// 15 sec timeout

I suspect that the problem is in Gtk::main::run() or gtk::main::quit(),
since the window closes when I try to exit the main program by doing
gtk::main:quit() in the main window. class.

Do you have any example of non-modal dialog boxes? I have not been able
to find anything except modal examples - even though they are useful, it
doesn't fit the purpose this time

Help/links/suggestions are appreciated.

Regards
Morten Bo Nielsen


---------- class code ----------

void GtkTimeoutWindow::run( unsigned long TimeoutTimeInSecs )
{
	<snip> OnTimer init stuff </snip>

	show_all();
	set_modal( false );

	Gtk::Main::run();
}

/** Final event that deletes the window with data */
bool GtkTimeoutWindow::on_delete_event( GdkEventAny * )
{
	TimeoutConnection.disconnect();

	Gtk::Main::quit();

	delete this;
	return true;
}

-----------------------------------



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]