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

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