开发者

How g_main_loop works in gtk programming?

I am new to GTK+ programming. I came across an API called g_main_loop(). I have used it in my code but I am still u开发者_如何学JAVAnaware that how exactly it works. Can somebody explain g_main_loop() with small code snippet?


I recommend reading the documentation, starting with the linked-to function g_main_loop_new().

Basically, letting glib "own" your application's main loop makes it easier to support things like "pluggable" event sources; where your application listens to both (for example) events coming from GTK+ widgets, and a network socket or Unix pipe. These are things that need to be hooked together at a fairly low level in an application's main loop, and letting glib own those parts makes it easier.

There are glib data structures (like IO channels) that are compatible with the main loop and allow you to add things to the set of inputs the loop manages. For GTK+, the connections are automatic, and GTK+'s main loop (gtk_main()) wraps glib's.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜