diff options
author | Joseph Herlant <herlantj@gmail.com> | 2018-05-25 22:06:51 -0700 |
---|---|---|
committer | Joseph Herlant <aerostitch@users.noreply.github.com> | 2018-05-25 22:17:50 -0700 |
commit | 8a76acb966f7059caf9d72c853175bd923b1e9d7 (patch) | |
tree | 1735178f7a0718831b88d2c36ea18a9955de3224 /navit/event_glib.c | |
parent | 032f15287b472f1a4b5349533f3e5b468684b281 (diff) | |
download | navit-8a76acb966f7059caf9d72c853175bd923b1e9d7.tar.gz |
cleanup:global:Use astyle to reformat everything
Diffstat (limited to 'navit/event_glib.c')
-rw-r--r-- | navit/event_glib.c | 209 |
1 files changed, 97 insertions, 112 deletions
diff --git a/navit/event_glib.c b/navit/event_glib.c index e9bad6c40..91dc4ad66 100644 --- a/navit/event_glib.c +++ b/navit/event_glib.c @@ -26,175 +26,160 @@ static GMainLoop *loop; -static void event_glib_main_loop_run(void) -{ - loop = g_main_loop_new (NULL, TRUE); - if (g_main_loop_is_running (loop)) - { - g_main_loop_run (loop); - } +static void event_glib_main_loop_run(void) { + loop = g_main_loop_new (NULL, TRUE); + if (g_main_loop_is_running (loop)) { + g_main_loop_run (loop); + } } -static void event_glib_main_loop_quit(void) -{ - if (loop) { - g_main_loop_quit(loop); - g_main_loop_unref(loop); - } +static void event_glib_main_loop_quit(void) { + if (loop) { + g_main_loop_quit(loop); + g_main_loop_unref(loop); + } } struct event_watch { - GIOChannel *iochan; - guint source; + GIOChannel *iochan; + guint source; }; static gboolean -event_glib_call_watch(GIOChannel * iochan, GIOCondition condition, gpointer t) -{ - struct callback *cb=t; - callback_call_0(cb); - return TRUE; +event_glib_call_watch(GIOChannel * iochan, GIOCondition condition, gpointer t) { + struct callback *cb=t; + callback_call_0(cb); + return TRUE; } static struct event_watch * -event_glib_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) -{ - struct event_watch *ret=g_new0(struct event_watch, 1); - int flags=0; - ret->iochan = g_io_channel_unix_new(fd); - switch (cond) { - case event_watch_cond_read: - flags=G_IO_IN; - break; - case event_watch_cond_write: - flags=G_IO_OUT; - break; - case event_watch_cond_except: - flags=G_IO_ERR|G_IO_HUP; - break; - } - ret->source = g_io_add_watch(ret->iochan, flags, event_glib_call_watch, (gpointer)cb); - return ret; +event_glib_add_watch(int fd, enum event_watch_cond cond, struct callback *cb) { + struct event_watch *ret=g_new0(struct event_watch, 1); + int flags=0; + ret->iochan = g_io_channel_unix_new(fd); + switch (cond) { + case event_watch_cond_read: + flags=G_IO_IN; + break; + case event_watch_cond_write: + flags=G_IO_OUT; + break; + case event_watch_cond_except: + flags=G_IO_ERR|G_IO_HUP; + break; + } + ret->source = g_io_add_watch(ret->iochan, flags, event_glib_call_watch, (gpointer)cb); + return ret; } static void -event_glib_remove_watch(struct event_watch *ev) -{ - if (! ev) - return; - g_source_remove(ev->source); - g_io_channel_unref(ev->iochan); - g_free(ev); +event_glib_remove_watch(struct event_watch *ev) { + if (! ev) + return; + g_source_remove(ev->source); + g_io_channel_unref(ev->iochan); + g_free(ev); } struct event_timeout { - guint source; - struct callback *cb; + guint source; + struct callback *cb; }; static gboolean -event_glib_call_timeout_single(struct event_timeout *ev) -{ - callback_call_0(ev->cb); - g_free(ev); - return FALSE; +event_glib_call_timeout_single(struct event_timeout *ev) { + callback_call_0(ev->cb); + g_free(ev); + return FALSE; } static gboolean -event_glib_call_timeout_multi(struct event_timeout *ev) -{ - callback_call_0(ev->cb); - return TRUE; +event_glib_call_timeout_multi(struct event_timeout *ev) { + callback_call_0(ev->cb); + return TRUE; } static struct event_timeout * -event_glib_add_timeout(int timeout, int multi, struct callback *cb) -{ - struct event_timeout *ret=g_new0(struct event_timeout, 1); - ret->cb=cb; - ret->source = g_timeout_add(timeout, multi ? (GSourceFunc)event_glib_call_timeout_multi : (GSourceFunc)event_glib_call_timeout_single, (gpointer)ret); +event_glib_add_timeout(int timeout, int multi, struct callback *cb) { + struct event_timeout *ret=g_new0(struct event_timeout, 1); + ret->cb=cb; + ret->source = g_timeout_add(timeout, + multi ? (GSourceFunc)event_glib_call_timeout_multi : (GSourceFunc)event_glib_call_timeout_single, (gpointer)ret); - return ret; + return ret; } static void -event_glib_remove_timeout(struct event_timeout *ev) -{ - if (! ev) - return; - g_source_remove(ev->source); - g_free(ev); +event_glib_remove_timeout(struct event_timeout *ev) { + if (! ev) + return; + g_source_remove(ev->source); + g_free(ev); } struct event_idle { - guint source; - struct callback *cb; + guint source; + struct callback *cb; }; static gboolean -event_glib_call_idle(struct event_idle *ev) -{ - callback_call_0(ev->cb); - return TRUE; +event_glib_call_idle(struct event_idle *ev) { + callback_call_0(ev->cb); + return TRUE; } static struct event_idle * -event_glib_add_idle(int priority, struct callback *cb) -{ - struct event_idle *ret=g_new0(struct event_idle, 1); - ret->cb=cb; - ret->source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+priority, (GSourceFunc)event_glib_call_idle, (gpointer)ret, NULL); - return ret; +event_glib_add_idle(int priority, struct callback *cb) { + struct event_idle *ret=g_new0(struct event_idle, 1); + ret->cb=cb; + ret->source = g_idle_add_full(G_PRIORITY_HIGH_IDLE+priority, (GSourceFunc)event_glib_call_idle, (gpointer)ret, NULL); + return ret; } static void -event_glib_remove_idle(struct event_idle *ev) -{ - if (! ev) - return; - g_source_remove(ev->source); - g_free(ev); +event_glib_remove_idle(struct event_idle *ev) { + if (! ev) + return; + g_source_remove(ev->source); + g_free(ev); } static void -event_glib_call_callback(struct callback_list *cb) -{ -/* - Idea for implementation: - Create a pipe then use add_watch - add callback to a queue - from here write to the pipe to wakeup the pool - then from the gui thread process the callback queue -*/ +event_glib_call_callback(struct callback_list *cb) { + /* + Idea for implementation: + Create a pipe then use add_watch + add callback to a queue + from here write to the pipe to wakeup the pool + then from the gui thread process the callback queue + */ } static struct event_methods event_glib_methods = { - event_glib_main_loop_run, - event_glib_main_loop_quit, - event_glib_add_watch, - event_glib_remove_watch, - event_glib_add_timeout, - event_glib_remove_timeout, - event_glib_add_idle, - event_glib_remove_idle, - event_glib_call_callback, + event_glib_main_loop_run, + event_glib_main_loop_quit, + event_glib_add_watch, + event_glib_remove_watch, + event_glib_add_timeout, + event_glib_remove_timeout, + event_glib_add_idle, + event_glib_remove_idle, + event_glib_call_callback, }; struct event_priv { - int data; + int data; }; static struct event_priv* -event_glib_new(struct event_methods *meth) -{ - *meth=event_glib_methods; - return (struct event_priv *)event_glib_new; +event_glib_new(struct event_methods *meth) { + *meth=event_glib_methods; + return (struct event_priv *)event_glib_new; } void -event_glib_init(void) -{ - plugin_register_category_event("glib", event_glib_new); +event_glib_init(void) { + plugin_register_category_event("glib", event_glib_new); } |