From 5b065b99f7dae9fa2a3841dc0065aa2c5e1af746 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 17 Oct 2013 18:59:21 -0300 Subject: [PATCH] Add quit command --- f2fchat.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/f2fchat.c b/f2fchat.c index eb9423c..05e6a5b 100644 --- a/f2fchat.c +++ b/f2fchat.c @@ -19,12 +19,21 @@ #include "friend.h" #include #include +#include "menu.h" -static gboolean quit(gpointer data) +static GMainLoop *uloop; + +static void quit(gchar **args, GSocketAddress *address) +{ + g_main_loop_quit(uloop); +} + +static struct menu_item quit_menu = { "quit", quit }; + +static void add_quit_cmd(GMainLoop *loop) { - GMainLoop *loop = data; - g_main_loop_quit(loop); - return G_SOURCE_CONTINUE; + uloop = loop; + menu_add(&quit_menu); } int main(int argc, char **argv) @@ -40,6 +49,7 @@ int main(int argc, char **argv) create_cache(&cache); load_cache(cache, "friends.cache"); loop = g_main_loop_new(g_main_context_default(), TRUE); + add_quit_cmd(loop); g_main_loop_run(loop); store_cache(cache, "friends.cache"); destroy_cache(cache); -- 2.20.1