aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/main.c
blob: a15c0ef84638ab886d34d91c73ceb76b5a0573ef (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* main.c
 *
 * Copyright (C) 2000, 2001, 2002, 2003  Ximian, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: Ettore Perazzoli
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-init.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <glade/glade.h>

#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-shlib-factory.h>
#include <bonobo/bonobo-exception.h>

#include <gal/widgets/e-cursors.h>

#include <evolution-shell-client.h>

#include "dialogs/cal-prefs-dialog.h"
#include "calendar-commands.h"
#include "calendar-config.h"
#include "calendar-component.h"
#include "e-comp-editor-registry.h"
#include "comp-editor-factory.h"
#include "control-factory.h"
#include "itip-bonobo-control.h"
#include "tasks-control.h"


#define FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_Factory"

#define CALENDAR_COMPONENT_ID  "OAFIID:GNOME_Evolution_Calendar_ShellComponent"
#define CALENDAR_CONTROL_ID    "OAFIID:GNOME_Evolution_Calendar_Control"
#define TASKS_CONTROL_ID       "OAFIID:GNOME_Evolution_Tasks_Control"
#define ITIP_CONTROL_ID        "OAFIID:GNOME_Evolution_Calendar_iTip_Control"
#define CONFIG_CONTROL_ID      "OAFIID:GNOME_Evolution_Calendar_ConfigControl"
#define COMP_EDITOR_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_CompEditorFactory"

ECompEditorRegistry *comp_editor_registry = NULL;

/* The component editor factory */
static CompEditorFactory *comp_editor_factory = NULL;


/* Factory function for the calendar component factory; just creates and
 * references a singleton service object.
 */
static BonoboObject *
comp_editor_factory_fn (void)
{
    if (!comp_editor_factory) {
        comp_editor_factory = comp_editor_factory_new ();
        if (!comp_editor_factory)
            return NULL;
    }

    bonobo_object_ref (BONOBO_OBJECT (comp_editor_factory));
    return BONOBO_OBJECT (comp_editor_factory);
}


/* Does a simple activation and unreffing of the alarm notification service so
 * that the daemon will be launched if it is not running yet.
 */
static gboolean
launch_alarm_daemon_cb (gpointer data)
{
    CORBA_Environment ev;
    GNOME_Evolution_Calendar_AlarmNotify an;
    guint *idle_id = (guint *) data;

    /* remove the idle function */
    g_source_remove (*idle_id);
    g_free (idle_id);

    /* activate the alarm daemon */
    CORBA_exception_init (&ev);
    an = bonobo_activation_activate_from_id ("OAFIID:GNOME_Evolution_Calendar_AlarmNotify", 0, NULL, &ev);

    if (BONOBO_EX (&ev)) {
        g_message ("launch_alarm_daemon_cb(): Could not activate the alarm notification service");
        CORBA_exception_free (&ev);
        return FALSE;
    }
    CORBA_exception_free (&ev);

    /* Just get rid of it; what we are interested in is that it gets launched */

    CORBA_exception_init (&ev);
    bonobo_object_release_unref (an, &ev);
    if (BONOBO_EX (&ev))
        g_message ("add_alarms(): Could not unref the alarm notification service");

    CORBA_exception_free (&ev);

    return FALSE;
}

static void
launch_alarm_daemon (void)
{
    guint *idle_id;

    idle_id = g_new0 (guint, 1);
    *idle_id = g_idle_add ((GSourceFunc) launch_alarm_daemon_cb, idle_id);
}

static void
initialize (void)
{
    comp_editor_registry = E_COMP_EDITOR_REGISTRY (e_comp_editor_registry_new ());
    
    calendar_config_init ();

#if 0
    itip_control_factory_init ();
    component_editor_factory_init ();
#endif

    launch_alarm_daemon ();
}


static BonoboObject *
factory (BonoboGenericFactory *factory,
     const char *component_id,
     void *closure)
{
    static gboolean initialized = FALSE;

    if (! initialized) {
        initialize ();
        initialized = TRUE;
    }

    if (strcmp (component_id, CALENDAR_COMPONENT_ID) == 0)
        return calendar_component_get_object ();
    if (strcmp (component_id, CALENDAR_CONTROL_ID) == 0)
        return BONOBO_OBJECT (control_factory_new_control ());
    if (strcmp (component_id, TASKS_CONTROL_ID) == 0)
        return BONOBO_OBJECT (tasks_control_new ());
    if (strcmp (component_id, ITIP_CONTROL_ID) == 0)
        return BONOBO_OBJECT (itip_bonobo_control_new ());
    if (strcmp (component_id, CONFIG_CONTROL_ID) == 0) {
        extern EvolutionShellClient *global_shell_client; /* FIXME ugly */

        if (global_shell_client == NULL)
            return NULL;
        else
            return BONOBO_OBJECT (cal_prefs_dialog_new ());
    }
    if (strcmp (component_id, COMP_EDITOR_FACTORY_ID) == 0)
        return BONOBO_OBJECT (comp_editor_factory_fn ());

    g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
    return NULL;
}

BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL)
d>Move the stragler's www.freebsd.org/~user distfiles to the officalobrien2000-06-291-1/+2 * Add the only file I missed it the last p5-* mega-update.will2000-06-171-0/+11 * Lots and lots of cleanups. Teach p5-* in general about PKGNAMEPREFIX.will2000-06-171-7/+6 * Make PLIST match BSD.x11.dist. Mostly cosmetic (added/deleted @dirrmasami2000-06-104-6/+1 * Split up XFree86-4 into several pieces. Pretty green, please test with care.asami2000-06-0837-0/+1447 * Fixed taipei16.bdf in this porttaoka2000-06-081-0/+38 * Remove empty fonts.dir and fonts.alias files. (Note chinese/kcfonts stillasami2000-06-011-0/+1 * Updated to 2.0.2taoka2000-05-302-2/+2 * Update to version 4.4.steve2000-05-293-9/+16 * Adding mozilla-fonts version 1.0.steve2000-05-017-0/+164 * Update to 8.3.shige2000-04-262-3/+4 * Revert erich's ports to ports@FreeBSD.org, as erich has been non-responsivekris2000-04-242-2/+2 * Update with the new PORTNAME/PORTVERSION variablescpiazza2000-04-1013-37/+37 * portlint:mharo2000-03-211-3/+2 * Make TTF support not optional, it never come into package otherwiseache2000-02-292-15/+6 * Change all www.freebsd.org/~user references to people.FreeBSD.org/~user,peter2000-02-081-1/+1 * Update to 8.2.shige2000-02-083-4/+4 * Updated MASTER_SITEStaoka2000-01-162-2/+3 * Update version to 4.3.3.imura2000-01-154-8/+17 * - Fix MASTER_SITESimura2000-01-152-3/+5 * Added intlfontstaoka2000-01-081-0/+1 * Free X11 fonts for all characters that Emacs can handletaoka2000-01-088-0/+375 * Upgrade to 8.1.shige1999-12-244-12/+19 * Work around the fact that Tcl's exec treats non-empty stderr as ansteve1999-11-273-6/+39 * Bump freetype's lib numberjseger1999-11-252-2/+2 * Update to 4.2.jfieber1999-11-164-29/+16 * Update to 8.0.shige1999-11-062-7/+6 * Update to 7.19.07.shige1999-10-222-3/+3 * Fix unfetchable problem.shige1999-10-222-6/+7 * Add nexfontseltaoka1999-09-291-0/+1 * A neXtaw based replacement for xfontseltaoka1999-09-295-0/+38 * ${GUNZIP} -> ${GUNZIP_CMD}. (mharo somehow misspelt these two.... ;)asami1999-09-091-1/+1 * Update MAINTAINER's email addresscpiazza1999-09-091-1/+1 * gzip -> ${GZIP_CMD}mharo1999-09-051-1/+1 * FreeBSD.ORG -> FreeBSD.orgmharo1999-08-314-6/+6 * $Id$ -> $FreeBSD$peter1999-08-3113-13/+13 * Caps, no period.hoek1999-08-301-1/+1 * awk -> ${AWK}mharo1999-08-232-4/+4 * chmod -> ${CHMOD}mharo1999-08-231-3/+3 * Add INSTALL and DEINSTALL scripts.shige1999-08-195-8/+36 * Add editors/bitmap-{emacs20,fonts}, x11-fonts/bitmap-font.asami1999-08-191-1/+2 * Bitmap font, 8 dots x 16 dots bitmap font.shige1999-08-186-0/+82 * Upgrade from 3.7 to 3.9.jfieber1999-08-143-20/+54 * Commit #2/4 to enforce Caps, no period. I ran this oe ashoek1999-06-278-8/+8 * Revert my previous fix. It seems I had an old distfile.steve1999-06-231-2/+2 * Set ${WRKSRC} correctly so this builds again.steve1999-05-311-5/+2 * a remove white spacemharo1999-05-031-1/+0 * type1inst requires mkfontdirtaoka1999-04-141-1/+3 * Adjust port Makefiles to new EXTRACT_* variable defaults. See log ofasami1999-02-031-2/+4 * Upgrade from 3.4 to 3.7.jfieber1999-01-172-5/+5 * Break up the "plan9" category -- all the ports are where they belong, andasami1999-01-092-3/+4 * Fix WRKSRC.asami1998-12-271-2/+2 * Activate p5-type1instjseger1998-12-131-1/+2 * Import of p5-type1inst 0.6.1jseger1998-12-135-0/+54 * Use libttf.3 of the new freetype 1.2jseger1998-12-131-2/+2 * Fixup CATEGORIES list.steve1998-11-221-2/+2 * Update MASTER_SITES, include my public_html dir as a site, asbillf1998-11-201-2/+3 * Portlint.asami1998-10-301-3/+3 * Upgrade and unbreak.jfieber1998-10-293-84/+59 * Move manpages to Makefile and use MAN1 macro.steve1998-10-052-2/+2 * Remove empty directories on deinstall.steve1998-10-051-0/+1 * Move manpages to Makefile and use MAN* macros.steve1998-10-041-0/+2 * freetype (libttf) is now converted to ELF.asami1998-09-211-2/+2 * Checksum changed....asami1998-09-151-1/+1 * ttmkfdir moved from x11 to x11-fonts.tg1998-09-091-1/+2 * Re-import to x11-fonts, as requested by Satoshi.tg1998-09-095-0/+32 * For removing this one manpage, I can not be bothered tohoek1998-08-201-1/+0 * Fix up dependencies for ports that moved into the x11-toolkits category.asami1998-08-081-2/+2 * Move "etlfonts freefonts getbdf sharefonts tkfont xfed xmbdfed" fromasami1998-08-087-14/+14 * New categories deskutils, x11-clocks, x11-fm, x11-fonts, x11-toolkitsasami1998-08-082-0/+13 * Rename all USE_X11 to USE_X_PREFIX. Requires 1.279 (3.0-current) orasami1998-08-056-12/+12 * Sort pkg/PLIST.vanilla1998-07-021-11/+11 * Sort pkg/PLIST.vanilla1998-07-022-52/+41 * Import of tkfont, a Tk-based replacement for xfontsel.mph1998-05-175-0/+51 * PR: ports/6139dburr1998-05-165-0/+95 * Mark as broken.jfieber1998-03-131-1/+3 * Be more selective about which ports to maintain. I no longer have timeasami1997-12-261-2/+2 * fix a typo error in pkg/DESCR, add @dirrm in pkg/PLISTvanilla1997-12-052-1/+2 * Fix a typo error.vanilla1997-12-041-2/+2 * Change MASTER_SITE to ftp.gimp.orgvanilla1997-12-011-2/+2 * Upgrade to version 2.7.jfieber1997-11-093-26/+31 * Upgrade to version 2.3. Bugfixes mostly.jfieber1997-09-222-5/+6 * A Motif tool for editing X11 bitmap fontsjfieber1997-07-167-0/+137 * /bin/sh -> ${SH}max1997-07-141-2/+2 * Add WRKSRC, seems like fetch creates all the subdirectories in theasami1997-03-041-1/+2 * Use xfed sources from ftp.demon.co.uk. I tried this server withtg1997-03-032-30/+4 * distfile changederich1997-01-272-3/+2 * Renaming the PKIGNAME, etlfnot-noncjk -> etlfonts-noncjk.max1997-01-031-3/+3 * Renaming etlfont -> etlfonts.max1997-01-037-0/+142