glademm/gtkmm: default constructor handling get_widget()?

barooo_at_gmail.com
Date: 05/13/05


Date: 13 May 2005 08:15:05 -0700

I'd like to be able to subclass a widget in gtkmm and have my widget's
default constructor do the libglademm work, so that a user of my widget
can just do something like:

window1 w;
//do stuff with w

instead of
window1* w;
glademm_xml->get_widget("window1", w);
//do stuff with w.

The best I've come up with is to call the Gtk::Window constructor with
a pointer to the GtkWindow* created by libglademm, something like this
(without handling dynamic_cast failure):

class window1 : public Gtk::Window
{
public:
    window1::window1() :
Gtk::Window(dynamic_cast<Gtk::Window*>(Gnome::Glade::Xml::create("window1.glade")
        ->get_widget("window1"))->gobj()) {};
    window1::window1(BaseObjectType* cobject,
                     const Glib::RefPtr<Gnome::Glade::Xml>& xml)
};

This gives a runtime warning of:

(glade_test:23016): glibmm-WARNING **: This object, of type
gtkmm__GtkWindow, already has a wrapper.
You should use wrap() instead of a constructor.

Is there a way to do what I'm wanting and still have window1 be a
Gtk::Window? Is that warning an indication of a potential memory leak/
crash/ other problem?



Relevant Pages

  • Re: glademm/gtkmm: default constructor handling get_widget()?
    ... > default constructor do the libglademm work, so that a user of my widget ... > window1 w; ... This handles all the libglademm stuff in the constructor. ... Printing on GNU/Linux? ...
    (comp.os.linux.development.apps)
  • Re: glademm/gtkmm: default constructor handling get_widget()?
    ... > I'd like to be able to subclass a widget in gtkmm and have my ... > default constructor do the libglademm work, so that a user of my ...
    (comp.os.linux.development.apps)
  • Re: Window class
    ... from the SettingsDlg constructor. ... references at this point an object of type Window1, ... and the SettingsDlg constructor is entered. ... possibly reimplemented by your subclass. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Window class
    ... from the SettingsDlg constructor. ... references at this point an object of type Window1, ... and the SettingsDlg constructor is entered. ... possibly reimplemented by your subclass. ...
    (microsoft.public.vc.language)
  • Re: Window class
    ... from the SettingsDlg constructor. ... references at this point an object of type Window1, ... and the SettingsDlg constructor is entered. ... possibly reimplemented by your subclass. ...
    (microsoft.public.win32.programmer.ui)