diff options
author | Iain Holmes <iain@src.gnome.org> | 2000-12-27 08:03:11 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2000-12-27 08:03:11 +0800 |
commit | 3e5f3687c7460009c93e876ae0ab7eb0e2a71648 (patch) | |
tree | b5c0e1743e85852038f5ad023616a7f89637e31e /executive-summary/component | |
parent | 138e45cc665e70e637652eca1cae64ddf7e3b979 (diff) | |
download | gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar.gz gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar.bz2 gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar.lz gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar.xz gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.tar.zst gsoc2013-evolution-3e5f3687c7460009c93e876ae0ab7eb0e2a71648.zip |
More fixes for new bonobo
pt 2
svn path=/trunk/; revision=7178
Diffstat (limited to 'executive-summary/component')
-rw-r--r-- | executive-summary/component/e-summary-url.c | 117 | ||||
-rw-r--r-- | executive-summary/component/e-summary.c | 103 | ||||
-rw-r--r-- | executive-summary/component/e-summary.h | 4 |
3 files changed, 145 insertions, 79 deletions
diff --git a/executive-summary/component/e-summary-url.c b/executive-summary/component/e-summary-url.c index c3be19ab78..a997184e42 100644 --- a/executive-summary/component/e-summary-url.c +++ b/executive-summary/component/e-summary-url.c @@ -81,18 +81,97 @@ typedef struct _PropertyDialog { } PropertyDialog; #define COMPOSER_IID "OAFIID:GNOME_Evolution_Mail_Composer" +#if HAVECACHE +static ESummaryCache *image_cache = NULL; +#endif + +#define USE_ASYNC + gboolean e_summary_url_mail_compose (ESummary *esummary, const char *url); gboolean e_summary_url_exec (const char *exec); +struct _DownloadInfo { + GtkHTMLStream *stream; + char *uri; + char *buffer; + + gboolean error; +}; +typedef struct _DownloadInfo DownloadInfo; + +#ifdef USE_ASYNC + +static void +close_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + DownloadInfo *info) +{ + if (info->error) { + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); + } else { + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_OK); + } + + g_free (info->uri); + g_free (info->buffer); + g_free (info); +} + +static void +read_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + gpointer buffer, + GnomeVFSFileSize bytes_requested, + GnomeVFSFileSize bytes_read, + DownloadInfo *info) +{ + if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) { + g_warning ("Read error"); + info->error = TRUE; + gnome_vfs_async_close (handle, close_callback, info); + } + + if (bytes_read == 0) { + info->error = FALSE; + gnome_vfs_async_close (handle, close_callback, info); + } else { + gtk_html_stream_write (info->stream, buffer, bytes_read); + gnome_vfs_async_read (handle, buffer, 4095, read_callback, + info); + } +} + +static void +open_callback (GnomeVFSAsyncHandle *handle, + GnomeVFSResult result, + DownloadInfo *info) +{ + if (result != GNOME_VFS_OK) { + gtk_html_stream_close (info->stream, GTK_HTML_STREAM_ERROR); + g_free (info->uri); + g_free (info); + return; + } + + info->buffer = g_new (char, 4096); + gnome_vfs_async_read (handle, info->buffer, 4095, read_callback, info); +} +#endif + void e_summary_url_request (GtkHTML *html, const gchar *url, GtkHTMLStream *stream) { char *filename; +#ifndef USE_ASYNC GnomeVFSHandle *handle = NULL; GnomeVFSResult result; +#else + GnomeVFSAsyncHandle *handle; + DownloadInfo *info; +#endif if (strncasecmp (url, "file:", 5) == 0) { url += 5; @@ -108,6 +187,7 @@ e_summary_url_request (GtkHTML *html, } g_print ("Filename: %s\n", filename); +#ifndef USE_ASYNC result = gnome_vfs_open (&handle, filename, GNOME_VFS_OPEN_READ); if (result != GNOME_VFS_OK) { @@ -142,6 +222,16 @@ e_summary_url_request (GtkHTML *html, gtk_html_stream_close (stream, GTK_HTML_STREAM_OK); gnome_vfs_close (handle); +#else + info = g_new (DownloadInfo, 1); + info->stream = stream; + info->uri = filename; + info->error = FALSE; + + gnome_vfs_async_open (&handle, filename, GNOME_VFS_OPEN_READ, + (GnomeVFSAsyncOpenCallback) open_callback, info); +#endif + } static char * @@ -443,9 +533,7 @@ e_summary_url_click (GtkWidget *widget, data->dialog = prefsbox; CORBA_exception_init (&ev); - data->eventsource = Bonobo_Unknown_queryInterface (window->propertycontrol, - "IDL:Bonobo/EventSource:1.0", - &ev); + data->eventsource = bonobo_object_dup_ref (window->event_source, &ev); data->listener = bonobo_listener_new (property_event, data); data->corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (data->listener)); Bonobo_EventSource_addListener (data->eventsource, @@ -746,3 +834,26 @@ e_summary_url_over (GtkHTML *html, e_summary_unset_message (esummary); } } + +/* Cache stuff */ +#if HAVECACHE +void +e_summary_url_init_cache (void) +{ + if (image_cache != NULL) + return; + + image_cache = e_summary_cache_new (); +} + +void +e_summary_url_cache_destroy (void) +{ + if (image_cache == NULL) + return; + + gtk_object_unref (GTK_OBJECT (image_cache)); + + image_cache = NULL; +} +#endif diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c index ef95c7e8b1..12ed32376e 100644 --- a/executive-summary/component/e-summary.c +++ b/executive-summary/component/e-summary.c @@ -337,25 +337,13 @@ make_control_html (ESummaryWindow *window, { char *html, *tmp; int id = GPOINTER_TO_INT (window); - gboolean u, d, l, r, config; + gboolean config; - u = d = l = r = config = TRUE; + config = TRUE; if (window->propertycontrol == CORBA_OBJECT_NIL) config = FALSE; - if (row == 0) /* Top row */ - u = FALSE; - - if (row >= numwindows - 3) /* Bottom row */ - d = FALSE; - - if (col == 0) /* Leftmost column */ - l = FALSE; - - if (col == 2 || ((row * 3) + col) == numwindows - 1) /* Rightmost column */ - r = FALSE; - html = g_strdup_printf ("<table><tr><td><a href=\"close://%d\">" "<img src=\"service-close.png\" border=\"0\">" "</a></td></tr><tr><td>", id); @@ -371,53 +359,6 @@ make_control_html (ESummaryWindow *window, } g_free (tmp); -#if 0 - tmp = html; - if (!l) { - html = g_strdup_printf ("%s<img src=\"service-left-disabled.png\">" - "</td><td>", tmp); - } else { - html = g_strdup_printf ("%s<a href=\"left://%d\">" - "<img src=\"service-left.png\" border=\"0\">" - "</a></td><td>", tmp, id); - } - g_free (tmp); - - tmp = html; - if (!r) { - html = g_strdup_printf ("%s<img src=\"service-right-disabled.png\">" - "</td></tr></table>", tmp); - } else { - html = g_strdup_printf ("%s<a href=\"right://%d\">" - "<img src=\"service-right.png\" border=\"0\">" - "</a></td></tr></table>", tmp, id); - } - g_free (tmp); - - - tmp = html; - if (!d) { - html = g_strdup_printf ("%s<img src=\"service-down-disabled.png\">" - "</td><td>", tmp); - } else { - html = g_strdup_printf ("%s<a href=\"down://%d\">" - "<img src=\"service-down.png\" border=\"0\">" - "</a></td><td>", tmp, id); - } - g_free (tmp); - - tmp = html; - if (!u) { - html = g_strdup_printf ("%s<img src=\"service-up-disabled.png\">" - "</td></tr></table>", tmp); - } else { - html = g_strdup_printf ("%s<a href=\"up://%d\">" - "<img src=\"service-up.png\" border=\"0\">" - "</a></td></tr></table>", tmp, id); - } - g_free (tmp); - -#endif return html; } @@ -648,9 +589,10 @@ html_event (BonoboListener *listener, } static void -prop_changed_cb (BonoboPropertyListener *listener, +prop_changed_cb (BonoboListener *listener, char *name, BonoboArg *arg, + CORBA_Environment *ev, ESummaryWindow *window) { if (strcmp (name, "window_title") == 0) { @@ -678,7 +620,6 @@ e_summary_add_service (ESummary *esummary, ESummaryWindow *window; ESummaryPrivate *priv; Bonobo_Unknown unknown = CORBA_OBJECT_NIL; - Bonobo_PropertyListener corba_listener; CORBA_Environment ev; g_return_val_if_fail (esummary != NULL, NULL); @@ -718,6 +659,16 @@ e_summary_add_service (ESummary *esummary, return NULL; } + window->event_source = Bonobo_Unknown_queryInterface(window->component, + "IDL:Bonobo/EventSource:1.0", &ev); + if (window->event_source == CORBA_OBJECT_NIL) { + g_warning ("There is no Bonobo::EventSource interface"); + + /* FIXME: Free whatever objects exist */ + g_free (window); + return NULL; + } + if (window->html != CORBA_OBJECT_NIL) { Bonobo_Listener listener; CORBA_Environment ev2; @@ -762,19 +713,21 @@ e_summary_add_service (ESummary *esummary, window->propertybag, "window_icon", NULL)); /* Listen to changes */ - window->listener = bonobo_property_listener_new (); - gtk_signal_connect (GTK_OBJECT (window->listener), "prop_changed", - GTK_SIGNAL_FUNC (prop_changed_cb), window); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->listener)); - Bonobo_PropertyBag_addChangeListener (window->propertybag, - "window_title", - corba_listener, &ev); - - Bonobo_PropertyBag_addChangeListener (window->propertybag, - "window_icon", - corba_listener, &ev); - CORBA_exception_free (&ev); + if (window->propertycontrol != CORBA_OBJECT_NIL) { + Bonobo_Listener listener; + CORBA_Environment ev2; + + window->listener = bonobo_listener_new (NULL, NULL); + listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->html_listener)); + Bonobo_EventSource_addListener (window->event_source, + listener, &ev); + + gtk_signal_connect (GTK_OBJECT (window->listener), "event_notify", + GTK_SIGNAL_FUNC (prop_changed_cb), window); + } + + CORBA_exception_free (&ev); priv->window_list = g_list_append (priv->window_list, window); return window; diff --git a/executive-summary/component/e-summary.h b/executive-summary/component/e-summary.h index 8d80b70939..3ac6b1eaeb 100644 --- a/executive-summary/component/e-summary.h +++ b/executive-summary/component/e-summary.h @@ -54,9 +54,11 @@ struct _ESummaryWindow { Bonobo_PersistStream persiststream; Bonobo_PropertyBag propertybag; Bonobo_PropertyControl propertycontrol; + Bonobo_EventSource property_event_source; Bonobo_EventSource event_source; + - BonoboPropertyListener *listener; + BonoboListener *listener; BonoboListener *html_listener; Bonobo_Listener html_corba_listener; |