main.c 1.68 KB
Newer Older
1
#include <config.h>
Arturo Espinosa's avatar
Arturo Espinosa committed
2
3
#include <gnome.h>
#include "gnumeric.h"
4
#include "xml-io.h"
5
#include "plugin.h"
6
#include "format.h"
Arturo Espinosa's avatar
Arturo Espinosa committed
7
#include "cursors.h"
Miguel de Icaza's avatar
New:    
Miguel de Icaza committed
8
#include "number-match.h"
9
#include "dump.h"
10
#include "main.h"
Arturo Espinosa's avatar
Arturo Espinosa committed
11

Mark Probst's avatar
Mark Probst committed
12
13
14
15
#ifdef HAVE_GUILE
#include <libguile.h>
#endif

Elliot Lee's avatar
Elliot Lee committed
16
static char *dump_file_name = NULL;
17
static char **startup_files = NULL;
18

19
20
21
22
23
poptContext ctx;
const struct poptOption gnumeric_popt_options [] = {
	{ "dump-func-defs", '\0', POPT_ARG_STRING, &dump_file_name, 0,
	  N_("Dumps the function definitions"), N_("FILE") },
	{ NULL, '\0', 0, NULL, 0 }
24
25
};

26
static void
Mark Probst's avatar
Mark Probst committed
27
gnumeric_main (void *closure, int argc, char *argv [])
Arturo Espinosa's avatar
Arturo Espinosa committed
28
{
29
	GList *l;
Elliot Lee's avatar
Elliot Lee committed
30
	int i;
31
	
32
33
	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
	textdomain (PACKAGE);
34

35
	gnumeric_arg_parse (argc, argv);
36

37
	string_init ();
Miguel de Icaza's avatar
New:    
Miguel de Icaza committed
38
	format_match_init ();
39
	style_init ();
40
41
	format_color_init ();
	cursors_init ();
Miguel de Icaza's avatar
Miguel de Icaza committed
42
	global_symbol_init ();
Arturo Espinosa's avatar
Arturo Espinosa committed
43
	constants_init ();
Arturo Espinosa's avatar
Arturo Espinosa committed
44
	functions_init ();
45
	plugins_init ();
46

47
48
49
50
51
	if (dump_file_name){
		dump_functions (dump_file_name);
		exit (1);
	}

52
53
54
55
56
57
58
	startup_files = poptGetArgs (ctx);
	if (startup_files)
		for (i = 0; startup_files [i]; i++) {
			current_workbook = workbook_read (startup_files [i]);
			
			if (current_workbook)
				gtk_widget_show (current_workbook->toplevel);
Elliot Lee's avatar
Elliot Lee committed
59
		}
60
	poptFreeContext (ctx);
61
62
	
	if (current_workbook == NULL){
63
		current_workbook = workbook_new_with_sheets (1);
64
65
		gtk_widget_show (current_workbook->toplevel);
	}
Arturo Espinosa's avatar
Arturo Espinosa committed
66
67
68

	gtk_main ();

69
	cursors_shutdown ();
Miguel de Icaza's avatar
New:    
Miguel de Icaza committed
70
	format_match_finish ();
71
	format_color_shutdown ();
Miguel de Icaza's avatar
Miguel de Icaza committed
72
73

	gnome_config_drop_all ();
Arturo Espinosa's avatar
Arturo Espinosa committed
74
}
75

76
#ifdef HAVE_GUILE
Mark Probst's avatar
Mark Probst committed
77
78
79
80
int
main (int argc, char *argv [])
{
	scm_boot_guile(argc, argv, gnumeric_main, 0);
81
82
	return 0;
}
Mark Probst's avatar
Mark Probst committed
83
#else
84
85
86
int
main (int argc, char *argv [])
{
Mark Probst's avatar
Mark Probst committed
87
88
89
	gnumeric_main(0, argc, argv);
	return 0;
}
90
#endif