X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/ef20e3f6c50a3090c8c21be293f6c856418ef94d..48254848ab0cbe2a9ed0549ecc997c17aa7a925f:/src/main.c diff --git a/src/main.c b/src/main.c index eee55b41..899548cb 100644 --- a/src/main.c +++ b/src/main.c @@ -19,14 +19,28 @@ * */ +#ifdef HAVE_CONFIG +#include "config.h" +#endif /* HAVE_CONFIG */ + #include "viking.h" #include "icons/viking_icon.png_h" #include "mapcache.h" #include "background.h" +#include "dems.h" #include "curl_download.h" +#include "preferences.h" + +#ifdef VIK_CONFIG_GEOCACHES +void a_datasource_gc_init(); +#endif +#include #include +#include +#include + #include "modules.h" #define MAX_WINDOWS 1024 @@ -79,27 +93,72 @@ static void open_window ( VikWindow *vw, const gchar **files ) } } +/* Options */ +static gboolean version = FALSE; + +static GOptionEntry entries[] = +{ + { "version", 'v', 0, G_OPTION_ARG_NONE, &version, N_("Show version"), NULL }, + { NULL } +}; + int main( int argc, char *argv[] ) { VikWindow *first_window; GdkPixbuf *main_icon; gboolean dashdash_already = FALSE; int i = 0; + GError *error = NULL; + gboolean gui_initialized; + + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); g_thread_init ( NULL ); gdk_threads_init (); - gtk_init (&argc, &argv); + gui_initialized = gtk_init_with_args (&argc, &argv, "files+", entries, NULL, &error); + if (!gui_initialized) + { + /* check if we have an error message */ + if (error == NULL) + { + /* no error message, the GUI initialization failed */ + const gchar *display_name = gdk_get_display_arg_name (); + g_fprintf (stderr, "Failed to open display: %s\n", (display_name != NULL) ? display_name : " "); + } + else + { + /* yep, there's an error, so print it */ + g_fprintf (stderr, "Parsing command line options failed: %s\n", error->message); + g_error_free (error); + g_fprintf (stderr, "Run \"%s --help\" to see the list of recognized options.\n",argv[0]); + } + return EXIT_FAILURE; + } + + if (version) + { + g_printf ("%s %s, Copyright (c) 2003-2007 Evan Battaglia\n", PACKAGE_NAME, PACKAGE_VERSION); + return EXIT_SUCCESS; + } -#ifdef HAVE_LIBCURL curl_download_init(); -#endif /* Init modules/plugins */ modules_init(); a_mapcache_init (); a_background_init (); + a_preferences_init (); + +#ifdef VIK_CONFIG_GEOCACHES + a_datasource_gc_init(); +#endif + + vik_layer_cursors_init (); + vik_window_cursors_init (); /* Set the icon */ main_icon = gdk_pixbuf_from_pixdata(&viking_icon, FALSE, NULL); @@ -120,6 +179,10 @@ int main( int argc, char *argv[] ) gdk_threads_leave (); a_mapcache_uninit (); + a_dems_uninit (); + a_preferences_uninit (); + vik_layer_cursors_uninit (); + vik_window_cursors_uninit (); return 0; }