Hi All,

Ive been trying to get the (NCI) callbacks working with GTK but somehow
cant. Mainly the attached file implements a (very) small test app where
it simply displays a button within a window.

The problem is that as soon as it goes onto installing the callback
parrot returns with a "get_string() not implemented in class
'UnManagedStruct'".

So what is happening there?  Either the small test program attached is
correct and therefore only need to implement that "get_string" for the
UnManagedStruct PMC.. or theres something wrong with the code?

Somehow I believe that the message (get_string not implemeted) is
somewhat missleading? mean at least I dont understand why it enters
this "get_string" function, as it dumps this message nomatther what
signature I could make parrot beleive the callback function has.

Also when trying to trace this with gdb, get_string gets called
from a PerlInt PMC, even thaught I'm not using any PerlInt PMC.

In GTK (using version 2) the calling function is:

    gulong g_signal_connect( gpointer      *object,
                             const gchar   *name,
                             GCallback     func,
                             gpointer      func_data );

and the called:

    void callback_func( GtkWidget *widget,
                        gpointer   callback_data );

Any hints/help greatly appreciated :)
Thanks,
Stephane

PS.: the attached file load "libgtk-x11-2.0" as this the GTK version 2
lib name on my RedHat.. please change that to libgtk or whatever GTKv2
libname on your system is to try it out.

# -- Gtk Button Example.

.sub _gtkcallback
  print "Hello\n"
.end

.sub main @MAIN
  .include "gtk.pasm"

  P0 = global "Gtk::gtk_init"
  I5 = 0
  invoke

  P0 = global "Gtk::gtk_window_new"
  null I5
  invoke

  P15 = P5

  P0 = global "Gtk::gtk_button_new_with_label"
  S5 = "Parrot"
  invoke

  # -- Save it.
  P6  = P5
  P11 = P5

  # -- install callback?
  newsub P6, .Sub, _gtkcallback
  new P7, .Integer  # -- just give it something even if dont care
  set P7, 42
  new_callback P5, P6, P7, "U"

  P0 = global "Gtk::g_signal_connect"
  S5 = "clicked"
  P6 = P7
  P5 = P11
  invoke
  # -- .

  P5 = P11
  P6 = P11

  P0 = global "Gtk::gtk_widget_show"
  invoke

  # -- Set the container.
  P5 = P15
 
  P0 = global "Gtk::gtk_container_add"
  invoke

  P0 = global "Gtk::gtk_widget_show"
  invoke

  P0 = global "Gtk::gtk_main"
  invoke

  end
.end
saveall
loadlib P1, 'libgtk-x11-2.0'
dlfunc P2, P1, 'gtk_init', 'vii'
store_global 'Gtk::gtk_init', P2
dlfunc P2, P1, 'gtk_main', 'vv'
store_global 'Gtk::gtk_main', P2
dlfunc P2, P1, 'gtk_widget_show', 'vp'
store_global 'Gtk::gtk_widget_show', P2
dlfunc P2, P1, 'gtk_container_add', 'vpp'
store_global 'Gtk::gtk_container_add', P2
dlfunc P2, P1, 'gtk_button_new_with_label', 'pt'
store_global 'Gtk::gtk_button_new_with_label', P2
dlfunc P2, P1, 'gtk_window_new', 'pi'
store_global 'Gtk::gtk_window_new', P2
dlfunc P2, P1, 'g_signal_connect', 'lptpP'
store_global 'Gtk::g_signal_connect', P2
restoreall
Summary of my parrot 0.1.0 configuration:
  configdate='Fri Aug 13 22:56:58 2004'
  Platform:
    osname=linux, archname=i386-linux-thread-multi
    jitcapable=1, jitarchname=i386-linux,
    jitosname=LINUX, jitcpuarch=i386
    execcapable=1
    perl=/usr/bin/perl
  Compiler:
    cc='gcc', ccflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING  
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
  Linker and Libraries:
    ld='gcc', ldflags=' -L/usr/local/lib',
    cc_ldflags='',
    libs='-lnsl -ldl -lm -lpthread -lcrypt -lutil -lrt -lgmp'
  Dynamic Linking:
    so='.so', ld_shared='-shared -L/usr/local/lib -fPIC',
    ld_shared_flags=''
  Types:
    iv=long, intvalsize=4, intsize=4, opcode_t=long, opcode_t_size=4,
    ptrsize=4, ptr_alignment=1 byteorder=1234, 
    nv=double, numvalsize=8, doublesize=8

Reply via email to