main.c 1.75 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"
7
#include "color.h"
Arturo Espinosa's avatar
Arturo Espinosa committed
8
#include "cursors.h"
9
#include "dump.h"
Arturo Espinosa's avatar
Arturo Espinosa committed
10

11
/* If set, the file to load at startup time */
12
static GList *startup_files;
13

14
15
16
17
18
19
static char *dump_file_name;

enum {
	DUMP_FUNCS_KEY = -1
};

20
static struct argp_option argp_options [] = {
21
	{ "dump-func-defs",  DUMP_FUNCS_KEY, N_("FILE"),  0, N_("Dumps the functions definitions") },
22
23
24
25
26
27
28
	{ NULL,     0,     NULL,          0, NULL, 0 },
};

static error_t
parse_an_arg (int key, char *arg, struct argp_state *state)
{
	switch (key){
29
30
31
32
	case DUMP_FUNCS_KEY:
		dump_file_name = arg;
		break;
		
33
34
35
36
	case ARGP_KEY_INIT:
	case ARGP_KEY_FINI:
		return 0;

37
	default:
38
39
		if (arg)
			startup_files = g_list_prepend (startup_files, arg);
40
	}
41
	
42
43
44
45
46
47
48
	return 0;
}

static struct argp parser = {
	argp_options, parse_an_arg, NULL, NULL, NULL, NULL, NULL
};

Arturo Espinosa's avatar
Arturo Espinosa committed
49
50
51
int
main (int argc, char *argv [])
{
52
53
	GList *l;
	
54
55
	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
	textdomain (PACKAGE);
56

57
	gnome_init ("Gnumeric", &parser, argc, argv, 0, NULL);
58

59
	color_init ();
60
	string_init ();
61
	style_init ();
62
63
	format_color_init ();
	cursors_init ();
64
	symbol_init ();
Arturo Espinosa's avatar
Arturo Espinosa committed
65
	constants_init ();
Arturo Espinosa's avatar
Arturo Espinosa committed
66
	functions_init ();
67
	plugins_init ();
68

69
70
71
72
73
74
	if (dump_file_name){
		dump_functions (dump_file_name);
		exit (1);
	}

	/* Load any specified files on the command line */
75
76
	for (l = startup_files; l; l = l->next){
		current_workbook = gnumericReadXmlWorkbook (l->data);
77

78
79
80
81
82
83
84
		if (current_workbook)
			gtk_widget_show (current_workbook->toplevel);
		
	}
	g_list_free (startup_files);
	
	if (current_workbook == NULL){
85
		current_workbook = workbook_new_with_sheets (1);
86
87
		gtk_widget_show (current_workbook->toplevel);
	}
Arturo Espinosa's avatar
Arturo Espinosa committed
88
89
90

	gtk_main ();

91
92
	cursors_shutdown ();
	format_color_shutdown ();
Arturo Espinosa's avatar
Arturo Espinosa committed
93
94
	return 0;
}
95