Stephane Peiry wrote:
[ segfaulting example ]
g_signal_connect_object (G_OBJECT (button), "clicked", G_CALLBACK (hello), NULL, 0);
Are you sure, that these two G_foo() aren't doing something with the function arguments?
I've beautified the example a bit, segfaults much nicer now ;) Dunno, what's wrong.
leo
# -- Gtk Button Example.
.sub _gtkcallback print "Hello\n" .end .sub _main @MAIN .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, "vU" # -- 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 "Gtk::g_signal_connect_object" sig_conn(button, "clicked", callback, userdata, 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