On Tue, Aug 24, 2004 at 09:44:56AM +0200, Leopold Toetsch wrote: > Whatever you'll try the current scheme is not compatible with this GTK > callback. Parrot needs a PMC as user_data. GTK awaits a GObject.
> Yes. But draining the event queue still needs a running Parrot runloop. This made me remember that Ive tried sometime ago another of those gtk callback installer function that is g_signal_connect_data (wich is what the #defined g_signal_connect uses actually. That didn't broke, or even freeze the app, or else.. but it was "say" actually working.. o well.. Mainly Ive traced it to be sure and indeed, parrot is properly called each time the button pressed. Just that, as you say, parrot piles it up in its event queue.. and never takes it, since its busy "doing gtk_main". Well at least I know for sure how the whole callback scheme works now in parrot and can go try this: > >Otherwise, already thaught of actually unrolling the gtk_main function > >and have it handled/implemented within parrot directly (mainly gtk_main > >simply loops and waits on the gtk event queue). > > That's the way to go. ! :) Thanks, Stephane
# -- Gtk Button Example. .sub _gtkcallback print "Hello\n" .end .sub _main @MAIN .include "glib.pasm" .include "gtk.pasm" .local pmc window .local pmc button .local pmc callback .local pmc userdata .local NCI init init = global "Gtk::gtk_init" init(0) # -- create the window .local NCI w_new w_new = global "Gtk::gtk_window_new" window = w_new(0) # -- create the button .local NCI b_new b_new = global "Gtk::gtk_button_new_with_label" button = b_new("Parrot") # -- install callback? .local pmc cb_sub cb_sub = global "_gtkcallback" userdata = new Integer userdata = 42 callback = new_callback cb_sub, userdata, "pU" # -- function sig is "'lptppi', then we have: # P5 is the button # P6 the callback # P7 data we may to pass through. # S5 "clicked" # I5 is 0 # -- Uncomment this section to actually install the callback # -- (this segfaulst on my system) .local NCI sig_conn sig_conn = global "Glib::g_signal_connect_data" sig_conn(button, "clicked", callback, userdata, 0, 0) # -- Set the container. .local NCI cont_add cont_add = global "Gtk::gtk_container_add" cont_add(window, button) # -- show button .local NCI w_show w_show = global "Gtk::gtk_widget_show" w_show(button) # -- show window w_show(window) .local NCI g_main g_main = global "Gtk::gtk_main" g_main() 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 restoreall
saveall loadlib P1, 'libgobject-2.0' dlfunc P2, P1, 'g_signal_connect_data', 'lptpPii' store_global 'Glib::g_signal_connect_data', P2 restoreall