diff options
author | Dan Winship <danw@src.gnome.org> | 2000-04-26 07:00:52 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-04-26 07:00:52 +0800 |
commit | 11ca78748823a81e9a063ea5354ff7f0051199eb (patch) | |
tree | 5ee1a3ebaf5370b01c3f7893f2907bde0c2ac866 /mail/mail-display.c | |
parent | 16bd7925283cca6663866210d87f6d6edd6aec86 (diff) | |
download | gsoc2013-evolution-11ca78748823a81e9a063ea5354ff7f0051199eb.tar.gz gsoc2013-evolution-11ca78748823a81e9a063ea5354ff7f0051199eb.tar.zst gsoc2013-evolution-11ca78748823a81e9a063ea5354ff7f0051199eb.zip |
Now that we're not limited to a single GtkHTML for the display, there's no
* mail-format.c, mail-display.c: Now that we're not limited to
a single GtkHTML for the display, there's no reason to embed
Bonobo objects for unrecognized content-types in GtkHTML rather
than embedded them into the vbox directly. So do that.
Meanwhile, fix up the handler-selection code so that we can
declare which built-in handlers are more desirable than external
handlers and which are less. (Of course, eventually we'll want
this to be customizable.) Add some cleverness to
handle_multipart_alternative as well so it doesn't accept an
alternative which we can display generically over one we can
display specifically.
svn path=/trunk/; revision=2616
Diffstat (limited to 'mail/mail-display.c')
-rw-r--r-- | mail/mail-display.c | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/mail/mail-display.c b/mail/mail-display.c index 215a74c2ab..f5595dd671 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -14,116 +14,15 @@ #include "mail-display.h" #include "mail-format.h" -/* corba/bonobo stuff */ -#include <bonobo.h> -#include <libgnorba/gnorba.h> -#include <bonobo/bonobo-stream-memory.h> - #define PARENT_TYPE (gtk_vbox_get_type ()) static GtkObjectClass *mail_display_parent_class; /*----------------------------------------------------------------------* - * Helper utility functions - *----------------------------------------------------------------------*/ - - -/* stuff to display Bonobo Components inside the html message - * body view */ -static gboolean -hydrate_persist_stream_from_gstring (Bonobo_PersistStream persist_stream, - GString* gstr) -{ - CORBA_Environment ev; - BonoboStream* mem_stream = - bonobo_stream_mem_create (gstr->str, gstr->len, TRUE, FALSE); - CORBA_Object mem_stream_corba = - bonobo_object_corba_objref (BONOBO_OBJECT (mem_stream)); - - g_assert (persist_stream != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - /* - * Load the file into the component using PersistStream. - */ - Bonobo_PersistStream_load (persist_stream, mem_stream_corba, &ev); - - bonobo_object_unref (BONOBO_OBJECT (mem_stream)); - - if (ev._major != CORBA_NO_EXCEPTION) { - gnome_warning_dialog (_("An exception occured while trying " - "to load data into the component with " - "PersistStream")); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - return TRUE; -} - - -static GString* -camel_stream_to_gstring (CamelStream* stream) -{ - gchar tmp_buffer[4097]; - GString *tmp_gstring = g_string_new (""); - - do { /* read next chunk of text */ - - gint nb_bytes_read; - - nb_bytes_read = camel_stream_read (stream, - tmp_buffer, - 4096); - tmp_buffer [nb_bytes_read] = '\0'; - - /* If there's any text, append it to the gstring */ - if (nb_bytes_read > 0) { - tmp_gstring = g_string_append (tmp_gstring, tmp_buffer); - } - - } while (!camel_stream_eos (stream)); - - return tmp_gstring; -} - -/*----------------------------------------------------------------------* * Callbacks *----------------------------------------------------------------------*/ -static void -embeddable_destroy_cb (GtkObject *obj, gpointer user_data) -{ - BonoboWidget *be; /* bonobo embeddable */ - BonoboViewFrame *vf; /* the embeddable view frame */ - BonoboObjectClient* server; - CORBA_Environment ev; - - printf ("in the bonobo embeddable destroy callback\n"); - be = BONOBO_WIDGET (obj); - server = bonobo_widget_get_server (be); - - vf = bonobo_widget_get_view_frame (be); - bonobo_control_frame_control_deactivate ( - BONOBO_CONTROL_FRAME (vf)); - /* w = bonobo_control_frame_get_widget (BONOBO_CONTROL_FRAME (vf)); */ - - /* gtk_widget_destroy (w); */ - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - CORBA_Object_release ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - - CORBA_exception_free (&ev); - bonobo_object_destroy (BONOBO_OBJECT (vf)); - /* gtk_object_unref (obj); */ -} - static CamelStream * cid_stream (const char *cid, CamelMimeMessage *message) { @@ -135,94 +34,6 @@ cid_stream (const char *cid, CamelMimeMessage *message) return camel_data_wrapper_get_output_stream (data); } -/* - * As a page is loaded, when gtkhtml comes across <object> tags, this - * callback is invoked. The GtkHTMLEmbedded param is a GtkContainer; - * our job in this function is to simply add a child widget to it. - */ -static void -on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) -{ - CamelStream *stream; - GString *camel_stream_gstr; - CamelMimeMessage *message = data; - GtkWidget *bonobo_embeddable; - BonoboObjectClient* server; - Bonobo_PersistStream persist; - CORBA_Environment ev; - gchar *uid = gtk_html_embedded_get_parameter (eb, "uid"); - - /* Both the classid (which specifies which bonobo object to - * fire up) and the uid (which tells us where to find data to - * persist from) must be available; if one of them isn't, - * print an error and bail. - */ - if (!uid || !eb->classid) { - printf ("on_object_requested: couldn't find %s%s%s\n", - uid ? "a uid" : "", - (!uid && !eb->classid) ? " or " : "", - eb->classid ? "a classid" : ""); - return; - } - printf ("object requested : %s\n", eb->classid); - printf ("UID = %s\n", uid); - - /* Try to get a server with goadid specified by eb->classid */ - bonobo_embeddable = bonobo_widget_new_subdoc (eb->classid, NULL); - gtk_signal_connect (GTK_OBJECT (bonobo_embeddable), - "destroy", embeddable_destroy_cb, NULL); - - server = bonobo_widget_get_server (BONOBO_WIDGET (bonobo_embeddable)); - if (!server) { - printf ("Couldn't get the server for the bonobo embeddable\n"); - return; - } - - if (!strncmp (uid, "cid:", 4)) { - stream = cid_stream (uid + 4, message); - g_return_if_fail (CAMEL_IS_STREAM (stream)); - } else - return; - - /* Try to get a PersistStream interface from the server; - if it doesn't support that interface, bail. */ - persist = (Bonobo_PersistStream) bonobo_object_client_query_interface ( - server, - "IDL:Bonobo/PersistStream:1.0", - NULL); - - if (persist == CORBA_OBJECT_NIL) { - gchar* msg = g_strdup_printf ( - _("The %s component doesn't support PersistStream!\n"), - uid); - - gnome_warning_dialog (msg); - gtk_object_unref (GTK_OBJECT (bonobo_embeddable)); - - g_free (msg); - return; - } - - /* Hydrate the PersistStream from the CamelStream */ - camel_stream_gstr = camel_stream_to_gstring (stream); - printf ("on_object_requested: The CamelStream has %d elements\n", - camel_stream_gstr->len); - hydrate_persist_stream_from_gstring (persist, camel_stream_gstr); - - /* Give our new window to the container */ - - gtk_widget_show (bonobo_embeddable); - gtk_container_add (GTK_CONTAINER(eb), bonobo_embeddable); - - /* Destroy the PersistStream object.*/ - CORBA_exception_init (&ev); - Bonobo_Unknown_unref (persist, &ev); - CORBA_Object_release (persist, &ev); - CORBA_exception_free (&ev); - - g_string_free (camel_stream_gstr, TRUE); -} - static void on_url_requested (GtkHTML *html, const char *url, GtkHTMLStreamHandle handle, gpointer user_data) @@ -265,8 +76,6 @@ mail_html_new (GtkHTML **html, GtkHTMLStreamHandle **stream, gtk_html_set_editable (*html, FALSE); gtk_signal_connect (GTK_OBJECT (*html), "size_request", GTK_SIGNAL_FUNC (html_size_req), NULL); - gtk_signal_connect (GTK_OBJECT (*html), "object_requested", - GTK_SIGNAL_FUNC (on_object_requested), root); gtk_signal_connect (GTK_OBJECT (*html), "url_requested", GTK_SIGNAL_FUNC (on_url_requested), root); |