summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2007-07-08 18:37:45 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2007-07-08 18:37:45 +0000
commit1714fec73c18b7b4e720fd1ffa92e8c8daabc8ec (patch)
tree979b35ac78b8f53a8fae817d90dc5cafa3f39c76 /main.c
parent99bad813c7a9ee16bf044f4cf1837e8afabd8674 (diff)
downloadnavit-svn-1714fec73c18b7b4e720fd1ffa92e8c8daabc8ec.tar.gz
Improved main loop handling
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit/src@285 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 28 insertions, 3 deletions
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 {