From 1714fec73c18b7b4e720fd1ffa92e8c8daabc8ec Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 8 Jul 2007 18:37:45 +0000 Subject: Improved main loop handling git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@285 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- main.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c2279a9b..32fa9e0d 100644 --- a/main.c +++ b/main.c @@ -9,6 +9,7 @@ #endif #include "file.h" #include "debug.h" +#include "main.h" #include "navit.h" #include "gui.h" #include "plugin.h" @@ -44,14 +45,34 @@ static gchar *get_home_directory(void) return homedir; } +static GList *navit; +#ifndef USE_GTK_MAIN_LOOP +static GMainLoop *loop; +#endif + +void +main_add_navit(struct navit *nav) +{ + navit=g_list_prepend(navit, nav); +} + +void +main_remove_navit(struct navit *nav) +{ + navit=g_list_remove(navit, nav); + if (! navit) { +#ifdef USE_GTK_MAIN_LOOP + gtk_main_quit(); +#else + g_main_loop_quit(loop); +#endif + } +} int main(int argc, char **argv) { GError *error = NULL; char *config_file = NULL; -#ifndef USE_GTK_MAIN_LOOP - GMainLoop *loop; -#endif signal(SIGCHLD, sigchld); @@ -83,6 +104,10 @@ int main(int argc, char **argv) } else { printf("Using '%s'\n", config_file); } + if (! navit) { + printf("No instance has been created, exiting\n"); + exit(1); + } if (main_loop_gui) { gui_run_main_loop(main_loop_gui); } else { -- cgit v1.2.1