[Glade-devel] Glade Binding Framework



On Mon, 2007-03-26 at 11:31 -0300, Juan Pablo Ugarte wrote:
On Sun, 2007-03-25 at 19:06 +0200, Murray Cumming wrote:
On Sat, 2007-03-24 at 11:46 -0400, Tristan Van Berkom wrote:
On Sat, 2007-03-24 at 12:08 +0100, Murray Cumming wrote:
[...]

Shouldn't we just provide the class definitions statically, so that
developers can subclass in the way it's usually done in most languages?

Yes, C++ cannot declare classes at runtime. And I wouldn't want it to.

I dont think that declaring C++ classes at runtime is the requirement
here - rather declaring GObject subclasses at runtime is what is needed.

We can do that.

And it's possible in gtkmm, by providing a GType name explicitly to the
Glib::ObjectBase base constructor. This is how we implement custom
GtkTreeModels and custom GtkCellRenderers.

Thats a very good thing!
hmm so.. if you implement a cell render in c++ and this one is used by
treeviews it means that gtkmm can create a proper GObject :)

More precisely, it create a new GType, and creates an instance of that
GType, which is GObject.

Could you send an example?

Here is a (not useful now) example of a custom cellrenderer:
http://svn.gnome.org/viewcvs/gtkmm/trunk/examples/cellrenderercustom/cellrendererpopup.cc?view=markup

Notice the use of 
"Glib::ObjectBase      (typeid(CellRendererPopup)),"
typeid() is a standard C++ keyword that returns a string.

I think this is only necessary when you want to implement a GInterface,
or you need to implement theming for custom widgets (RC files refer to
GType names). 

a GtkLabel derived object with, lets say, a diferent background color
setted in some method like realize

That doesn't require any special technique in gtkmm, because all gtkmm
widgets have a special GType. For instance a Gtk::Label is actually of
GType gtkmm_GtkLabel. That allows us to hook in our own vfuncs, which
are forwarded to C++ virtual methods. You don't need to think about that
usually.

So we can just override the C++ on_expose() method. For instance:
http://svn.gnome.org/viewcvs/gtkmm/trunk/examples/book/custom/custom_widget/mywidget.cc?view=markup

So I can give it a try and if everything works as expected I will be
able to write a glade binding for gtkmm :)

It's not all very clear yet. But if someone tries it, do ask on
gtkmm-list if you have problems, directing us to the exact Glade API
that you are trying to use.

-- 
Murray Cumming
murrayc at murrayc.com
www.murrayc.com
www.openismus.com





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