marshalling



Hi,

I'm currently building a binding library between gtk and O'Caml
(http://pauillac.inria.fr/ocaml). As you can see with the attached sample
code, it provides an easy object-oriented and typesafe interface.

However, I still have problems with callbacks that take extra parameters.

The callback function:
gint mlgtk_callback_exec(GtkObject *object, value *closurep,
  int n_args, GtkArg *args)
{
  int i;
  fprintf(stderr, "Callback called with %d arguments.\n", n_args);
  for (i=0; i<n_args; i++)
    fprintf(stderr, "arg #%d type %d\n", i, args[i].type);

connected with:

gtk_signal_connect_interp(
    GtkObject_ml(object), String_val(name),
    mlgtk_callback_exec, cbk,
    mlgtk_callback_destroy, 1)

prints
Callback called with 1 arguments.
arg #0 type 18956

when getting the delete_event signal on a toplevel window.

How are callback arguments supposed to be decoded?
Especially, what do the types mean?

(Callbacks such as "clicked on button" work fine now. The sample code
provided runs perfectly.)

regards, David
open ObjGtk;;

let window = window_new Gtk.WINDOW_TOPLEVEL in
  ( let vbox = vbox_new false 0 in
      vbox #show();
      window #container_add (vbox :> widget);

      ( let label = label_new "Dialog box" in
          label #show();
          vbox #box_pack_start (label :> widget) false false 0          
      );

      ( let hbox = hbox_new false 10 in
          List.iter
            (fun s -> let button = check_button_new_with_label s in
               button #show();
               hbox #box_pack_start (button :> widget) true false 0;
            ) ["foo"; "bar"; "moo"; "cow"];
          hbox #show();
          vbox #box_pack_start (hbox :> widget) false false 0          
      );

      ( let hsep = hseparator_new () in
          hsep #show();
          vbox #box_pack_start (hsep :> widget) false false 5
      );

      ( let quitbox = hbox_new false 0 in
          ( let quit = button_new_with_label "Quit" in
              quit #connect_clicked Gtk.main_quit;
              quit #show();
              quitbox #box_pack_start (quit :> widget) true false 0
          );
          quitbox #show();
          vbox #box_pack_start (quitbox :> widget) false false 0
      )
  );
  window #connect_delete_event Gtk.main_quit;
  window #show ();;



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