Declaring curl_download_init function.
[viking/gosmore.git] / src / main.c
blob243a8fceb4d0c1b28cf1152b4547463a0c437de7
1 /*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "viking.h"
23 #include "icons/viking_18.png_h"
24 #include "mapcache.h"
25 #include "background.h"
27 #include <string.h>
29 #include "modules.h"
31 #define MAX_WINDOWS 1024
33 static guint window_count = 0;
35 static VikWindow *new_window ();
36 static void open_window ( VikWindow *vw, const gchar **files );
37 static void destroy( GtkWidget *widget,
38 gpointer data );
41 /* Another callback */
42 static void destroy( GtkWidget *widget,
43 gpointer data )
45 if ( ! --window_count )
46 gtk_main_quit ();
49 static VikWindow *new_window ()
51 if ( window_count < MAX_WINDOWS )
53 VikWindow *vw = vik_window_new ();
55 g_signal_connect (G_OBJECT (vw), "destroy",
56 G_CALLBACK (destroy), NULL);
57 g_signal_connect (G_OBJECT (vw), "newwindow",
58 G_CALLBACK (new_window), NULL);
59 g_signal_connect (G_OBJECT (vw), "openwindow",
60 G_CALLBACK (open_window), NULL);
62 gtk_widget_show_all ( GTK_WIDGET(vw) );
64 window_count++;
66 return vw;
68 return NULL;
71 static void open_window ( VikWindow *vw, const gchar **files )
73 VikWindow *newvw = new_window();
74 gboolean change_fn = (!files[1]); /* only change fn if one file */
75 if ( newvw )
76 while ( *files ) {
77 vik_window_open_file ( newvw, *(files++), change_fn );
81 int main( int argc, char *argv[] )
83 VikWindow *first_window;
84 GdkPixbuf *main_icon;
85 gboolean dashdash_already = FALSE;
86 int i = 0;
88 g_thread_init ( NULL );
89 gdk_threads_init ();
91 gtk_init (&argc, &argv);
93 #ifdef HAVE_LIBCURL
94 curl_download_init();
95 #endif
97 /* Init modules/plugins */
98 modules_init();
100 a_mapcache_init ();
101 a_background_init ();
103 /* Set the icon */
104 main_icon = gdk_pixbuf_from_pixdata(&viking_18, FALSE, NULL);
105 gtk_window_set_default_icon(main_icon);
107 /* Create the first window */
108 first_window = new_window();
110 gdk_threads_enter ();
111 while ( ++i < argc ) {
112 if ( strcmp(argv[i],"--") == 0 && !dashdash_already )
113 dashdash_already = TRUE; /* hack to open '-' */
114 else
115 vik_window_open_file ( first_window, argv[i], argc == 2 );
118 gtk_main ();
119 gdk_threads_leave ();
121 a_mapcache_uninit ();
123 return 0;