[prev in list] [next in list] [prev in thread] [next in thread]
List: gtkmm
Subject: Re: [gtkmm] Connecting signals with libglade and gtkmm
From: Ben Liblit <liblit () eecs ! berkeley ! edu>
Date: 2001-08-25 19:34:56
[Download RAW message or body]
Loban Amaan Rahman suggested:
>
> I think you also need to convert the Gtk+ widget into a Gtk-- widget.
> So ...
>
> Gtk::Button* quitbutton;
> quitbutton = static_cast<Gtk::Button*>(Gtk::wrap(glade_xml_widget(xml,
> "quitbutton");
I'd suggest two stylistic changes to this. First, Gtk::wrap() is
overloaded, and if you cast *before* calling it rather than after, the
wrapped object it produces will already have the proper type. Second,
static_cast<>() does no checking; I would use GTK+ casting macros
instead, because they will give back informative error messages if
somebody tweaked your glade file so that "quitbutton" is not actually a
button.
So putting those together, we get:
Gtk::Button *quitbutton =
Gtk::wrap(GTK_BUTTON(glade_xml_widget(xml, "quitbutton");
The overloaded Gtk::wrap() functions are really nifty here. Because
GTK_BUTTON yields a GtkButton *, the selected Gtk::wrap() function is
the one that turns a GtkButton * into a Gtk::Button *, which is exactly
what you want.
_______________________________________________
to unsubscribe or change your subscription parameters :
http://lists.sourceforge.net/lists/listinfo/gtkmm-main
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic