Re: Wrapping my own widgets



On Fri, 2005-09-16 at 04:40 +0100, Chris Seaton wrote:
> Hi,
> 
> I'm writing a widget in C with a C++ wrapper.
> 
> I don't think I want to use the gtkmm generators, as it's only one class 
> and I don't want to make people download the sources of gtkmm just to 
> build my widget's bindings, so I'm writing it by hand.

1. gmmproc is in glibmm, not gtkmm. That's smaller.
2. People don't need gmmproc unless they are building your bindings from
cvs. For instance, you don't need gmmproc to build gtkmm from the
tarball.

I suggest you do it the standard way.

> I'm looking at the Gtk::DrawingArea widget as an example, as my widget 
> was based (just based in the copy-and-paste sense, not inherited or 
> anything) on that when I was writing the C code for the widget, but the 
> code makes no sense!
> 
> I know that it's generated so it'll be a bit of a mess, but nothing adds up!
> 
> For example, DrawingArea_Class is declared with no members at all, but 
> then there is code for DrawingArea_Class::init().

You are probably looking at a prototype declaration. It is declared in
the gtkmm/private/drawingarea_p.h file.

> The destructor calls some function called _destroy(),

destroy_().

>  but I have no idea 
> what's providing this. It doesn't seem to be Glib::Object or 
> Glib::ObjectBase.

It's in Gtk::Window.

> What's the point in the typedefs
> 
> typedef struct _GtkDrawingArea GtkDrawingArea;
> typedef struct _GtkDrawingAreaClass GtkDrawingAreaClass;

They are prototype declarations for the C structs. If we have these then
we don't need to #include the C headers in our C++ headers.

> that are already defined by the C code header?
> 
> Why is (GObject*) used instead of G_OBJECT()

Probably for performance.

> Could someone take the time to explain how to write a gtkmm style 
> language binding for my widget?

It's best to use gmmproc.

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





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