Wrap Callback Question
- Posted by Icy_Viking 3 months ago
- 373 views
Hi all,
After going through and looking at GTK, I think I'm gonna at least take a crack at trying to wrap GTK 4. However I'm a bit confused on how I'd wrap this callback function.
C Code [https://docs.gtk.org/gtk4/getting_started.html]
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv);
Possible Eu Code
public constant xg_signal_connect = define_c_func(gtk,"+g_signal_connect",{C_POINTER,C_STRING,C_POINTER,C_POINTER},C_POINTER) public constant xg_application_run = define_c_func(gtk,"+g_application_run",{C_POINTER,C_POINTER,C_STRING},C_POINTER) public function g_signal_connect(atom app,sequence cmd,atom cb,atom x) return c_func(xg_signal_connect,{app,cmd,cb,x}) end function public function g_application_run(atom app,atom argc,sequence argv) return c_func(xg_application_run,{app,argc,argv}) end function
The above eu code is basically pseudo code for now. I'm just trying to guess how I'd wrap that, callbacks still kinda throw me off.
NOTE: For those wondering where C_STRING comes from, I'm using Greg's FFI Euphoria library which has a nice C_STRING type to help with wrapping strings and structs. You can find it here [https://github.com/ghaberek/libffi-euphoria]