RE: [gtkmm] Double Window Hell



Murray Cumming
www.murrayc.com
murrayc usa net

> -----Original Message-----
> From: Dennis Craven [mailto:linuxnewb rogers com] 
> Sent: Dienstag, 16. Dezember 2003 19:33
> To: Cumming Murray (CNET External)
> Cc: gtkmm-list gnome org
> Subject: RE: [gtkmm] Double Window Hell
> 
> 
> On Tue, 2003-12-16 at 08:54, Murray Cumming Comneon com wrote:
> > If the "main" window is not in the .glade file, and is not in his 
> > application, then I can't imagine where is coming from. I suggest 
> > grepping for "main".
> 
> This is the same line of thought I had.. The only "main" in 
> my source code was the function named "main". I thought I had 
> better leave that there :)

Maybe your executable filename was called main, so that was the default
window title.
 
> Anyways, I did get around it. I don't know if this is the 
> proper way to do it, but in case anyone is searching these 
> archives for the same problem, this is what I did:
> 
> In main.cc:
> 
> #include "MyWindow.hh"
> 
> int main(int argc, char ** argv)
> {
>   Gtk::Main kit(&argc, &argv);
>   MyWindow mainWindow;
>   mainWindow.run();
> 
>   return (0);
> }
> 
> In MyWindow.hh:
> 
> #include <gtkmm.h>
> #include <libglademm/xml.h>
> 
> class MyWindow : public Gtk::Window
> {
> public:
>   MyWindow();
>   virtual ~MyWindow();
>   virtual void run(void);
> 
> protected:
>   Glib::RefPtr<Gnome::Glade::Xml> refXml;
> };
> 
> 
> In MyWindow.cc:
> 
> #include "MyWindow.hh"
> 
> MyWindow::MyWindow()
> {
>   Gtk::Window * main = 0;
>   refXml = Gnome::Glade::Xml::create("gotter2.glade");
> }
> 
> MyWindow::~MyWindow()
> {
> }
> 
> void MyWindow::run(void)
> {
>   Gtk::Main::run();
> }
> 
> As you can see, I merely moved the Gtk::Main::run() function 
> call into the MyWindow class and just called it from the main 
> function.

If you don't want one of the windows then just don't have one of the
windows. Either remove the MainWindow from your main() function, or remove
the visible property from the window in your .glade file. If you remove the
MainWindow from your main() function, then you might choose to use the
window in your .glade file as the one that you supply to Gtk::Main::run(),
to control the lifetime of your application.


> It appears to work fine, but like I said, I'm not 
> sure that this is the appropriate solution. The .glade file 
> is untouched since I first emailed the list about this issue, 
> and the window is obviously functionless, but that is 
> something I can work on now.

The window is there because you put it there.

> If anyone sees any potential problems with this solution, 
> please let me know. If I come across any myself, I'll notify 
> the list of the correction so that the archives are accurate. 

I see no actual problem so far, so there is no need for a solution.

> If you guys think the solution is sound, I'll make up a 
> little gtkmm/libglademm tutorial once I make more progress 
> and produce some content.

I don't know how it could get any simpler than the current example:
http://cvs.gnome.org/lxr/source/gnomemm/libglademm/examples/basic/

Murray Cumming
www.murrayc.com
murrayc usa net



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