Re: [gtkmm] some help needed for a standard process



On Thu, 2004-03-18 at 12:54, Andreas B. Thun wrote:
> Hi,
> 
> I need some help with my Gtk::FileSelection:
> The FileSelection window (derived from Gtk::FileSelection)
> is started with run() in the ctor.
> 
> When a selected file is not ok, I want to close
> the displayed window and show a new FileSelection
> window. I want to do this until the user selected
> a valid file.
> 
> However, the window object I delete is still displayed
> and I get many windows! :-(
> Any idea?
> 
>    // I want to display the FileSelection window
>    // until the selected file is ok
>    string dataBaseFile;
>    while (dataBaseFile.length() == 0) {
> 	// Display window for file selection
> 	FileSelection *fileSel = new FileSelection(string("select file:"));
> 	dataBaseFile = fileSel->getSelectedFile(); // returns "" if file is not valid
> 	fileSel->response(Gtk::RESPONSE_OK); // has no effect
> 	delete fileSel;
>    }

Suggestion:  this seems like it would be better as has-a instead of
is-a.  Let FileSelection::ctor create the Gtk::FileSelection. 
getSelectedFile() can hook up the signals to destroy the Gtk::FileSel at
the appropriate time, and then call the run() on the filesel.  It can
also hook up the signal to grab the filename to be returned after run()
is done.





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