Generated files should not appears on CVS
[viking.git] / src / main.c
blob09497d3e4aa741467eaa88a0d25d91cc961c1113
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 "mapcache.h"
24 #include "background.h"
26 #include <string.h>
28 #define MAX_WINDOWS 1024
30 static guint window_count = 0;
32 static VikWindow *new_window ();
33 static void open_window ( VikWindow *vw, const gchar **files );
34 static void destroy( GtkWidget *widget,
35 gpointer data );
38 /* Another callback */
39 static void destroy( GtkWidget *widget,
40 gpointer data )
42 if ( ! --window_count )
43 gtk_main_quit ();
46 static VikWindow *new_window ()
48 if ( window_count < MAX_WINDOWS )
50 VikWindow *vw = vik_window_new ();
52 g_signal_connect (G_OBJECT (vw), "destroy",
53 G_CALLBACK (destroy), NULL);
54 g_signal_connect (G_OBJECT (vw), "newwindow",
55 G_CALLBACK (new_window), NULL);
56 g_signal_connect (G_OBJECT (vw), "openwindow",
57 G_CALLBACK (open_window), NULL);
59 gtk_widget_show_all ( GTK_WIDGET(vw) );
61 window_count++;
63 return vw;
65 return NULL;
68 static void open_window ( VikWindow *vw, const gchar **files )
70 VikWindow *newvw = new_window();
71 gboolean change_fn = (!files[1]); /* only change fn if one file */
72 if ( newvw )
73 while ( *files ) {
74 vik_window_open_file ( newvw, *(files++), change_fn );
75 files++;
79 int main( int argc, char *argv[] )
81 VikWindow *first_window;
82 gboolean dashdash_already = FALSE;
83 int i = 0;
85 g_thread_init ( NULL );
86 gdk_threads_init ();
88 gtk_init (&argc, &argv);
90 a_mapcache_init ();
91 a_background_init ();
93 first_window = new_window();
95 gdk_threads_enter ();
96 while ( ++i < argc ) {
97 if ( strcmp(argv[i],"--") == 0 && !dashdash_already )
98 dashdash_already = TRUE; /* hack to open '-' */
99 else
100 vik_window_open_file ( first_window, argv[i], argc == 2 );
103 gtk_main ();
104 gdk_threads_leave ();
106 a_clipboard_uninit ();
107 a_mapcache_uninit ();
109 return 0;