source: trunk/third/evolution/shell/evolution-session.c @ 16770

Revision 16770, 5.3 KB checked in by ghudson, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r16769, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2/* evolution-session.c
3 *
4 * Copyright (C) 2000  Ximian, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 * Author: Ettore Perazzoli
22 */
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif
27
28#include <gtk/gtksignal.h>
29#include <gal/util/e-util.h>
30
31#include "Evolution.h"
32
33#include "evolution-session.h"
34
35
36#define PARENT_TYPE bonobo_object_get_type ()
37static BonoboObjectClass *parent_class = NULL;
38
39struct _EvolutionSessionPrivate {
40        int dummy;
41};
42
43enum {
44        LOAD_CONFIGURATION,
45        SAVE_CONFIGURATION,
46        LAST_SIGNAL
47};
48
49static int signals[LAST_SIGNAL];
50
51
52/* GtkObject methods.  */
53
54static void
55impl_destroy (GtkObject *object)
56{
57        EvolutionSession *session;
58        EvolutionSessionPrivate *priv;
59
60        session = EVOLUTION_SESSION (object);
61        priv = session->priv;
62
63        g_free (priv);
64
65        (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
66}
67
68
69/* CORBA interface implementation.  */
70
71static void
72impl_GNOME_Evolution_Session_saveConfiguration (PortableServer_Servant servant,
73                                                const CORBA_char *prefix,
74                                                CORBA_Environment *ev)
75{
76        BonoboObject *self;
77
78        self = bonobo_object_from_servant (servant);
79        gtk_signal_emit (GTK_OBJECT (self), signals[SAVE_CONFIGURATION], prefix);
80}
81
82static void
83impl_GNOME_Evolution_Session_loadConfiguration (PortableServer_Servant servant,
84                                                const CORBA_char *prefix,
85                                                CORBA_Environment *ev)
86{
87        BonoboObject *self;
88
89        self = bonobo_object_from_servant (servant);
90        gtk_signal_emit (GTK_OBJECT (self), signals[LOAD_CONFIGURATION], prefix);
91}
92
93
94/* Initialization.  */
95
96static POA_GNOME_Evolution_Session__vepv GNOME_Evolution_Session_vepv;
97
98static void
99corba_class_init (void)
100{
101        POA_GNOME_Evolution_Session__vepv *vepv;
102        POA_GNOME_Evolution_Session__epv *epv;
103        PortableServer_ServantBase__epv *base_epv;
104
105        base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
106        base_epv->_private    = NULL;
107        base_epv->finalize    = NULL;
108        base_epv->default_POA = NULL;
109
110        epv = g_new0 (POA_GNOME_Evolution_Session__epv, 1);
111        epv->saveConfiguration = impl_GNOME_Evolution_Session_saveConfiguration;
112        epv->loadConfiguration = impl_GNOME_Evolution_Session_loadConfiguration;
113
114        vepv = &GNOME_Evolution_Session_vepv;
115        vepv->_base_epv             = base_epv;
116        vepv->Bonobo_Unknown_epv    = bonobo_object_get_epv ();
117        vepv->GNOME_Evolution_Session_epv = epv;
118}
119
120static void
121class_init (EvolutionSessionClass *klass)
122{
123        GtkObjectClass *object_class;
124
125        object_class = GTK_OBJECT_CLASS (klass);
126        parent_class = gtk_type_class (bonobo_object_get_type ());
127
128        object_class->destroy = impl_destroy;
129
130        signals[LOAD_CONFIGURATION]
131                = gtk_signal_new ("load_configuration",
132                                  GTK_RUN_FIRST,
133                                  object_class->type,
134                                  GTK_SIGNAL_OFFSET (EvolutionSessionClass, load_configuration),
135                                  gtk_marshal_NONE__STRING,
136                                  GTK_TYPE_NONE, 1,
137                                  GTK_TYPE_STRING);
138        signals[SAVE_CONFIGURATION]
139                = gtk_signal_new ("save_configuration",
140                                  GTK_RUN_FIRST,
141                                  object_class->type,
142                                  GTK_SIGNAL_OFFSET (EvolutionSessionClass, save_configuration),
143                                  gtk_marshal_NONE__STRING,
144                                  GTK_TYPE_NONE, 1,
145                                  GTK_TYPE_STRING);
146
147        gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
148
149        corba_class_init ();
150}
151
152static void
153init (EvolutionSession *session)
154{
155        EvolutionSessionPrivate *priv;
156
157        priv = g_new (EvolutionSessionPrivate, 1);
158
159        session->priv = priv;
160}
161
162
163static GNOME_Evolution_Session
164create_corba_session (BonoboObject *object)
165{
166        POA_GNOME_Evolution_Session *servant;
167        CORBA_Environment ev;
168
169        servant = (POA_GNOME_Evolution_Session *) g_new0 (BonoboObjectServant, 1);
170        servant->vepv = &GNOME_Evolution_Session_vepv;
171
172        CORBA_exception_init (&ev);
173
174        POA_GNOME_Evolution_Session__init ((PortableServer_Servant) servant, &ev);
175        if (ev._major != CORBA_NO_EXCEPTION) {
176                g_free (servant);
177                CORBA_exception_free (&ev);
178                return CORBA_OBJECT_NIL;
179        }
180
181        CORBA_exception_free (&ev);
182        return (GNOME_Evolution_Session) bonobo_object_activate_servant (object, servant);
183}
184
185void
186evolution_session_construct (EvolutionSession *session,
187                             CORBA_Object corba_session)
188{
189        g_return_if_fail (session != NULL);
190        g_return_if_fail (corba_session != CORBA_OBJECT_NIL);
191
192        bonobo_object_construct (BONOBO_OBJECT (session), corba_session);
193}
194
195EvolutionSession *
196evolution_session_new (void)
197{
198        EvolutionSession *session;
199        GNOME_Evolution_Session corba_session;
200
201        session = gtk_type_new (evolution_session_get_type ());
202
203        corba_session = create_corba_session (BONOBO_OBJECT (session));
204        if (corba_session == CORBA_OBJECT_NIL) {
205                bonobo_object_unref (BONOBO_OBJECT (session));
206                return NULL;
207        }
208
209        evolution_session_construct (session, corba_session);
210        return session;
211}
212
213
214E_MAKE_TYPE (evolution_session, "EvolutionSession", EvolutionSession, class_init, init, PARENT_TYPE)
Note: See TracBrowser for help on using the repository browser.