Re: [[gtkmm] Alternate libglademm interface]
- From: Murray Cumming <murrayc usa net>
- To: Christer Palm <palm nogui se>, <gtkmm-list gnome org>
- Subject: Re: [[gtkmm] Alternate libglademm interface]
- Date: Tue, 07 Oct 2003 09:36:57 +0200
Christer Palm <palm nogui se> wrote:
> Hi!
>
> Thanks to Murray's explanation on how to properly derive gtkmm objects
> from GTK+ objects, I was able to implement my idea on how to solve some
> annoying things with the way libglademm is implemented (Basically I
> solved the problems I had by simply using libglademm in the first place
> :-) ).
>
> I've attached a copy of my code (including a small example). The idea is
> that it should have the following advantages to libglademm and
> get_widget_derived() in particular:
>
> - Allow arbitrary constructor arguments for derived widget classes.
This could be nice. Obviously it would be impractical to typedef an Adapter
for every possible class, so I think that the example code should use the
Adapter template without a typedef.
> - Straightforward creation of derived widgets, no Xml::create(),
> get_derived_widget(), etc.
By putting the glade filename in the constructor, yes. But would this allow us
to have 2 derived child-widgets that have been layed out in the same container
widget in a .glade file. I think the existing get_widget_derived() method
allows us to reuse an existing Gnome::Glade::Xml instance, but this one
creates a new one for each class.
> - Hides more (most) glade stuff from the user.
See above. This might be a problem if the top-most class is not one of your
derived classes. Maybe that is not a common case.
> - Makes it easy to catch runtime errors when, for example, making a
> bunch of get_widget() calls by using exceptions.
I don't see a need to create a new exception class. Gnome::Glade::Xml::Error
should be enough. Also, I don't think we use throw() declarations in our *mm
stuff.
> Please keep in mind that this is a quick proof-of-concept hack. I'd like
> to hear your comments, as I suspect that the approach I'm using may not
> be 100% flawless.
I don't see where you are instantiating the gtkmm GTypes. This code just seems
to instantiate the GTK+ Gtype:
Base::Base(const std::string& filename, const std::string& widgetname)
throw (Exception)
{
try {
xml = Gnome::Glade::Xml::create(filename);
} catch (Gnome::Glade::XmlError& e) {
throw Exception(e.what());
}
baseObject = glade_xml_get_widget(xml->gobj(), widgetname.c_str());
In general, I would prefer patches (although new files generally need to be
tarballed up separately) in bugzilla. You can put the URL in emails.
This is interesting. I particularly don't like that the classes used with the
current get_widget_derived() are forced to all have the same constructor
parameters.
Murray Cumming
murrayc usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]