Web lists-archives.com

Re: How to invoke none blocking main, with thread safety.

7.11.2017 14:01 Mike Rosset <mike.rosset@xxxxxxxxx> wrote:
>  Hello,
>  I need to create window instance, with a WebKitWebView. I'm writing this in
> C.

Short answer: gtk_window_new() followed by gtk_widget_show() or
gtk_window_present() should do what you want. Of course you must
also put a WebKitWebView instance inside.

> However all of the examples I have seen are invoked from a main function and
> use either gtk_application_run or gtk_main, both of which block. Unfortunately
> I can only write this as a shared library.
>  How can I start a gtk instance without it blocking? Also hopefully I can do
> this with some thread safety.

Long answer: I'm not sure what you are trying to achieve but
I have a feeling that you are going to do it incorrectly.
First of all, you absolutely need a blocking function.
Otherwise your program will create and show a window and
then will terminate releasing all resources including the
window. Second, if you don't like gtk_main() and
gtk_application_run() (which internally calls gtk_main() )
then probably you have implemented your own main loop. You
must make sure that your own implementation does the same
event processing as the original gtk_main(). You must make
sure that mouse events, keystrokes, timer events, redraw,
resize etc. are handled correctly. Otherwise your window
may become unresponsive or may even not appear. Maybe it's
more reasonable to drop your own implementation and use the
default GTK implementation? Third, GTK functions will not work
without gtk_init(). If gtk_window_new() is the first GTK function
you call you will get some strange runtime error messages like
"GtkWindow class is unknown".


gtk-list mailing list