aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-03-24 10:05:26 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-03-24 10:05:26 +0800
commit6e163b39c75dbba470d073b4f79a897aa6fb0e54 (patch)
tree86e93752711579676337bb7cfef18c903b6c7538 /mail
parent4cec9fc7169dc3b810321555a70cda916720867d (diff)
downloadgsoc2013-evolution-6e163b39c75dbba470d073b4f79a897aa6fb0e54.tar.gz
gsoc2013-evolution-6e163b39c75dbba470d073b4f79a897aa6fb0e54.tar.zst
gsoc2013-evolution-6e163b39c75dbba470d073b4f79a897aa6fb0e54.zip
Saving progress again on the attachment rewrite.
svn path=/branches/kill-bonobo/; revision=37470
Diffstat (limited to 'mail')
-rw-r--r--mail/Makefile.am2
-rw-r--r--mail/e-mail-attachment-bar.c656
-rw-r--r--mail/e-mail-attachment-bar.h77
-rw-r--r--mail/em-format-html-display.c235
-rw-r--r--mail/em-format-html.c4
5 files changed, 771 insertions, 203 deletions
diff --git a/mail/Makefile.am b/mail/Makefile.am
index ef5b769ce4..f2b3119308 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -35,6 +35,8 @@ module_LTLIBRARIES = \
libevolution-module-mail.la
libevolution_module_mail_la_SOURCES = \
+ e-mail-attachment-bar.c \
+ e-mail-attachment-bar.h \
e-mail-browser.c \
e-mail-browser.h \
e-mail-display.c \
diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c
new file mode 100644
index 0000000000..4424a84684
--- /dev/null
+++ b/mail/e-mail-attachment-bar.c
@@ -0,0 +1,656 @@
+/*
+ * e-mail-attachment-bar.c
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-mail-attachment-bar.h"
+
+#include <glib/gi18n.h>
+#include "e-util/e-binding.h"
+#include "e-attachment-store.h"
+#include "e-attachment-icon-view.h"
+#include "e-attachment-tree-view.h"
+
+#define E_MAIL_ATTACHMENT_BAR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarPrivate))
+
+#define NUM_VIEWS 2
+
+struct _EMailAttachmentBarPrivate {
+ GtkTreeModel *model;
+ GtkWidget *vbox;
+ GtkWidget *expander;
+ GtkWidget *combo_box;
+ GtkWidget *icon_view;
+ GtkWidget *tree_view;
+ GtkWidget *icon_frame;
+ GtkWidget *tree_frame;
+ GtkWidget *status_icon;
+ GtkWidget *status_label;
+
+ gint active_view;
+ guint expanded : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_ACTIVE_VIEW,
+ PROP_EDITABLE,
+ PROP_EXPANDED
+};
+
+static gpointer parent_class;
+
+static void
+mail_attachment_bar_sync_icon_view (EMailAttachmentBar *bar)
+{
+ EAttachmentView *source;
+ EAttachmentView *target;
+
+ source = E_ATTACHMENT_VIEW (bar->priv->tree_view);
+ target = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+
+ /* Only sync if the tree view is active. This prevents the
+ * two views from endlessly trying to sync with each other. */
+ if (e_mail_attachment_bar_get_active_view (bar) == 1)
+ e_attachment_view_sync_selection (source, target);
+}
+
+static void
+mail_attachment_bar_sync_tree_view (EMailAttachmentBar *bar)
+{
+ EAttachmentView *source;
+ EAttachmentView *target;
+
+ source = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+ target = E_ATTACHMENT_VIEW (bar->priv->tree_view);
+
+ /* Only sync if the icon view is active. This prevents the
+ * two views from endlessly trying to sync with each other. */
+ if (e_mail_attachment_bar_get_active_view (bar) == 0)
+ e_attachment_view_sync_selection (source, target);
+}
+
+static void
+mail_attachment_bar_update_status (EMailAttachmentBar *bar)
+{
+ EAttachmentView *view;
+ EAttachmentStore *store;
+ GtkExpander *expander;
+ GtkLabel *label;
+ gint num_attachments;
+ guint64 total_size;
+ gchar *display_size;
+ gchar *markup;
+
+ view = E_ATTACHMENT_VIEW (bar);
+ store = e_attachment_view_get_store (view);
+ expander = GTK_EXPANDER (bar->priv->expander);
+ label = GTK_LABEL (bar->priv->status_label);
+
+ num_attachments = e_attachment_store_get_num_attachments (store);
+ total_size = e_attachment_store_get_total_size (store);
+ display_size = g_format_size_for_display (total_size);
+
+ markup = g_strdup_printf (
+ "<b>%d</b> %s (%s)", num_attachments, ngettext (
+ "Attachment", "Attachments", num_attachments),
+ display_size);
+ gtk_label_set_markup (label, markup);
+ g_free (markup);
+
+ g_free (display_size);
+}
+
+static void
+mail_attachment_bar_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_VIEW:
+ e_mail_attachment_bar_set_active_view (
+ E_MAIL_ATTACHMENT_BAR (object),
+ g_value_get_int (value));
+ return;
+
+ case PROP_EDITABLE:
+ e_attachment_view_set_editable (
+ E_ATTACHMENT_VIEW (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_EXPANDED:
+ e_mail_attachment_bar_set_expanded (
+ E_MAIL_ATTACHMENT_BAR (object),
+ g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_attachment_bar_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_ACTIVE_VIEW:
+ g_value_set_int (
+ value,
+ e_mail_attachment_bar_get_active_view (
+ E_MAIL_ATTACHMENT_BAR (object)));
+ return;
+
+ case PROP_EDITABLE:
+ g_value_set_boolean (
+ value,
+ e_attachment_view_get_editable (
+ E_ATTACHMENT_VIEW (object)));
+ return;
+
+ case PROP_EXPANDED:
+ g_value_set_boolean (
+ value,
+ e_mail_attachment_bar_get_expanded (
+ E_MAIL_ATTACHMENT_BAR (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+mail_attachment_bar_dispose (GObject *object)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (object);
+
+ if (priv->model != NULL) {
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+
+ if (priv->vbox != NULL) {
+ g_object_unref (priv->vbox);
+ priv->vbox = NULL;
+ }
+
+ if (priv->expander != NULL) {
+ g_object_unref (priv->expander);
+ priv->expander = NULL;
+ }
+
+ if (priv->combo_box != NULL) {
+ g_object_unref (priv->combo_box);
+ priv->combo_box = NULL;
+ }
+
+ if (priv->icon_view != NULL) {
+ g_object_unref (priv->icon_view);
+ priv->icon_view = NULL;
+ }
+
+ if (priv->tree_view != NULL) {
+ g_object_unref (priv->tree_view);
+ priv->tree_view = NULL;
+ }
+
+ if (priv->icon_frame != NULL) {
+ g_object_unref (priv->icon_frame);
+ priv->icon_frame = NULL;
+ }
+
+ if (priv->tree_frame != NULL) {
+ g_object_unref (priv->tree_frame);
+ priv->tree_frame = NULL;
+ }
+
+ if (priv->status_icon != NULL) {
+ g_object_unref (priv->status_icon);
+ priv->status_icon = NULL;
+ }
+
+ if (priv->status_label != NULL) {
+ g_object_unref (priv->status_label);
+ priv->status_label = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+mail_attachment_bar_constructed (GObject *object)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (object);
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "active-view",
+ G_OBJECT (priv->combo_box), "active");
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "editable",
+ G_OBJECT (priv->icon_view), "editable");
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "editable",
+ G_OBJECT (priv->tree_view), "editable");
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "expanded",
+ G_OBJECT (priv->expander), "expanded");
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "expanded",
+ G_OBJECT (priv->combo_box), "visible");
+
+ e_mutual_binding_new (
+ G_OBJECT (object), "expanded",
+ G_OBJECT (priv->vbox), "visible");
+}
+
+static EAttachmentViewPrivate *
+mail_attachment_bar_get_private (EAttachmentView *view)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ return e_attachment_view_get_private (view);
+}
+
+static EAttachmentStore *
+mail_attachment_bar_get_store (EAttachmentView *view)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ return e_attachment_view_get_store (view);
+}
+
+static GtkTreePath *
+mail_attachment_bar_get_path_at_pos (EAttachmentView *view,
+ gint x,
+ gint y)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ return e_attachment_view_get_path_at_pos (view, x, y);
+}
+
+static GList *
+mail_attachment_bar_get_selected_paths (EAttachmentView *view)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ return e_attachment_view_get_selected_paths (view);
+}
+
+static gboolean
+mail_attachment_bar_path_is_selected (EAttachmentView *view,
+ GtkTreePath *path)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ return e_attachment_view_path_is_selected (view, path);
+}
+
+static void
+mail_attachment_bar_select_path (EAttachmentView *view,
+ GtkTreePath *path)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ e_attachment_view_select_path (view, path);
+}
+
+static void
+mail_attachment_bar_unselect_path (EAttachmentView *view,
+ GtkTreePath *path)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ e_attachment_view_unselect_path (view, path);
+}
+
+static void
+mail_attachment_bar_select_all (EAttachmentView *view)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ e_attachment_view_select_all (view);
+}
+
+static void
+mail_attachment_bar_unselect_all (EAttachmentView *view)
+{
+ EMailAttachmentBarPrivate *priv;
+
+ priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (view);
+ view = E_ATTACHMENT_VIEW (priv->icon_view);
+
+ e_attachment_view_unselect_all (view);
+}
+
+static void
+mail_attachment_bar_class_init (EMailAttachmentBarClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EMailAttachmentBarPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = mail_attachment_bar_set_property;
+ object_class->get_property = mail_attachment_bar_get_property;
+ object_class->dispose = mail_attachment_bar_dispose;
+ object_class->constructed = mail_attachment_bar_constructed;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ACTIVE_VIEW,
+ g_param_spec_int (
+ "active-view",
+ "Active View",
+ NULL,
+ 0,
+ NUM_VIEWS,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_EXPANDED,
+ g_param_spec_boolean (
+ "expanded",
+ "Expanded",
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_override_property (
+ object_class, PROP_EDITABLE, "editable");
+}
+
+static void
+mail_attachment_bar_iface_init (EAttachmentViewIface *iface)
+{
+ iface->get_private = mail_attachment_bar_get_private;
+ iface->get_store = mail_attachment_bar_get_store;
+ iface->get_path_at_pos = mail_attachment_bar_get_path_at_pos;
+ iface->get_selected_paths = mail_attachment_bar_get_selected_paths;
+ iface->path_is_selected = mail_attachment_bar_path_is_selected;
+ iface->select_path = mail_attachment_bar_select_path;
+ iface->unselect_path = mail_attachment_bar_unselect_path;
+ iface->select_all = mail_attachment_bar_select_all;
+ iface->unselect_all = mail_attachment_bar_unselect_all;
+}
+
+static void
+mail_attachment_bar_init (EMailAttachmentBar *bar)
+{
+ GtkTreeSelection *selection;
+ GtkSizeGroup *size_group;
+ GtkWidget *container;
+ GtkWidget *widget;
+
+ bar->priv = E_MAIL_ATTACHMENT_BAR_GET_PRIVATE (bar);
+ bar->priv->model = e_attachment_store_new ();
+
+ gtk_box_set_spacing (GTK_BOX (bar), 6);
+
+ /* Keep the expander label and save button the same height. */
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+
+ /* Construct the Controls */
+
+ container = GTK_WIDGET (bar);
+
+ widget = gtk_hbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_expander_new (NULL);
+ gtk_expander_set_spacing (GTK_EXPANDER (widget), 0);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->expander = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_alignment_new (1.0, 0.5, 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_combo_box_new_text ();
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Icon View"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("List View"));
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ bar->priv->combo_box = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = bar->priv->expander;
+
+ widget = gtk_hbox_new (FALSE, 0);
+ gtk_size_group_add_widget (size_group, widget);
+ gtk_expander_set_label_widget (GTK_EXPANDER (container), widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = gtk_image_new_from_icon_name (
+ "mail-attachment", GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->status_icon = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new (NULL);
+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->status_label = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ /* Construct the Attachment Views */
+
+ container = GTK_WIDGET (bar);
+
+ widget = gtk_vbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ bar->priv->vbox = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = bar->priv->vbox;
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ bar->priv->icon_frame = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_attachment_icon_view_new ();
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_icon_view_set_model (GTK_ICON_VIEW (widget), bar->priv->model);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ bar->priv->icon_view = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = bar->priv->vbox;
+
+ widget = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
+ bar->priv->tree_frame = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ container = widget;
+
+ widget = e_attachment_tree_view_new ();
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (widget), bar->priv->model);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+ bar->priv->tree_view = g_object_ref (widget);
+ gtk_widget_show (widget);
+
+ selection = gtk_tree_view_get_selection (
+ GTK_TREE_VIEW (bar->priv->tree_view));
+
+ g_signal_connect_swapped (
+ selection, "changed",
+ G_CALLBACK (mail_attachment_bar_sync_icon_view), bar);
+
+ g_signal_connect_swapped (
+ bar->priv->icon_view, "selection-changed",
+ G_CALLBACK (mail_attachment_bar_sync_tree_view), bar);
+
+ g_signal_connect_swapped (
+ bar->priv->model, "notify::num-attachments",
+ G_CALLBACK (mail_attachment_bar_update_status), bar);
+
+ g_signal_connect_swapped (
+ bar->priv->model, "notify::total-size",
+ G_CALLBACK (mail_attachment_bar_update_status), bar);
+
+ g_object_unref (size_group);
+}
+
+GType
+e_mail_attachment_bar_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (EMailAttachmentBarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) mail_attachment_bar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EMailAttachmentBar),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) mail_attachment_bar_init,
+ NULL /* value_table */
+ };
+
+ static const GInterfaceInfo iface_info = {
+ (GInterfaceInitFunc) mail_attachment_bar_iface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface_data */
+ };
+
+ type = g_type_register_static (
+ GTK_TYPE_VBOX, "EMailAttachmentBar", &type_info, 0);
+
+ g_type_add_interface_static (
+ type, E_TYPE_ATTACHMENT_VIEW, &iface_info);
+ }
+
+ return type;
+}
+
+GtkWidget *
+e_mail_attachment_bar_new (void)
+{
+ return g_object_new (
+ E_TYPE_MAIL_ATTACHMENT_BAR,
+ "editable", FALSE, NULL);
+}
+
+gint
+e_mail_attachment_bar_get_active_view (EMailAttachmentBar *bar)
+{
+ g_return_val_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar), 0);
+
+ return bar->priv->active_view;
+}
+
+void
+e_mail_attachment_bar_set_active_view (EMailAttachmentBar *bar,
+ gint active_view)
+{
+ g_return_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar));
+ g_return_if_fail (active_view >= 0 && active_view < NUM_VIEWS);
+
+ bar->priv->active_view = active_view;
+
+ if (active_view == 0) {
+ gtk_widget_show (bar->priv->icon_frame);
+ gtk_widget_hide (bar->priv->tree_frame);
+ } else {
+ gtk_widget_hide (bar->priv->icon_frame);
+ gtk_widget_show (bar->priv->tree_frame);
+ }
+
+ g_object_notify (G_OBJECT (bar), "active-view");
+}
+
+gboolean
+e_mail_attachment_bar_get_expanded (EMailAttachmentBar *bar)
+{
+ g_return_val_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar), FALSE);
+
+ return bar->priv->expanded;
+}
+
+void
+e_mail_attachment_bar_set_expanded (EMailAttachmentBar *bar,
+ gboolean expanded)
+{
+ g_return_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar));
+
+ bar->priv->expanded = expanded;
+
+ g_object_notify (G_OBJECT (bar), "expanded");
+}
diff --git a/mail/e-mail-attachment-bar.h b/mail/e-mail-attachment-bar.h
new file mode 100644
index 0000000000..e32f6e2ede
--- /dev/null
+++ b/mail/e-mail-attachment-bar.h
@@ -0,0 +1,77 @@
+/*
+ * e-mail-attachment-bar.h
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef E_MAIL_ATTACHMENT_BAR_H
+#define E_MAIL_ATTACHMENT_BAR_H
+
+#include <gtk/gtk.h>
+#include <widgets/misc/e-attachment-view.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_ATTACHMENT_BAR \
+ (e_mail_attachment_bar_get_type ())
+#define E_MAIL_ATTACHMENT_BAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBar))
+#define E_MAIL_ATTACHMENT_BAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarClass))
+#define E_IS_MAIL_ATTACHMENT_BAR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_MAIL_ATTACHMENT_BAR))
+#define E_IS_MAIL_ATTACHMENT_BAR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_MAIL_ATTACHMENT_BAR))
+#define E_MAIL_ATTACHMENT_BAR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_MAIL_ATTACHMENT_BAR, EMailAttachmentBarClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EMailAttachmentBar EMailAttachmentBar;
+typedef struct _EMailAttachmentBarClass EMailAttachmentBarClass;
+typedef struct _EMailAttachmentBarPrivate EMailAttachmentBarPrivate;
+
+struct _EMailAttachmentBar {
+ GtkVBox parent;
+ EMailAttachmentBarPrivate *priv;
+};
+
+struct _EMailAttachmentBarClass {
+ GtkVBoxClass parent_class;
+};
+
+GType e_mail_attachment_bar_get_type (void);
+GtkWidget * e_mail_attachment_bar_new (void);
+gint e_mail_attachment_bar_get_active_view
+ (EMailAttachmentBar *bar);
+void e_mail_attachment_bar_set_active_view
+ (EMailAttachmentBar *bar,
+ gint active_view);
+gboolean e_mail_attachment_bar_get_expanded
+ (EMailAttachmentBar *bar);
+void e_mail_attachment_bar_set_expanded
+ (EMailAttachmentBar *bar,
+ gboolean expanded);
+
+G_END_DECLS
+
+#endif /* E_MAIL_ATTACHMENT_BAR_H */
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 <pthread.h>,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;
}
@@ -1481,23 +1475,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)
{
#if 0 /* KILL-BONOBO */
@@ -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, "<td><object classid=\"%s\"></object></td>", classid);
-
-}
static void
efhd_message_add_bar(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info)
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 6308947a26..fae1566876 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -200,10 +200,6 @@ efh_format_exec (struct _format_msg *m)
handle = em_format_find_handler((EMFormat *)m->format, "x-evolution/message/rfc822");
if (handle)
handle->handler((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message, handle);
- handle = em_format_find_handler((EMFormat *)m->format, "x-evolution/message/post-header-closure");
- if (handle && !((EMFormat *)m->format)->print)
- handle->handler((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message, handle);
-
}
camel_stream_flush((CamelStream *)m->estream);