aboutsummaryrefslogtreecommitdiffstats
path: root/shell/main.c
blob: 9fa59a6ee01bb5f9ce2be62876676a9e72bfc3dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Main evolution shell application
 *
 * Authors:
 *   Miguel de Icaza (miguel@helixcode.com)
 *
 */

#include <config.h>

#include <gnome.h>
#include <bonobo.h>
#include <e-util/e-gui-utils.h>
#include <e-util/e-cursors.h>
#include <e-util/e-setup.h> /* for e_setup_base_dir */
#include <glade/glade.h>
#include <glade/glade-xml.h>

#ifdef USING_OAF
#include <liboaf/liboaf.h>
#else
#include <libgnorba/gnorba.h>
#endif

#include "e-shell.h"
#include "e-shell-view.h"

int shell_debugging = 0;

poptContext ctx;

EShell *eshell;

const struct poptOption shell_popt_options [] = {
    { "debug", '\0', POPT_ARG_INT, &shell_debugging, 0,
      N_("Enables some debugging functions"), N_("LEVEL") },
        { NULL, '\0', 0, NULL, 0 }
};

#ifdef USING_OAF

static void
corba_init (int *argc, char *argv [])
{
    gnomelib_register_popt_table (shell_popt_options, "Evolution shell options");

    gnome_init_with_popt_table ("Evolution", VERSION, *argc, argv,
                    oaf_popt_options, 0, NULL);

    oaf_init (*argc, argv);
}

#else  /* USING_OAF */

static void
corba_init (int *argc, char *argv [])
{
    CORBA_Environment ev;
    
    CORBA_exception_init (&ev);
    gnome_CORBA_init_with_popt_table (
        "Evolution", VERSION, argc, argv,
        shell_popt_options, 0, &ctx, GNORBA_INIT_SERVER_FUNC, &ev);
    CORBA_exception_free (&ev);
}

#endif /* USING_OAF */

static void
init_bonobo (void)
{
    if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE){
        e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
              _("Failed to initialize the Bonobo component system"));
        exit (1);
    }
}

static void
gui_init (void)
{
    e_cursors_init ();

    glade_gnome_init ();

    bonobo_activate ();
}

static void
gui_shutdown (void)
{
    /* shutdown */
    e_cursors_shutdown ();
}

static void
evolution_boot (void)
{
    EShellView *e_shell_view;

    if (!e_setup_base_dir ()){
        e_notice (
            NULL, GNOME_MESSAGE_BOX_ERROR,
            _("It was not possible to setup the Evolution startup files.  Please\n"
              "fix the problem, and restart Evolution"));
        exit (0);
    }
    
    eshell = e_shell_new ();
    e_shell_view = E_SHELL_VIEW (
        e_shell_view_new (eshell,
                  eshell->default_folders.inbox,
                  TRUE));
    gtk_signal_connect (GTK_OBJECT (e_shell_view), "destroy",
                GTK_SIGNAL_FUNC(gtk_main_quit),
                NULL);
    
    gtk_widget_show (GTK_WIDGET (e_shell_view));
}

int
main (int argc, char *argv [])
{
    bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
    textdomain (PACKAGE);

    corba_init (&argc, argv);
    init_bonobo ();

    gui_init ();

    evolution_boot ();
    
    gtk_main ();

    gui_shutdown ();

    return 0;
}