Can somebody show me how to correctly plug onboard (the keyboard) into the Socket?
I have:
I add a socket into expander:
let expander: Expander = builder.object("expander").expect("Couldn't get expander");
let socket: Socket = gtk::Socket::new();
expander.add(&socket);
I spawn onboard:
let io: Result<(Pid, i32, i32, i32), Error> =
glib::spawn_async_with_pipes(working_directory, &argv, &envp, flags, child_setup);
I create io channel for communication between onboard and the widget:
let channel = glib_sys::g_io_channel_unix_new(pid.2);
Then I create watch for watching the events from onboard:
let socket_ptr: *mut std::ffi::c_void =
&mut socket as *mut _ as *mut std::ffi::c_void;
let user_data: [gpointer; 1] = [socket_ptr];
glib_sys::g_io_add_watch(channel, condition, Some(watch_out_channel), socket_ptr);
And finally I add the window id to the socket:
unsafe extern "C" fn watch_out_channel(
channel: *mut GIOChannel,
condition: u32,
socket: gpointer,
) -> gboolean {
let mut raw: *mut c_char = std::ptr::null_mut();
let size: *mut GType = std::ptr::null_mut();
let terminator_pos: *mut GType = std::ptr::null_mut();
let ptr_error = std::ptr::null_mut();
glib_sys::g_io_channel_read_line(channel, &mut raw, size, terminator_pos, ptr_error);
if !raw.is_null() {
println!("{}", *raw);
let window_number = (*raw).into();
gtk_sys::gtk_socket_add_id(socket as *mut GtkSocket, window_number);
}
1
}
But unfortunately I'm getting crash. It stops debugging in the file called @g_type_check_instance_is_a
When I highlight the socket variable I see info that there is a invalid enum value.
Thanks for any help with this