]>
Commit | Line | Data |
---|---|---|
d740413d AM |
1 | Index: executive-summary/component/e-summary.c |
2 | =================================================================== | |
3 | RCS file: /cvs/gnome/evolution/executive-summary/component/e-summary.c,v | |
4 | retrieving revision 1.16 | |
5 | retrieving revision 1.18 | |
6 | diff -u -r1.16 -r1.18 | |
7 | --- executive-summary/component/e-summary.c 2000/12/13 18:26:45 1.16 | |
8 | +++ executive-summary/component/e-summary.c 2000/12/30 01:34:03 1.18 | |
9 | @@ -337,25 +337,13 @@ | |
10 | { | |
11 | char *html, *tmp; | |
12 | int id = GPOINTER_TO_INT (window); | |
13 | - gboolean u, d, l, r, config; | |
14 | + gboolean config; | |
15 | ||
16 | - u = d = l = r = config = TRUE; | |
17 | + config = TRUE; | |
18 | ||
19 | if (window->propertycontrol == CORBA_OBJECT_NIL) | |
20 | config = FALSE; | |
21 | ||
22 | - if (row == 0) /* Top row */ | |
23 | - u = FALSE; | |
24 | - | |
25 | - if (row >= numwindows - 3) /* Bottom row */ | |
26 | - d = FALSE; | |
27 | - | |
28 | - if (col == 0) /* Leftmost column */ | |
29 | - l = FALSE; | |
30 | - | |
31 | - if (col == 2 || ((row * 3) + col) == numwindows - 1) /* Rightmost column */ | |
32 | - r = FALSE; | |
33 | - | |
34 | html = g_strdup_printf ("<table><tr><td><a href=\"close://%d\">" | |
35 | "<img src=\"service-close.png\" border=\"0\">" | |
36 | "</a></td></tr><tr><td>", id); | |
37 | @@ -371,53 +359,6 @@ | |
38 | } | |
39 | g_free (tmp); | |
40 | ||
41 | -#if 0 | |
42 | - tmp = html; | |
43 | - if (!l) { | |
44 | - html = g_strdup_printf ("%s<img src=\"service-left-disabled.png\">" | |
45 | - "</td><td>", tmp); | |
46 | - } else { | |
47 | - html = g_strdup_printf ("%s<a href=\"left://%d\">" | |
48 | - "<img src=\"service-left.png\" border=\"0\">" | |
49 | - "</a></td><td>", tmp, id); | |
50 | - } | |
51 | - g_free (tmp); | |
52 | - | |
53 | - tmp = html; | |
54 | - if (!r) { | |
55 | - html = g_strdup_printf ("%s<img src=\"service-right-disabled.png\">" | |
56 | - "</td></tr></table>", tmp); | |
57 | - } else { | |
58 | - html = g_strdup_printf ("%s<a href=\"right://%d\">" | |
59 | - "<img src=\"service-right.png\" border=\"0\">" | |
60 | - "</a></td></tr></table>", tmp, id); | |
61 | - } | |
62 | - g_free (tmp); | |
63 | - | |
64 | - | |
65 | - tmp = html; | |
66 | - if (!d) { | |
67 | - html = g_strdup_printf ("%s<img src=\"service-down-disabled.png\">" | |
68 | - "</td><td>", tmp); | |
69 | - } else { | |
70 | - html = g_strdup_printf ("%s<a href=\"down://%d\">" | |
71 | - "<img src=\"service-down.png\" border=\"0\">" | |
72 | - "</a></td><td>", tmp, id); | |
73 | - } | |
74 | - g_free (tmp); | |
75 | - | |
76 | - tmp = html; | |
77 | - if (!u) { | |
78 | - html = g_strdup_printf ("%s<img src=\"service-up-disabled.png\">" | |
79 | - "</td></tr></table>", tmp); | |
80 | - } else { | |
81 | - html = g_strdup_printf ("%s<a href=\"up://%d\">" | |
82 | - "<img src=\"service-up.png\" border=\"0\">" | |
83 | - "</a></td></tr></table>", tmp, id); | |
84 | - } | |
85 | - g_free (tmp); | |
86 | - | |
87 | -#endif | |
88 | return html; | |
89 | } | |
90 | ||
91 | @@ -631,43 +572,31 @@ | |
92 | } | |
93 | ||
94 | static void | |
95 | -html_event (BonoboListener *listener, | |
96 | - char *event_name, | |
97 | - CORBA_any *any, | |
98 | - CORBA_Environment *ev, | |
99 | - gpointer user_data) | |
100 | +listener_event (BonoboListener *listener, | |
101 | + char *event_name, | |
102 | + BonoboArg *event_data, | |
103 | + CORBA_Environment *ev, | |
104 | + gpointer user_data) | |
105 | { | |
106 | ESummaryWindow *window = (ESummaryWindow *) user_data; | |
107 | ||
108 | - g_print ("Event: %s\n", event_name); | |
109 | - if (strcmp (event_name, EXECUTIVE_SUMMARY_HTML_VIEW_HTML_CHANGED) != 0) { | |
110 | - return; | |
111 | - } | |
112 | - | |
113 | - e_summary_queue_rebuild (window->esummary); | |
114 | -} | |
115 | - | |
116 | -static void | |
117 | -prop_changed_cb (BonoboPropertyListener *listener, | |
118 | - char *name, | |
119 | - BonoboArg *arg, | |
120 | - ESummaryWindow *window) | |
121 | -{ | |
122 | - if (strcmp (name, "window_title") == 0) { | |
123 | + if (strcmp (event_name, "Bonobo/Property:change:window_title") == 0) { | |
124 | if (window->title != NULL) | |
125 | g_free (window->title); | |
126 | - window->title = g_strdup (BONOBO_ARG_GET_STRING (arg)); | |
127 | - e_summary_queue_rebuild (window->esummary); | |
128 | - return; | |
129 | - } | |
130 | ||
131 | - if (strcmp (name, "window_icon") == 0) { | |
132 | + window->title = g_strdup (BONOBO_ARG_GET_STRING (event_data)); | |
133 | + e_summary_queue_rebuild (window->esummary); | |
134 | + } else if (strcmp (event_name, "Bonobo/Property:change:window_icon") == 0) { | |
135 | if (window->icon != NULL) | |
136 | g_free (window->icon); | |
137 | - window->icon = g_strdup (BONOBO_ARG_GET_STRING (arg)); | |
138 | + | |
139 | + window->icon = g_strdup (BONOBO_ARG_GET_STRING (event_data)); | |
140 | e_summary_queue_rebuild (window->esummary); | |
141 | - return; | |
142 | + } else if (strcmp (event_name, EXECUTIVE_SUMMARY_HTML_VIEW_HTML_CHANGED) == 0) { | |
143 | + e_summary_queue_rebuild (window->esummary); | |
144 | } | |
145 | + | |
146 | + return; | |
147 | } | |
148 | ||
149 | ESummaryWindow * | |
150 | @@ -678,7 +607,7 @@ | |
151 | ESummaryWindow *window; | |
152 | ESummaryPrivate *priv; | |
153 | Bonobo_Unknown unknown = CORBA_OBJECT_NIL; | |
154 | - Bonobo_PropertyListener corba_listener; | |
155 | + Bonobo_Listener listener; | |
156 | CORBA_Environment ev; | |
157 | ||
158 | g_return_val_if_fail (esummary != NULL, NULL); | |
159 | @@ -718,26 +647,22 @@ | |
160 | return NULL; | |
161 | } | |
162 | ||
163 | - if (window->html != CORBA_OBJECT_NIL) { | |
164 | - Bonobo_Listener listener; | |
165 | - CORBA_Environment ev2; | |
166 | - | |
167 | - /* If HTML view, then set up the listeners. */ | |
168 | - window->event_source = Bonobo_Unknown_queryInterface (window->html, | |
169 | - "IDL:Bonobo/EventSource:1.0", | |
170 | - &ev); | |
171 | - window->html_listener = bonobo_listener_new (html_event, | |
172 | - window); | |
173 | - listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->html_listener)); | |
174 | - window->html_corba_listener = listener; | |
175 | + window->event_source = Bonobo_Unknown_queryInterface(window->component, | |
176 | + "IDL:Bonobo/EventSource:1.0", &ev); | |
177 | + if (window->event_source == CORBA_OBJECT_NIL) { | |
178 | + g_warning ("There is no Bonobo::EventSource interface"); | |
179 | ||
180 | - CORBA_exception_init (&ev2); | |
181 | - Bonobo_EventSource_addListener (window->event_source, | |
182 | - listener, &ev2); | |
183 | - /* Catch error? FIXME */ | |
184 | - CORBA_exception_free (&ev2); | |
185 | + /* FIXME: Free whatever objects exist */ | |
186 | + g_free (window); | |
187 | + return NULL; | |
188 | } | |
189 | ||
190 | + window->listener = bonobo_listener_new (NULL, NULL); | |
191 | + gtk_signal_connect (GTK_OBJECT (window->listener), "event_notify", | |
192 | + GTK_SIGNAL_FUNC (listener_event), window); | |
193 | + listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->listener)); | |
194 | + window->listener_id = Bonobo_EventSource_addListener (window->event_source, listener, &ev); | |
195 | + | |
196 | unknown = Bonobo_Unknown_queryInterface (component, | |
197 | "IDL:Bonobo/PropertyBag:1.0", | |
198 | &ev); | |
199 | @@ -761,20 +686,8 @@ | |
200 | window->icon = g_strdup (bonobo_property_bag_client_get_value_string ( | |
201 | window->propertybag, | |
202 | "window_icon", NULL)); | |
203 | - /* Listen to changes */ | |
204 | - window->listener = bonobo_property_listener_new (); | |
205 | - gtk_signal_connect (GTK_OBJECT (window->listener), "prop_changed", | |
206 | - GTK_SIGNAL_FUNC (prop_changed_cb), window); | |
207 | - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->listener)); | |
208 | - Bonobo_PropertyBag_addChangeListener (window->propertybag, | |
209 | - "window_title", | |
210 | - corba_listener, &ev); | |
211 | - | |
212 | - Bonobo_PropertyBag_addChangeListener (window->propertybag, | |
213 | - "window_icon", | |
214 | - corba_listener, &ev); | |
215 | - CORBA_exception_free (&ev); | |
216 | ||
217 | + CORBA_exception_free (&ev); | |
218 | priv->window_list = g_list_append (priv->window_list, window); | |
219 | ||
220 | return window; | |
221 | @@ -821,7 +734,7 @@ | |
222 | ||
223 | if (window->event_source != CORBA_OBJECT_NIL) { | |
224 | Bonobo_EventSource_removeListener (window->event_source, | |
225 | - window->html_corba_listener, | |
226 | + window->listener_id, | |
227 | &ev); | |
228 | if (ev._major != CORBA_NO_EXCEPTION) { | |
229 | g_warning ("CORBA ERROR: %s", CORBA_exception_id (&ev)); | |
230 | @@ -829,10 +742,6 @@ | |
231 | bonobo_object_release_unref (window->event_source, &ev); | |
232 | } | |
233 | ||
234 | - if (window->html != CORBA_OBJECT_NIL) { | |
235 | - bonobo_object_release_unref (window->html, &ev); | |
236 | - } | |
237 | - | |
238 | if (window->propertybag != CORBA_OBJECT_NIL) { | |
239 | bonobo_object_release_unref (window->propertybag, &ev); | |
240 | } | |
241 | @@ -849,8 +758,8 @@ | |
242 | bonobo_object_unref (BONOBO_OBJECT (window->listener)); | |
243 | } | |
244 | ||
245 | - if (window->html_listener) { | |
246 | - bonobo_object_unref (BONOBO_OBJECT (window->html_listener)); | |
247 | + if (window->html != CORBA_OBJECT_NIL) { | |
248 | + bonobo_object_release_unref (window->html, &ev); | |
249 | } | |
250 | ||
251 | bonobo_object_release_unref (window->component, &ev); | |
252 | Index: executive-summary/component/e-summary.h | |
253 | =================================================================== | |
254 | RCS file: /cvs/gnome/evolution/executive-summary/component/e-summary.h,v | |
255 | retrieving revision 1.9 | |
256 | retrieving revision 1.11 | |
257 | diff -u -r1.9 -r1.11 | |
258 | --- executive-summary/component/e-summary.h 2000/12/11 20:00:24 1.9 | |
259 | +++ executive-summary/component/e-summary.h 2000/12/30 01:34:03 1.11 | |
260 | @@ -55,10 +55,10 @@ | |
261 | Bonobo_PropertyBag propertybag; | |
262 | Bonobo_PropertyControl propertycontrol; | |
263 | Bonobo_EventSource event_source; | |
264 | - | |
265 | - BonoboPropertyListener *listener; | |
266 | - BonoboListener *html_listener; | |
267 | - Bonobo_Listener html_corba_listener; | |
268 | + | |
269 | + /* Listener for the event_source */ | |
270 | + BonoboListener *listener; | |
271 | + int listener_id; | |
272 | ||
273 | char *iid; | |
274 | char *title; | |
275 | Index: executive-summary/component/e-summary-url.c | |
276 | =================================================================== | |
277 | RCS file: /cvs/gnome/evolution/executive-summary/component/e-summary-url.c,v | |
278 | retrieving revision 1.9 | |
279 | retrieving revision 1.11 | |
280 | diff -u -r1.9 -r1.11 | |
281 | --- executive-summary/component/e-summary-url.c 2000/12/12 23:29:56 1.9 | |
282 | +++ executive-summary/component/e-summary-url.c 2000/12/30 01:34:03 1.11 | |
283 | @@ -75,25 +75,96 @@ | |
284 | ||
285 | typedef struct _PropertyDialog { | |
286 | BonoboListener *listener; | |
287 | - Bonobo_Listener corba_listener; | |
288 | + int listener_id; | |
289 | + | |
290 | Bonobo_EventSource eventsource; | |
291 | GtkWidget *dialog; | |
292 | } PropertyDialog; | |
293 | #define COMPOSER_IID "OAFIID:GNOME_Evolution_Mail_Composer" | |
294 | ||
295 | +#if HAVECACHE | |
296 | +static ESummaryCache *image_cache = NULL; | |
297 | +#endif | |
298 | + | |
299 | gboolean e_summary_url_mail_compose (ESummary *esummary, | |
300 | const char *url); | |
301 | gboolean e_summary_url_exec (const char *exec); | |
302 | ||
303 | +struct _DownloadInfo { | |
304 | + GtkHTMLStream *stream; | |
305 | + char *uri; | |
306 | + char *buffer; | |
307 | + | |
308 | + gboolean error; | |
309 | +}; | |
310 | +typedef struct _DownloadInfo DownloadInfo; | |
311 | + | |
312 | +static void | |
313 | +close_callback (GnomeVFSAsyncHandle *handle, | |
314 | + GnomeVFSResult result, | |
315 | + DownloadInfo *info) | |
316 | +{ | |
317 | + if (info->error) { | |
318 | + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); | |
319 | + } else { | |
320 | + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_OK); | |
321 | + } | |
322 | + | |
323 | + g_free (info->uri); | |
324 | + g_free (info->buffer); | |
325 | + g_free (info); | |
326 | +} | |
327 | + | |
328 | +static void | |
329 | +read_callback (GnomeVFSAsyncHandle *handle, | |
330 | + GnomeVFSResult result, | |
331 | + gpointer buffer, | |
332 | + GnomeVFSFileSize bytes_requested, | |
333 | + GnomeVFSFileSize bytes_read, | |
334 | + DownloadInfo *info) | |
335 | +{ | |
336 | + if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { | |
337 | + g_warning ("Read error"); | |
338 | + info->error = TRUE; | |
339 | + gnome_vfs_async_close (handle, close_callback, info); | |
340 | + } | |
341 | + | |
342 | + if (bytes_read == 0) { | |
343 | + info->error = FALSE; | |
344 | + gnome_vfs_async_close (handle, close_callback, info); | |
345 | + } else { | |
346 | + gtk_html_stream_write (info->stream, buffer, bytes_read); | |
347 | + gnome_vfs_async_read (handle, buffer, 4095, read_callback, | |
348 | + info); | |
349 | + } | |
350 | +} | |
351 | + | |
352 | +static void | |
353 | +open_callback (GnomeVFSAsyncHandle *handle, | |
354 | + GnomeVFSResult result, | |
355 | + DownloadInfo *info) | |
356 | +{ | |
357 | + if (result != GNOME_VFS_OK) { | |
358 | + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); | |
359 | + g_free (info->uri); | |
360 | + g_free (info); | |
361 | + return; | |
362 | + } | |
363 | + | |
364 | + info->buffer = g_new (char, 4096); | |
365 | + gnome_vfs_async_read (handle, info->buffer, 4095, read_callback, info); | |
366 | +} | |
367 | + | |
368 | void | |
369 | e_summary_url_request (GtkHTML *html, | |
370 | const gchar *url, | |
371 | GtkHTMLStream *stream) | |
372 | { | |
373 | char *filename; | |
374 | - GnomeVFSHandle *handle = NULL; | |
375 | - GnomeVFSResult result; | |
376 | + GnomeVFSAsyncHandle *handle; | |
377 | + DownloadInfo *info; | |
378 | ||
379 | + g_print ("url: %s\n", url); | |
380 | if (strncasecmp (url, "file:", 5) == 0) { | |
381 | url += 5; | |
382 | filename = e_pixmap_file (url); | |
383 | @@ -108,40 +179,14 @@ | |
384 | } | |
385 | ||
386 | g_print ("Filename: %s\n", filename); | |
387 | - result = gnome_vfs_open (&handle, filename, GNOME_VFS_OPEN_READ); | |
388 | - | |
389 | - if (result != GNOME_VFS_OK) { | |
390 | - g_warning ("%s: %s", filename, | |
391 | - gnome_vfs_result_to_string (result)); | |
392 | - g_free (filename); | |
393 | - gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR); | |
394 | - return; | |
395 | - } | |
396 | - | |
397 | - g_free (filename); | |
398 | - while (1) { | |
399 | - char buffer[4096]; | |
400 | - GnomeVFSFileSize size; | |
401 | - | |
402 | - /* Clear buffer */ | |
403 | - memset (buffer, 0x00, 4096); | |
404 | - | |
405 | - result = gnome_vfs_read (handle, buffer, 4096, &size); | |
406 | - if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { | |
407 | - g_warning ("Error reading data: %s", | |
408 | - gnome_vfs_result_to_string (result)); | |
409 | - gnome_vfs_close (handle); | |
410 | - gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR); | |
411 | - } | |
412 | ||
413 | - if (size == 0) | |
414 | - break; /* EOF */ | |
415 | + info = g_new (DownloadInfo, 1); | |
416 | + info->stream = stream; | |
417 | + info->uri = filename; | |
418 | + info->error = FALSE; | |
419 | ||
420 | - gtk_html_stream_write (stream, buffer, size); | |
421 | - } | |
422 | - | |
423 | - gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); | |
424 | - gnome_vfs_close (handle); | |
425 | + gnome_vfs_async_open (&handle, filename, GNOME_VFS_OPEN_READ, | |
426 | + (GnomeVFSAsyncOpenCallback) open_callback, info); | |
427 | } | |
428 | ||
429 | static char * | |
430 | @@ -373,13 +418,12 @@ | |
431 | ||
432 | CORBA_exception_init (&ev); | |
433 | Bonobo_EventSource_removeListener (dialog->eventsource, | |
434 | - dialog->corba_listener, &ev); | |
435 | + dialog->listener_id, &ev); | |
436 | if (ev._major != CORBA_NO_EXCEPTION) { | |
437 | g_warning ("Error: %s", CORBA_exception_id (&ev)); | |
438 | } | |
439 | ||
440 | bonobo_object_unref (BONOBO_OBJECT (dialog->listener)); | |
441 | - bonobo_object_release_unref (dialog->eventsource, &ev); | |
442 | CORBA_exception_free (&ev); | |
443 | g_free (dialog); | |
444 | } | |
445 | @@ -394,6 +438,7 @@ | |
446 | int address; | |
447 | ESummaryWindow *window; | |
448 | Bonobo_Control control; | |
449 | + Bonobo_Listener corba_listener; | |
450 | GtkWidget *prefsbox, *control_widget; | |
451 | CORBA_Environment ev; | |
452 | PropertyDialog *data; | |
453 | @@ -443,13 +488,11 @@ | |
454 | data->dialog = prefsbox; | |
455 | ||
456 | CORBA_exception_init (&ev); | |
457 | - data->eventsource = Bonobo_Unknown_queryInterface (window->propertycontrol, | |
458 | - "IDL:Bonobo/EventSource:1.0", | |
459 | - &ev); | |
460 | + data->eventsource = window->event_source; | |
461 | data->listener = bonobo_listener_new (property_event, data); | |
462 | - data->corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (data->listener)); | |
463 | - Bonobo_EventSource_addListener (data->eventsource, | |
464 | - data->corba_listener, &ev); | |
465 | + corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (data->listener)); | |
466 | + data->listener_id = Bonobo_EventSource_addListener (data->eventsource, | |
467 | + corba_listener, &ev); | |
468 | ||
469 | gtk_signal_connect (GTK_OBJECT (prefsbox), "apply", | |
470 | GTK_SIGNAL_FUNC (property_apply), | |
471 | @@ -746,3 +789,26 @@ | |
472 | e_summary_unset_message (esummary); | |
473 | } | |
474 | } | |
475 | + | |
476 | +/* Cache stuff */ | |
477 | +#if HAVECACHE | |
478 | +void | |
479 | +e_summary_url_init_cache (void) | |
480 | +{ | |
481 | + if (image_cache != NULL) | |
482 | + return; | |
483 | + | |
484 | + image_cache = e_summary_cache_new (); | |
485 | +} | |
486 | + | |
487 | +void | |
488 | +e_summary_url_cache_destroy (void) | |
489 | +{ | |
490 | + if (image_cache == NULL) | |
491 | + return; | |
492 | + | |
493 | + gtk_object_unref (GTK_OBJECT (image_cache)); | |
494 | + | |
495 | + image_cache = NULL; | |
496 | +} | |
497 | +#endif | |
498 | Index: executive-summary/component/e-summary-util.c | |
499 | =================================================================== | |
500 | RCS file: /cvs/gnome/evolution/executive-summary/component/e-summary-util.c,v | |
501 | retrieving revision 1.4 | |
502 | retrieving revision 1.5 | |
503 | diff -u -r1.4 -r1.5 | |
504 | --- executive-summary/component/e-summary-util.c 2000/12/13 18:26:45 1.4 | |
505 | +++ executive-summary/component/e-summary-util.c 2001/01/12 20:40:09 1.5 | |
506 | @@ -102,6 +102,9 @@ | |
507 | g_warning ("Opening: %s", path); | |
508 | base = opendir (path); | |
509 | ||
510 | + if (base == NULL) | |
511 | + return; | |
512 | + | |
513 | contents = readdir (base); | |
514 | while (contents != NULL) { | |
515 | char *fullpath; |