1 /* modest-main.c -- part of modest */
4 #include "modest-conf.h"
5 #include "modest-account-mgr.h"
6 #include "modest-identity-mgr.h"
8 #include "modest-icon-factory.h"
12 #endif /*HAVE_CONFIG_H*/
15 static void install_basic_conf_settings (ModestConf *conf);
18 main (int argc, char *argv[])
20 GOptionContext *context = NULL;
21 ModestConf *modest_conf = NULL;
22 ModestUI *modest_ui = NULL;
27 static gboolean update, debug, reinstall;
28 static gchar *mailto, *subject, *bcc, *cc, *body;
30 static GOptionEntry options[] = {
31 { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
32 "Run in debug mode" },
33 { "update", 'u', 0, G_OPTION_ARG_NONE, &update,
34 "Send/receive all accounts and exit"},
35 { "mailto", 'm', 0, G_OPTION_ARG_STRING, &mailto,
36 "Start writing a new email to <addresses>"},
37 { "subject", 's', 0, G_OPTION_ARG_STRING, &subject,
38 "Subject for a new mail"},
39 { "body", 'b', 0, G_OPTION_ARG_STRING, &body,
40 "Body for a new email"},
41 { "cc", 0, 0, G_OPTION_ARG_STRING, &cc,
42 "CC-addresses for a new mail (comma-separated)"},
43 { "bcc", 0, 0, G_OPTION_ARG_STRING, &bcc,
44 "BCC-adresses for a new mail (comma-separated)"},
45 { "reinstall-factory-settings", 0, 0, G_OPTION_ARG_NONE, &reinstall,
46 "Delete all settings and start over (*DESTRUCTIVE*)"
51 gtk_init (&argc, &argv);
53 context = g_option_context_new (NULL);
54 g_option_context_add_main_entries (context, options, NULL);
56 if (!g_option_context_parse (context, &argc, &argv, &err)) {
57 g_printerr ("modest: error in command line parameter(s): %s\n",
58 err ? err->message : "");
64 g_log_set_always_fatal (G_LOG_LEVEL_WARNING);
67 modest_conf = MODEST_CONF(modest_conf_new());
69 g_warning ("failed to initialize config system");
74 modest_conf_remove_key (modest_conf, MODEST_CONF_NAMESPACE, NULL);
75 install_basic_conf_settings (modest_conf);
79 modest_icon_factory_init ();
81 modest_ui = MODEST_UI(modest_ui_new (modest_conf));
83 g_warning ("failed to initialize ui");
89 gtk_init (&argc, &argv);
91 if (mailto||cc||bcc||subject||body) {
94 ok = modest_ui_new_edit_window (modest_ui,
98 subject, /* subject */
100 NULL); /* attachments */
103 ok = modest_ui_show_main_window (modest_ui);
106 g_warning ("showing window failed");
117 g_option_context_free (context);
120 g_object_unref (modest_ui);
123 g_object_unref (modest_conf);
125 modest_icon_factory_uninit ();
133 install_basic_conf_settings (ModestConf *conf)
135 g_return_if_fail (conf);
137 /* main window size */
138 modest_conf_set_int (conf, MODEST_CONF_MAIN_WINDOW_WIDTH,
139 MODEST_CONF_MAIN_WINDOW_WIDTH_DEFAULT, NULL);
140 modest_conf_set_int (conf, MODEST_CONF_MAIN_WINDOW_HEIGHT,
141 MODEST_CONF_MAIN_WINDOW_HEIGHT_DEFAULT, NULL);
143 /* edit window size */
144 modest_conf_set_int (conf, MODEST_CONF_EDIT_WINDOW_WIDTH,
145 MODEST_CONF_EDIT_WINDOW_WIDTH_DEFAULT, NULL);
146 modest_conf_set_int (conf, MODEST_CONF_EDIT_WINDOW_HEIGHT,
147 MODEST_CONF_EDIT_WINDOW_HEIGHT_DEFAULT, NULL);
149 g_print ("modest: returned to factory settings\n");