Pascal OOP binding



Hi!

Since a while I'm developing an OOP binding for GTK-1.2 for FreePascal.
Currently I don't have time to upgrade to GTK-2.x. So I have to stick
with GTK-1.2. The wrapper is quite similar to GTK-- despite signal
handlers are solved a little bit different.

A lot of widgets are already working quite fine. Today I needed a
GtkFileSelection. To be notified when the OK button is pressed, I tried
to add a signal handler to the ok_button.

Unfortunately, "wrapping" a _real_ GtkButton object (as it is created in
the gtk_file_selection_new() function) into my CButton Pascal class
doesn't change the GtkButton->klass to my own and thus doesn't change
the pointers to the signal callbacks.

When I create a CButton (which is the descendant class of GtkButton in
my wrapper) with gtk_object_new(GetType,Nil) (as every object) the
signal handlers calling _my_ callbacks are in place and work as desired.

To get notified when the dialog's OK button is pressed, I tried to
change the PGtkObject->klass->clicked value to point to my callback
function. But I think this is rather intrusive. GTK-- doesn't have to do
this either.

Then I tried to change PGtkObject->klass to gtk_type_class(CButtonType);
This works quite nice but when the file_selection dialog is closed, an
error message from "free()" complaints about an erroneous pointer.
Again, GTK-- doesn't have to do this (e.g. at
/gtkmm-1.2.8/examples/filesel/filesel.cc they simply connect a slot, but
no additional work is done, that this slot is actually notifed when the
button is pressed).

Could you please tell me, what exactly I have to do, that wrapping an
original GTK object into one of mine also "replaces" the signal
callbacks?

Thanks
  Hansi

-- 
Johann Glaser   <Johann Glaser gmx at>
   Vienna University of Technology
       Electrical Engineering
____ http://www.johann-glaser.at/ ____




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