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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* pas-book-view.c
*
* Copyright 2000, Helix Code, Inc.
*/
#include <glib.h>
#include "pas-book-view.h"
static BonoboObjectClass *pas_book_view_parent_class;
POA_Evolution_BookView__vepv pas_book_view_vepv;
struct _PASBookViewPrivate {
Evolution_BookViewListener listener;
};
/**
* pas_book_view_notify_change:
*/
void
pas_book_view_notify_change (PASBookView *book_view,
const GList *cards)
{
CORBA_Environment ev;
gint i, length;
CORBA_sequence_Evolution_VCard card_sequence;
length = g_list_length((GList *) cards);
card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length);
card_sequence._maximum = length;
card_sequence._length = length;
for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
card_sequence._buffer[i] = (char *) cards->data;
}
CORBA_exception_init (&ev);
Evolution_BookViewListener_signal_card_changed (
book_view->priv->listener, &card_sequence, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_change: Exception signaling BookListener!\n");
}
CORBA_exception_free (&ev);
CORBA_free(card_sequence._buffer);
}
/**
* pas_book_view_notify_remove:
*/
void
pas_book_view_notify_remove (PASBookView *book_view,
const char *id)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
Evolution_BookViewListener_signal_card_removed (
book_view->priv->listener, (Evolution_CardId) id, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_remove: Exception signaling BookListener!\n");
}
CORBA_exception_free (&ev);
}
/**
* pas_book_view_notify_add:
*/
void
pas_book_view_notify_add (PASBookView *book_view,
const GList *cards)
{
CORBA_Environment ev;
gint i, length;
CORBA_sequence_Evolution_VCard card_sequence;
length = g_list_length((GList *)cards);
card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length);
card_sequence._maximum = length;
card_sequence._length = length;
for ( i = 0; cards; cards = g_list_next(cards), i++ ) {
card_sequence._buffer[i] = (char *) cards->data;
}
CORBA_exception_init (&ev);
Evolution_BookViewListener_signal_card_added (
book_view->priv->listener, &card_sequence, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("pas_book_view_notify_add: Exception signaling BookListener!\n");
}
CORBA_exception_free (&ev);
CORBA_free(card_sequence._buffer);
}
static gboolean
pas_book_view_construct (PASBookView *book_view,
Evolution_BookViewListener listener)
{
POA_Evolution_BookView *servant;
CORBA_Environment ev;
CORBA_Object obj;
g_assert (book_view != NULL);
g_assert (PAS_IS_BOOK_VIEW (book_view));
g_assert (listener != CORBA_OBJECT_NIL);
servant = (POA_Evolution_BookView *) g_new0 (BonoboObjectServant, 1);
servant->vepv = &pas_book_view_vepv;
CORBA_exception_init (&ev);
POA_Evolution_BookView__init ((PortableServer_Servant) servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_free (servant);
CORBA_exception_free (&ev);
return FALSE;
}
CORBA_exception_free (&ev);
obj = bonobo_object_activate_servant (BONOBO_OBJECT (book_view), servant);
if (obj == CORBA_OBJECT_NIL) {
g_free (servant);
return FALSE;
}
bonobo_object_construct (BONOBO_OBJECT (book_view), obj);
book_view->priv->listener = listener;
return TRUE;
}
/**
* pas_book_view_new:
*/
PASBookView *
pas_book_view_new (Evolution_BookViewListener listener)
{
PASBookView *book_view;
g_return_val_if_fail (listener != CORBA_OBJECT_NIL, NULL);
book_view = gtk_type_new (pas_book_view_get_type ());
if (! pas_book_view_construct (book_view, listener)) {
gtk_object_unref (GTK_OBJECT (book_view));
return NULL;
}
return book_view;
}
static void
pas_book_view_destroy (GtkObject *object)
{
PASBookView *book_view = PAS_BOOK_VIEW (object);
g_free (book_view->priv);
GTK_OBJECT_CLASS (pas_book_view_parent_class)->destroy (object);
}
static POA_Evolution_BookView__epv *
pas_book_view_get_epv (void)
{
POA_Evolution_BookView__epv *epv;
epv = g_new0 (POA_Evolution_BookView__epv, 1);
return epv;
}
static void
pas_book_view_corba_class_init (void)
{
pas_book_view_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
pas_book_view_vepv.Evolution_BookView_epv = pas_book_view_get_epv ();
}
static void
pas_book_view_class_init (PASBookViewClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
pas_book_view_parent_class = gtk_type_class (bonobo_object_get_type ());
object_class->destroy = pas_book_view_destroy;
pas_book_view_corba_class_init ();
}
static void
pas_book_view_init (PASBookView *book_view)
{
book_view->priv = g_new0 (PASBookViewPrivate, 1);
book_view->priv->listener = CORBA_OBJECT_NIL;
}
/**
* pas_book_view_get_type:
*/
GtkType
pas_book_view_get_type (void)
{
static GtkType type = 0;
if (! type) {
GtkTypeInfo info = {
"PASBookView",
sizeof (PASBookView),
sizeof (PASBookViewClass),
(GtkClassInitFunc) pas_book_view_class_init,
(GtkObjectInitFunc) pas_book_view_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (bonobo_object_get_type (), &info);
}
return type;
}
|