From: Thadeu Lima de Souza Cascardo Date: Mon, 7 Oct 2013 11:38:06 +0000 (-0300) Subject: Use a GLib main loop X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Ff2fchat.git;a=commitdiff_plain;h=1f9e5dd106300779e6e699c819a48f6165ac4c99 Use a GLib main loop --- diff --git a/f2fchat.c b/f2fchat.c index 55bdc5a..00c774f 100644 --- a/f2fchat.c +++ b/f2fchat.c @@ -17,16 +17,24 @@ */ #include "friend.h" +#include + +static gboolean quit(gpointer data) +{ + GMainLoop *loop = data; + g_main_loop_quit(loop); + return G_SOURCE_CONTINUE; +} int main(int argc, char **argv) { struct cache *cache; - int out = 0; + GMainLoop *loop; create_cache(&cache); load_cache(cache, "friends.cache"); - while (!out) { - out = 1; - } + loop = g_main_loop_new(g_main_context_default(), TRUE); + g_idle_add(quit, loop); + g_main_loop_run(loop); store_cache(cache, "friends.cache"); destroy_cache(cache); return 0;