aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-format-html-display.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-04-28 03:36:19 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-04-28 03:36:19 +0800
commit4449a34101406bffe508dd40b8b653f7c7d14c7d (patch)
treee9fb2ce7efd3901cf1090040666f0ce15ad70554 /mail/em-format-html-display.c
parente377ea5e61171e57f9e892652d0fd1f77953eda8 (diff)
downloadgsoc2013-evolution-4449a34101406bffe508dd40b8b653f7c7d14c7d.tar.gz
gsoc2013-evolution-4449a34101406bffe508dd40b8b653f7c7d14c7d.tar.zst
gsoc2013-evolution-4449a34101406bffe508dd40b8b653f7c7d14c7d.zip
Commit the rest of the attachment UI rewrite
Oops, last commit only included the -new- files. This also removes EExpander, which is no longer used.
Diffstat (limited to 'mail/em-format-html-display.c')
-rw-r--r--mail/em-format-html-display.c615
1 files changed, 103 insertions, 512 deletions
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index ad72ee8bdd..789705879d 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -80,14 +80,15 @@
#include "mail-config.h"
+#include "e-mail-attachment-bar.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"
+#include "widgets/misc/e-attachment-button.h"
+#include "widgets/misc/e-attachment-view.h"
#ifdef G_OS_WIN32
/* Undefine the similar macro from <pthread.h>,it doesn't check if
@@ -113,18 +114,7 @@ struct _EMFormatHTMLDisplayPrivate {
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;
- 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 */
};
static int efhd_html_button_press_event (GtkWidget *widget, GdkEventButton *event, EMFormatHTMLDisplay *efh);
@@ -134,8 +124,6 @@ static void efhd_html_on_url (GtkHTML *html, const char *url, EMFormatHTMLDispla
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_bar_refresh (EMFormatHTMLDisplay *efhd);
struct _attach_puri {
EMFormatPURI puri;
@@ -186,7 +174,6 @@ static void efhd_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, c
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 gboolean efhd_bonobo_object(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject);
static gboolean efhd_use_component(const char *mime_type);
@@ -279,9 +266,6 @@ efhd_init(GObject *o)
#undef efh
efhd->nobar = getenv("EVOLUTION_NO_BAR") != NULL;
-
- efhd->priv->show_bar = FALSE;
- efhd->priv->files = NULL;
}
static void
@@ -291,9 +275,6 @@ efhd_finalise(GObject *o)
/* check pending stuff */
- if (efhd->priv->files)
- g_hash_table_destroy(efhd->priv->files);
-
g_free(efhd->priv->search_text);
g_free(efhd->priv);
@@ -431,12 +412,6 @@ void em_format_html_display_set_caret_mode(EMFormatHTMLDisplay *efhd, gboolean s
gtk_html_set_caret_mode(((EMFormatHTML *)efhd)->html, state);
}
-EAttachmentBar *
-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)
{
@@ -933,11 +908,6 @@ efhd_complete(EMFormat *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;
- }
}
/* ********************************************************************** */
@@ -1293,9 +1263,7 @@ static EMFormatHandler type_builtin_table[] = {
{ "image/pjpeg", (EMFormatFunc)efhd_image },
{ "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 },
-
+ { "x-evolution/message/post-header", (EMFormatFunc)efhd_message_add_bar }
};
static void
@@ -1343,15 +1311,8 @@ static const EMFormatHandler *efhd_find_handler(EMFormat *emf, const char *mime_
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;
+ if (emf != src)
((EMFormatHTML *) emf)->header_wrap_flags = 0;
- }
((EMFormatClass *)efhd_parent)->format_clone(emf, folder, uid, msg, src);
}
@@ -1467,12 +1428,14 @@ efhd_attachment_show(EPopup *ep, EPopupItem *item, void *data)
}
static void
-efhd_attachment_button_show(GtkWidget *w, void *data)
+efhd_attachment_button_expanded (GtkWidget *widget,
+ GParamSpec *pspec,
+ 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
@@ -1811,16 +1774,12 @@ 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;
- GtkTargetEntry drag_types[] = {
- { NULL, 0, 0 },
- { "text/uri-list", 0, 1 },
- };
- AtkObject *a11y;
+ EAttachmentView *view;
+ EAttachmentStore *store;
+ EAttachment *attachment;
+ GtkWidget *widget;
+ gpointer parent;
/* FIXME: handle default shown case */
d(printf("adding attachment button/content\n"));
@@ -1832,139 +1791,36 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje
return TRUE;
}
- if (efhd->priv->attachment_bar) {
- file = camel_mime_part_get_filename(info->puri.part);
-
- new = info->attachment;
-
- if (!file) {
- file = "attachment.dat";
- new->file_name = g_strdup(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));
- g_free (new->file_name);
- new->file_name = new_file;
- } else {
- g_hash_table_insert (efhd->priv->files, g_strdup(file), GUINT_TO_POINTER(1));
- }
-
- /* 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);
- }
-
- mainbox = gtk_hbox_new(FALSE, 0);
-
- 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);
- }
-
- 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);
-
- /* 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);
-
- /* 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);
- }
- } 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;
- 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);
+ 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);
- 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));
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (efh->html));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
- a11y = gtk_widget_get_accessible (button);
- atk_object_set_name (a11y, _("Attachment"));
+ view = E_ATTACHMENT_VIEW (efhd->priv->attachment_view);
+ gtk_widget_show (efhd->priv->attachment_view);
- 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);
+ store = e_attachment_view_get_store (view);
+ e_attachment_store_add_attachment (store, info->attachment);
- g_object_set_data (G_OBJECT (button), "efh", efh);
+ e_attachment_load_async (
+ info->attachment, (GAsyncReadyCallback)
+ e_attachment_load_handle_error, parent);
- gtk_widget_show_all(mainbox);
+ widget = e_attachment_button_new (view);
+ e_attachment_button_set_attachment (
+ E_ATTACHMENT_BUTTON (widget), attachment);
+ gtk_container_add (GTK_CONTAINER (eb), widget);
+ gtk_widget_show (widget);
- if (info->shown)
- gtk_widget_hide(info->forward);
- else if (info->down)
- gtk_widget_hide(info->down);
+ g_object_set_data (G_OBJECT (widget), "efh", efh);
- gtk_container_add((GtkContainer *)eb, mainbox);
+ g_signal_connect (
+ widget, "notify::expanded",
+ G_CALLBACK (efhd_attachment_button_expanded), info);
return TRUE;
}
@@ -2138,330 +1994,57 @@ type_ok:
}
static void
-attachment_bar_arrow_clicked(GtkWidget *w, EMFormatHTMLDisplay *efhd)
+efhd_bar_resize (EMFormatHTML *efh,
+ GtkAllocation *event)
{
+ EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh;
+ GtkWidget *widget;
+ gint width;
- efhd->priv->show_bar = !efhd->priv->show_bar;
+ widget = GTK_WIDGET (efh->html);
+ width = widget->allocation.width - 12;
- 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);
+ if (width > 0) {
+ widget = efhd->priv->attachment_view;
+ gtk_widget_set_size_request (widget, width, -1);
}
}
-static void
-attachments_save_all_clicked (GtkWidget *widget, EMFormatHTMLDisplay *efhd)
-{
- GSList *attachment_parts;
- guint n_attachment_parts;
-
- 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);
-
- if (n_attachment_parts == 1)
- em_utils_save_part (
- widget, _("Save attachment as"),
- attachment_parts->data);
- else
- em_utils_save_parts (
- widget, _("Select folder to save all attachments"),
- attachment_parts);
-
- g_slist_free (attachment_parts);
-}
-
-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;
-}
-
-static void
-efhd_bar_save_selected(EPopup *ep, EPopupItem *item, void *data)
-{
- EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)data;
- GSList *attachment_parts, *tmp;
- GSList *parts = NULL;
-
- attachment_parts = e_attachment_bar_get_selected(E_ATTACHMENT_BAR(efhd->priv->attachment_bar));
-
- 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);
- 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},
-};
-
-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);
-}
-
-static void
-efhd_attachment_bar_refresh (EMFormatHTMLDisplay *efhd)
-{
- int nattachments;
-
- if (!efhd->priv->attachment_bar)
- return;
-
- nattachments = e_attachment_bar_get_num_attachments (E_ATTACHMENT_BAR(efhd->priv->attachment_bar));
- if (nattachments) {
- char *txt;
-
- /* 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);
-
- /* 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"));
-
- 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"));
- }
- }
-}
-
-static void
-efhd_bar_resize(GtkWidget *w, GtkAllocation *event, EMFormatHTML *efh)
+efhd_add_bar (EMFormatHTML *efh,
+ GtkHTMLEmbedded *eb,
+ EMFormatHTMLPObject *pobject)
{
- int width;
- GtkRequisition req;
EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *) efh;
+ GtkWidget *widget;
- 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);
-}
-
-static gboolean
-efhd_bar_scroll_event(GtkWidget *w, GdkEventScroll *event, EMFormatHTMLDisplay *efhd)
-{
- 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->formathtml.html), "scroll_event", event, &ret);
-
- 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)
-{
- EMFormatHTMLDisplay *efhd = (EMFormatHTMLDisplay *)efh;
- struct _EMFormatHTMLDisplayPrivate *priv = efhd->priv;
-
- if (priv->attachment_bar)
- e_attachment_bar_refresh (E_ATTACHMENT_BAR (priv->attachment_bar));
-
- return TRUE;
-}
-
-static gboolean
-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_bar = e_attachment_bar_new(NULL);
- 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);
- 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_bar);
-
- gtk_widget_get_size_request(priv->attachment_bar, &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,
- 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);
-
- /* 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);
+ efhd->priv->attachment_view = widget;
+ gtk_widget_hide (widget);
- 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);
+ g_signal_connect_swapped (
+ eb, "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->nobar || 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, "<td><object classid=\"%s\"></object></td>", classid);
-
-}
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;
const char *classid = "attachment-bar";
- if (efhd->nobar || efhd->priv->files)
- return;
+ em_format_html_add_pobject (
+ (EMFormatHTML *) emf,
+ sizeof (EMFormatHTMLPObject),
+ classid, part, efhd_add_bar);
- 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((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_add_bar);
- camel_stream_printf(stream, "<td><object classid=\"%s\"></object></td>", classid);
+ camel_stream_printf (
+ stream, "<td><object classid=\"%s\"></object></td>", classid);
}
static void
@@ -2470,43 +2053,50 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part,
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);
+ 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->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;
info->encrypt = emf->valid->encrypt.status;
}
- camel_stream_write_string(stream,
- EM_FORMAT_HTML_VPAD
- "<table cellspacing=0 cellpadding=0><tr><td>"
- "<table width=10 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td>");
+ camel_stream_write_string (
+ stream, EM_FORMAT_HTML_VPAD
+ "<table cellspacing=0 cellpadding=0><tr><td>"
+ "<table width=10 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td>");
- camel_stream_printf(stream, "<td><object classid=\"%s\"></object></td>", classid);
+ camel_stream_printf (
+ stream, "<td><object classid=\"%s\"></object></td>", classid);
- camel_stream_write_string(stream,
- "<td><table width=3 cellspacing=0 cellpadding=0>"
- "<tr><td></td></tr></table></td><td><font size=-1>");
+ camel_stream_write_string (
+ stream, "<td><table width=3 cellspacing=0 cellpadding=0>"
+ "<tr><td></td></tr></table></td><td><font size=-1>");
/* 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,
- "</font></td></tr><tr></table>\n"
- EM_FORMAT_HTML_VPAD);
+ 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, "</font></td></tr><tr></table>\n"
+ EM_FORMAT_HTML_VPAD);
if (handle) {
if (info->shown)
@@ -2653,7 +2243,8 @@ efhd_format_optional(EMFormat *emf, CamelStream *fstream, CamelMimePart *part, C
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;