aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/control-factory.c
blob: 8df9559ea17c8d8fd359baefdd3bcd2c8edfbea4 (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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* control-factory.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 <ettore@ximian.com>
 */

#include <config.h>
#include <string.h>
#include <gtk/gtksignal.h>
#include <glade/glade.h>
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-persist-file.h>
#include <bonobo/bonobo-context.h>
#include <glade/glade.h>
#include <libgnomeui/gnome-dialog-util.h>

#include <libecal/e-cal-time-util.h>
#include <gui/gnome-cal.h>
#include <gui/calendar-commands.h>
#include <gui/calendar-config.h>

#include "control-factory.h"

/* Are these supposed to be global or static? */
CORBA_Environment ev;
CORBA_ORB orb;

static void
control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
{
    GnomeCalendar *gcal;

    gcal = GNOME_CALENDAR (data);

    if (activate)
        calendar_control_activate (control, gcal);
    else
        calendar_control_deactivate (control, gcal);
}

BonoboControl *
control_factory_new_control (void)
{
    BonoboControl *control;
    GnomeCalendar *gcal;

    gcal = GNOME_CALENDAR (gnome_calendar_new ());
    if (!gcal)
        return NULL;

    gtk_widget_show (GTK_WIDGET (gcal));

    control = bonobo_control_new (GTK_WIDGET (gcal));
    if (!control) {
        g_message ("control_factory_fn(): could not create the control!");
        return NULL;
    }
    g_object_set_data (G_OBJECT (gcal), "control", control);

    g_signal_connect (control, "activate", G_CALLBACK (control_activate_cb), gcal);

    return control;
}