From cea054cd54d84479352a43bbabc19c9ce9af5efb Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 8 Aug 2008 04:26:12 +0000 Subject: Merge revisions 35747:35930 from trunk. svn path=/branches/kill-bonobo/; revision=35931 --- mail/em-format-html-display.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d34f08a837..36b7e74cf6 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -100,8 +100,6 @@ #define d(x) -#define EFHD_TABLE_OPEN "" - struct _EMFormatHTMLDisplayPrivate { /* For the interactive search dialogue */ /* TODO: Should this be more subtle, like the mozilla one? */ @@ -1030,10 +1028,10 @@ efhd_xpkcs7mime_viewcert_clicked(GtkWidget *button, struct _smime_pobject *po) #endif static void -efhd_xpkcs7mime_add_cert_table(GtkWidget *vbox, EDList *certlist, struct _smime_pobject *po) +efhd_xpkcs7mime_add_cert_table(GtkWidget *vbox, CamelDList *certlist, struct _smime_pobject *po) { CamelCipherCertInfo *info = (CamelCipherCertInfo *)certlist->head; - GtkTable *table = (GtkTable *)gtk_table_new(e_dlist_length(certlist), 2, FALSE); + GtkTable *table = (GtkTable *)gtk_table_new(camel_dlist_length(certlist), 2, FALSE); int n = 0; while (info->next) { @@ -1135,7 +1133,7 @@ efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); } - if (!e_dlist_empty(&po->valid->sign.signers)) + if (!camel_dlist_empty(&po->valid->sign.signers)) efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->sign.signers, po); gtk_widget_show_all(vbox); @@ -1167,7 +1165,7 @@ efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); } - if (!e_dlist_empty(&po->valid->encrypt.encrypters)) + if (!camel_dlist_empty(&po->valid->encrypt.encrypters)) efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->encrypt.encrypters, po); gtk_widget_show_all(vbox); -- cgit v1.2.3 From 7ade227e6409c98a4010992450e111cf7bb10520 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 14 Aug 2008 20:19:12 +0000 Subject: Merge revisions 35951:35992 from trunk. svn path=/branches/kill-bonobo/; revision=35994 --- mail/em-format-html-display.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 36b7e74cf6..199ff19b67 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1181,15 +1181,16 @@ efhd_xpkcs7mime_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje { GtkWidget *icon, *button; struct _smime_pobject *po = (struct _smime_pobject *)pobject; - const char *name; + const char *icon_name; /* FIXME: need to have it based on encryption and signing too */ if (po->valid->sign.status != 0) - name = smime_sign_table[po->valid->sign.status].icon; + icon_name = smime_sign_table[po->valid->sign.status].icon; else - name = smime_encrypt_table[po->valid->encrypt.status].icon; + icon_name = smime_encrypt_table[po->valid->encrypt.status].icon; - icon = e_icon_factory_get_image (name, E_ICON_SIZE_LARGE_TOOLBAR); + icon = gtk_image_new_from_icon_name ( + icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_show(icon); button = gtk_button_new(); @@ -2371,7 +2372,8 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb button = gtk_button_new(); hbox = gtk_hbox_new (FALSE, 0); - img = e_icon_factory_get_image ("stock_show-all", E_ICON_SIZE_BUTTON); + img = gtk_image_new_from_icon_name ( + "stock_show-all", GTK_ICON_SIZE_BUTTON); label = gtk_label_new_with_mnemonic(_("View _Unformatted")); g_object_set_data (G_OBJECT (button), "text-label", (gpointer)label); gtk_box_pack_start (GTK_BOX (hbox), img, TRUE, TRUE, 2); @@ -2390,7 +2392,8 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb button = gtk_button_new(); hbox = gtk_hbox_new (FALSE, 0); - img = e_icon_factory_get_image ("stock_open", E_ICON_SIZE_BUTTON); + img = gtk_image_new_from_stock ( + GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON); label = gtk_label_new_with_mnemonic(_("O_pen With")); gtk_box_pack_start (GTK_BOX (hbox), img, TRUE, TRUE, 2); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 2); -- cgit v1.2.3 From c0a255eb90769638d57ae4122932f75c46e4e531 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 11 Sep 2008 15:34:29 +0000 Subject: Merge revisions 36016:36303 from trunk. svn path=/branches/kill-bonobo/; revision=36307 --- mail/em-format-html-display.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 199ff19b67..5bb9cc32d3 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -1249,7 +1250,12 @@ efhd_image(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormat info->handle = handle; info->shown = TRUE; info->snoop_mime_type = ((EMFormat *) efh)->snoop_mime_type; - info->fit_width = ((GtkWidget *)((EMFormatHTML *)info->puri.format)->html)->allocation.width - 12; + if (camel_operation_cancel_check (NULL) || !info->puri.format || !((EMFormatHTML *)info->puri.format)->html) { + /* some fake value, we are cancelled anyway, thus doesn't matter */ + info->fit_width = 256; + } else { + info->fit_width = ((GtkWidget *)((EMFormatHTML *)info->puri.format)->html)->allocation.width - 12; + } camel_stream_printf(stream, "", classid); g_free(classid); @@ -2446,7 +2452,12 @@ efhd_format_optional(EMFormat *emf, CamelStream *fstream, CamelMimePart *part, C { char *classid, *html; struct _attach_puri *info; - CamelStream *stream = ((CamelStreamFilter *) fstream)->source; + CamelStream *stream; + + if (CAMEL_IS_STREAM_FILTER (fstream) && ((CamelStreamFilter *) fstream)->source) + stream = ((CamelStreamFilter *) fstream)->source; + else + stream = fstream; classid = g_strdup_printf("optional%s", emf->part_id->str); info = (struct _attach_puri *)em_format_add_puri(emf, sizeof(*info), classid, part, efhd_attachment_frame); -- cgit v1.2.3 From b2cda1d0c6d44f53f71bad9e256f41188677dfba Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 1 Oct 2008 20:56:04 +0000 Subject: Merge revisions 36016:36533 from trunk. svn path=/branches/kill-bonobo/; revision=36534 --- mail/em-format-html-display.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 5bb9cc32d3..90e6acb54e 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1,22 +1,22 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * Authors: Michael Zucchi + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * Authors: + * Michael Zucchi + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) * */ -- cgit v1.2.3 From 54b80a7271e8ce1b2f3ccc68bb553940a24b80e2 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 17 Oct 2008 03:48:03 +0000 Subject: Get the mail folder tree compiling, though I'm not yet sure why it's not showing anything. Probably something stupid. Also enabled the composer. svn path=/branches/kill-bonobo/; revision=36623 --- mail/em-format-html-display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 90e6acb54e..20f86ca562 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -80,7 +80,6 @@ #include "mail-config.h" #include "em-format-html-display.h" -#include "em-marshal.h" #include "e-searching-tokenizer.h" #include "em-icon-stream.h" #include "em-utils.h" @@ -337,7 +336,7 @@ efhd_class_init(GObjectClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, popup_event), efhd_bool_accumulator, NULL, - em_marshal_BOOLEAN__BOXED_POINTER_POINTER, + e_marshal_BOOLEAN__BOXED_POINTER_POINTER, G_TYPE_BOOLEAN, 3, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE, G_TYPE_POINTER, G_TYPE_POINTER); @@ -621,8 +620,10 @@ em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd) p->search_entry = e_icon_entry_get_entry (E_ICON_ENTRY (icon_entry)); gtk_label_set_mnemonic_widget (GTK_LABEL (label1), p->search_entry); gtk_widget_show (p->search_entry); +#if 0 /* KILL-BONOBO */ clear_button = e_icon_entry_create_button ("gtk-clear"); e_icon_entry_pack_widget (E_ICON_ENTRY (icon_entry), clear_button, FALSE); +#endif gtk_widget_show_all (icon_entry); gtk_widget_hide (clear_button); -- cgit v1.2.3 From c7d3c9f95609123035ebaa267f9d2e6ecfa8c2e8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 12 Jan 2009 04:12:01 +0000 Subject: Merge revisions 36866:37046 from trunk. svn path=/branches/kill-bonobo/; revision=37050 --- mail/em-format-html-display.c | 189 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 20f86ca562..b87767654a 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -187,6 +188,8 @@ static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart static void efhd_complete(EMFormat *); gboolean efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd); +static gboolean efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); +static gboolean efhd_use_component(const char *mime_type); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); enum { @@ -1304,10 +1307,37 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) } /* ********************************************************************** */ - +static void +efhd_bonobo_unknown(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +{ + char *classid; + + classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); + em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); + camel_stream_printf(stream, "
\n", classid, info->mime_type); + g_free(classid); +} + + /* ********************************************************************** */ static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type) { - return ((EMFormatClass *)efhd_parent)->find_handler(emf, mime_type); + const EMFormatHandler *handle; + + if ( (handle = ((EMFormatClass *)efhd_parent)->find_handler(emf, mime_type)) == NULL + && efhd_use_component(mime_type) + && (handle = g_hash_table_lookup(efhd_bonobo_handlers, mime_type)) == NULL) { + + EMFormatHandler *h = g_malloc0(sizeof(*h)); + + h->mime_type = g_strdup(mime_type); + h->handler = efhd_bonobo_unknown; + h->flags = EM_FORMAT_HANDLER_INLINE_DISPOSITION; + g_hash_table_insert(efhd_bonobo_handlers, h->mime_type, h); + + handle = h; + } + + return handle; } static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *src) @@ -1957,6 +1987,155 @@ efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) } } +static gboolean +efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) +{ + CamelDataWrapper *wrapper; + Bonobo_ServerInfo *component; + GtkWidget *embedded; + Bonobo_PersistStream persist; + CORBA_Environment ev; + CamelStreamMem *cstream; + BonoboStream *bstream; + BonoboControlFrame *control_frame; + Bonobo_PropertyBag prop_bag; + + component = bonobo_activation_get_default_component_for_mime_type (eb->type); + if (component == NULL) + return FALSE; + + embedded = bonobo_widget_new_control(component->iid, NULL); + CORBA_free(component); + if (embedded == NULL) + return FALSE; + + CORBA_exception_init(&ev); + + control_frame = bonobo_widget_get_control_frame((BonoboWidget *)embedded); + prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL); + if (prop_bag != CORBA_OBJECT_NIL) { + /* + * Now we can take care of business. Currently, the only control + * that needs something passed to it through a property bag is + * the iTip control, and it needs only the From email address, + * but perhaps in the future we can generalize this section of code + * to pass a bunch of useful things to all embedded controls. + */ + const CamelInternetAddress *from; + char *from_address; + + from = camel_mime_message_get_from((CamelMimeMessage *)((EMFormat *)efh)->message); + from_address = camel_address_encode((CamelAddress *)from); + bonobo_property_bag_client_set_value_string(prop_bag, "from_address", from_address, &ev); + g_free(from_address); + + Bonobo_Unknown_unref(prop_bag, &ev); + } + + persist = (Bonobo_PersistStream)Bonobo_Unknown_queryInterface(bonobo_widget_get_objref((BonoboWidget *)embedded), + "IDL:Bonobo/PersistStream:1.0", &ev); + if (persist == CORBA_OBJECT_NIL) { + g_object_ref_sink(embedded); + CORBA_exception_free(&ev); + return FALSE; + } + + /* Write the data to a CamelStreamMem... */ + cstream = (CamelStreamMem *)camel_stream_mem_new(); + wrapper = camel_medium_get_content_object((CamelMedium *)pobject->part); + if (FALSE && !g_ascii_strncasecmp (eb->type, "text/", 5)) { + /* do charset conversion, etc */ + d(printf("performing charset conversion for %s component\n", eb->type)); + em_format_format_text((EMFormat *)efh, (CamelStream *)cstream, wrapper); + } else { + camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) cstream); + } + + /* ...convert the CamelStreamMem to a BonoboStreamMem... */ + bstream = bonobo_stream_mem_create((char *)cstream->buffer->data, cstream->buffer->len, TRUE, FALSE); + camel_object_unref(cstream); + + /* ...and hydrate the PersistStream from the BonoboStream. */ + Bonobo_PersistStream_load(persist, + bonobo_object_corba_objref(BONOBO_OBJECT (bstream)), + eb->type, &ev); + bonobo_object_unref(BONOBO_OBJECT (bstream)); + Bonobo_Unknown_unref(persist, &ev); + CORBA_Object_release(persist, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_object_ref_sink(embedded); + CORBA_exception_free(&ev); + return FALSE; + } + CORBA_exception_free(&ev); + + gtk_widget_show(embedded); + gtk_container_add(GTK_CONTAINER (eb), embedded); + + return TRUE; +} + +static gboolean +efhd_check_server_prop(Bonobo_ServerInfo *component, const char *propname, const char *value) +{ + CORBA_sequence_CORBA_string stringv; + Bonobo_ActivationProperty *prop; + int i; + + prop = bonobo_server_info_prop_find(component, propname); + if (!prop || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) + return FALSE; + + stringv = prop->v._u.value_stringv; + for (i = 0; i < stringv._length; i++) { + if (!g_ascii_strcasecmp(value, stringv._buffer[i])) + return TRUE; + } + + return FALSE; +} + +static gboolean +efhd_use_component(const char *mime_type) +{ + GList *components, *iter; + Bonobo_ServerInfo *component = NULL; + + /* should this cache it? */ + + if (g_ascii_strcasecmp(mime_type, "text/x-vcard") != 0 + && g_ascii_strcasecmp(mime_type, "text/calendar") != 0) { + const char **mime_types; + int i; + + mime_types = mail_config_get_allowable_mime_types(); + for (i = 0; mime_types[i]; i++) { + if (!g_ascii_strcasecmp(mime_types[i], mime_type)) + goto type_ok; + } + return FALSE; + } +type_ok: + components = bonobo_activation_get_all_components_for_mime_type (mime_type); + for (iter = components; iter; iter = iter->next) { + Bonobo_ServerInfo *comp = iter->data; + + comp = iter->data; + if (efhd_check_server_prop(comp, "repo_ids", "IDL:Bonobo/PersistStream:1.0") + && efhd_check_server_prop(comp, "bonobo:supported_mime_types", mime_type)) { + component = comp; + break; + } + } + + /* FIXME: How should I free the Bonobo_ServerInfo's ? */ + g_list_foreach (components, (GFunc)CORBA_free, NULL); + g_list_free (components); + + return component != NULL; +} + static void attachment_bar_arrow_clicked(GtkWidget *w, EMFormatHTMLDisplay *efhd) { @@ -2330,6 +2509,12 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, if (handle) { if (info->shown) handle->handler(emf, stream, part, handle); + } else if (efhd_use_component(mime_type)) { + g_free(classid); /* messy */ + + classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); + em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); + camel_stream_printf(stream, "
>\n", classid, mime_type); } g_free(classid); -- cgit v1.2.3 From fee5916b60c605ff5086d8fdc2a85c5ea21351f6 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 31 Jan 2009 19:03:12 +0000 Subject: Merge revisions 37108:37199 from trunk. svn path=/branches/kill-bonobo/; revision=37200 --- mail/em-format-html-display.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index b87767654a..1bdbcbea0e 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -2353,7 +2353,8 @@ efhd_update_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pob EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; - e_attachment_bar_refresh (E_ATTACHMENT_BAR (priv->attachment_bar)); + if (priv->attachment_bar) + e_attachment_bar_refresh (E_ATTACHMENT_BAR (priv->attachment_bar)); return TRUE; } @@ -2436,7 +2437,7 @@ efhd_message_update_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; const char *classid = "attachment-bar-refresh"; - if (efhd->nobar || efhd->priv->updated || !efhd->priv->attachment_bar) + if (efhd->nobar || efhd->priv->updated) return; efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); -- cgit v1.2.3 From 6bffa31112ca78585f3528bbd2ad52b84231e3f4 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 12 Feb 2009 04:13:26 +0000 Subject: Make saving attachments work. svn path=/branches/kill-bonobo/; revision=37250 --- mail/em-format-html-display.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 1bdbcbea0e..d1c69fc3df 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -2158,19 +2158,23 @@ attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd) { GSList *attachment_parts; guint n_attachment_parts; + gpointer parent; attachment_parts = e_attachment_bar_get_parts ( E_ATTACHMENT_BAR (efhd->priv->attachment_bar)); n_attachment_parts = g_slist_length (attachment_parts); g_return_if_fail (n_attachment_parts > 0); + parent = gtk_widget_get_toplevel (widget); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; + if (n_attachment_parts == 1) em_utils_save_part ( - widget, _("Save attachment as"), + parent, _("Save attachment as"), attachment_parts->data); else em_utils_save_parts ( - widget, _("Select folder to save all attachments"), + parent, _("Select folder to save all attachments"), attachment_parts); g_slist_free (attachment_parts); -- cgit v1.2.3 From 10c3ddb38138f3408044fd46115d5804f057c13a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 13 Feb 2009 03:23:04 +0000 Subject: Make attachment saving work everywhere. svn path=/branches/kill-bonobo/; revision=37259 --- mail/em-format-html-display.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d1c69fc3df..e9516100f0 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -2209,14 +2209,20 @@ efhd_bar_save_selected(EPopup *ep, EPopupItem *item, void *data) EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)data; GSList *attachment_parts, *tmp; GSList *parts = NULL; + GtkWidget *widget; + gpointer parent; + + widget = efhd->priv->attachment_bar; + parent = gtk_widget_get_toplevel (widget); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - attachment_parts = e_attachment_bar_get_selected(E_ATTACHMENT_BAR(efhd->priv->attachment_bar)); + attachment_parts = e_attachment_bar_get_selected(E_ATTACHMENT_BAR(widget)); for (tmp = attachment_parts; tmp; tmp=tmp->next) parts = g_slist_prepend(parts, ((EAttachment *)tmp->data)->body); parts = g_slist_reverse(parts); - em_utils_save_parts(efhd->priv->attachment_bar, _("Select folder to save selected attachments..."), parts); + em_utils_save_parts(parent, _("Select folder to save selected attachments..."), parts); g_slist_free (parts); g_slist_foreach(attachment_parts, (GFunc)g_object_unref, NULL); -- cgit v1.2.3 From f7e298665b02f72890c6681e6d21ef5601beccbb Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 15 Feb 2009 03:27:31 +0000 Subject: Merge revisions 37200:3266 from trunk. svn path=/branches/kill-bonobo/; revision=37270 --- mail/em-format-html-display.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index e9516100f0..ff7e77c8f6 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1227,14 +1227,17 @@ efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, Came pobj = (struct _smime_pobject *)em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(*pobj), classid, part, efhd_xpkcs7mime_button); pobj->valid = camel_cipher_validity_clone(valid); pobj->object.free = efhd_xpkcs7mime_free; - camel_stream_printf(stream, "
", classid); + camel_stream_printf(stream, "", classid); g_free(classid); if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { - camel_stream_printf(stream, "%s
", _(smime_sign_table[valid->sign.status].shortdesc)); + camel_stream_printf (stream, "%s", _(smime_sign_table[valid->sign.status].shortdesc)); } if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) { - camel_stream_printf(stream, "%s
", _(smime_encrypt_table[valid->encrypt.status].shortdesc)); + if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { + camel_stream_printf (stream, "
"); + } + camel_stream_printf (stream, "%s", _(smime_encrypt_table[valid->encrypt.status].shortdesc)); } camel_stream_printf(stream, "
"); -- cgit v1.2.3 From fd564be3203400024147469faaa7de0884861566 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 19 Feb 2009 01:36:04 +0000 Subject: Clean up the EMFormat stack. Add some GObject properties to bind to. Add some handy color conversion functions to e-util. svn path=/branches/kill-bonobo/; revision=37290 --- mail/em-format-html-display.c | 275 ++++++++++++++++++++++++++++++------------ 1 file changed, 197 insertions(+), 78 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index ff7e77c8f6..03ded0ef5c 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -101,6 +101,10 @@ #define d(x) +#define EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate)) + struct _EMFormatHTMLDisplayPrivate { /* For the interactive search dialogue */ /* TODO: Should this be more subtle, like the mozilla one? */ @@ -127,6 +131,12 @@ struct _EMFormatHTMLDisplayPrivate { gboolean updated; }; +enum { + PROP_0, + PROP_ANIMATE, + PROP_CARET_MODE +}; + static int efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormatHTMLDisplay *efh); static void efhd_html_link_clicked (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd); static void efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd); @@ -207,57 +217,50 @@ static EMFormatHTMLClass *efhd_parent; static EMFormatClass *efhd_format_class; static void -efhd_gtkhtml_realise(GtkHTML *html, EMFormatHTMLDisplay *efhd) +efhd_gtkhtml_realize(GtkHTML *html, EMFormatHTMLDisplay *efhd) { + EMFormatHTMLColorType type; + EMFormatHTML *efh; + GdkColor *color; GtkStyle *style; + gint state; - /* FIXME: does this have to be re-done every time we draw? */ - - /* My favorite thing to do... muck around with colors so we respect people's stupid themes. - However, we only do this if we are rendering to the screen -- we ignore the theme - when we are printing. */ - style = gtk_widget_get_style((GtkWidget *)html); - if (style) { - int state = GTK_WIDGET_STATE(html); - gushort r, g, b; - - r = style->fg[state].red >> 8; - g = style->fg[state].green >> 8; - b = style->fg[state].blue >> 8; + efh = EM_FORMAT_HTML (efhd); + state = GTK_WIDGET_STATE (html); - efhd->formathtml.header_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; - - r = style->bg[state].red >> 8; - g = style->bg[state].green >> 8; - b = style->bg[state].blue >> 8; + style = gtk_widget_get_style (GTK_WIDGET (html)); + if (style == NULL) + return; - efhd->formathtml.body_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; + g_object_freeze_notify (G_OBJECT (efh)); - r = style->dark[state].red >> 8; - g = style->dark[state].green >> 8; - b = style->dark[state].blue >> 8; + color = &style->bg[state]; + type = EM_FORMAT_HTML_COLOR_BODY; + em_format_html_set_color (efh, type, color); - efhd->formathtml.frame_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; + color = &style->base[GTK_STATE_NORMAL]; + type = EM_FORMAT_HTML_COLOR_CONTENT; + em_format_html_set_color (efh, type, color); - r = style->base[GTK_STATE_NORMAL].red >> 8; - g = style->base[GTK_STATE_NORMAL].green >> 8; - b = style->base[GTK_STATE_NORMAL].blue >> 8; + color = &style->dark[state]; + type = EM_FORMAT_HTML_COLOR_FRAME; + em_format_html_set_color (efh, type, color); - efhd->formathtml.content_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; + color = &style->fg[state]; + type = EM_FORMAT_HTML_COLOR_HEADER; + em_format_html_set_color (efh, type, color); - r = style->text[state].red >> 8; - g = style->text[state].green >> 8; - b = style->text[state].blue >> 8; + color = &style->text[state]; + type = EM_FORMAT_HTML_COLOR_TEXT; + em_format_html_set_color (efh, type, color); - efhd->formathtml.text_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; -#undef DARKER - } + g_object_thaw_notify (G_OBJECT (efh)); } static void efhd_gtkhtml_style_set(GtkHTML *html, GtkStyle *old, EMFormatHTMLDisplay *efhd) { - efhd_gtkhtml_realise(html, efhd); + efhd_gtkhtml_realize(html, efhd); em_format_redraw((EMFormat *)efhd); } @@ -267,12 +270,12 @@ efhd_init(GObject *o) EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)o; #define efh ((EMFormatHTML *)efhd) - efhd->priv = g_malloc0(sizeof(*efhd->priv)); + efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(efhd); efhd->search_tok = (ESearchingTokenizer *)e_searching_tokenizer_new(); gtk_html_set_tokenizer (efh->html, (HTMLTokenizer *)efhd->search_tok); - g_signal_connect(efh->html, "realize", G_CALLBACK(efhd_gtkhtml_realise), o); + g_signal_connect(efh->html, "realize", G_CALLBACK(efhd_gtkhtml_realize), o); g_signal_connect(efh->html, "style-set", G_CALLBACK(efhd_gtkhtml_style_set), o); /* we want to convert url's etc */ efh->text_html_flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; @@ -285,19 +288,65 @@ efhd_init(GObject *o) } static void -efhd_finalise(GObject *o) +efhd_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_ANIMATE: + em_format_html_display_set_animate ( + EM_FORMAT_HTML_DISPLAY (object), + g_value_get_boolean (value)); + return; + + case PROP_CARET_MODE: + em_format_html_display_set_caret_mode ( + EM_FORMAT_HTML_DISPLAY (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +efhd_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_ANIMATE: + g_value_set_boolean ( + value, em_format_html_display_get_animate ( + EM_FORMAT_HTML_DISPLAY (object))); + return; + + case PROP_CARET_MODE: + g_value_set_boolean ( + value, em_format_html_display_get_caret_mode ( + EM_FORMAT_HTML_DISPLAY (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +efhd_finalize (GObject *object) { - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)o; + EMFormatHTMLDisplayPrivate *priv; - /* check pending stuff */ + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (object); - if (efhd->priv->files) - g_hash_table_destroy(efhd->priv->files); + if (priv->files != NULL) + g_hash_table_destroy (priv->files); - g_free(efhd->priv->search_text); - g_free(efhd->priv); + g_free (priv->search_text); - ((GObjectClass *)efhd_parent)->finalize(o); + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (efhd_parent)->finalize (object); } static gboolean @@ -311,22 +360,51 @@ efhd_bool_accumulator(GSignalInvocationHint *ihint, GValue *out, const GValue *i } static void -efhd_class_init(GObjectClass *klass) -{ - ((EMFormatClass *)klass)->find_handler = efhd_find_handler; - ((EMFormatClass *)klass)->format_clone = efhd_format_clone; - ((EMFormatClass *)klass)->format_error = efhd_format_error; - ((EMFormatClass *)klass)->format_source = efhd_format_source; - ((EMFormatClass *)klass)->format_attachment = efhd_format_attachment; - ((EMFormatClass *)klass)->format_optional = efhd_format_optional; - ((EMFormatClass *)klass)->format_secure = efhd_format_secure; - ((EMFormatClass *)klass)->complete = efhd_complete; - - klass->finalize = efhd_finalise; +efhd_class_init (GObjectClass *class) +{ + GObjectClass *object_class; + EMFormatClass *format_class; + + g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = efhd_set_property; + object_class->get_property = efhd_get_property; + object_class->finalize = efhd_finalize; + + format_class = EM_FORMAT_CLASS (class); + format_class->find_handler = efhd_find_handler; + format_class->format_clone = efhd_format_clone; + format_class->format_error = efhd_format_error; + format_class->format_source = efhd_format_source; + format_class->format_attachment = efhd_format_attachment; + format_class->format_optional = efhd_format_optional; + format_class->format_secure = efhd_format_secure; + format_class->complete = efhd_complete; + + g_object_class_install_property ( + object_class, + PROP_ANIMATE, + g_param_spec_boolean ( + "animate", + "Animate Images", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_CARET_MODE, + g_param_spec_boolean ( + "caret-mode", + "Caret Mode", + NULL, + FALSE, + G_PARAM_READWRITE)); efhd_signals[EFHD_LINK_CLICKED] = g_signal_new("link_clicked", - G_TYPE_FROM_CLASS(klass), + G_TYPE_FROM_CLASS(class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, link_clicked), NULL, NULL, @@ -335,7 +413,7 @@ efhd_class_init(GObjectClass *klass) efhd_signals[EFHD_POPUP_EVENT] = g_signal_new("popup_event", - G_TYPE_FROM_CLASS(klass), + G_TYPE_FROM_CLASS(class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, popup_event), efhd_bool_accumulator, NULL, @@ -346,7 +424,7 @@ efhd_class_init(GObjectClass *klass) efhd_signals[EFHD_ON_URL] = g_signal_new("on_url", - G_TYPE_FROM_CLASS(klass), + G_TYPE_FROM_CLASS(class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, on_url), NULL, NULL, @@ -354,7 +432,7 @@ efhd_class_init(GObjectClass *klass) G_TYPE_NONE, 1, G_TYPE_STRING); - efhd_builtin_init((EMFormatHTMLDisplayClass *)klass); + efhd_builtin_init((EMFormatHTMLDisplayClass *)class); } GType @@ -388,11 +466,11 @@ efhd_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay *efhd { if(event->direction == GDK_SCROLL_UP) { - gtk_html_zoom_in (efhd->formathtml.html); + gtk_html_zoom_in (efhd->parent.html); } else if(event->direction == GDK_SCROLL_DOWN) { - gtk_html_zoom_out (efhd->formathtml.html); + gtk_html_zoom_out (efhd->parent.html); } return TRUE; } @@ -405,30 +483,71 @@ EMFormatHTMLDisplay *em_format_html_display_new(void) efhd = g_object_new(em_format_html_display_get_type(), 0); - g_signal_connect(efhd->formathtml.html, "iframe_created", G_CALLBACK(efhd_iframe_created), efhd); - g_signal_connect(efhd->formathtml.html, "link_clicked", G_CALLBACK(efhd_html_link_clicked), efhd); - g_signal_connect(efhd->formathtml.html, "on_url", G_CALLBACK(efhd_html_on_url), efhd); - g_signal_connect(efhd->formathtml.html, "button_press_event", G_CALLBACK(efhd_html_button_press_event), efhd); - g_signal_connect(efhd->formathtml.html,"scroll_event", G_CALLBACK(efhd_scroll_event), efhd); + g_signal_connect(efhd->parent.html, "iframe_created", G_CALLBACK(efhd_iframe_created), efhd); + g_signal_connect(efhd->parent.html, "link_clicked", G_CALLBACK(efhd_html_link_clicked), efhd); + g_signal_connect(efhd->parent.html, "on_url", G_CALLBACK(efhd_html_on_url), efhd); + g_signal_connect(efhd->parent.html, "button_press_event", G_CALLBACK(efhd_html_button_press_event), efhd); + g_signal_connect(efhd->parent.html,"scroll_event", G_CALLBACK(efhd_scroll_event), efhd); return efhd; } -void em_format_html_display_goto_anchor(EMFormatHTMLDisplay *efhd, const char *name) +gboolean +em_format_html_display_get_animate (EMFormatHTMLDisplay *efhd) { - printf("FIXME: go to anchor '%s'\n", name); + GtkHTML *html; + + g_return_val_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd), FALSE); + + html = ((EMFormatHTML *) efhd)->html; + + return gtk_html_get_animate (html); } -void em_format_html_display_set_animate(EMFormatHTMLDisplay *efhd, gboolean state) +void +em_format_html_display_set_animate (EMFormatHTMLDisplay *efhd, + gboolean animate) { - efhd->animate = state; - gtk_html_set_animate(((EMFormatHTML *)efhd)->html, state); + GtkHTML *html; + + /* XXX Note this is imperfect. If animate is set by + * some other means we won't emit a notification. */ + + g_return_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd)); + + html = ((EMFormatHTML *) efhd)->html; + gtk_html_set_animate (html, animate); + + g_object_notify (G_OBJECT (efhd), "animate"); } -void em_format_html_display_set_caret_mode(EMFormatHTMLDisplay *efhd, gboolean state) +gboolean +em_format_html_display_get_caret_mode (EMFormatHTMLDisplay *efhd) { - efhd->caret_mode = state; - gtk_html_set_caret_mode(((EMFormatHTML *)efhd)->html, state); + GtkHTML *html; + + g_return_val_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd), FALSE); + + html = ((EMFormatHTML *) efhd)->html; + + return gtk_html_get_caret_mode (html); +} + +void +em_format_html_display_set_caret_mode (EMFormatHTMLDisplay *efhd, + gboolean caret_mode) +{ + GtkHTML *html; + + /* XXX Note this is imperfect. If caret mode is set by + * some other means we won't emit a notification. */ + + g_return_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd)); + + html = ((EMFormatHTML *) efhd)->html; + gtk_html_set_caret_mode (html, caret_mode); + + g_object_notify (G_OBJECT (efhd), "caret-mode"); } EAttachmentBar * @@ -883,7 +1002,7 @@ em_format_html_display_popup_menu (EMFormatHTMLDisplay *efhd) EMFormatPURI *puri = NULL; gboolean res = FALSE; - html = efhd->formathtml.html; + html = efhd->parent.html; efhd_get_uri_puri (GTK_WIDGET (html), NULL, efhd, &uri, &puri); @@ -2347,7 +2466,7 @@ efhd_bar_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay * /* Emulate the scroll over the attachment bar, as if it is scrolled in the window. * It doesnt go automatically since the GnomeIconList is a layout by itself */ - g_signal_emit_by_name (gtk_widget_get_parent((GtkWidget *)efhd->formathtml.html), "scroll_event", event, &ret); + g_signal_emit_by_name (gtk_widget_get_parent((GtkWidget *)efhd->parent.html), "scroll_event", event, &ret); return TRUE; } -- cgit v1.2.3 From ed77e8e15bbbb886cf92dfb0fb1700a1c1d92548 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 21 Feb 2009 03:36:34 +0000 Subject: Convert eab-vcard-control.c to a new "vcard-inline" plugin, similar to the "audio-inline" plugin. svn path=/branches/kill-bonobo/; revision=37301 --- mail/em-format-html-display.c | 208 ++---------------------------------------- 1 file changed, 6 insertions(+), 202 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 03ded0ef5c..70b92c39ff 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -46,11 +46,6 @@ #include -#include -#include -#include -#include - #include #include #include @@ -198,8 +193,6 @@ static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart static void efhd_complete(EMFormat *); gboolean efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd); -static gboolean efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); -static gboolean efhd_use_component(const char *mime_type); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); enum { @@ -211,8 +204,6 @@ enum { static guint efhd_signals[EFHD_LAST_SIGNAL] = { 0 }; -/* EMFormatHandler's for bonobo objects */ -static GHashTable *efhd_bonobo_handlers; static EMFormatHTMLClass *efhd_parent; static EMFormatClass *efhd_format_class; @@ -436,7 +427,7 @@ efhd_class_init (GObjectClass *class) } GType -em_format_html_display_get_type(void) +em_format_html_display_get_type (void) { static GType type = 0; @@ -452,8 +443,6 @@ em_format_html_display_get_type(void) efhd_parent = g_type_class_ref(em_format_html_get_type()); efhd_format_class = g_type_class_ref(em_format_get_type()); type = g_type_register_static(em_format_html_get_type(), "EMFormatHTMLDisplay", &info, 0); - - efhd_bonobo_handlers = g_hash_table_new(g_str_hash, g_str_equal); } return type; @@ -1428,38 +1417,10 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]); } -/* ********************************************************************** */ -static void -efhd_bonobo_unknown(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) -{ - char *classid; - - classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); - camel_stream_printf(stream, "
\n", classid, info->mime_type); - g_free(classid); -} - - /* ********************************************************************** */ -static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type) +static const EMFormatHandler * +efhd_find_handler(EMFormat *emf, const char *mime_type) { - const EMFormatHandler *handle; - - if ( (handle = ((EMFormatClass *)efhd_parent)->find_handler(emf, mime_type)) == NULL - && efhd_use_component(mime_type) - && (handle = g_hash_table_lookup(efhd_bonobo_handlers, mime_type)) == NULL) { - - EMFormatHandler *h = g_malloc0(sizeof(*h)); - - h->mime_type = g_strdup(mime_type); - h->handler = efhd_bonobo_unknown; - h->flags = EM_FORMAT_HANDLER_INLINE_DISPOSITION; - g_hash_table_insert(efhd_bonobo_handlers, h->mime_type, h); - - handle = h; - } - - return handle; + return ((EMFormatClass *) efhd_parent)->find_handler (emf, mime_type); } static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *src) @@ -2109,155 +2070,6 @@ efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) } } -static gboolean -efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) -{ - CamelDataWrapper *wrapper; - Bonobo_ServerInfo *component; - GtkWidget *embedded; - Bonobo_PersistStream persist; - CORBA_Environment ev; - CamelStreamMem *cstream; - BonoboStream *bstream; - BonoboControlFrame *control_frame; - Bonobo_PropertyBag prop_bag; - - component = bonobo_activation_get_default_component_for_mime_type (eb->type); - if (component == NULL) - return FALSE; - - embedded = bonobo_widget_new_control(component->iid, NULL); - CORBA_free(component); - if (embedded == NULL) - return FALSE; - - CORBA_exception_init(&ev); - - control_frame = bonobo_widget_get_control_frame((BonoboWidget *)embedded); - prop_bag = bonobo_control_frame_get_control_property_bag(control_frame, NULL); - if (prop_bag != CORBA_OBJECT_NIL) { - /* - * Now we can take care of business. Currently, the only control - * that needs something passed to it through a property bag is - * the iTip control, and it needs only the From email address, - * but perhaps in the future we can generalize this section of code - * to pass a bunch of useful things to all embedded controls. - */ - const CamelInternetAddress *from; - char *from_address; - - from = camel_mime_message_get_from((CamelMimeMessage *)((EMFormat *)efh)->message); - from_address = camel_address_encode((CamelAddress *)from); - bonobo_property_bag_client_set_value_string(prop_bag, "from_address", from_address, &ev); - g_free(from_address); - - Bonobo_Unknown_unref(prop_bag, &ev); - } - - persist = (Bonobo_PersistStream)Bonobo_Unknown_queryInterface(bonobo_widget_get_objref((BonoboWidget *)embedded), - "IDL:Bonobo/PersistStream:1.0", &ev); - if (persist == CORBA_OBJECT_NIL) { - g_object_ref_sink(embedded); - CORBA_exception_free(&ev); - return FALSE; - } - - /* Write the data to a CamelStreamMem... */ - cstream = (CamelStreamMem *)camel_stream_mem_new(); - wrapper = camel_medium_get_content_object((CamelMedium *)pobject->part); - if (FALSE && !g_ascii_strncasecmp (eb->type, "text/", 5)) { - /* do charset conversion, etc */ - d(printf("performing charset conversion for %s component\n", eb->type)); - em_format_format_text((EMFormat *)efh, (CamelStream *)cstream, wrapper); - } else { - camel_data_wrapper_decode_to_stream (wrapper, (CamelStream *) cstream); - } - - /* ...convert the CamelStreamMem to a BonoboStreamMem... */ - bstream = bonobo_stream_mem_create((char *)cstream->buffer->data, cstream->buffer->len, TRUE, FALSE); - camel_object_unref(cstream); - - /* ...and hydrate the PersistStream from the BonoboStream. */ - Bonobo_PersistStream_load(persist, - bonobo_object_corba_objref(BONOBO_OBJECT (bstream)), - eb->type, &ev); - bonobo_object_unref(BONOBO_OBJECT (bstream)); - Bonobo_Unknown_unref(persist, &ev); - CORBA_Object_release(persist, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_object_ref_sink(embedded); - CORBA_exception_free(&ev); - return FALSE; - } - CORBA_exception_free(&ev); - - gtk_widget_show(embedded); - gtk_container_add(GTK_CONTAINER (eb), embedded); - - return TRUE; -} - -static gboolean -efhd_check_server_prop(Bonobo_ServerInfo *component, const char *propname, const char *value) -{ - CORBA_sequence_CORBA_string stringv; - Bonobo_ActivationProperty *prop; - int i; - - prop = bonobo_server_info_prop_find(component, propname); - if (!prop || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) - return FALSE; - - stringv = prop->v._u.value_stringv; - for (i = 0; i < stringv._length; i++) { - if (!g_ascii_strcasecmp(value, stringv._buffer[i])) - return TRUE; - } - - return FALSE; -} - -static gboolean -efhd_use_component(const char *mime_type) -{ - GList *components, *iter; - Bonobo_ServerInfo *component = NULL; - - /* should this cache it? */ - - if (g_ascii_strcasecmp(mime_type, "text/x-vcard") != 0 - && g_ascii_strcasecmp(mime_type, "text/calendar") != 0) { - const char **mime_types; - int i; - - mime_types = mail_config_get_allowable_mime_types(); - for (i = 0; mime_types[i]; i++) { - if (!g_ascii_strcasecmp(mime_types[i], mime_type)) - goto type_ok; - } - return FALSE; - } -type_ok: - components = bonobo_activation_get_all_components_for_mime_type (mime_type); - for (iter = components; iter; iter = iter->next) { - Bonobo_ServerInfo *comp = iter->data; - - comp = iter->data; - if (efhd_check_server_prop(comp, "repo_ids", "IDL:Bonobo/PersistStream:1.0") - && efhd_check_server_prop(comp, "bonobo:supported_mime_types", mime_type)) { - component = comp; - break; - } - } - - /* FIXME: How should I free the Bonobo_ServerInfo's ? */ - g_list_foreach (components, (GFunc)CORBA_free, NULL); - g_list_free (components); - - return component != NULL; -} - static void attachment_bar_arrow_clicked(GtkWidget *w, EMFormatHTMLDisplay *efhd) { @@ -2639,16 +2451,8 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, "\n" EM_FORMAT_HTML_VPAD); - if (handle) { - if (info->shown) - handle->handler(emf, stream, part, handle); - } else if (efhd_use_component(mime_type)) { - g_free(classid); /* messy */ - - classid = g_strdup_printf("bonobo-unknown:///em-format-html-display/%s", emf->part_id->str); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_bonobo_object); - camel_stream_printf(stream, "
>\n", classid, mime_type); - } + if (handle && info->shown) + handle->handler(emf, stream, part, handle); g_free(classid); } -- cgit v1.2.3 From 08b1d0ae8e36ef20da800bf6358ca0cd9fb4e026 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 1 Mar 2009 13:16:31 +0000 Subject: Split the interactive parts of the message display out of EMFormatHTMLDisplay to a new GtkHTML subclass named EMailDisplay, and have EMFormatHTML create an instance of that. EMailDisplay will handle link clicking, mousing over URIs, popup menus, and interactive search. This makes EMFormatHTMLDisplay and EMailReader more lightweight. Clean up more of the EMFormat stack. svn path=/branches/kill-bonobo/; revision=37346 --- mail/em-format-html-display.c | 1509 ++++++++++++++++------------------------- 1 file changed, 578 insertions(+), 931 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 70b92c39ff..72cec78559 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -75,6 +75,7 @@ #include "mail-config.h" +#include "e-mail-display.h" #include "em-format-html-display.h" #include "e-searching-tokenizer.h" #include "em-icon-stream.h" @@ -126,20 +127,47 @@ struct _EMFormatHTMLDisplayPrivate { gboolean updated; }; -enum { - PROP_0, - PROP_ANIMATE, - PROP_CARET_MODE +struct _smime_pobject { + EMFormatHTMLPObject object; + + int signature; + CamelCipherValidity *valid; + GtkWidget *widget; +}; + +/* TODO: move the dialogue elsehwere */ +/* FIXME: also in em-format-html.c */ +static const struct { + const char *icon, *shortdesc, *description; +} smime_sign_table[5] = { + { "stock_signature-bad", N_("Unsigned"), N_("This message is not signed. There is no guarantee that this message is authentic.") }, + { "stock_signature-ok", N_("Valid signature"), N_("This message is signed and is valid meaning that it is very likely that this message is authentic.") }, + { "stock_signature-bad", N_("Invalid signature"), N_("The signature of this message cannot be verified, it may have been altered in transit.") }, + { "stock_signature", N_("Valid signature, but cannot verify sender"), N_("This message is signed with a valid signature, but the sender of the message cannot be verified.") }, + { "stock_signature-bad", N_("Signature exists, but need public key"), N_("This message is signed with a signature, but there is no corresponding public key.") }, + +}; + +static const struct { + const char *icon, *shortdesc, *description; +} smime_encrypt_table[4] = { + { "stock_lock-broken", N_("Unencrypted"), N_("This message is not encrypted. Its content may be viewed in transit across the Internet.") }, + { "stock_lock-ok", N_("Encrypted, weak"), N_("This message is encrypted, but with a weak encryption algorithm. It would be difficult, but not impossible for an outsider to view the content of this message in a practical amount of time.") }, + { "stock_lock-ok", N_("Encrypted"), N_("This message is encrypted. It would be difficult for an outsider to view the content of this message.") }, + { "stock_lock-ok", N_("Encrypted, strong"), N_("This message is encrypted, with a strong encryption algorithm. It would be very difficult for an outsider to view the content of this message in a practical amount of time.") }, }; -static int efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormatHTMLDisplay *efh); -static void efhd_html_link_clicked (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd); -static void efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd); +static const char *smime_sign_colour[5] = { + "", " bgcolor=\"#88bb88\"", " bgcolor=\"#bb8888\"", " bgcolor=\"#e8d122\"","" +}; static void efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri); static gboolean efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static void efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); static void efhd_message_update_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); +static void efhd_attachment_button_show (GtkWidget *w, void *data); +static gboolean efhd_attachment_button (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); +static gboolean efhd_attachment_optional (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *object); static void efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd); struct _attach_puri { @@ -177,151 +205,250 @@ struct _attach_puri { }; -static void efhd_iframe_created(GtkHTML *html, GtkHTML *iframe, EMFormatHTMLDisplay *efh); -/*static void efhd_url_requested(GtkHTML *html, const char *url, GtkHTMLStream *handle, EMFormatHTMLDisplay *efh); - static gboolean efhd_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTMLDisplay *efh);*/ - static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info); -static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_type); -static void efhd_format_clone(EMFormat *, CamelFolder *folder, const char *, CamelMimeMessage *msg, EMFormat *); -static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt); -static void efhd_format_source(EMFormat *, CamelStream *, CamelMimePart *); -static void efhd_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const char *, const EMFormatHandler *); -static void efhd_format_optional(EMFormat *, CamelStream *, CamelMimePart *, CamelStream *); -static void efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); static void efhd_complete(EMFormat *); gboolean efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); -enum { - EFHD_LINK_CLICKED, - EFHD_POPUP_EVENT, - EFHD_ON_URL, - EFHD_LAST_SIGNAL, -}; - -static guint efhd_signals[EFHD_LAST_SIGNAL] = { 0 }; - -static EMFormatHTMLClass *efhd_parent; -static EMFormatClass *efhd_format_class; +static EMFormatHTMLClass *parent_class; static void -efhd_gtkhtml_realize(GtkHTML *html, EMFormatHTMLDisplay *efhd) +efhd_xpkcs7mime_free (EMFormatHTMLPObject *o) { - EMFormatHTMLColorType type; - EMFormatHTML *efh; - GdkColor *color; - GtkStyle *style; - gint state; + struct _smime_pobject *po = (struct _smime_pobject *)o; - efh = EM_FORMAT_HTML (efhd); - state = GTK_WIDGET_STATE (html); + if (po->widget) + gtk_widget_destroy(po->widget); + camel_cipher_validity_free(po->valid); +} - style = gtk_widget_get_style (GTK_WIDGET (html)); - if (style == NULL) - return; +static void +efhd_xpkcs7mime_info_response (GtkWidget *widget, + guint button, + struct _smime_pobject *po) +{ + gtk_widget_destroy (widget); + po->widget = NULL; +} - g_object_freeze_notify (G_OBJECT (efh)); +#ifdef HAVE_NSS +static void +efhd_xpkcs7mime_viewcert_clicked (GtkWidget *button, + struct _smime_pobject *po) +{ + CamelCipherCertInfo *info = g_object_get_data((GObject *)button, "e-cert-info"); + ECertDB *db = e_cert_db_peek(); + ECert *ec = NULL; - color = &style->bg[state]; - type = EM_FORMAT_HTML_COLOR_BODY; - em_format_html_set_color (efh, type, color); + if (info->email) + ec = e_cert_db_find_cert_by_email_address(db, info->email, NULL); - color = &style->base[GTK_STATE_NORMAL]; - type = EM_FORMAT_HTML_COLOR_CONTENT; - em_format_html_set_color (efh, type, color); + if (ec == NULL && info->name) + ec = e_cert_db_find_cert_by_nickname(db, info->name, NULL); - color = &style->dark[state]; - type = EM_FORMAT_HTML_COLOR_FRAME; - em_format_html_set_color (efh, type, color); + if (ec != NULL) { + GtkWidget *w = certificate_viewer_show(ec); - color = &style->fg[state]; - type = EM_FORMAT_HTML_COLOR_HEADER; - em_format_html_set_color (efh, type, color); + /* oddly enough certificate_viewer_show doesn't ... */ + gtk_widget_show(w); + g_signal_connect(w, "response", G_CALLBACK(gtk_widget_destroy), NULL); - color = &style->text[state]; - type = EM_FORMAT_HTML_COLOR_TEXT; - em_format_html_set_color (efh, type, color); + if (w && po->widget) + gtk_window_set_transient_for((GtkWindow *)w, (GtkWindow *)po->widget); - g_object_thaw_notify (G_OBJECT (efh)); + g_object_unref(ec); + } else { + g_warning("can't find certificate for %s <%s>", info->name?info->name:"", info->email?info->email:""); + } } +#endif static void -efhd_gtkhtml_style_set(GtkHTML *html, GtkStyle *old, EMFormatHTMLDisplay *efhd) +efhd_xpkcs7mime_add_cert_table (GtkWidget *vbox, + CamelDList *certlist, + struct _smime_pobject *po) { - efhd_gtkhtml_realize(html, efhd); - em_format_redraw((EMFormat *)efhd); + CamelCipherCertInfo *info = (CamelCipherCertInfo *)certlist->head; + GtkTable *table = (GtkTable *)gtk_table_new(camel_dlist_length(certlist), 2, FALSE); + int n = 0; + + while (info->next) { + char *la = NULL; + const char *l = NULL; + + if (info->name) { + if (info->email && strcmp(info->name, info->email) != 0) + l = la = g_strdup_printf("%s <%s>", info->name, info->email); + else + l = info->name; + } else { + if (info->email) + l = info->email; + } + + if (l) { + GtkWidget *w; +#if defined(HAVE_NSS) + ECertDB *db = e_cert_db_peek(); + ECert *ec = NULL; +#endif + w = gtk_label_new(l); + gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); + g_free(la); + gtk_table_attach(table, w, 0, 1, n, n+1, GTK_FILL, GTK_FILL, 3, 3); +#if defined(HAVE_NSS) + w = gtk_button_new_with_mnemonic(_("_View Certificate")); + gtk_table_attach(table, w, 1, 2, n, n+1, 0, 0, 3, 3); + g_object_set_data((GObject *)w, "e-cert-info", info); + g_signal_connect(w, "clicked", G_CALLBACK(efhd_xpkcs7mime_viewcert_clicked), po); + + if (info->email) + ec = e_cert_db_find_cert_by_email_address(db, info->email, NULL); + if (ec == NULL && info->name) + ec = e_cert_db_find_cert_by_nickname(db, info->name, NULL); + + if (ec == NULL) + gtk_widget_set_sensitive(w, FALSE); + else + g_object_unref(ec); +#else + w = gtk_label_new (_("This certificate is not viewable")); + gtk_table_attach(table, w, 1, 2, n, n+1, 0, 0, 3, 3); +#endif + n++; + } + + info = info->next; + } + + gtk_box_pack_start((GtkBox *)vbox, (GtkWidget *)table, TRUE, TRUE, 6); } static void -efhd_init(GObject *o) +efhd_xpkcs7mime_validity_clicked (GtkWidget *button, + EMFormatHTMLPObject *pobject) { - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)o; -#define efh ((EMFormatHTML *)efhd) + struct _smime_pobject *po = (struct _smime_pobject *)pobject; + GladeXML *xml; + GtkWidget *vbox, *w; + char *gladefile; + + if (po->widget) + /* FIXME: window raise? */ + return; - efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(efhd); + gladefile = g_build_filename ( + EVOLUTION_GLADEDIR, "mail-dialogs.glade", NULL); + xml = glade_xml_new (gladefile, "message_security_dialog", NULL); + g_free (gladefile); - efhd->search_tok = (ESearchingTokenizer *)e_searching_tokenizer_new(); - gtk_html_set_tokenizer (efh->html, (HTMLTokenizer *)efhd->search_tok); + po->widget = glade_xml_get_widget(xml, "message_security_dialog"); - g_signal_connect(efh->html, "realize", G_CALLBACK(efhd_gtkhtml_realize), o); - g_signal_connect(efh->html, "style-set", G_CALLBACK(efhd_gtkhtml_style_set), o); - /* we want to convert url's etc */ - efh->text_html_flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; -#undef efh + vbox = glade_xml_get_widget(xml, "signature_vbox"); + w = gtk_label_new (_(smime_sign_table[po->valid->sign.status].description)); + gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); + gtk_label_set_line_wrap((GtkLabel *)w, TRUE); + gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); + if (po->valid->sign.description) { + GtkTextBuffer *buffer; - efhd->nobar = getenv("EVOLUTION_NO_BAR") != NULL; + buffer = gtk_text_buffer_new(NULL); + gtk_text_buffer_set_text(buffer, po->valid->sign.description, strlen(po->valid->sign.description)); + w = g_object_new(gtk_scrolled_window_get_type(), + "hscrollbar_policy", GTK_POLICY_AUTOMATIC, + "vscrollbar_policy", GTK_POLICY_AUTOMATIC, + "shadow_type", GTK_SHADOW_IN, + "child", g_object_new(gtk_text_view_get_type(), + "buffer", buffer, + "cursor_visible", FALSE, + "editable", FALSE, + "width_request", 500, + "height_request", 160, + NULL), + NULL); + g_object_unref(buffer); - efhd->priv->show_bar = FALSE; - efhd->priv->files = NULL; -} + gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); + } -static void -efhd_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_ANIMATE: - em_format_html_display_set_animate ( - EM_FORMAT_HTML_DISPLAY (object), - g_value_get_boolean (value)); - return; + if (!camel_dlist_empty(&po->valid->sign.signers)) + efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->sign.signers, po); - case PROP_CARET_MODE: - em_format_html_display_set_caret_mode ( - EM_FORMAT_HTML_DISPLAY (object), - g_value_get_boolean (value)); - return; + gtk_widget_show_all(vbox); + + vbox = glade_xml_get_widget(xml, "encryption_vbox"); + w = gtk_label_new(_(smime_encrypt_table[po->valid->encrypt.status].description)); + gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); + gtk_label_set_line_wrap((GtkLabel *)w, TRUE); + gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); + if (po->valid->encrypt.description) { + GtkTextBuffer *buffer; + + buffer = gtk_text_buffer_new(NULL); + gtk_text_buffer_set_text(buffer, po->valid->encrypt.description, strlen(po->valid->encrypt.description)); + w = g_object_new(gtk_scrolled_window_get_type(), + "hscrollbar_policy", GTK_POLICY_AUTOMATIC, + "vscrollbar_policy", GTK_POLICY_AUTOMATIC, + "shadow_type", GTK_SHADOW_IN, + "child", g_object_new(gtk_text_view_get_type(), + "buffer", buffer, + "cursor_visible", FALSE, + "editable", FALSE, + "width_request", 500, + "height_request", 160, + NULL), + NULL); + g_object_unref(buffer); + + gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); } - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + if (!camel_dlist_empty(&po->valid->encrypt.encrypters)) + efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->encrypt.encrypters, po); + + gtk_widget_show_all(vbox); + + g_object_unref(xml); + + g_signal_connect(po->widget, "response", G_CALLBACK(efhd_xpkcs7mime_info_response), po); + gtk_widget_show(po->widget); } -static void -efhd_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_ANIMATE: - g_value_set_boolean ( - value, em_format_html_display_get_animate ( - EM_FORMAT_HTML_DISPLAY (object))); - return; +static gboolean +efhd_xpkcs7mime_button (EMFormatHTML *efh, + GtkHTMLEmbedded *eb, + EMFormatHTMLPObject *pobject) +{ + GtkWidget *container; + GtkWidget *widget; + struct _smime_pobject *po = (struct _smime_pobject *)pobject; + const char *icon_name; - case PROP_CARET_MODE: - g_value_set_boolean ( - value, em_format_html_display_get_caret_mode ( - EM_FORMAT_HTML_DISPLAY (object))); - return; - } + /* FIXME: need to have it based on encryption and signing too */ + if (po->valid->sign.status != 0) + icon_name = smime_sign_table[po->valid->sign.status].icon; + else + icon_name = smime_encrypt_table[po->valid->encrypt.status].icon; + + container = GTK_WIDGET (eb); - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + widget = gtk_button_new (); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (efhd_xpkcs7mime_validity_clicked), pobject); + gtk_container_add (GTK_CONTAINER (container), widget); + gtk_widget_show (widget); + + container = widget; + + widget = gtk_image_new_from_icon_name ( + icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); + gtk_container_add (GTK_CONTAINER (container), widget); + gtk_widget_show (widget); + + return TRUE; } static void @@ -337,206 +464,294 @@ efhd_finalize (GObject *object) g_free (priv->search_text); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (efhd_parent)->finalize (object); + G_OBJECT_CLASS (parent_class)->finalize (object); } -static gboolean -efhd_bool_accumulator(GSignalInvocationHint *ihint, GValue *out, const GValue *in, void *data) +static void +efhd_format_clone (EMFormat *emf, + CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *msg, + EMFormat *src) { - gboolean val = g_value_get_boolean(in); + EMFormatHTMLDisplayPrivate *priv; - g_value_set_boolean(out, val); + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (emf); - return !val; + if (emf != src) { + priv->show_bar = (src != NULL) ? + EM_FORMAT_HTML_DISPLAY (src)->priv->show_bar : FALSE; + + EM_FORMAT_HTML (emf)->header_wrap_flags = 0; + } + + /* Chain up to parent's format_clone() method. */ + EM_FORMAT_CLASS (parent_class)-> + format_clone (emf, folder, uid, msg, src); } static void -efhd_class_init (GObjectClass *class) +efhd_format_attachment (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const gchar *mime_type, + const EMFormatHandler *handle) { - GObjectClass *object_class; - EMFormatClass *format_class; + char *classid, *text, *html; + struct _attach_puri *info; - g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate)); + classid = g_strdup_printf ("attachment%s", emf->part_id->str); + info = (struct _attach_puri *) em_format_add_puri ( + emf, sizeof (*info), classid, part, efhd_attachment_frame); + em_format_html_add_pobject ( + EM_FORMAT_HTML (emf), sizeof (EMFormatHTMLPObject), + classid, part, efhd_attachment_button); + info->handle = handle; + info->shown = em_format_is_inline ( + emf, info->puri.part_id, info->puri.part, handle); + info->snoop_mime_type = emf->snoop_mime_type; + info->attachment = e_attachment_new_from_mime_part (info->puri.part); + e_attachment_bar_create_attachment_cache (info->attachment); - object_class = G_OBJECT_CLASS (class); - object_class->set_property = efhd_set_property; - object_class->get_property = efhd_get_property; - object_class->finalize = efhd_finalize; + if (emf->valid) { + info->sign = emf->valid->sign.status; + info->encrypt = emf->valid->encrypt.status; + } - format_class = EM_FORMAT_CLASS (class); - format_class->find_handler = efhd_find_handler; - format_class->format_clone = efhd_format_clone; - format_class->format_error = efhd_format_error; - format_class->format_source = efhd_format_source; - format_class->format_attachment = efhd_format_attachment; - format_class->format_optional = efhd_format_optional; - format_class->format_secure = efhd_format_secure; - format_class->complete = efhd_complete; + camel_stream_write_string( + stream, EM_FORMAT_HTML_VPAD + ""); - g_object_class_install_property ( - object_class, - PROP_ANIMATE, - g_param_spec_boolean ( - "animate", - "Animate Images", - NULL, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_CARET_MODE, - g_param_spec_boolean ( - "caret-mode", - "Caret Mode", - NULL, - FALSE, - G_PARAM_READWRITE)); - - efhd_signals[EFHD_LINK_CLICKED] = - g_signal_new("link_clicked", - G_TYPE_FROM_CLASS(class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, link_clicked), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - efhd_signals[EFHD_POPUP_EVENT] = - g_signal_new("popup_event", - G_TYPE_FROM_CLASS(class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, popup_event), - efhd_bool_accumulator, NULL, - e_marshal_BOOLEAN__BOXED_POINTER_POINTER, - G_TYPE_BOOLEAN, 3, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE, - G_TYPE_POINTER, G_TYPE_POINTER); - - efhd_signals[EFHD_ON_URL] = - g_signal_new("on_url", - G_TYPE_FROM_CLASS(class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(EMFormatHTMLDisplayClass, on_url), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - efhd_builtin_init((EMFormatHTMLDisplayClass *)class); -} + camel_stream_printf ( + stream, "", classid); -GType -em_format_html_display_get_type (void) -{ - static GType type = 0; + camel_stream_write_string ( + stream, "
" + "" + "
" + "
"); - if (type == 0) { - static const GTypeInfo info = { - sizeof(EMFormatHTMLDisplayClass), - NULL, NULL, - (GClassInitFunc)efhd_class_init, - NULL, NULL, - sizeof(EMFormatHTMLDisplay), 0, - (GInstanceInitFunc)efhd_init - }; - efhd_parent = g_type_class_ref(em_format_html_get_type()); - efhd_format_class = g_type_class_ref(em_format_get_type()); - type = g_type_register_static(em_format_html_get_type(), "EMFormatHTMLDisplay", &info, 0); - } + /* output some info about it */ + /* FIXME: should we look up mime_type from object again? */ + text = em_format_describe_part (part, mime_type); + html = camel_text_to_html ( + text, EM_FORMAT_HTML (emf)->text_html_flags & + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + camel_stream_write_string (stream, html); + g_free (html); + g_free (text); + + camel_stream_write_string ( + stream, "
\n" + EM_FORMAT_HTML_VPAD); - return type; + if (handle && info->shown) + handle->handler (emf, stream, part, handle); + + g_free (classid); } -static gboolean -efhd_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay *efhd) +static void +efhd_format_optional (EMFormat *emf, + CamelStream *fstream, + CamelMimePart *part, + CamelStream *mstream) { - if(event->state & GDK_CONTROL_MASK) - { - if(event->direction == GDK_SCROLL_UP) - { - gtk_html_zoom_in (efhd->parent.html); - } - else if(event->direction == GDK_SCROLL_DOWN) - { - gtk_html_zoom_out (efhd->parent.html); - } - return TRUE; + char *classid, *html; + struct _attach_puri *info; + CamelStream *stream; + + if (CAMEL_IS_STREAM_FILTER (fstream) && ((CamelStreamFilter *) fstream)->source) + stream = ((CamelStreamFilter *) fstream)->source; + else + stream = fstream; + + classid = g_strdup_printf ("optional%s", emf->part_id->str); + info = (struct _attach_puri *) em_format_add_puri ( + emf, sizeof (*info), classid, part, efhd_attachment_frame); + em_format_html_add_pobject ( + EM_FORMAT_HTML (emf), sizeof (EMFormatHTMLPObject), + classid, part, efhd_attachment_optional); + info->handle = em_format_find_handler (emf, "text/plain"); + info->shown = FALSE; + info->snoop_mime_type = "text/plain"; + info->attachment = e_attachment_new_from_mime_part (info->puri.part); + info->mstream = (CamelStreamMem *) mstream; + if (emf->valid) { + info->sign = emf->valid->sign.status; + info->encrypt = emf->valid->encrypt.status; } - return FALSE; -} -EMFormatHTMLDisplay *em_format_html_display_new(void) -{ - EMFormatHTMLDisplay *efhd; + camel_stream_write_string ( + stream, EM_FORMAT_HTML_VPAD + "
" + "

"); + + html = camel_text_to_html ( + _("Evolution cannot render this email as it is too " + "large to process. You can view it unformatted or " + "with an external text editor."), + EM_FORMAT_HTML (emf)->text_html_flags & + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); + camel_stream_write_string (stream, html); + camel_stream_write_string ( + stream, "

\n"); + camel_stream_write_string ( + stream, ""); + camel_stream_printf ( + stream, "
" + "
", classid); - efhd = g_object_new(em_format_html_display_get_type(), 0); + g_free(html); - g_signal_connect(efhd->parent.html, "iframe_created", G_CALLBACK(efhd_iframe_created), efhd); - g_signal_connect(efhd->parent.html, "link_clicked", G_CALLBACK(efhd_html_link_clicked), efhd); - g_signal_connect(efhd->parent.html, "on_url", G_CALLBACK(efhd_html_on_url), efhd); - g_signal_connect(efhd->parent.html, "button_press_event", G_CALLBACK(efhd_html_button_press_event), efhd); - g_signal_connect(efhd->parent.html,"scroll_event", G_CALLBACK(efhd_scroll_event), efhd); + camel_stream_write_string ( + stream, EM_FORMAT_HTML_VPAD); - return efhd; + g_free (classid); } -gboolean -em_format_html_display_get_animate (EMFormatHTMLDisplay *efhd) +static void +efhd_format_secure (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + CamelCipherValidity *valid) { - GtkHTML *html; + EM_FORMAT_CLASS (parent_class)-> + format_secure (emf, stream, part, valid); + + if (emf->valid == valid + && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE + || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) { + char *classid; + struct _smime_pobject *pobj; - g_return_val_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd), FALSE); + camel_stream_printf ( + stream, "", + smime_sign_colour[valid->sign.status]); + + classid = g_strdup_printf ( + "smime:///em-format-html/%s/icon/signed", + emf->part_id->str); + pobj = (struct _smime_pobject *) em_format_html_add_pobject ( + EM_FORMAT_HTML (emf), sizeof (*pobj), + classid, part, efhd_xpkcs7mime_button); + pobj->valid = camel_cipher_validity_clone(valid); + pobj->object.free = efhd_xpkcs7mime_free; + camel_stream_printf ( + stream, "
" + "", + classid); + g_free (classid); - html = ((EMFormatHTML *) efhd)->html; + if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { + const gchar *desc; + gint status; - return gtk_html_get_animate (html); + status = valid->sign.status; + desc = smime_sign_table[status].shortdesc; + camel_stream_printf (stream, "%s", gettext (desc)); + } + + if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) { + const gchar *desc; + gint status; + + if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { + camel_stream_printf (stream, "
"); + } + + status = valid->encrypt.status; + desc = smime_encrypt_table[status].shortdesc; + camel_stream_printf (stream, "%s", gettext (desc)); + } + + camel_stream_printf(stream, "
"); + } } -void -em_format_html_display_set_animate (EMFormatHTMLDisplay *efhd, - gboolean animate) +static void +efhd_class_init (EMFormatHTMLDisplayClass *class) { - GtkHTML *html; + GObjectClass *object_class; + EMFormatClass *format_class; + EMFormatHTMLClass *format_html_class; - /* XXX Note this is imperfect. If animate is set by - * some other means we won't emit a notification. */ + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->finalize = efhd_finalize; - g_return_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd)); + format_class = EM_FORMAT_CLASS (class); + format_class->format_clone = efhd_format_clone; + format_class->format_attachment = efhd_format_attachment; + format_class->format_optional = efhd_format_optional; + format_class->format_secure = efhd_format_secure; + format_class->complete = efhd_complete; - html = ((EMFormatHTML *) efhd)->html; - gtk_html_set_animate (html, animate); + format_html_class = EM_FORMAT_HTML_CLASS (class); + format_html_class->html_widget_type = E_TYPE_MAIL_DISPLAY; - g_object_notify (G_OBJECT (efhd), "animate"); + efhd_builtin_init (class); } -gboolean -em_format_html_display_get_caret_mode (EMFormatHTMLDisplay *efhd) +static void +efhd_init (EMFormatHTMLDisplay *efhd) { GtkHTML *html; - g_return_val_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd), FALSE); + html = EM_FORMAT_HTML (efhd)->html; + + efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efhd); + + e_mail_display_set_formatter ( + E_MAIL_DISPLAY (html), EM_FORMAT_HTML (efhd)); - html = ((EMFormatHTML *) efhd)->html; + efhd->search_tok = + (ESearchingTokenizer *) e_searching_tokenizer_new (); + gtk_html_set_tokenizer (html, (HTMLTokenizer *) efhd->search_tok); - return gtk_html_get_caret_mode (html); + /* we want to convert url's etc */ + EM_FORMAT_HTML (efhd)->text_html_flags |= + CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | + CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; + + efhd->priv->show_bar = FALSE; + efhd->priv->files = NULL; } -void -em_format_html_display_set_caret_mode (EMFormatHTMLDisplay *efhd, - gboolean caret_mode) +GType +em_format_html_display_get_type (void) { - GtkHTML *html; + static GType type = 0; - /* XXX Note this is imperfect. If caret mode is set by - * some other means we won't emit a notification. */ + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMFormatHTMLDisplayClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) efhd_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMFormatHTMLDisplay), + 0, /* n_preallocs */ + (GInstanceInitFunc) efhd_init, + NULL /* value_table */ + }; - g_return_if_fail (EM_IS_FORMAT_HTML_DISPLAY (efhd)); + type = g_type_register_static ( + EM_TYPE_FORMAT_HTML, "EMFormatHTMLDisplay", + &type_info, 0); + } - html = ((EMFormatHTML *) efhd)->html; - gtk_html_set_caret_mode (html, caret_mode); + return type; +} - g_object_notify (G_OBJECT (efhd), "caret-mode"); +EMFormatHTMLDisplay * +em_format_html_display_new (void) +{ + return g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL); } EAttachmentBar * @@ -779,579 +994,138 @@ em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd) efhd_update_matches(efhd); - return (GtkWidget *)p->search_dialog; - -} - -static void -set_focus_cb (GtkWidget *window, GtkWidget *widget, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GtkWidget *sbar = GTK_WIDGET (p->search_dialog); - - while (widget != NULL && widget != sbar) { - widget = widget->parent; - } - - if (widget != sbar) - efhd_search_destroy(widget, efhd); -} - -/** - * em_format_html_display_search: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - GtkWidget *toplevel; - - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - gtk_widget_grab_focus (p->search_entry); - gtk_widget_show (p->search_entry_box); - - p->search_active = TRUE; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (p->search_dialog)); - - g_signal_connect (toplevel, "set-focus", - G_CALLBACK (set_focus_cb), efhd); - } - -} -/** - * em_format_html_display_search_with: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - p->search_active = TRUE; - - /* Set the query */ - gtk_entry_set_text (GTK_ENTRY (p->search_entry), word); - gtk_widget_hide (p->search_entry_box); - - /* Trigger the search */ - g_signal_emit_by_name (p->search_entry, "activate", efhd); - } -} - -void -em_format_html_display_search_close (EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog && p->search_active) - efhd_search_destroy(GTK_WIDGET (p->search_dialog), efhd); -} - -void -em_format_html_display_cut (EMFormatHTMLDisplay *efhd) -{ - gtk_html_cut (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_copy (EMFormatHTMLDisplay *efhd) -{ - gtk_html_copy (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_paste (EMFormatHTMLDisplay *efhd) -{ - gtk_html_paste (((EMFormatHTML *) efhd)->html, FALSE); -} - -void -em_format_html_display_zoom_in (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_in (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_zoom_out (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_out (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_zoom_reset (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_reset (((EMFormatHTML *) efhd)->html); -} - -/* ********************************************************************** */ - -static void -efhd_iframe_created(GtkHTML *html, GtkHTML *iframe, EMFormatHTMLDisplay *efh) -{ - d(printf("Iframe created %p ... \n", iframe)); - - g_signal_connect(iframe, "button_press_event", G_CALLBACK (efhd_html_button_press_event), efh); - - return; -} - -static void -efhd_get_uri_puri (GtkWidget *html, GdkEventButton *event, EMFormatHTMLDisplay *efhd, char **uri, EMFormatPURI **puri) -{ - char *url, *img_url; - - g_return_if_fail (html != NULL); - g_return_if_fail (GTK_IS_HTML (html)); - g_return_if_fail (efhd != NULL); - - if (event) { - url = gtk_html_get_url_at (GTK_HTML (html), event->x, event->y); - img_url = gtk_html_get_image_src_at (GTK_HTML (html), event->x, event->y); - } else { - url = gtk_html_get_cursor_url (GTK_HTML (html)); - img_url = gtk_html_get_cursor_image_src (GTK_HTML (html)); - } - - if (img_url) { - if (!(strstr (img_url, "://") || g_ascii_strncasecmp (img_url, "cid:", 4) == 0)) { - char *u = g_strconcat ("file://", img_url, NULL); - g_free (img_url); - img_url = u; - } - } - - if (puri) { - if (url) - *puri = em_format_find_puri ((EMFormat *)efhd, url); - - if (!*puri && img_url) - *puri = em_format_find_puri ((EMFormat *)efhd, img_url); - } - - if (uri) { - *uri = NULL; - if (img_url && g_ascii_strncasecmp (img_url, "cid:", 4) != 0) { - if (url) - *uri = g_strdup_printf ("%s\n%s", url, img_url); - else { - *uri = img_url; - img_url = NULL; - } - } else { - *uri = url; - url = NULL; - } - } - - g_free (url); - g_free (img_url); -} - -static int -efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormatHTMLDisplay *efhd) -{ - char *uri = NULL; - EMFormatPURI *puri = NULL; - gboolean res = FALSE; - - if (event->button != 3) - return FALSE; - - d(printf("popup button pressed\n")); - - efhd_get_uri_puri (widget, event, efhd, &uri, &puri); - - if (uri && !strncmp (uri, "##", 2)) { - g_free (uri); - return TRUE; - } - - g_signal_emit((GtkObject *)efhd, efhd_signals[EFHD_POPUP_EVENT], 0, event, uri, puri?puri->part:NULL, &res); - - g_free (uri); - - return res; -} - -gboolean -em_format_html_display_popup_menu (EMFormatHTMLDisplay *efhd) -{ - GtkHTML *html; - char *uri = NULL; - EMFormatPURI *puri = NULL; - gboolean res = FALSE; - - html = efhd->parent.html; - - efhd_get_uri_puri (GTK_WIDGET (html), NULL, efhd, &uri, &puri); - - g_signal_emit ((GtkObject *)efhd, efhd_signals[EFHD_POPUP_EVENT], 0, NULL, uri, puri?puri->part:NULL, &res); - - g_free (uri); - - return res; -} - -static void -efhd_html_link_clicked (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd) -{ - d(printf("link clicked event '%s'\n", url)); - if (url && !strncmp(url, "##", 2)) { - if (!strcmp (url, "##TO##")) - if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_TO)) - ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_TO; - else - ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_TO; - else if (!strcmp (url, "##CC##")) - if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_CC)) - ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_CC; - else - ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_CC; - else if (!strcmp (url, "##BCC##")) { - if (!(((EMFormatHTML *) efhd)->header_wrap_flags & EM_FORMAT_HTML_HEADER_BCC)) - ((EMFormatHTML *) efhd)->header_wrap_flags |= EM_FORMAT_HTML_HEADER_BCC; - else - ((EMFormatHTML *) efhd)->header_wrap_flags &= ~EM_FORMAT_HTML_HEADER_BCC; - } - em_format_redraw((EMFormat *)efhd); - } else - g_signal_emit((GObject *)efhd, efhd_signals[EFHD_LINK_CLICKED], 0, url); -} - -static void -efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDisplay *efhd) -{ - d(printf("on_url event '%s'\n", url)); - - g_signal_emit((GObject *)efhd, efhd_signals[EFHD_ON_URL], 0, url); -} - -static void -efhd_complete(EMFormat *emf) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)emf; - - if (efhd->priv->search_dialog && efhd->priv->search_active) - efhd_update_matches(efhd); - - if (efhd->priv->files) { - g_hash_table_destroy (efhd->priv->files); - efhd->priv->files = NULL; - } -} - -/* ********************************************************************** */ - -/* TODO: move the dialogue elsehwere */ -/* FIXME: also in em-format-html.c */ -static const struct { - const char *icon, *shortdesc, *description; -} smime_sign_table[5] = { - { "stock_signature-bad", N_("Unsigned"), N_("This message is not signed. There is no guarantee that this message is authentic.") }, - { "stock_signature-ok", N_("Valid signature"), N_("This message is signed and is valid meaning that it is very likely that this message is authentic.") }, - { "stock_signature-bad", N_("Invalid signature"), N_("The signature of this message cannot be verified, it may have been altered in transit.") }, - { "stock_signature", N_("Valid signature, but cannot verify sender"), N_("This message is signed with a valid signature, but the sender of the message cannot be verified.") }, - { "stock_signature-bad", N_("Signature exists, but need public key"), N_("This message is signed with a signature, but there is no corresponding public key.") }, - -}; - -static const struct { - const char *icon, *shortdesc, *description; -} smime_encrypt_table[4] = { - { "stock_lock-broken", N_("Unencrypted"), N_("This message is not encrypted. Its content may be viewed in transit across the Internet.") }, - { "stock_lock-ok", N_("Encrypted, weak"), N_("This message is encrypted, but with a weak encryption algorithm. It would be difficult, but not impossible for an outsider to view the content of this message in a practical amount of time.") }, - { "stock_lock-ok", N_("Encrypted"), N_("This message is encrypted. It would be difficult for an outsider to view the content of this message.") }, - { "stock_lock-ok", N_("Encrypted, strong"), N_("This message is encrypted, with a strong encryption algorithm. It would be very difficult for an outsider to view the content of this message in a practical amount of time.") }, -}; - -static const char *smime_sign_colour[5] = { - "", " bgcolor=\"#88bb88\"", " bgcolor=\"#bb8888\"", " bgcolor=\"#e8d122\"","" -}; - -struct _smime_pobject { - EMFormatHTMLPObject object; - - int signature; - CamelCipherValidity *valid; - GtkWidget *widget; -}; - -static void -efhd_xpkcs7mime_free(EMFormatHTMLPObject *o) -{ - struct _smime_pobject *po = (struct _smime_pobject *)o; - - if (po->widget) - gtk_widget_destroy(po->widget); - camel_cipher_validity_free(po->valid); -} - -static void -efhd_xpkcs7mime_info_response(GtkWidget *w, guint button, struct _smime_pobject *po) -{ - gtk_widget_destroy(w); - po->widget = NULL; -} - -#ifdef HAVE_NSS -static void -efhd_xpkcs7mime_viewcert_foad(GtkWidget *w, guint button, struct _smime_pobject *po) -{ - gtk_widget_destroy(w); -} - -static void -efhd_xpkcs7mime_viewcert_clicked(GtkWidget *button, struct _smime_pobject *po) -{ - CamelCipherCertInfo *info = g_object_get_data((GObject *)button, "e-cert-info"); - ECertDB *db = e_cert_db_peek(); - ECert *ec = NULL; - - if (info->email) - ec = e_cert_db_find_cert_by_email_address(db, info->email, NULL); - - if (ec == NULL && info->name) - ec = e_cert_db_find_cert_by_nickname(db, info->name, NULL); - - if (ec != NULL) { - GtkWidget *w = certificate_viewer_show(ec); - - /* oddly enough certificate_viewer_show doesn't ... */ - gtk_widget_show(w); - g_signal_connect(w, "response", G_CALLBACK(efhd_xpkcs7mime_viewcert_foad), po); - - if (w && po->widget) - gtk_window_set_transient_for((GtkWindow *)w, (GtkWindow *)po->widget); - - g_object_unref(ec); - } else { - g_warning("can't find certificate for %s <%s>", info->name?info->name:"", info->email?info->email:""); - } -} -#endif - -static void -efhd_xpkcs7mime_add_cert_table(GtkWidget *vbox, CamelDList *certlist, struct _smime_pobject *po) -{ - CamelCipherCertInfo *info = (CamelCipherCertInfo *)certlist->head; - GtkTable *table = (GtkTable *)gtk_table_new(camel_dlist_length(certlist), 2, FALSE); - int n = 0; - - while (info->next) { - char *la = NULL; - const char *l = NULL; - - if (info->name) { - if (info->email && strcmp(info->name, info->email) != 0) - l = la = g_strdup_printf("%s <%s>", info->name, info->email); - else - l = info->name; - } else { - if (info->email) - l = info->email; - } - - if (l) { - GtkWidget *w; -#if defined(HAVE_NSS) - ECertDB *db = e_cert_db_peek(); - ECert *ec = NULL; -#endif - w = gtk_label_new(l); - gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); - g_free(la); - gtk_table_attach(table, w, 0, 1, n, n+1, GTK_FILL, GTK_FILL, 3, 3); -#if defined(HAVE_NSS) - w = gtk_button_new_with_mnemonic(_("_View Certificate")); - gtk_table_attach(table, w, 1, 2, n, n+1, 0, 0, 3, 3); - g_object_set_data((GObject *)w, "e-cert-info", info); - g_signal_connect(w, "clicked", G_CALLBACK(efhd_xpkcs7mime_viewcert_clicked), po); - - if (info->email) - ec = e_cert_db_find_cert_by_email_address(db, info->email, NULL); - if (ec == NULL && info->name) - ec = e_cert_db_find_cert_by_nickname(db, info->name, NULL); - - if (ec == NULL) - gtk_widget_set_sensitive(w, FALSE); - else - g_object_unref(ec); -#else - w = gtk_label_new (_("This certificate is not viewable")); - gtk_table_attach(table, w, 1, 2, n, n+1, 0, 0, 3, 3); -#endif - n++; - } - - info = info->next; - } - - gtk_box_pack_start((GtkBox *)vbox, (GtkWidget *)table, TRUE, TRUE, 6); -} - -static void -efhd_xpkcs7mime_validity_clicked(GtkWidget *button, EMFormatHTMLPObject *pobject) -{ - struct _smime_pobject *po = (struct _smime_pobject *)pobject; - GladeXML *xml; - GtkWidget *vbox, *w; - char *gladefile; - - if (po->widget) - /* FIXME: window raise? */ - return; + return (GtkWidget *)p->search_dialog; - gladefile = g_build_filename (EVOLUTION_GLADEDIR, - "mail-dialogs.glade", - NULL); - xml = glade_xml_new(gladefile, "message_security_dialog", NULL); - g_free (gladefile); +} - po->widget = glade_xml_get_widget(xml, "message_security_dialog"); +static void +set_focus_cb (GtkWidget *window, GtkWidget *widget, EMFormatHTMLDisplay *efhd) +{ + struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; + GtkWidget *sbar = GTK_WIDGET (p->search_dialog); - vbox = glade_xml_get_widget(xml, "signature_vbox"); - w = gtk_label_new (_(smime_sign_table[po->valid->sign.status].description)); - gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); - if (po->valid->sign.description) { - GtkTextBuffer *buffer; + while (widget != NULL && widget != sbar) { + widget = widget->parent; + } - buffer = gtk_text_buffer_new(NULL); - gtk_text_buffer_set_text(buffer, po->valid->sign.description, strlen(po->valid->sign.description)); - w = g_object_new(gtk_scrolled_window_get_type(), - "hscrollbar_policy", GTK_POLICY_AUTOMATIC, - "vscrollbar_policy", GTK_POLICY_AUTOMATIC, - "shadow_type", GTK_SHADOW_IN, - "child", g_object_new(gtk_text_view_get_type(), - "buffer", buffer, - "cursor_visible", FALSE, - "editable", FALSE, - "width_request", 500, - "height_request", 160, - NULL), - NULL); - g_object_unref(buffer); + if (widget != sbar) + efhd_search_destroy(widget, efhd); +} - gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); - } +/** + * em_format_html_display_search: + * @efhd: + * + * Run an interactive search dialogue. + **/ +void +em_format_html_display_search(EMFormatHTMLDisplay *efhd) +{ + struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - if (!camel_dlist_empty(&po->valid->sign.signers)) - efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->sign.signers, po); + if (p->search_dialog){ + GtkWidget *toplevel; - gtk_widget_show_all(vbox); + gtk_widget_show (GTK_WIDGET (p->search_dialog)); + gtk_widget_grab_focus (p->search_entry); + gtk_widget_show (p->search_entry_box); - vbox = glade_xml_get_widget(xml, "encryption_vbox"); - w = gtk_label_new(_(smime_encrypt_table[po->valid->encrypt.status].description)); - gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.5); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); - if (po->valid->encrypt.description) { - GtkTextBuffer *buffer; + p->search_active = TRUE; - buffer = gtk_text_buffer_new(NULL); - gtk_text_buffer_set_text(buffer, po->valid->encrypt.description, strlen(po->valid->encrypt.description)); - w = g_object_new(gtk_scrolled_window_get_type(), - "hscrollbar_policy", GTK_POLICY_AUTOMATIC, - "vscrollbar_policy", GTK_POLICY_AUTOMATIC, - "shadow_type", GTK_SHADOW_IN, - "child", g_object_new(gtk_text_view_get_type(), - "buffer", buffer, - "cursor_visible", FALSE, - "editable", FALSE, - "width_request", 500, - "height_request", 160, - NULL), - NULL); - g_object_unref(buffer); + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (p->search_dialog)); - gtk_box_pack_start((GtkBox *)vbox, w, TRUE, TRUE, 6); + g_signal_connect (toplevel, "set-focus", + G_CALLBACK (set_focus_cb), efhd); } - if (!camel_dlist_empty(&po->valid->encrypt.encrypters)) - efhd_xpkcs7mime_add_cert_table(vbox, &po->valid->encrypt.encrypters, po); +} +/** + * em_format_html_display_search_with: + * @efhd: + * + * Run an interactive search dialogue. + **/ +void +em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word) +{ + struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - gtk_widget_show_all(vbox); + if (p->search_dialog){ + gtk_widget_show (GTK_WIDGET (p->search_dialog)); + p->search_active = TRUE; - g_object_unref(xml); + /* Set the query */ + gtk_entry_set_text (GTK_ENTRY (p->search_entry), word); + gtk_widget_hide (p->search_entry_box); - g_signal_connect(po->widget, "response", G_CALLBACK(efhd_xpkcs7mime_info_response), po); - gtk_widget_show(po->widget); + /* Trigger the search */ + g_signal_emit_by_name (p->search_entry, "activate", efhd); + } } -static gboolean -efhd_xpkcs7mime_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) +void +em_format_html_display_search_close (EMFormatHTMLDisplay *efhd) { - GtkWidget *icon, *button; - struct _smime_pobject *po = (struct _smime_pobject *)pobject; - const char *icon_name; + struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - /* FIXME: need to have it based on encryption and signing too */ - if (po->valid->sign.status != 0) - icon_name = smime_sign_table[po->valid->sign.status].icon; - else - icon_name = smime_encrypt_table[po->valid->encrypt.status].icon; + if (p->search_dialog && p->search_active) + efhd_search_destroy(GTK_WIDGET (p->search_dialog), efhd); +} - icon = gtk_image_new_from_icon_name ( - icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); - gtk_widget_show(icon); +void +em_format_html_display_cut (EMFormatHTMLDisplay *efhd) +{ + gtk_html_cut (((EMFormatHTML *) efhd)->html); +} - button = gtk_button_new(); - g_signal_connect(button, "clicked", G_CALLBACK(efhd_xpkcs7mime_validity_clicked), pobject); +void +em_format_html_display_copy (EMFormatHTMLDisplay *efhd) +{ + gtk_html_copy (((EMFormatHTML *) efhd)->html); +} - gtk_container_add((GtkContainer *)button, icon); - gtk_widget_show(button); - gtk_container_add((GtkContainer *)eb, button); +void +em_format_html_display_paste (EMFormatHTMLDisplay *efhd) +{ + gtk_html_paste (((EMFormatHTML *) efhd)->html, FALSE); +} - return TRUE; +void +em_format_html_display_zoom_in (EMFormatHTMLDisplay *efhd) +{ + gtk_html_zoom_in (((EMFormatHTML *) efhd)->html); } -static void -efhd_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid) +void +em_format_html_display_zoom_out (EMFormatHTMLDisplay *efhd) { - /* Note: We call EMFormatClass directly, not EMFormatHTML, our parent */ - efhd_format_class->format_secure(emf, stream, part, valid); + gtk_html_zoom_out (((EMFormatHTML *) efhd)->html); +} - if (emf->valid == valid - && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE - || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) { - char *classid; - struct _smime_pobject *pobj; +void +em_format_html_display_zoom_reset (EMFormatHTMLDisplay *efhd) +{ + gtk_html_zoom_reset (((EMFormatHTML *) efhd)->html); +} - camel_stream_printf (stream, "", - smime_sign_colour[valid->sign.status]); +/* ********************************************************************** */ - classid = g_strdup_printf("smime:///em-format-html/%s/icon/signed", emf->part_id->str); - pobj = (struct _smime_pobject *)em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(*pobj), classid, part, efhd_xpkcs7mime_button); - pobj->valid = camel_cipher_validity_clone(valid); - pobj->object.free = efhd_xpkcs7mime_free; - camel_stream_printf(stream, "
", classid); - g_free(classid); - if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { - camel_stream_printf (stream, "%s", _(smime_sign_table[valid->sign.status].shortdesc)); - } +static void +efhd_complete(EMFormat *emf) +{ + EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)emf; - if (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE) { - if (valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE) { - camel_stream_printf (stream, "
"); - } - camel_stream_printf (stream, "%s", _(smime_encrypt_table[valid->encrypt.status].shortdesc)); - } + if (efhd->priv->search_dialog && efhd->priv->search_active) + efhd_update_matches(efhd); - camel_stream_printf(stream, "
"); + if (efhd->priv->files) { + g_hash_table_destroy (efhd->priv->files); + efhd->priv->files = NULL; } } +/* ********************************************************************** */ + static void efhd_image(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *handle) { @@ -1417,27 +1191,6 @@ efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) em_format_class_add_handler((EMFormatClass *)efhc, &type_builtin_table[i]); } -static const EMFormatHandler * -efhd_find_handler(EMFormat *emf, const char *mime_type) -{ - return ((EMFormatClass *) efhd_parent)->find_handler (emf, mime_type); -} - -static void efhd_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *src) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; - - if (emf != src) { - if (src) - efhd->priv->show_bar = ((EMFormatHTMLDisplay *)src)->priv->show_bar; - else - efhd->priv->show_bar = FALSE; - ((EMFormatHTML *) emf)->header_wrap_flags = 0; - } - - ((EMFormatClass *)efhd_parent)->format_clone(emf, folder, uid, msg, src); -} - static void efhd_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) { @@ -1449,7 +1202,8 @@ efhd_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) camel_stream_close(stream); } -static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +static void +efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) { const char *flag, *comp, *due; time_t date; @@ -1508,17 +1262,6 @@ static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePar camel_stream_printf(stream, ""); } -/* TODO: if these aren't going to do anything should remove */ -static void efhd_format_error(EMFormat *emf, CamelStream *stream, const char *txt) -{ - ((EMFormatClass *)efhd_parent)->format_error(emf, stream, txt); -} - -static void efhd_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part) -{ - ((EMFormatClass *)efhd_parent)->format_source(emf, stream, part); -} - /* ********************************************************************** */ /* Checks on the widget whether it can be processed, based on the state of EMFormatHTML. @@ -2381,7 +2124,7 @@ efhd_message_update_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; const char *classid = "attachment-bar-refresh"; - if (efhd->nobar || efhd->priv->updated) + if (efhd->priv->updated) return; efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -2397,7 +2140,7 @@ efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, co EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; const char *classid = "attachment-bar"; - if (efhd->nobar || efhd->priv->files) + if (efhd->priv->files) return; efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -2407,56 +2150,6 @@ efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, co camel_stream_printf(stream, "", classid); } -static void -efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type, const EMFormatHandler *handle) -{ - char *classid, *text, *html; - struct _attach_puri *info; - - classid = g_strdup_printf("attachment%s", emf->part_id->str); - info = (struct _attach_puri *)em_format_add_puri(emf, sizeof(*info), classid, part, efhd_attachment_frame); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_attachment_button); - info->handle = handle; - info->shown = em_format_is_inline(emf, info->puri.part_id, info->puri.part, handle); - info->snoop_mime_type = emf->snoop_mime_type; - info->attachment = e_attachment_new_from_mime_part (info->puri.part); - e_attachment_bar_create_attachment_cache (info->attachment); - - if (emf->valid) { - info->sign = emf->valid->sign.status; - info->encrypt = emf->valid->encrypt.status; - } - - camel_stream_write_string(stream, - EM_FORMAT_HTML_VPAD - ""); - - camel_stream_printf(stream, "", classid); - - camel_stream_write_string(stream, - "
" - "" - "
" - "
"); - - /* output some info about it */ - /* FIXME: should we look up mime_type from object again? */ - text = em_format_describe_part(part, mime_type); - html = camel_text_to_html(text, ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string(stream, html); - g_free(html); - g_free(text); - - camel_stream_write_string(stream, - "
\n" - EM_FORMAT_HTML_VPAD); - - if (handle && info->shown) - handle->handler(emf, stream, part, handle); - - g_free(classid); -} - static void efhd_optional_button_show (GtkWidget *widget, GtkWidget *w) { @@ -2570,49 +2263,3 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb return TRUE; } -static void -efhd_format_optional(EMFormat *emf, CamelStream *fstream, CamelMimePart *part, CamelStream *mstream) -{ - char *classid, *html; - struct _attach_puri *info; - CamelStream *stream; - - if (CAMEL_IS_STREAM_FILTER (fstream) && ((CamelStreamFilter *) fstream)->source) - stream = ((CamelStreamFilter *) fstream)->source; - else - stream = fstream; - - classid = g_strdup_printf("optional%s", emf->part_id->str); - info = (struct _attach_puri *)em_format_add_puri(emf, sizeof(*info), classid, part, efhd_attachment_frame); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_attachment_optional); - info->handle = em_format_find_handler(emf, "text/plain"); - info->shown = FALSE; - info->snoop_mime_type = "text/plain"; - info->attachment = e_attachment_new_from_mime_part (info->puri.part); - info->mstream = (CamelStreamMem *)mstream; - if (emf->valid) { - info->sign = emf->valid->sign.status; - info->encrypt = emf->valid->encrypt.status; - } - - camel_stream_write_string(stream, - EM_FORMAT_HTML_VPAD - "

"); - - html = camel_text_to_html(_("Evolution cannot render this email as it is too large to process. You can view it unformatted or with an external text editor."), ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string(stream, html); - camel_stream_write_string(stream, - "

\n"); - camel_stream_write_string(stream, - "" - ""); - camel_stream_printf(stream, "
", classid); - - g_free(html); - - camel_stream_write_string(stream, -/* "\n" */ - EM_FORMAT_HTML_VPAD); - - g_free(classid); -} -- cgit v1.2.3 From 85d0142d21286ce87cd5f6c3d1e2f71aa994151f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 2 Mar 2009 03:14:42 +0000 Subject: Move text searching UI into a new EMailSearchBar widget. svn path=/branches/kill-bonobo/; revision=37351 --- mail/em-format-html-display.c | 341 +----------------------------------------- 1 file changed, 4 insertions(+), 337 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 72cec78559..6710abeb98 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -40,7 +40,6 @@ #include #include -#include #include @@ -77,13 +76,11 @@ #include "e-mail-display.h" #include "em-format-html-display.h" -#include "e-searching-tokenizer.h" #include "em-icon-stream.h" #include "em-utils.h" #include "em-popup.h" #include "e-attachment.h" #include "e-attachment-bar.h" -#include "e-icon-entry.h" #ifdef G_OS_WIN32 /* Undefine the similar macro from ,it doesn't check if @@ -102,17 +99,6 @@ ((obj), EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate)) struct _EMFormatHTMLDisplayPrivate { - /* For the interactive search dialogue */ - /* TODO: Should this be more subtle, like the mozilla one? */ - GtkHBox *search_dialog; - GtkWidget *search_entry; - GtkWidget *search_entry_box; - GtkWidget *search_matches_label; - GtkWidget *search_case_check; - char *search_text; - int search_wrap; /* are we doing a wrap search */ - gboolean search_active; /* if the search is active */ - /* for Attachment bar */ GtkWidget *attachment_bar; GtkWidget *attachment_box; @@ -461,8 +447,6 @@ efhd_finalize (GObject *object) if (priv->files != NULL) g_hash_table_destroy (priv->files); - g_free (priv->search_text); - /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -616,8 +600,10 @@ efhd_format_secure (EMFormat *emf, CamelMimePart *part, CamelCipherValidity *valid) { - EM_FORMAT_CLASS (parent_class)-> - format_secure (emf, stream, part, valid); + EMFormatClass *format_class; + + format_class = g_type_class_peek (EM_TYPE_FORMAT); + format_class->format_secure (emf, stream, part, valid); if (emf->valid == valid && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE @@ -708,10 +694,6 @@ efhd_init (EMFormatHTMLDisplay *efhd) e_mail_display_set_formatter ( E_MAIL_DISPLAY (html), EM_FORMAT_HTML (efhd)); - efhd->search_tok = - (ESearchingTokenizer *) e_searching_tokenizer_new (); - gtk_html_set_tokenizer (html, (HTMLTokenizer *) efhd->search_tok); - /* we want to convert url's etc */ EM_FORMAT_HTML (efhd)->text_html_flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | @@ -760,318 +742,6 @@ em_format_html_display_get_bar (EMFormatHTMLDisplay *efhd) return E_ATTACHMENT_BAR (efhd->priv->attachment_bar); } -void -em_format_html_display_set_search(EMFormatHTMLDisplay *efhd, int type, GSList *strings) -{ - switch(type&3) { - case EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY: - e_searching_tokenizer_set_primary_case_sensitivity(efhd->search_tok, (type&EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE) == 0); - e_searching_tokenizer_set_primary_search_string(efhd->search_tok, NULL); - while (strings) { - e_searching_tokenizer_add_primary_search_string(efhd->search_tok, strings->data); - strings = strings->next; - } - break; - case EM_FORMAT_HTML_DISPLAY_SEARCH_SECONDARY: - default: - e_searching_tokenizer_set_secondary_case_sensitivity(efhd->search_tok, (type&EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE) == 0); - e_searching_tokenizer_set_secondary_search_string(efhd->search_tok, NULL); - while (strings) { - e_searching_tokenizer_add_secondary_search_string(efhd->search_tok, strings->data); - strings = strings->next; - } - break; - } - - d(printf("redrawing with search\n")); - em_format_redraw((EMFormat *)efhd); -} - -static void -efhd_update_matches(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - char *str; - /* message-search popup match count string */ - char *fmt = _("Matches: %d"); - - if (p->search_dialog) { - str = alloca(strlen(fmt)+32); - sprintf(str, fmt, e_searching_tokenizer_match_count(efhd->search_tok)); - gtk_label_set_text((GtkLabel *)p->search_matches_label, str); - } - gtk_widget_show((GtkWidget *)p->search_matches_label); - -} - -static void -efhd_update_search(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GSList *words = NULL; - int flags = 0; - - if (!gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check)) - flags = EM_FORMAT_HTML_DISPLAY_SEARCH_ICASE | EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY; - else - flags = EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY; - - if (p->search_text) - words = g_slist_append(words, p->search_text); - - em_format_html_display_set_search(efhd, flags, words); - g_slist_free(words); -} - -static void -efhd_search_response(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry)); - - g_strstrip(txt); - if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) { - gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, TRUE); - if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html)) - p->search_wrap = TRUE; - g_free(txt); - } else { - g_free(p->search_text); - p->search_text = txt; - if (!p->search_wrap) - efhd_update_search(efhd); - p->search_wrap = FALSE; - gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt, - gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check), - TRUE, FALSE); - } -} - - -static void -efhd_search_response_back (GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - char *txt = g_strdup(gtk_entry_get_text((GtkEntry *)p->search_entry)); - - g_strstrip(txt); - if (p->search_text && strcmp(p->search_text, txt) == 0 && !p->search_wrap) { - gtk_html_engine_search_set_forward (((EMFormatHTML *)efhd)->html, FALSE); - if (!gtk_html_engine_search_next(((EMFormatHTML *)efhd)->html)) - p->search_wrap = TRUE; - g_free(txt); - } else { - g_free(p->search_text); - p->search_text = txt; - if (!p->search_wrap) - efhd_update_search(efhd); - p->search_wrap = FALSE; - gtk_html_engine_search(((EMFormatHTML *)efhd)->html, txt, - gtk_toggle_button_get_active((GtkToggleButton *)p->search_case_check), - FALSE, FALSE); - } -} - - -static void -efhd_search_destroy(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - g_free(p->search_text); - p->search_text = NULL; - gtk_widget_hide((GtkWidget *)p->search_dialog); - em_format_html_display_set_search(efhd, EM_FORMAT_HTML_DISPLAY_SEARCH_PRIMARY, NULL); - p->search_active = FALSE; -} - -static void -efhd_search_case_toggled(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - g_free(p->search_text); - p->search_text = NULL; - efhd_search_response(w, efhd); -} - -static gboolean -efhd_key_pressed (GtkWidget *w, GdkEventKey *event, EMFormatHTMLDisplay *efhd) -{ - if (event->keyval == GDK_Escape){ - efhd_search_destroy (w, efhd); - return TRUE; - } - return FALSE; -} - -static void -clear_button_clicked_cb (GtkWidget *widget, gpointer dummy, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - gtk_entry_set_text (GTK_ENTRY (p->search_entry), ""); - - g_signal_emit_by_name (p->search_entry, "activate", efhd); -} - -/* Controlls the visibility of icon_entry's visibility */ -static void -icon_entry_changed_cb (GtkWidget *widget, GtkWidget *clear_button) -{ - const char *text = gtk_entry_get_text (GTK_ENTRY (widget)); - - if (text && *text) - gtk_widget_show (clear_button); - else - gtk_widget_hide (clear_button); -} - -GtkWidget * -em_format_html_get_search_dialog (EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GtkWidget *hbox2, *button3, *button2, *label1; - GtkWidget *icon_entry, *clear_button; - - p->search_entry_box = gtk_hbox_new (FALSE, 0); - - label1 = gtk_label_new_with_mnemonic (_("Fin_d:")); - gtk_widget_show (label1); - gtk_box_pack_start ((GtkBox *)(p->search_entry_box), label1, FALSE, FALSE, 5); - - /* Icon entry */ - icon_entry = e_icon_entry_new (); - p->search_entry = e_icon_entry_get_entry (E_ICON_ENTRY (icon_entry)); - gtk_label_set_mnemonic_widget (GTK_LABEL (label1), p->search_entry); - gtk_widget_show (p->search_entry); -#if 0 /* KILL-BONOBO */ - clear_button = e_icon_entry_create_button ("gtk-clear"); - e_icon_entry_pack_widget (E_ICON_ENTRY (icon_entry), clear_button, FALSE); -#endif - gtk_widget_show_all (icon_entry); - gtk_widget_hide (clear_button); - - g_signal_connect (G_OBJECT (clear_button), "button-press-event", (GCallback) clear_button_clicked_cb, efhd); - g_signal_connect (G_OBJECT (p->search_entry), "changed", (GCallback) icon_entry_changed_cb, clear_button); - - gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, FALSE, FALSE, 0); -// gtk_box_pack_start ((GtkBox *)(p->search_entry_box), icon_entry, TRUE, TRUE, 0); - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, FALSE, FALSE, 5); -// gtk_box_pack_start ((GtkBox *)(hbox2), p->search_entry_box, TRUE, TRUE, 5); - - button3 = gtk_button_new_with_mnemonic (_("_Previous")); - gtk_button_set_image (GTK_BUTTON (button3), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_GO_BACK, GTK_ICON_SIZE_BUTTON))); - gtk_widget_show (button3); - gtk_box_pack_start (GTK_BOX (hbox2), button3, FALSE, FALSE, 5); - - button2 = gtk_button_new_with_mnemonic (_("_Next")); - gtk_button_set_image (GTK_BUTTON (button2), gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON)); - gtk_widget_show (button2); - gtk_box_pack_start (GTK_BOX (hbox2), button2, FALSE, FALSE, 5); - - p->search_case_check = gtk_check_button_new_with_mnemonic (_("M_atch case")); - gtk_widget_show (p->search_case_check); - gtk_box_pack_start (GTK_BOX (hbox2), p->search_case_check, FALSE, FALSE, 0); - - p->search_matches_label = gtk_label_new (""); - gtk_widget_show (p->search_matches_label); - gtk_box_pack_start (GTK_BOX (hbox2), p->search_matches_label, TRUE, TRUE, 0); - p->search_dialog = GTK_HBOX (hbox2); - - p->search_wrap = FALSE; - - g_signal_connect (p->search_entry, "activate", G_CALLBACK(efhd_search_response), efhd); - g_signal_connect (p->search_entry, "key-press-event", G_CALLBACK(efhd_key_pressed), efhd); - g_signal_connect (p->search_case_check, "toggled", G_CALLBACK(efhd_search_case_toggled), efhd); - g_signal_connect (button2, "clicked", G_CALLBACK(efhd_search_response), efhd); - g_signal_connect (button3, "clicked", G_CALLBACK(efhd_search_response_back), efhd); - - p->search_active = FALSE; - - efhd_update_matches(efhd); - - return (GtkWidget *)p->search_dialog; - -} - -static void -set_focus_cb (GtkWidget *window, GtkWidget *widget, EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - GtkWidget *sbar = GTK_WIDGET (p->search_dialog); - - while (widget != NULL && widget != sbar) { - widget = widget->parent; - } - - if (widget != sbar) - efhd_search_destroy(widget, efhd); -} - -/** - * em_format_html_display_search: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search(EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - GtkWidget *toplevel; - - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - gtk_widget_grab_focus (p->search_entry); - gtk_widget_show (p->search_entry_box); - - p->search_active = TRUE; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (p->search_dialog)); - - g_signal_connect (toplevel, "set-focus", - G_CALLBACK (set_focus_cb), efhd); - } - -} -/** - * em_format_html_display_search_with: - * @efhd: - * - * Run an interactive search dialogue. - **/ -void -em_format_html_display_search_with (EMFormatHTMLDisplay *efhd, char *word) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog){ - gtk_widget_show (GTK_WIDGET (p->search_dialog)); - p->search_active = TRUE; - - /* Set the query */ - gtk_entry_set_text (GTK_ENTRY (p->search_entry), word); - gtk_widget_hide (p->search_entry_box); - - /* Trigger the search */ - g_signal_emit_by_name (p->search_entry, "activate", efhd); - } -} - -void -em_format_html_display_search_close (EMFormatHTMLDisplay *efhd) -{ - struct _EMFormatHTMLDisplayPrivate *p = efhd->priv; - - if (p->search_dialog && p->search_active) - efhd_search_destroy(GTK_WIDGET (p->search_dialog), efhd); -} - void em_format_html_display_cut (EMFormatHTMLDisplay *efhd) { @@ -1115,9 +785,6 @@ efhd_complete(EMFormat *emf) { EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)emf; - if (efhd->priv->search_dialog && efhd->priv->search_active) - efhd_update_matches(efhd); - if (efhd->priv->files) { g_hash_table_destroy (efhd->priv->files); efhd->priv->files = NULL; -- cgit v1.2.3 From f963cc39a7d21f64f578dae50fd08c44181a3bf6 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 9 Mar 2009 03:31:24 +0000 Subject: Cleaning up the attachment bar, centralizing its popup menu, and converting everything to GtkUIManager/GtkActions. Saving progress mid-stream... not sure about the MIME part utilities yet. Also, add some EActivity subclasses. Considering an EFileActivity subclass for asynchronous GIO operations (loading/saving attachments, etc.), but still ironing out details. svn path=/branches/kill-bonobo/; revision=37389 --- mail/em-format-html-display.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 6710abeb98..59f63adc6c 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1331,7 +1331,7 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje if (!file) { file = "attachment.dat"; - new->file_name = g_strdup(file); + e_attachment_set_filename (new, file); } tmp = g_hash_table_lookup (efhd->priv->files, file); @@ -1349,8 +1349,8 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje g_free (tmp_file); g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(count)); - g_free (new->file_name); - new->file_name = new_file; + e_attachment_set_filename (new, new_file); + g_free (new_file); } else { g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1)); } @@ -1562,8 +1562,13 @@ efhd_bar_save_selected(EPopup *ep, EPopupItem *item, void *data) attachment_parts = e_attachment_bar_get_selected(E_ATTACHMENT_BAR(widget)); - for (tmp = attachment_parts; tmp; tmp=tmp->next) - parts = g_slist_prepend(parts, ((EAttachment *)tmp->data)->body); + for (tmp = attachment_parts; tmp; tmp=tmp->next) { + EAttachment *attachment = tmp->data; + CamelMimePart *mime_part; + + mime_part = e_attachment_get_mime_part (attachment); + parts = g_slist_prepend (parts, mime_part); + } parts = g_slist_reverse(parts); em_utils_save_parts(parent, _("Select folder to save selected attachments..."), parts); @@ -1721,7 +1726,7 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobjec GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image, *save, *scroll; int width, height, bar_width; - priv->attachment_bar = e_attachment_bar_new(NULL); + priv->attachment_bar = e_attachment_bar_new (); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); ((EAttachmentBar *)priv->attachment_bar)->expand = TRUE; -- cgit v1.2.3 From 4cec9fc7169dc3b810321555a70cda916720867d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 20 Mar 2009 19:06:59 +0000 Subject: Saving progress on a massive attachment handling rewrite. svn path=/branches/kill-bonobo/; revision=37465 --- mail/em-format-html-display.c | 136 ++++++++++++------------------------------ 1 file changed, 37 insertions(+), 99 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 59f63adc6c..242dcdceb8 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -79,8 +79,8 @@ #include "em-icon-stream.h" #include "em-utils.h" #include "em-popup.h" -#include "e-attachment.h" -#include "e-attachment-bar.h" +#include "widgets/misc/e-attachment-view.h" +#include "widgets/misc/e-attachment-icon-view.h" #ifdef G_OS_WIN32 /* Undefine the similar macro from ,it doesn't check if @@ -100,7 +100,7 @@ struct _EMFormatHTMLDisplayPrivate { /* for Attachment bar */ - GtkWidget *attachment_bar; + GtkWidget *attachment_view; GtkWidget *attachment_box; GtkWidget *label; GtkWidget *save_txt; @@ -494,8 +494,8 @@ efhd_format_attachment (EMFormat *emf, info->shown = em_format_is_inline ( emf, info->puri.part_id, info->puri.part, handle); info->snoop_mime_type = emf->snoop_mime_type; - info->attachment = e_attachment_new_from_mime_part (info->puri.part); - e_attachment_bar_create_attachment_cache (info->attachment); + info->attachment = e_attachment_new (); + e_attachment_set_mime_part (info->attachment, info->puri.part); if (emf->valid) { info->sign = emf->valid->sign.status; @@ -559,7 +559,8 @@ efhd_format_optional (EMFormat *emf, info->handle = em_format_find_handler (emf, "text/plain"); info->shown = FALSE; info->snoop_mime_type = "text/plain"; - info->attachment = e_attachment_new_from_mime_part (info->puri.part); + info->attachment = e_attachment_new (); + e_attachment_set_mime_part (info->attachment, info->puri.part); info->mstream = (CamelStreamMem *) mstream; if (emf->valid) { info->sign = emf->valid->sign.status; @@ -736,12 +737,6 @@ em_format_html_display_new (void) return g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL); } -EAttachmentBar * -em_format_html_display_get_bar (EMFormatHTMLDisplay *efhd) -{ - return E_ATTACHMENT_BAR (efhd->priv->attachment_bar); -} - void em_format_html_display_cut (EMFormatHTMLDisplay *efhd) { @@ -1302,6 +1297,7 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec static gboolean efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) { +#if 0 /* KILL-BONOBO !! FIXME !! */ EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; EAttachment *new; struct _attach_puri *info; @@ -1324,7 +1320,10 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje return TRUE; } - if (efhd->priv->attachment_bar) { + if (efhd->priv->attachment_view) { + EAttachmentView *view; + EAttachmentStore *store; + file = camel_mime_part_get_filename(info->puri.part); new = info->attachment; @@ -1457,6 +1456,7 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje gtk_widget_hide(info->down); gtk_container_add((GtkContainer *)eb, mainbox); +#endif return TRUE; } @@ -1500,6 +1500,7 @@ attachment_bar_arrow_clicked(GtkWidget *w, EMFormatHTMLDisplay *efhd) static void attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd) { +#if 0 /* KILL-BONOBO */ GSList *attachment_parts; guint n_attachment_parts; gpointer parent; @@ -1522,31 +1523,10 @@ attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd) attachment_parts); g_slist_free (attachment_parts); +#endif } -static void -efhd_bar_popup_position(GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data) -{ - EAttachmentBar *bar = user_data; - GnomeIconList *icon_list = user_data; - GList *selection; - GnomeCanvasPixbuf *image; - - gdk_window_get_origin (((GtkWidget*) bar)->window, x, y); - - selection = gnome_icon_list_get_selection (icon_list); - if (selection == NULL) - return; - - image = gnome_icon_list_get_icon_pixbuf_item (icon_list, GPOINTER_TO_INT(selection->data)); - if (image == NULL) - return; - - /* Put menu to the center of icon. */ - *x += (int)(image->item.x1 + image->item.x2) / 2; - *y += (int)(image->item.y1 + image->item.y2) / 2; -} - +#if 0 /* KILL-BONOBO -- Move this to EAttachmentView */ static void efhd_bar_save_selected(EPopup *ep, EPopupItem *item, void *data) { @@ -1582,68 +1562,24 @@ static EPopupItem efhd_bar_menu_items[] = { { E_POPUP_BAR, "05.display", }, { E_POPUP_ITEM, "05.display.01", N_("_Save Selected..."), efhd_bar_save_selected, NULL, NULL, EM_POPUP_ATTACHMENTS_MULTIPLE}, }; - -static gboolean -efhd_bar_button_press_event(EAttachmentBar *bar, GdkEventButton *event, EMFormat *emf) -{ - GtkMenu *menu; - GSList *list=NULL; - EPopupTarget *target; - EMPopup *emp; - GSList *menus = NULL; - int i; - - if (event && event->button != 3) - return FALSE; - - /** @HookPoint-EMPopup: Attachment Bar Context Menu - * @Id: org.gnome.evolution.mail.attachments.popup - * @Class: org.gnome.evolution.mail.popup:1.0 - * @Target: EMPopupTargetPart - * - * This is the drop-down menu shown when a user clicks on the attachment bar - * when attachments are selected. - */ - emp = em_popup_new("org.gnome.evolution.mail.attachments.popup"); - - /* Add something like save-selected, foward selected attachments in a mail etc....*/ - list = e_attachment_bar_get_selected(bar); - - /* Lets not propagate any more the r-click which is intended to us*/ - if ( g_slist_length (list) == 0) - return TRUE; - - target = (EPopupTarget *)em_popup_target_new_attachments(emp, list); - for (i=0; i<2; i++) - menus = g_slist_prepend(menus, &efhd_bar_menu_items[i]); - e_popup_add_items((EPopup *)emp, menus, NULL, efhd_menu_items_free, emf); - - ((EMPopupTargetPart *)target)->target.widget = (GtkWidget *)bar; - menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)target, 0); - if (event) - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time); - else - gtk_menu_popup(menu, NULL, NULL, (GtkMenuPositionFunc)efhd_bar_popup_position, bar, 0, gtk_get_current_event_time()); - - return TRUE; -} - -static gboolean -efhd_bar_popup_menu_event (EAttachmentBar *bar, EMFormat *emf) -{ - return efhd_bar_button_press_event(bar, NULL, emf); -} +#endif static void efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd) { - int nattachments; + EAttachmentStore *store; + EAttachmentView *view; + guint nattachments; - if (!efhd->priv->attachment_bar) + if (!efhd->priv->attachment_view) return; - nattachments = e_attachment_bar_get_num_attachments (E_ATTACHMENT_BAR(efhd->priv->attachment_bar)); - if (nattachments) { + view = E_ATTACHMENT_VIEW (efhd->priv->attachment_view); + store = e_attachment_view_get_store (view); + + nattachments = e_attachment_store_get_num_attachments (store); + + if (nattachments > 0) { char *txt; /* Cant i put in the number of attachments here ?*/ @@ -1673,6 +1609,7 @@ efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd) static void efhd_bar_resize(GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh) { +#if 0 /* KILL-BONOBO -- Does EAttachmentIconView need a resize method? */ int width; GtkRequisition req; EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh; @@ -1683,17 +1620,20 @@ efhd_bar_resize(GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh) /* Update the width of the bar when the width is greater than 1*/ if (width > 0) e_attachment_bar_set_width(E_ATTACHMENT_BAR(efhd->priv->attachment_bar), width); +#endif } static gboolean efhd_bar_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay *efhd) { +#if 0 /* KILL-BONOBO -- Do we still need this for a GtkIconView? */ gboolean ret; /* Emulate the scroll over the attachment bar, as if it is scrolled in the window. * It doesnt go automatically since the GnomeIconList is a layout by itself */ g_signal_emit_by_name (gtk_widget_get_parent((GtkWidget *)efhd->parent.html), "scroll_event", event, &ret); +#endif return TRUE; } @@ -1709,11 +1649,13 @@ efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd) static gboolean efhd_update_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) { +#if 0 /* KILL-BONOBO -- Does EAttachmentIconView need a refresh method? */ EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; if (priv->attachment_bar) e_attachment_bar_refresh (E_ATTACHMENT_BAR (priv->attachment_bar)); +#endif return TRUE; } @@ -1726,10 +1668,9 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobjec GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image, *save, *scroll; int width, height, bar_width; - priv->attachment_bar = e_attachment_bar_new (); + priv->attachment_view = e_attachment_icon_view_new (); scroll = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - ((EAttachmentBar *)priv->attachment_bar)->expand = TRUE; priv->forward = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); priv->down = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); @@ -1759,14 +1700,14 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobjec priv->attachment_box = scroll; gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); - gtk_container_add ((GtkContainer *)priv->attachment_box, priv->attachment_bar); + gtk_container_add ((GtkContainer *)priv->attachment_box, priv->attachment_view); - gtk_widget_get_size_request(priv->attachment_bar, &width, &height); + gtk_widget_get_size_request(priv->attachment_view, &width, &height); /* FIXME: What if the text is more?. Should we reduce the text with appending ...? * or resize the bar? How to figure out that, it needs more space? */ bar_width = ((GtkWidget *)efh->html)->parent->allocation.width - /* FIXME */16; - gtk_widget_set_size_request (priv->attachment_bar, + gtk_widget_set_size_request (priv->attachment_view, bar_width > 0 ? bar_width : 0, 84 /* FIXME: Default show only one row, Dont hardcode size*/); @@ -1782,11 +1723,8 @@ efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobjec gtk_widget_hide_all (priv->attachment_area); g_signal_connect (priv->arrow, "clicked", G_CALLBACK(attachment_bar_arrow_clicked), efh); - g_signal_connect (priv->attachment_bar, "button_press_event", G_CALLBACK(efhd_bar_button_press_event), efhd); - g_signal_connect (priv->attachment_bar, "popup-menu", G_CALLBACK(efhd_bar_popup_menu_event), efhd); g_signal_connect (save, "clicked", G_CALLBACK(attachments_save_all_clicked), efh); g_signal_connect (eb, "size_allocate", G_CALLBACK (efhd_bar_resize), efh); - g_signal_connect (priv->attachment_bar, "scroll_event", G_CALLBACK(efhd_bar_scroll_event), efhd); return TRUE; } -- cgit v1.2.3 From 6e163b39c75dbba470d073b4f79a897aa6fb0e54 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 24 Mar 2009 02:05:26 +0000 Subject: Saving progress again on the attachment rewrite. svn path=/branches/kill-bonobo/; revision=37470 --- mail/em-format-html-display.c | 235 +++++++----------------------------------- 1 file changed, 36 insertions(+), 199 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 242dcdceb8..7ccdc07e63 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -75,12 +75,12 @@ #include "mail-config.h" #include "e-mail-display.h" +#include "e-mail-attachment-bar.h" #include "em-format-html-display.h" #include "em-icon-stream.h" #include "em-utils.h" #include "em-popup.h" #include "widgets/misc/e-attachment-view.h" -#include "widgets/misc/e-attachment-icon-view.h" #ifdef G_OS_WIN32 /* Undefine the similar macro from ,it doesn't check if @@ -100,8 +100,7 @@ struct _EMFormatHTMLDisplayPrivate { /* for Attachment bar */ - GtkWidget *attachment_view; - GtkWidget *attachment_box; + GtkWidget *attachment_bar; GtkWidget *label; GtkWidget *save_txt; GtkWidget *arrow; @@ -150,11 +149,9 @@ static const char *smime_sign_colour[5] = { static void efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri); static gboolean efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static void efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); -static void efhd_message_update_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); static void efhd_attachment_button_show (GtkWidget *w, void *data); static gboolean efhd_attachment_button (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static gboolean efhd_attachment_optional (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *object); -static void efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd); struct _attach_puri { EMFormatPURI puri; @@ -194,7 +191,6 @@ struct _attach_puri { static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info); static void efhd_complete(EMFormat *); -gboolean efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); @@ -481,6 +477,9 @@ efhd_format_attachment (EMFormat *emf, const gchar *mime_type, const EMFormatHandler *handle) { + EMFormatHTMLDisplay *efhd; + EAttachmentView *view; + EAttachmentStore *store; char *classid, *text, *html; struct _attach_puri *info; @@ -840,8 +839,6 @@ static EMFormatHandler type_builtin_table[] = { { "x-evolution/message/prefix", (EMFormatFunc)efhd_message_prefix }, { "x-evolution/message/post-header", (EMFormatFunc)efhd_message_add_bar }, - { "x-evolution/message/post-header-closure", (EMFormatFunc)efhd_message_update_bar }, - }; static void @@ -1297,7 +1294,6 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec static gboolean efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) { -#if 0 /* KILL-BONOBO !! FIXME !! */ EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; EAttachment *new; struct _attach_puri *info; @@ -1320,10 +1316,15 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje return TRUE; } - if (efhd->priv->attachment_view) { + if (efhd->priv->attachment_bar) { EAttachmentView *view; EAttachmentStore *store; + view = E_ATTACHMENT_VIEW (efhd->priv->attachment_bar); + store = e_attachment_view_get_store (view); + e_attachment_store_add_attachment (store, info->attachment); + +#if 0 /* KILL-BONOBO */ file = camel_mime_part_get_filename(info->puri.part); new = info->attachment; @@ -1353,16 +1354,10 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje } else { g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1)); } +#endif - /* Store the status of encryption / signature on the attachment for emblem display - * FIXME: May not work well always - */ - new->sign = info->sign; - new->encrypt = info->encrypt; - - /* Add the attachment to the bar.*/ - e_attachment_bar_add_attachment_silent (E_ATTACHMENT_BAR(efhd->priv->attachment_bar), new); - efhd_attachment_bar_refresh(efhd); + e_attachment_set_encrypted (info->attachment, info->encrypt); + e_attachment_set_signed (info->attachment, info->sign); } mainbox = gtk_hbox_new(FALSE, 0); @@ -1456,7 +1451,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje gtk_widget_hide(info->down); gtk_container_add((GtkContainer *)eb, mainbox); -#endif return TRUE; } @@ -1480,23 +1474,6 @@ efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) } } -static void -attachment_bar_arrow_clicked(GtkWidget *w, EMFormatHTMLDisplay *efhd) -{ - - efhd->priv->show_bar = !efhd->priv->show_bar; - - if (efhd->priv->show_bar) { - gtk_widget_show(efhd->priv->attachment_box); - gtk_widget_show(efhd->priv->down); - gtk_widget_hide(efhd->priv->forward); - } else { - gtk_widget_hide(efhd->priv->attachment_box); - gtk_widget_show(efhd->priv->forward); - gtk_widget_hide(efhd->priv->down); - } -} - static void attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd) { @@ -1565,184 +1542,44 @@ static EPopupItem efhd_bar_menu_items[] = { #endif static void -efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd) +efhd_bar_resize (EMFormatHTML *efh, + GtkAllocation *event) { - EAttachmentStore *store; - EAttachmentView *view; - guint nattachments; - - if (!efhd->priv->attachment_view) - return; - - view = E_ATTACHMENT_VIEW (efhd->priv->attachment_view); - store = e_attachment_view_get_store (view); - - nattachments = e_attachment_store_get_num_attachments (store); - - if (nattachments > 0) { - char *txt; + EMFormatHTMLDisplay *efhd; + GtkWidget *widget; + gint width; - /* Cant i put in the number of attachments here ?*/ - txt = g_strdup_printf(ngettext("%d at_tachment", "%d at_tachments", nattachments), nattachments); - gtk_label_set_text_with_mnemonic ((GtkLabel *)efhd->priv->label, txt); - g_free (txt); + efhd = EM_FORMAT_HTML_DISPLAY (efh); - /* Show the bar even when the first attachment is added */ - if (nattachments == 1) { - gtk_widget_show_all (efhd->priv->attachment_area); - gtk_label_set_text_with_mnemonic ((GtkLabel *)efhd->priv->save_txt, _("S_ave")); + widget = GTK_WIDGET (efh->html); + width = widget->allocation.width - 12; - if (efhd->priv->show_bar) { - gtk_widget_show(efhd->priv->down); - gtk_widget_hide(efhd->priv->forward); - } else { - gtk_widget_show(efhd->priv->forward); - gtk_widget_hide(efhd->priv->down); - gtk_widget_hide(efhd->priv->attachment_box); - } - } else if (nattachments > 1) { - gtk_label_set_text_with_mnemonic ((GtkLabel *)efhd->priv->save_txt, _("S_ave All")); - } + if (width > 0) { + widget = efhd->priv->attachment_bar; + gtk_widget_set_size_request (widget, width, -1); } } -static void -efhd_bar_resize(GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh) -{ -#if 0 /* KILL-BONOBO -- Does EAttachmentIconView need a resize method? */ - int width; - GtkRequisition req; - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh; - - gtk_widget_size_request (efhd->priv->attachment_bar, &req); - width = ((GtkWidget *) efh->html)->allocation.width - 16; - - /* Update the width of the bar when the width is greater than 1*/ - if (width > 0) - e_attachment_bar_set_width(E_ATTACHMENT_BAR(efhd->priv->attachment_bar), width); -#endif -} - static gboolean -efhd_bar_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay *efhd) -{ -#if 0 /* KILL-BONOBO -- Do we still need this for a GtkIconView? */ - gboolean ret; - - /* Emulate the scroll over the attachment bar, as if it is scrolled in the window. - * It doesnt go automatically since the GnomeIconList is a layout by itself - */ - g_signal_emit_by_name (gtk_widget_get_parent((GtkWidget *)efhd->parent.html), "scroll_event", event, &ret); -#endif - - return TRUE; -} - -gboolean -efhd_mnemonic_show_bar (GtkWidget *widget, gboolean focus, GtkWidget *efhd) -{ - attachment_bar_arrow_clicked (NULL, (EMFormatHTMLDisplay *)efhd); - - return TRUE; -} - -static gboolean -efhd_update_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) -{ -#if 0 /* KILL-BONOBO -- Does EAttachmentIconView need a refresh method? */ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; - struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; - - if (priv->attachment_bar) - e_attachment_bar_refresh (E_ATTACHMENT_BAR (priv->attachment_bar)); -#endif - - return TRUE; -} - -static gboolean -efhd_add_bar(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) +efhd_add_bar (EMFormatHTML *efh, + GtkHTMLEmbedded *eb, + EMFormatHTMLPObject *pobject) { EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; - GtkWidget *hbox1, *hbox2, *hbox3, *vbox, *txt, *image, *save, *scroll; - int width, height, bar_width; - - priv->attachment_view = e_attachment_icon_view_new (); - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - - priv->forward = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - priv->down = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE); - hbox3 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start ((GtkBox *)hbox3, priv->forward, FALSE, FALSE, 0); - gtk_box_pack_start ((GtkBox *)hbox3, priv->down, FALSE, FALSE, 0); - priv->arrow = (GtkWidget *)gtk_tool_button_new(hbox3, NULL); - g_signal_connect (priv->arrow, "mnemonic_activate", G_CALLBACK (efhd_mnemonic_show_bar), efh); - atk_object_set_name (gtk_widget_get_accessible (priv->arrow), _("Show Attachments")); - - priv->label = gtk_label_new(_("No Attachment")); - gtk_label_set_mnemonic_widget (GTK_LABEL (priv->label), priv->arrow); - save = gtk_button_new(); - image = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_BUTTON); - txt = gtk_label_new_with_mnemonic(_("S_ave")); - priv->save_txt = txt; - hbox1 = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start((GtkBox *)hbox1, image, FALSE, FALSE, 2); - gtk_box_pack_start((GtkBox *)hbox1, txt, FALSE, FALSE, 0); - - gtk_container_add((GtkContainer *)save, hbox1); - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start ((GtkBox *)hbox2, priv->arrow, FALSE, FALSE, 0); - gtk_box_pack_start ((GtkBox *)hbox2, priv->label, FALSE, FALSE, 2); - gtk_box_pack_start ((GtkBox *)hbox2, save, FALSE, FALSE, 2); - - priv->attachment_box = scroll; - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); - gtk_container_add ((GtkContainer *)priv->attachment_box, priv->attachment_view); - - gtk_widget_get_size_request(priv->attachment_view, &width, &height); - - /* FIXME: What if the text is more?. Should we reduce the text with appending ...? - * or resize the bar? How to figure out that, it needs more space? */ - bar_width = ((GtkWidget *)efh->html)->parent->allocation.width - /* FIXME */16; - gtk_widget_set_size_request (priv->attachment_view, - bar_width > 0 ? bar_width : 0, - 84 /* FIXME: Default show only one row, Dont hardcode size*/); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start ((GtkBox *)vbox, hbox2, FALSE, FALSE, 2); - gtk_box_pack_start ((GtkBox *)vbox, priv->attachment_box, TRUE, TRUE, 2); - - gtk_container_add ((GtkContainer *)eb, vbox); - gtk_widget_show ((GtkWidget *)eb); + GtkWidget *widget; - /* Lets hide it by default and show only when there are attachments */ - priv->attachment_area = vbox; - gtk_widget_hide_all (priv->attachment_area); + widget = e_mail_attachment_bar_new (); + gtk_container_add (GTK_CONTAINER (eb), widget); + priv->attachment_bar = g_object_ref (widget); + gtk_widget_show (widget); - g_signal_connect (priv->arrow, "clicked", G_CALLBACK(attachment_bar_arrow_clicked), efh); - g_signal_connect (save, "clicked", G_CALLBACK(attachments_save_all_clicked), efh); - g_signal_connect (eb, "size_allocate", G_CALLBACK (efhd_bar_resize), efh); + g_signal_connect_swapped ( + widget, "size-allocate", + G_CALLBACK (efhd_bar_resize), efh); return TRUE; } -static void -efhd_message_update_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; - const char *classid = "attachment-bar-refresh"; - - if (efhd->priv->updated) - return; - - efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - efhd->priv->updated = TRUE; - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_update_bar); - camel_stream_printf(stream, "", classid); - -} static void efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) -- cgit v1.2.3 From c05c973cff53769ef575bfc5257a2a414117b323 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 26 Mar 2009 04:48:21 +0000 Subject: Saving progress again on the attachment rewrite. svn path=/branches/kill-bonobo/; revision=37476 --- mail/em-format-html-display.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 7ccdc07e63..6020ce4845 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1319,10 +1319,17 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje if (efhd->priv->attachment_bar) { EAttachmentView *view; EAttachmentStore *store; + gpointer parent; + + parent = gtk_widget_get_toplevel (efhd->priv->attachment_bar); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; view = E_ATTACHMENT_VIEW (efhd->priv->attachment_bar); store = e_attachment_view_get_store (view); e_attachment_store_add_attachment (store, info->attachment); + e_attachment_load_async ( + info->attachment, (GAsyncReadyCallback) + e_attachment_load_handle_error, parent); #if 0 /* KILL-BONOBO */ file = camel_mime_part_get_filename(info->puri.part); -- cgit v1.2.3 From bc4f60ba176b64cc8fd8ffa47a01542f8eb25bdf Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 26 Mar 2009 19:33:16 +0000 Subject: Saving progress again on the attachment rewrite. svn path=/branches/kill-bonobo/; revision=37478 --- mail/em-format-html-display.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 6020ce4845..1bbe282394 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -477,9 +477,6 @@ efhd_format_attachment (EMFormat *emf, const gchar *mime_type, const EMFormatHandler *handle) { - EMFormatHTMLDisplay *efhd; - EAttachmentView *view; - EAttachmentStore *store; char *classid, *text, *html; struct _attach_puri *info; @@ -1295,11 +1292,9 @@ static gboolean efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) { EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; - EAttachment *new; struct _attach_puri *info; GtkWidget *hbox, *w, *button, *mainbox; - char *simple_type, *tmp, *new_file = NULL; - const char *file; + char *simple_type; GtkTargetEntry drag_types[] = { { NULL, 0, 0 }, { "text/uri-list", 0, 1 }, @@ -1321,7 +1316,7 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje EAttachmentStore *store; gpointer parent; - parent = gtk_widget_get_toplevel (efhd->priv->attachment_bar); + parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html)); parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; view = E_ATTACHMENT_VIEW (efhd->priv->attachment_bar); -- cgit v1.2.3 From 04cc4a2cb1bf87417f82d1094ddde611019c0ab8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 30 Mar 2009 22:26:35 +0000 Subject: Saving progress again on the attachment rewrite. svn path=/branches/kill-bonobo/; revision=37486 --- mail/em-format-html-display.c | 106 ++---------------------------------------- 1 file changed, 5 insertions(+), 101 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 1bbe282394..346efff92a 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1319,6 +1319,8 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html)); parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; + gtk_widget_show (efhd->priv->attachment_bar); + view = E_ATTACHMENT_VIEW (efhd->priv->attachment_bar); store = e_attachment_view_get_store (view); e_attachment_store_add_attachment (store, info->attachment); @@ -1326,38 +1328,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje info->attachment, (GAsyncReadyCallback) e_attachment_load_handle_error, parent); -#if 0 /* KILL-BONOBO */ - file = camel_mime_part_get_filename(info->puri.part); - - new = info->attachment; - - if (!file) { - file = "attachment.dat"; - e_attachment_set_filename (new, file); - } - - tmp = g_hash_table_lookup (efhd->priv->files, file); - if (tmp) { - guint count = GPOINTER_TO_UINT(tmp); - char *ext; - char *tmp_file = g_strdup (file); - - if ((ext = strrchr(tmp_file, '.'))) { - ext[0] = 0; - new_file = g_strdup_printf("%s(%d).%s", tmp_file, count++, ext+1); - } else { - new_file = g_strdup_printf("%s(%d)", tmp_file, count++); - } - - g_free (tmp_file); - g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(count)); - e_attachment_set_filename (new, new_file); - g_free (new_file); - } else { - g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1)); - } -#endif - e_attachment_set_encrypted (info->attachment, info->encrypt); e_attachment_set_signed (info->attachment, info->sign); } @@ -1476,73 +1446,6 @@ efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) } } -static void -attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd) -{ -#if 0 /* KILL-BONOBO */ - GSList *attachment_parts; - guint n_attachment_parts; - gpointer parent; - - attachment_parts = e_attachment_bar_get_parts ( - E_ATTACHMENT_BAR (efhd->priv->attachment_bar)); - n_attachment_parts = g_slist_length (attachment_parts); - g_return_if_fail (n_attachment_parts > 0); - - parent = gtk_widget_get_toplevel (widget); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - if (n_attachment_parts == 1) - em_utils_save_part ( - parent, _("Save attachment as"), - attachment_parts->data); - else - em_utils_save_parts ( - parent, _("Select folder to save all attachments"), - attachment_parts); - - g_slist_free (attachment_parts); -#endif -} - -#if 0 /* KILL-BONOBO -- Move this to EAttachmentView */ -static void -efhd_bar_save_selected(EPopup *ep, EPopupItem *item, void *data) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)data; - GSList *attachment_parts, *tmp; - GSList *parts = NULL; - GtkWidget *widget; - gpointer parent; - - widget = efhd->priv->attachment_bar; - parent = gtk_widget_get_toplevel (widget); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - - attachment_parts = e_attachment_bar_get_selected(E_ATTACHMENT_BAR(widget)); - - for (tmp = attachment_parts; tmp; tmp=tmp->next) { - EAttachment *attachment = tmp->data; - CamelMimePart *mime_part; - - mime_part = e_attachment_get_mime_part (attachment); - parts = g_slist_prepend (parts, mime_part); - } - - parts = g_slist_reverse(parts); - em_utils_save_parts(parent, _("Select folder to save selected attachments..."), parts); - g_slist_free (parts); - - g_slist_foreach(attachment_parts, (GFunc)g_object_unref, NULL); - g_slist_free (attachment_parts); -} - -static EPopupItem efhd_bar_menu_items[] = { - { E_POPUP_BAR, "05.display", }, - { E_POPUP_ITEM, "05.display.01", N_("_Save Selected..."), efhd_bar_save_selected, NULL, NULL, EM_POPUP_ATTACHMENTS_MULTIPLE}, -}; -#endif - static void efhd_bar_resize (EMFormatHTML *efh, GtkAllocation *event) @@ -1569,15 +1472,16 @@ efhd_add_bar (EMFormatHTML *efh, { EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; + GtkRequisition requisition; GtkWidget *widget; widget = e_mail_attachment_bar_new (); gtk_container_add (GTK_CONTAINER (eb), widget); priv->attachment_bar = g_object_ref (widget); - gtk_widget_show (widget); + gtk_widget_hide (widget); g_signal_connect_swapped ( - widget, "size-allocate", + eb, "size-allocate", G_CALLBACK (efhd_bar_resize), efh); return TRUE; -- cgit v1.2.3 From da68ab65008bff803a3ea7940fa861c7cb055d08 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 2 Apr 2009 21:12:13 +0000 Subject: Split the attachment button into a separate widget that integrates with EAttachmentView and EAttachmentStore. Clicking the button works, but I still have to finish the pop-up menu and drag-and-drop. Kill e-util/e-gui-utils.c: e_icon_for_mime_type() replaced by g_content_type_get_icon() svn path=/branches/kill-bonobo/; revision=37491 --- mail/em-format-html-display.c | 268 +++++++++++------------------------------- 1 file changed, 68 insertions(+), 200 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 346efff92a..5faa671fd8 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -63,7 +63,6 @@ #include #include -#include #include #include @@ -76,6 +75,7 @@ #include "e-mail-display.h" #include "e-mail-attachment-bar.h" +#include "e-mail-attachment-button.h" #include "em-format-html-display.h" #include "em-icon-stream.h" #include "em-utils.h" @@ -99,17 +99,7 @@ ((obj), EM_TYPE_FORMAT_HTML_DISPLAY, EMFormatHTMLDisplayPrivate)) struct _EMFormatHTMLDisplayPrivate { - /* for Attachment bar */ - GtkWidget *attachment_bar; - GtkWidget *label; - GtkWidget *save_txt; - GtkWidget *arrow; - GtkWidget *forward; - GtkWidget *down; - GtkWidget *attachment_area; - gboolean show_bar; - GHashTable *files; - gboolean updated; + GtkWidget *attachment_view; /* weak reference */ }; struct _smime_pobject { @@ -149,7 +139,6 @@ static const char *smime_sign_colour[5] = { static void efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri); static gboolean efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static void efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); -static void efhd_attachment_button_show (GtkWidget *w, void *data); static gboolean efhd_attachment_button (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static gboolean efhd_attachment_optional (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *object); @@ -164,7 +153,6 @@ struct _attach_puri { GtkWidget *forward, *down; /* currently no way to correlate this data to the frame :( */ GtkHTML *frame; - CamelStream *output; unsigned int shown:1; /* Embedded Frame */ @@ -190,11 +178,9 @@ struct _attach_puri { static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info); -static void efhd_complete(EMFormat *); - static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); -static EMFormatHTMLClass *parent_class; +static gpointer parent_class; static void efhd_xpkcs7mime_free (EMFormatHTMLPObject *o) @@ -433,20 +419,6 @@ efhd_xpkcs7mime_button (EMFormatHTML *efh, return TRUE; } -static void -efhd_finalize (GObject *object) -{ - EMFormatHTMLDisplayPrivate *priv; - - priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (object); - - if (priv->files != NULL) - g_hash_table_destroy (priv->files); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static void efhd_format_clone (EMFormat *emf, CamelFolder *folder, @@ -454,16 +426,8 @@ efhd_format_clone (EMFormat *emf, CamelMimeMessage *msg, EMFormat *src) { - EMFormatHTMLDisplayPrivate *priv; - - priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (emf); - - if (emf != src) { - priv->show_bar = (src != NULL) ? - EM_FORMAT_HTML_DISPLAY (src)->priv->show_bar : FALSE; - + if (emf != src) EM_FORMAT_HTML (emf)->header_wrap_flags = 0; - } /* Chain up to parent's format_clone() method. */ EM_FORMAT_CLASS (parent_class)-> @@ -656,22 +620,17 @@ efhd_format_secure (EMFormat *emf, static void efhd_class_init (EMFormatHTMLDisplayClass *class) { - GObjectClass *object_class; EMFormatClass *format_class; EMFormatHTMLClass *format_html_class; parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate)); - object_class = G_OBJECT_CLASS (class); - object_class->finalize = efhd_finalize; - format_class = EM_FORMAT_CLASS (class); format_class->format_clone = efhd_format_clone; format_class->format_attachment = efhd_format_attachment; format_class->format_optional = efhd_format_optional; format_class->format_secure = efhd_format_secure; - format_class->complete = efhd_complete; format_html_class = EM_FORMAT_HTML_CLASS (class); format_html_class->html_widget_type = E_TYPE_MAIL_DISPLAY; @@ -695,9 +654,6 @@ efhd_init (EMFormatHTMLDisplay *efhd) EM_FORMAT_HTML (efhd)->text_html_flags |= CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS | CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES; - - efhd->priv->show_bar = FALSE; - efhd->priv->files = NULL; } GType @@ -733,55 +689,6 @@ em_format_html_display_new (void) return g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL); } -void -em_format_html_display_cut (EMFormatHTMLDisplay *efhd) -{ - gtk_html_cut (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_copy (EMFormatHTMLDisplay *efhd) -{ - gtk_html_copy (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_paste (EMFormatHTMLDisplay *efhd) -{ - gtk_html_paste (((EMFormatHTML *) efhd)->html, FALSE); -} - -void -em_format_html_display_zoom_in (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_in (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_zoom_out (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_out (((EMFormatHTML *) efhd)->html); -} - -void -em_format_html_display_zoom_reset (EMFormatHTMLDisplay *efhd) -{ - gtk_html_zoom_reset (((EMFormatHTML *) efhd)->html); -} - -/* ********************************************************************** */ - -static void -efhd_complete(EMFormat *emf) -{ - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)emf; - - if (efhd->priv->files) { - g_hash_table_destroy (efhd->priv->files); - efhd->priv->files = NULL; - } -} - /* ********************************************************************** */ static void @@ -948,12 +855,13 @@ efhd_attachment_show(EPopup *ep, EPopupItem *item, void *data) } static void -efhd_attachment_button_show(GtkWidget *w, void *data) +efhd_attachment_button_clicked (GtkWidget *widget, + struct _attach_puri *info) { - if (!efhd_can_process_attachment (w)) + if (!efhd_can_process_attachment (widget)) return; - efhd_attachment_show(NULL, NULL, data); + efhd_attachment_show (NULL, NULL, info); } static void @@ -1301,6 +1209,12 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje }; AtkObject *a11y; + EAttachmentView *view; + EAttachmentStore *store; + EAttachment *attachment; + GtkWidget *widget; + gpointer parent; + /* FIXME: handle default shown case */ d(printf("adding attachment button/content\n")); @@ -1311,60 +1225,40 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje return TRUE; } - if (efhd->priv->attachment_bar) { - EAttachmentView *view; - EAttachmentStore *store; - gpointer parent; + attachment = info->attachment; + e_attachment_set_signed (attachment, info->sign); + e_attachment_set_encrypted (attachment, info->encrypt); - parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html)); - parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; + parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html)); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - gtk_widget_show (efhd->priv->attachment_bar); + view = E_ATTACHMENT_VIEW (efhd->priv->attachment_view); + gtk_widget_show (efhd->priv->attachment_view); - view = E_ATTACHMENT_VIEW (efhd->priv->attachment_bar); - store = e_attachment_view_get_store (view); - e_attachment_store_add_attachment (store, info->attachment); - e_attachment_load_async ( - info->attachment, (GAsyncReadyCallback) - e_attachment_load_handle_error, parent); + store = e_attachment_view_get_store (view); + e_attachment_store_add_attachment (store, info->attachment); - e_attachment_set_encrypted (info->attachment, info->encrypt); - e_attachment_set_signed (info->attachment, info->sign); - } - - mainbox = gtk_hbox_new(FALSE, 0); + e_attachment_load_async ( + info->attachment, (GAsyncReadyCallback) + e_attachment_load_handle_error, parent); - button = gtk_button_new(); - - if (info->handle) { - g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_button_show), info); - g_object_set_data (G_OBJECT (button), "efh", efh); - } else { - gtk_widget_set_sensitive(button, FALSE); - GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); - } - - hbox = gtk_hbox_new(FALSE, 2); - info->forward = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_BUTTON); - gtk_box_pack_start((GtkBox *)hbox, info->forward, TRUE, TRUE, 0); - if (info->handle) { - info->down = gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON); - gtk_box_pack_start((GtkBox *)hbox, info->down, TRUE, TRUE, 0); - } + widget = e_mail_attachment_button_new (view); + e_mail_attachment_button_set_attachment ( + E_MAIL_ATTACHMENT_BUTTON (widget), attachment); + e_mail_attachment_button_set_expandable ( + E_MAIL_ATTACHMENT_BUTTON (widget), (info->handle != NULL)); + e_mail_attachment_button_set_expanded ( + E_MAIL_ATTACHMENT_BUTTON (widget), info->shown); + gtk_container_add (GTK_CONTAINER (eb), widget); + gtk_widget_show (widget); - w = gtk_image_new(); - gtk_widget_set_size_request(w, 24, 24); - gtk_box_pack_start((GtkBox *)hbox, w, TRUE, TRUE, 0); - gtk_container_add((GtkContainer *)button, hbox); - gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0); + g_object_set_data (G_OBJECT (widget), "efh", efh); - /* Check for snooped type to get the right icon/processing */ - if (info->snoop_mime_type) - simple_type = g_strdup(info->snoop_mime_type); - else - simple_type = camel_content_type_simple (((CamelDataWrapper *)pobject->part)->mime_type); - camel_strdown(simple_type); + g_signal_connect ( + widget, "clicked", + G_CALLBACK (efhd_attachment_button_clicked), info); +#if 0 /* FIXME: offline parts, just get icon */ if (camel_content_type_is(((CamelDataWrapper *)pobject->part)->mime_type, "image", "*")) { EMFormatHTMLJob *job; @@ -1383,16 +1277,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje job->stream = (CamelStream *)em_icon_stream_new((GtkImage *)w, key, 24, 24, FALSE); em_format_html_job_queue(efh, job); } - } else { - GdkPixbuf *pixbuf, *mini; - - if ((pixbuf = e_icon_for_mime_type (simple_type, 24))) { - if ((mini = e_icon_factory_pixbuf_scale (pixbuf, 24, 24))) { - gtk_image_set_from_pixbuf ((GtkImage *) w, mini); - g_object_unref (mini); - } - g_object_unref (pixbuf); - } } drag_types[0].target = simple_type; @@ -1401,28 +1285,11 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje g_signal_connect (button, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject); g_free(simple_type); - button = gtk_button_new(); - /*GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);*/ - gtk_container_add((GtkContainer *)button, gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE)); - - a11y = gtk_widget_get_accessible (button); - atk_object_set_name (a11y, _("Attachment")); - g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0); - - g_object_set_data (G_OBJECT (button), "efh", efh); - - gtk_widget_show_all(mainbox); - - if (info->shown) - gtk_widget_hide(info->forward); - else if (info->down) - gtk_widget_hide(info->down); - - gtk_container_add((GtkContainer *)eb, mainbox); +#endif return TRUE; } @@ -1430,37 +1297,34 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje /* not used currently */ /* frame source callback */ static void -efhd_attachment_frame(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +efhd_attachment_frame (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri) { struct _attach_puri *info = (struct _attach_puri *)puri; - if (info->shown) { - d(printf("writing to frame content, handler is '%s'\n", info->handle->mime_type)); - info->handle->handler(emf, stream, info->puri.part, info->handle); - camel_stream_close(stream); - } else { - /* FIXME: this is leaked if the object is closed without showing it - NB: need a virtual puri_free method? */ - info->output = stream; - camel_object_ref(stream); - } + if (info->shown) + info->handle->handler ( + emf, stream, info->puri.part, info->handle); + + camel_stream_close (stream); } static void efhd_bar_resize (EMFormatHTML *efh, GtkAllocation *event) { - EMFormatHTMLDisplay *efhd; + EMFormatHTMLDisplayPrivate *priv; GtkWidget *widget; gint width; - efhd = EM_FORMAT_HTML_DISPLAY (efh); + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efh); widget = GTK_WIDGET (efh->html); width = widget->allocation.width - 12; if (width > 0) { - widget = efhd->priv->attachment_bar; + widget = priv->attachment_view; gtk_widget_set_size_request (widget, width, -1); } } @@ -1470,14 +1334,14 @@ efhd_add_bar (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject) { - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; - struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv; - GtkRequisition requisition; + EMFormatHTMLDisplayPrivate *priv; GtkWidget *widget; + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efh); + widget = e_mail_attachment_bar_new (); gtk_container_add (GTK_CONTAINER (eb), widget); - priv->attachment_bar = g_object_ref (widget); + priv->attachment_view = widget; gtk_widget_hide (widget); g_signal_connect_swapped ( @@ -1488,19 +1352,23 @@ efhd_add_bar (EMFormatHTML *efh, } static void -efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +efhd_message_add_bar (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info) { - EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) emf; + EMFormatHTMLDisplayPrivate *priv; const char *classid = "attachment-bar"; - if (efhd->priv->files) - return; + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (emf); - efhd->priv->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - efhd->priv->updated = FALSE; + em_format_html_add_pobject ( + EM_FORMAT_HTML (emf), + sizeof (EMFormatHTMLPObject), + classid, part, efhd_add_bar); - em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_add_bar); - camel_stream_printf(stream, "", classid); + camel_stream_printf ( + stream, "", classid); } static void -- cgit v1.2.3 From a843a2a4d205ef45d8a5670cf0b17c238cee1f37 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 7 Apr 2009 21:40:49 +0000 Subject: Attachment rewrite pretty much complete. Just testing now. svn path=/branches/kill-bonobo/; revision=37504 --- mail/em-format-html-display.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 5faa671fd8..de965135c8 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -75,11 +75,11 @@ #include "e-mail-display.h" #include "e-mail-attachment-bar.h" -#include "e-mail-attachment-button.h" #include "em-format-html-display.h" #include "em-icon-stream.h" #include "em-utils.h" #include "em-popup.h" +#include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" #ifdef G_OS_WIN32 @@ -855,8 +855,9 @@ efhd_attachment_show(EPopup *ep, EPopupItem *item, void *data) } static void -efhd_attachment_button_clicked (GtkWidget *widget, - struct _attach_puri *info) +efhd_attachment_button_expanded (GtkWidget *widget, + GParamSpec *pspec, + struct _attach_puri *info) { if (!efhd_can_process_attachment (widget)) return; @@ -1242,21 +1243,21 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje info->attachment, (GAsyncReadyCallback) e_attachment_load_handle_error, parent); - widget = e_mail_attachment_button_new (view); - e_mail_attachment_button_set_attachment ( - E_MAIL_ATTACHMENT_BUTTON (widget), attachment); - e_mail_attachment_button_set_expandable ( - E_MAIL_ATTACHMENT_BUTTON (widget), (info->handle != NULL)); - e_mail_attachment_button_set_expanded ( - E_MAIL_ATTACHMENT_BUTTON (widget), info->shown); + widget = e_attachment_button_new (view); + e_attachment_button_set_attachment ( + E_ATTACHMENT_BUTTON (widget), attachment); + e_attachment_button_set_expandable ( + E_ATTACHMENT_BUTTON (widget), (info->handle != NULL)); + e_attachment_button_set_expanded ( + E_ATTACHMENT_BUTTON (widget), info->shown); gtk_container_add (GTK_CONTAINER (eb), widget); gtk_widget_show (widget); g_object_set_data (G_OBJECT (widget), "efh", efh); g_signal_connect ( - widget, "clicked", - G_CALLBACK (efhd_attachment_button_clicked), info); + widget, "notify::expanded", + G_CALLBACK (efhd_attachment_button_expanded), info); #if 0 /* FIXME: offline parts, just get icon */ @@ -1294,8 +1295,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje return TRUE; } -/* not used currently */ -/* frame source callback */ static void efhd_attachment_frame (EMFormat *emf, CamelStream *stream, -- cgit v1.2.3 From 1509a85170184895f6c91f9c57167a74af5cd2db Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 10 Apr 2009 11:05:55 +0000 Subject: Convert "import-ics-attachments" plugin to an EAttachmentHandler subclass. svn path=/branches/kill-bonobo/; revision=37510 --- mail/em-format-html-display.c | 46 +------------------------------------------ 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index de965135c8..d413133c3d 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -462,7 +462,7 @@ efhd_format_attachment (EMFormat *emf, info->encrypt = emf->valid->encrypt.status; } - camel_stream_write_string( + camel_stream_write_string ( stream, EM_FORMAT_HTML_VPAD "
" "" @@ -1202,14 +1202,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje { EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh; struct _attach_puri *info; - GtkWidget *hbox, *w, *button, *mainbox; - char *simple_type; - GtkTargetEntry drag_types[] = { - { NULL, 0, 0 }, - { "text/uri-list", 0, 1 }, - }; - AtkObject *a11y; - EAttachmentView *view; EAttachmentStore *store; EAttachment *attachment; @@ -1259,39 +1251,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje widget, "notify::expanded", G_CALLBACK (efhd_attachment_button_expanded), info); -#if 0 - /* FIXME: offline parts, just get icon */ - if (camel_content_type_is(((CamelDataWrapper *)pobject->part)->mime_type, "image", "*")) { - EMFormatHTMLJob *job; - GdkPixbuf *mini; - char *key; - - key = pobject->classid; - mini = em_icon_stream_get_image(key, 24, 24); - if (mini) { - d(printf("got image from cache '%s'\n", key)); - gtk_image_set_from_pixbuf((GtkImage *)w, mini); - g_object_unref(mini); - } else { - d(printf("need to create icon image '%s'\n", key)); - job = em_format_html_job_new(efh, efhd_write_icon_job, pobject); - job->stream = (CamelStream *)em_icon_stream_new((GtkImage *)w, key, 24, 24, FALSE); - em_format_html_job_queue(efh, job); - } - } - - drag_types[0].target = simple_type; - gtk_drag_source_set(button, GDK_BUTTON1_MASK, drag_types, sizeof(drag_types)/sizeof(drag_types[0]), GDK_ACTION_COPY); - g_signal_connect(button, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject); - g_signal_connect (button, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject); - g_free(simple_type); - - g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); - g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); - g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); - gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0); -#endif - return TRUE; } @@ -1356,11 +1315,8 @@ efhd_message_add_bar (EMFormat *emf, CamelMimePart *part, const EMFormatHandler *info) { - EMFormatHTMLDisplayPrivate *priv; const char *classid = "attachment-bar"; - priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (emf); - em_format_html_add_pobject ( EM_FORMAT_HTML (emf), sizeof (EMFormatHTMLPObject), -- cgit v1.2.3 From ca691310d85f7a266d070cb004d3534215ac47d0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 15 Apr 2009 00:15:46 +0000 Subject: Add "View Inline" / "Hide" menu items to the popup menu. Add application icons to the "Open With" menu items. svn path=/branches/kill-bonobo/; revision=37524 --- mail/em-format-html-display.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d413133c3d..6faa6ae803 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1219,8 +1219,10 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje } attachment = info->attachment; + e_attachment_set_shown (attachment, info->shown); e_attachment_set_signed (attachment, info->sign); e_attachment_set_encrypted (attachment, info->encrypt); + e_attachment_set_can_show (attachment, info->handle != NULL); parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html)); parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; @@ -1238,10 +1240,6 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje widget = e_attachment_button_new (view); e_attachment_button_set_attachment ( E_ATTACHMENT_BUTTON (widget), attachment); - e_attachment_button_set_expandable ( - E_ATTACHMENT_BUTTON (widget), (info->handle != NULL)); - e_attachment_button_set_expanded ( - E_ATTACHMENT_BUTTON (widget), info->shown); gtk_container_add (GTK_CONTAINER (eb), widget); gtk_widget_show (widget); -- cgit v1.2.3 From 2393a5d17e92435cb3d7726b04ff6f4a5c27c8db Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 24 May 2009 11:54:43 -0400 Subject: Eliminate redundant E_ICON_SIZE_* enumeration. --- mail/em-format-html-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 6faa6ae803..1cc7d43175 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -783,7 +783,7 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF camel_stream_printf(stream, "
"); comp = camel_folder_get_message_user_tag(emf->folder, emf->uid, "completed-on"); - iconpath = e_icon_factory_get_icon_filename (comp && comp[0] ? "stock_flag-for-followup-done" : "stock_flag-for-followup", E_ICON_SIZE_MENU); + iconpath = e_icon_factory_get_icon_filename (comp && comp[0] ? "stock_flag-for-followup-done" : "stock_flag-for-followup", GTK_ICON_SIZE_MENU); if (iconpath) { CamelMimePart *iconpart; -- cgit v1.2.3 From e4afd3f9fb962ea1295a0657ec9f83a427829171 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 26 May 2009 23:21:02 -0400 Subject: Remove trailing whitespace, again. --- mail/em-format-html-display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 8863bf7f08..8d25923658 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -10,7 +10,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see + * License along with the program; if not, see * * * Authors: @@ -186,13 +186,13 @@ efhd_gtkhtml_realise(GtkHTML *html, EMFormatHTMLDisplay *efhd) r = style->fg[state].red >> 8; g = style->fg[state].green >> 8; - b = style->fg[state].blue >> 8; + b = style->fg[state].blue >> 8; efhd->formathtml.header_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; r = style->bg[state].red >> 8; g = style->bg[state].green >> 8; - b = style->bg[state].blue >> 8; + b = style->bg[state].blue >> 8; efhd->formathtml.body_colour = ((r<<16) | (g<< 8) | b) & 0xffffff; -- cgit v1.2.3 From 948235c3d1076dbe6ed2e57a24c16a083bbd9f01 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 27 May 2009 10:29:19 -0400 Subject: Prefer GLib basic types over C types. --- mail/em-format-html-display.c | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 1cfe836e76..dbd3ddbbc3 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -105,7 +105,7 @@ struct _EMFormatHTMLDisplayPrivate { struct _smime_pobject { EMFormatHTMLPObject object; - int signature; + gint signature; CamelCipherValidity *valid; GtkWidget *widget; }; @@ -113,7 +113,7 @@ struct _smime_pobject { /* TODO: move the dialogue elsehwere */ /* FIXME: also in em-format-html.c */ static const struct { - const char *icon, *shortdesc, *description; + const gchar *icon, *shortdesc, *description; } smime_sign_table[5] = { { "stock_signature-bad", N_("Unsigned"), N_("This message is not signed. There is no guarantee that this message is authentic.") }, { "stock_signature-ok", N_("Valid signature"), N_("This message is signed and is valid meaning that it is very likely that this message is authentic.") }, @@ -124,7 +124,7 @@ static const struct { }; static const struct { - const char *icon, *shortdesc, *description; + const gchar *icon, *shortdesc, *description; } smime_encrypt_table[4] = { { "stock_lock-broken", N_("Unencrypted"), N_("This message is not encrypted. Its content may be viewed in transit across the Internet.") }, { "stock_lock-ok", N_("Encrypted, weak"), N_("This message is encrypted, but with a weak encryption algorithm. It would be difficult, but not impossible for an outsider to view the content of this message in a practical amount of time.") }, @@ -132,7 +132,7 @@ static const struct { { "stock_lock-ok", N_("Encrypted, strong"), N_("This message is encrypted, with a strong encryption algorithm. It would be very difficult for an outsider to view the content of this message in a practical amount of time.") }, }; -static const char *smime_sign_colour[5] = { +static const gchar *smime_sign_colour[5] = { "", " bgcolor=\"#88bb88\"", " bgcolor=\"#bb8888\"", " bgcolor=\"#e8d122\"","" }; @@ -147,13 +147,13 @@ struct _attach_puri { const EMFormatHandler *handle; - const char *snoop_mime_type; + const gchar *snoop_mime_type; /* for the > and V buttons */ GtkWidget *forward, *down; /* currently no way to correlate this data to the frame :( */ GtkHTML *frame; - unsigned int shown:1; + guint shown:1; /* Embedded Frame */ GtkHTMLEmbedded *html; @@ -162,8 +162,8 @@ struct _attach_puri { EAttachment *attachment; /* image stuff */ - int fit_width; - int fit_height; + gint fit_width; + gint fit_height; GtkImage *image; GtkWidget *event_box; @@ -240,11 +240,11 @@ efhd_xpkcs7mime_add_cert_table (GtkWidget *vbox, { CamelCipherCertInfo *info = (CamelCipherCertInfo *)certlist->head; GtkTable *table = (GtkTable *)gtk_table_new(camel_dlist_length(certlist), 2, FALSE); - int n = 0; + gint n = 0; while (info->next) { - char *la = NULL; - const char *l = NULL; + gchar *la = NULL; + const gchar *l = NULL; if (info->name) { if (info->email && strcmp(info->name, info->email) != 0) @@ -301,7 +301,7 @@ efhd_xpkcs7mime_validity_clicked (GtkWidget *button, struct _smime_pobject *po = (struct _smime_pobject *)pobject; GladeXML *xml; GtkWidget *vbox, *w; - char *gladefile; + gchar *gladefile; if (po->widget) /* FIXME: window raise? */ @@ -392,7 +392,7 @@ efhd_xpkcs7mime_button (EMFormatHTML *efh, GtkWidget *container; GtkWidget *widget; struct _smime_pobject *po = (struct _smime_pobject *)pobject; - const char *icon_name; + const gchar *icon_name; /* FIXME: need to have it based on encryption and signing too */ if (po->valid->sign.status != 0) @@ -441,7 +441,7 @@ efhd_format_attachment (EMFormat *emf, const gchar *mime_type, const EMFormatHandler *handle) { - char *classid, *text, *html; + gchar *classid, *text, *html; struct _attach_puri *info; classid = g_strdup_printf ("attachment%s", emf->part_id->str); @@ -501,7 +501,7 @@ efhd_format_optional (EMFormat *emf, CamelMimePart *part, CamelStream *mstream) { - char *classid, *html; + gchar *classid, *html; struct _attach_puri *info; CamelStream *stream; @@ -569,7 +569,7 @@ efhd_format_secure (EMFormat *emf, if (emf->valid == valid && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE || valid->sign.status != CAMEL_CIPHER_VALIDITY_SIGN_NONE)) { - char *classid; + gchar *classid; struct _smime_pobject *pobj; camel_stream_printf ( @@ -694,7 +694,7 @@ em_format_html_display_new (void) static void efhd_image(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *handle) { - char *classid; + gchar *classid; struct _attach_puri *info; classid = g_strdup_printf("image%s", ((EMFormat *)efh)->part_id->str); @@ -748,7 +748,7 @@ static EMFormatHandler type_builtin_table[] = { static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc) { - int i; + gint i; for (i=0;ifolder == NULL || emf->uid == NULL || (flag = camel_folder_get_message_user_tag(emf->folder, emf->uid, "follow-up")) == NULL @@ -790,7 +790,7 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", iconpath); g_free (iconpath); if (iconpart) { - char *classid; + gchar *classid; classid = g_strdup_printf("icon:///em-format-html-display/%s/%s", emf->part_id->str, comp&&comp[0]?"comp":"uncomp"); camel_stream_printf(stream, "", classid); @@ -844,7 +844,7 @@ efhd_can_process_attachment (GtkWidget *button) /* if it hasn't been processed yet, format the attachment */ static void -efhd_attachment_show(EPopup *ep, EPopupItem *item, void *data) +efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data) { struct _attach_puri *info = data; @@ -866,7 +866,7 @@ efhd_attachment_button_expanded (GtkWidget *widget, } static void -efhd_image_fit(EPopup *ep, EPopupItem *item, void *data) +efhd_image_fit(EPopup *ep, EPopupItem *item, gpointer data) { struct _attach_puri *info = data; @@ -875,7 +875,7 @@ efhd_image_fit(EPopup *ep, EPopupItem *item, void *data) } static void -efhd_image_unfit(EPopup *ep, EPopupItem *item, void *data) +efhd_image_unfit(EPopup *ep, EPopupItem *item, gpointer data) { struct _attach_puri *info = data; @@ -892,13 +892,13 @@ static EPopupItem efhd_menu_items[] = { }; static void -efhd_menu_items_free(EPopup *ep, GSList *items, void *data) +efhd_menu_items_free(EPopup *ep, GSList *items, gpointer data) { g_slist_free(items); } static void -efhd_popup_place_widget(GtkMenu *menu, int *x, int *y, gboolean *push_in, gpointer user_data) +efhd_popup_place_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) { GtkWidget *w = user_data; @@ -983,7 +983,7 @@ static void efhd_drag_data_get(GtkWidget *w, GdkDragContext *drag, GtkSelectionData *data, guint info, guint time, EMFormatHTMLPObject *pobject) { CamelMimePart *part = pobject->part; - char *uri, *uri_crlf, *path; + gchar *uri, *uri_crlf, *path; CamelStream *stream; switch (info) { @@ -1009,7 +1009,7 @@ efhd_drag_data_get(GtkWidget *w, GdkDragContext *drag, GtkSelectionData *data, g /* Kludge around Nautilus requesting the same data many times */ uri = g_object_get_data((GObject *)w, "e-drag-uri"); if (uri) { - gtk_selection_data_set(data, data->target, 8, (unsigned char *)uri, strlen(uri)); + gtk_selection_data_set(data, data->target, 8, (guchar *)uri, strlen(uri)); return; } @@ -1021,7 +1021,7 @@ efhd_drag_data_get(GtkWidget *w, GdkDragContext *drag, GtkSelectionData *data, g g_free(path); uri_crlf = g_strconcat(uri, "\r\n", NULL); g_free(uri); - gtk_selection_data_set(data, data->target, 8, (unsigned char *)uri_crlf, strlen(uri_crlf)); + gtk_selection_data_set(data, data->target, 8, (guchar *)uri_crlf, strlen(uri_crlf)); g_object_set_data_full((GObject *)w, "e-drag-uri", uri_crlf, g_free); break; default: @@ -1032,7 +1032,7 @@ efhd_drag_data_get(GtkWidget *w, GdkDragContext *drag, GtkSelectionData *data, g static void efhd_drag_data_delete(GtkWidget *w, GdkDragContext *drag, EMFormatHTMLPObject *pobject) { - char *uri; + gchar *uri; uri = g_object_get_data((GObject *)w, "e-drag-uri"); if (uri) { @@ -1041,7 +1041,7 @@ efhd_drag_data_delete(GtkWidget *w, GdkDragContext *drag, EMFormatHTMLPObject *p /* NB even more: doesn't the e-drag-uri have \r\n * appended? (see efhd_drag_data_get()) */ - char *filename = g_filename_from_uri (uri, NULL, NULL); + gchar *filename = g_filename_from_uri (uri, NULL, NULL); g_unlink(filename); g_free(filename); g_object_set_data((GObject *)w, "e-drag-uri", NULL); @@ -1049,7 +1049,7 @@ efhd_drag_data_delete(GtkWidget *w, GdkDragContext *drag, EMFormatHTMLPObject *p } static void -efhd_write_icon_job(struct _EMFormatHTMLJob *job, int cancelled) +efhd_write_icon_job(struct _EMFormatHTMLJob *job, gint cancelled) { EMFormatHTMLPObject *pobject; CamelDataWrapper *dw; @@ -1067,7 +1067,7 @@ static void efhd_image_resized(GtkWidget *w, GtkAllocation *event, struct _attach_puri *info) { GdkPixbuf *pb; - int width; + gint width; if (info->fit_width == 0) return; @@ -1099,7 +1099,7 @@ efhd_change_cursor(GtkWidget *w, GdkEventCrossing *event, struct _attach_puri *i static void efhd_image_fit_width(GtkWidget *widget, GdkEventButton *event, struct _attach_puri *info) { - int width; + gint width; width = ((GtkWidget *)((EMFormatHTML *)info->puri.format)->html)->allocation.width - 12; @@ -1150,7 +1150,7 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec { NULL, 0, 0 }, { (gchar *) "text/uri-list", 0, 1 }, }; - char *simple_type; + gchar *simple_type; info = (struct _attach_puri *)em_format_find_puri((EMFormat *)efh, pobject->classid); @@ -1313,7 +1313,7 @@ efhd_message_add_bar (EMFormat *emf, CamelMimePart *part, const EMFormatHandler *info) { - const char *classid = "attachment-bar"; + const gchar *classid = "attachment-bar"; em_format_html_add_pobject ( EM_FORMAT_HTML (emf), @@ -1413,7 +1413,7 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE); gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (view)); - gtk_text_buffer_set_text (buffer, (char *)info->mstream->buffer->data, info->mstream->buffer->len); + gtk_text_buffer_set_text (buffer, (gchar *)info->mstream->buffer->data, info->mstream->buffer->len); camel_object_unref(info->mstream); info->mstream = NULL; gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), -- cgit v1.2.3 From 14f8eee012382f04090ea9277e9567d5f32e8bf0 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 28 May 2009 13:06:29 -0400 Subject: Whitespace cleanup. --- mail/em-format-html-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index dbd3ddbbc3..2a51bfad6c 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1090,7 +1090,7 @@ efhd_change_cursor(GtkWidget *w, GdkEventCrossing *event, struct _attach_puri *i if (info->shown && info->image) { if (info->fit_width != 0) { if (em_icon_stream_is_resized(info->puri.cid, info->fit_width, info->fit_height)) - e_cursor_set(w->window, E_CURSOR_ZOOM_IN); + e_cursor_set(w->window, E_CURSOR_ZOOM_IN); } } -- cgit v1.2.3 From 46905edb53ecdc18f59c701cb5be3fd3829e9198 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Jun 2009 15:32:20 -0400 Subject: Fix crash when printing an email. --- mail/em-format-html-display.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 2a51bfad6c..e4aa4e06ab 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -1293,6 +1293,10 @@ efhd_add_bar (EMFormatHTML *efh, EMFormatHTMLDisplayPrivate *priv; GtkWidget *widget; + /* XXX See note in efhd_message_add_bar(). */ + if (!EM_IS_FORMAT_HTML_DISPLAY (efh)) + return FALSE; + priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efh); widget = e_mail_attachment_bar_new (); @@ -1315,6 +1319,10 @@ efhd_message_add_bar (EMFormat *emf, { const gchar *classid = "attachment-bar"; + /* XXX Apparently this installs the callback for -all- + * EMFormatHTML subclasses, not just this subclass. + * Bad idea. So we have to filter out other types + * in the callback. */ em_format_html_add_pobject ( EM_FORMAT_HTML (emf), sizeof (EMFormatHTMLPObject), -- cgit v1.2.3 From 374bd42f69aca2e132fd854c9619f3d7491f1f96 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 12 Jul 2009 23:33:07 -0400 Subject: Fix excessive whitespace. --- mail/em-format-html-display.c | 1 - 1 file changed, 1 deletion(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index e4aa4e06ab..375eadafe2 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -175,7 +175,6 @@ struct _attach_puri { camel_cipher_validity_encrypt_t encrypt; }; - static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info); static void efhd_builtin_init(EMFormatHTMLDisplayClass *efhc); -- cgit v1.2.3 From fa360fde289f9b850191f89059d1a5e6d67c07c7 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 18 Jul 2009 14:07:42 -0400 Subject: More whitespace cleanup. --- mail/em-format-html-display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 375eadafe2..270db0e698 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -223,7 +223,7 @@ efhd_xpkcs7mime_viewcert_clicked (GtkWidget *button, g_signal_connect(w, "response", G_CALLBACK(gtk_widget_destroy), NULL); if (w && po->widget) - gtk_window_set_transient_for((GtkWindow *)w, (GtkWindow *)po->widget); + gtk_window_set_transient_for ((GtkWindow *)w, (GtkWindow *)po->widget); g_object_unref(ec); } else { @@ -1105,7 +1105,7 @@ efhd_image_fit_width(GtkWidget *widget, GdkEventButton *event, struct _attach_pu if (info->shown && info->image) { if (info->fit_width != 0) { if (em_icon_stream_is_resized(info->puri.cid, info->fit_width, info->fit_height)) { - if(info->fit_width != width) { + if (info->fit_width != width) { info->fit_width = width; e_cursor_set (widget->window, E_CURSOR_ZOOM_IN); } else { -- cgit v1.2.3 From 45d475c31b2dbda8033021984ba9a429b9eddf51 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 9 Aug 2009 20:03:24 -0400 Subject: Kill EMMenu and EMPopup. Also finish adapting Templates plugin to EPluginUI. It was still leaning pretty hard on EMPopup. --- mail/em-format-html-display.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 270db0e698..a15b0d671f 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -78,7 +78,6 @@ #include "em-format-html-display.h" #include "em-icon-stream.h" #include "em-utils.h" -#include "em-popup.h" #include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" @@ -841,6 +840,7 @@ efhd_can_process_attachment (GtkWidget *button) return efh && efh->state != EM_FORMAT_HTML_STATE_RENDERING; } +#if 0 /* KILL-BONOBO */ /* if it hasn't been processed yet, format the attachment */ static void efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data) @@ -975,6 +975,7 @@ efhd_attachment_popup_menu(GtkWidget *w, struct _attach_puri *info) { return efhd_attachment_popup(w, NULL, info); } +#endif /* ********************************************************************** */ @@ -1132,9 +1133,13 @@ efhd_image_unallocate (struct _EMFormatPURI * puri) struct _attach_puri *info = (struct _attach_puri *) puri; g_signal_handlers_disconnect_by_func(info->html, efhd_image_resized, info); +#if 0 /* KILL-BONOBO */ g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_popup, info); +#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_change_cursor, info); +#if 0 /* KILL-BONOBO */ g_signal_handlers_disconnect_by_func(info->event_box, efhd_attachment_popup_menu, info); +#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_fit_width, info); } @@ -1185,9 +1190,13 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec g_signal_connect(box, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject); g_signal_connect (box, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject); +#if 0 /* KILL-BONOBO */ g_signal_connect(box, "button_press_event", G_CALLBACK(efhd_image_popup), info); +#endif g_signal_connect(box, "enter-notify-event", G_CALLBACK(efhd_change_cursor), info); +#if 0 /* KILL-BONOBO */ g_signal_connect(box, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); +#endif g_signal_connect(box, "button-press-event", G_CALLBACK(efhd_image_fit_width), info); g_object_set_data (G_OBJECT (box), "efh", efh); @@ -1244,9 +1253,11 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje g_object_set_data (G_OBJECT (widget), "efh", efh); +#if 0 /* KILL-BONOBO */ g_signal_connect ( widget, "notify::expanded", G_CALLBACK (efhd_attachment_button_expanded), info); +#endif return TRUE; } @@ -1407,9 +1418,11 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb a11y = gtk_widget_get_accessible (button); atk_object_set_name (a11y, _("Attachment")); +#if 0 /* KILL-BONOBO */ g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); +#endif gtk_box_pack_start(GTK_BOX (mainbox), button, FALSE, FALSE, 6); gtk_widget_show_all(mainbox); -- cgit v1.2.3 From 50302d03b3ce145b165db2ddef4e92ad190cbef9 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 4 Aug 2009 15:04:02 +0200 Subject: Bug #205137 - Configurable date formats in components --- mail/em-format-html-display.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index a15b0d671f..70b8547972 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -63,6 +63,7 @@ #include #include +#include "e-util/e-datetime-format.h" #include #include @@ -81,16 +82,6 @@ #include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" -#ifdef G_OS_WIN32 -/* Undefine the similar macro from ,it doesn't check if - * localtime() returns NULL. - */ -#undef localtime_r - -/* The localtime() in Microsoft's C library is MT-safe */ -#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0) -#endif - #define d(x) #define EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(obj) \ @@ -768,9 +759,7 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF { const gchar *flag, *comp, *due; time_t date; - gchar due_date[128]; - struct tm due_tm; - gchar *iconpath; + gchar *iconpath, *due_date_str; if (emf->folder == NULL || emf->uid == NULL || (flag = camel_folder_get_message_user_tag(emf->folder, emf->uid, "follow-up")) == NULL @@ -801,10 +790,10 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF camel_stream_printf(stream, "
"); if (comp && comp[0]) { - date = camel_header_decode_date(comp, NULL); - localtime_r(&date, &due_tm); - e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("Completed on %B %d, %Y, %l:%M %p"), &due_tm); - camel_stream_printf(stream, "%s, %s", flag, due_date); + date = camel_header_decode_date (comp, NULL); + due_date_str = e_datetime_format_format ("mail", "header", DTFormatKindDateTime, date); + camel_stream_printf (stream, "%s, %s %s", flag, _("Completed on"), due_date_str ? due_date_str : "???"); + g_free (due_date_str); } else if ((due = camel_folder_get_message_user_tag(emf->folder, emf->uid, "due-by")) != NULL && due[0]) { time_t now; @@ -813,9 +802,9 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF if (now > date) camel_stream_printf(stream, "%s ", _("Overdue:")); - localtime_r(&date, &due_tm); - e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("by %B %d, %Y, %l:%M %p"), &due_tm); - camel_stream_printf(stream, "%s %s", flag, due_date); + due_date_str = e_datetime_format_format ("mail", "header", DTFormatKindDateTime, date); + /* To Translators: the "by" is part of the string, like "Follow-up by Tuesday, January 13, 2009" */ + camel_stream_printf (stream, "%s %s %s", flag, _("by"), due_date_str ? due_date_str : "???"); } else { camel_stream_printf(stream, "%s", flag); } -- cgit v1.2.3 From ca961d33468429155901985b803fc794fcd462c5 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 17 Aug 2009 15:30:25 -0400 Subject: =?UTF-8?q?Bug=C2=A0591830=20-=20Inline=20attachments=20no=20longe?= =?UTF-8?q?r=20shown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail/em-format-html-display.c | 154 ++---------------------------------------- 1 file changed, 6 insertions(+), 148 deletions(-) (limited to 'mail/em-format-html-display.c') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 70b8547972..38e3af3587 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -814,8 +814,9 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF /* ********************************************************************** */ -/* Checks on the widget whether it can be processed, based on the state of EMFormatHTML. - The widget should have set "efh" data as the EMFormatHTML instance. */ +/* Checks on the widget whether it can be processed, based on the + * state of EMFormatHTML. The widget should have set "efh" data as + * the EMFormatHTML instance. */ static gboolean efhd_can_process_attachment (GtkWidget *button) { @@ -829,19 +830,6 @@ efhd_can_process_attachment (GtkWidget *button) return efh && efh->state != EM_FORMAT_HTML_STATE_RENDERING; } -#if 0 /* KILL-BONOBO */ -/* if it hasn't been processed yet, format the attachment */ -static void -efhd_attachment_show(EPopup *ep, EPopupItem *item, gpointer data) -{ - struct _attach_puri *info = data; - - d(printf("show attachment button called %p\n", info)); - - info->shown = ~info->shown; - em_format_set_inline(info->puri.format, info->puri.part_id, info->shown); -} - static void efhd_attachment_button_expanded (GtkWidget *widget, GParamSpec *pspec, @@ -850,121 +838,10 @@ efhd_attachment_button_expanded (GtkWidget *widget, if (!efhd_can_process_attachment (widget)) return; - efhd_attachment_show (NULL, NULL, info); -} - -static void -efhd_image_fit(EPopup *ep, EPopupItem *item, gpointer data) -{ - struct _attach_puri *info = data; - - info->fit_width = ((GtkWidget *)((EMFormatHTML *)info->puri.format)->html)->allocation.width - 12; - gtk_image_set_from_pixbuf(info->image, em_icon_stream_get_image(info->puri.cid, info->fit_width, info->fit_height)); -} - -static void -efhd_image_unfit(EPopup *ep, EPopupItem *item, gpointer data) -{ - struct _attach_puri *info = data; - - info->fit_width = 0; - gtk_image_set_from_pixbuf((GtkImage *)info->image, em_icon_stream_get_image(info->puri.cid, info->fit_width, info->fit_height)); -} - -static EPopupItem efhd_menu_items[] = { - { E_POPUP_BAR, (gchar *) "05.display" }, - { E_POPUP_ITEM, (gchar *) "05.display.00", (gchar *) N_("_View Inline"), efhd_attachment_show }, - { E_POPUP_ITEM, (gchar *) "05.display.00", (gchar *) N_("_Hide"), efhd_attachment_show }, - { E_POPUP_ITEM, (gchar *) "05.display.01", (gchar *) N_("_Fit to Width"), efhd_image_fit, NULL, NULL, EM_POPUP_PART_IMAGE }, - { E_POPUP_ITEM, (gchar *) "05.display.01", (gchar *) N_("Show _Original Size"), efhd_image_unfit, NULL, NULL, EM_POPUP_PART_IMAGE }, -}; - -static void -efhd_menu_items_free(EPopup *ep, GSList *items, gpointer data) -{ - g_slist_free(items); -} - -static void -efhd_popup_place_widget(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data) -{ - GtkWidget *w = user_data; - - gdk_window_get_origin(gtk_widget_get_parent_window(w), x, y); - *x += w->allocation.x + w->allocation.width; - *y += w->allocation.y; -} - -static gboolean -efhd_attachment_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri *info) -{ - GtkMenu *menu; - GSList *menus = NULL; - EMPopup *emp; - EMPopupTargetPart *target; - - d(printf("attachment popup, button %d\n", event->button)); - - if (event && event->button != 1 && event->button != 3) { - /* ?? gtk_propagate_event(GTK_WIDGET (user_data), (GdkEvent *)event);*/ - return FALSE; - } - - if (!efhd_can_process_attachment (w)) - return FALSE; - - /** @HookPoint-EMPopup: Attachment Button Context Menu - * @Id: org.gnome.evolution.mail.formathtmldisplay.popup - * @Class: org.gnome.evolution.mail.popup:1.0 - * @Target: EMPopupTargetPart - * - * This is the drop-down menu shown when a user clicks on the down arrow - * of the attachment button in inline mail content. - */ - emp = em_popup_new("org.gnome.evolution.mail.formathtmldisplay.popup"); - target = em_popup_target_new_part(emp, info->puri.part, info->handle?info->handle->mime_type:NULL); - target->target.widget = w; - - /* add our local menus */ - if (info->handle) { - /* show/hide menus, only if we have an inline handler */ - menus = g_slist_prepend(menus, &efhd_menu_items[0]); - menus = g_slist_prepend(menus, &efhd_menu_items[info->shown?2:1]); - if (info->shown && info->image) { - if (info->fit_width != 0) { - if (em_icon_stream_is_resized(info->puri.cid, info->fit_width, info->fit_height)) - menus = g_slist_prepend(menus, &efhd_menu_items[4]); - } else - menus = g_slist_prepend(menus, &efhd_menu_items[3]); - } - } - - e_popup_add_items((EPopup *)emp, menus, NULL, efhd_menu_items_free, info); - - menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)target, 0); - if (event) - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button, event->time); - else - gtk_menu_popup(menu, NULL, NULL, (GtkMenuPositionFunc)efhd_popup_place_widget, w, 0, gtk_get_current_event_time()); - - return TRUE; -} - -static gboolean -efhd_image_popup(GtkWidget *w, GdkEventButton *event, struct _attach_puri *info) -{ - if (event && event->button != 3) - return FALSE; - - return efhd_attachment_popup(w, event, info); -} - -static gboolean -efhd_attachment_popup_menu(GtkWidget *w, struct _attach_puri *info) -{ - return efhd_attachment_popup(w, NULL, info); + info->shown = ~info->shown; + em_format_set_inline ( + info->puri.format, info->puri.part_id, info->shown); } -#endif /* ********************************************************************** */ @@ -1122,13 +999,7 @@ efhd_image_unallocate (struct _EMFormatPURI * puri) struct _attach_puri *info = (struct _attach_puri *) puri; g_signal_handlers_disconnect_by_func(info->html, efhd_image_resized, info); -#if 0 /* KILL-BONOBO */ - g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_popup, info); -#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_change_cursor, info); -#if 0 /* KILL-BONOBO */ - g_signal_handlers_disconnect_by_func(info->event_box, efhd_attachment_popup_menu, info); -#endif g_signal_handlers_disconnect_by_func(info->event_box, efhd_image_fit_width, info); } @@ -1179,13 +1050,7 @@ efhd_attachment_image(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObjec g_signal_connect(box, "drag-data-get", G_CALLBACK(efhd_drag_data_get), pobject); g_signal_connect (box, "drag-data-delete", G_CALLBACK(efhd_drag_data_delete), pobject); -#if 0 /* KILL-BONOBO */ - g_signal_connect(box, "button_press_event", G_CALLBACK(efhd_image_popup), info); -#endif g_signal_connect(box, "enter-notify-event", G_CALLBACK(efhd_change_cursor), info); -#if 0 /* KILL-BONOBO */ - g_signal_connect(box, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); -#endif g_signal_connect(box, "button-press-event", G_CALLBACK(efhd_image_fit_width), info); g_object_set_data (G_OBJECT (box), "efh", efh); @@ -1242,11 +1107,9 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje g_object_set_data (G_OBJECT (widget), "efh", efh); -#if 0 /* KILL-BONOBO */ g_signal_connect ( widget, "notify::expanded", G_CALLBACK (efhd_attachment_button_expanded), info); -#endif return TRUE; } @@ -1407,11 +1270,6 @@ efhd_attachment_optional(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPOb a11y = gtk_widget_get_accessible (button); atk_object_set_name (a11y, _("Attachment")); -#if 0 /* KILL-BONOBO */ - g_signal_connect(button, "button_press_event", G_CALLBACK(efhd_attachment_popup), info); - g_signal_connect(button, "popup_menu", G_CALLBACK(efhd_attachment_popup_menu), info); - g_signal_connect(button, "clicked", G_CALLBACK(efhd_attachment_popup_menu), info); -#endif gtk_box_pack_start(GTK_BOX (mainbox), button, FALSE, FALSE, 6); gtk_widget_show_all(mainbox); -- cgit v1.2.3