aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/dialogs/comp-editor.c24
-rw-r--r--calendar/gui/e-attachment-handler-calendar.c9
-rw-r--r--mail/e-attachment-handler-mail.c159
-rw-r--r--widgets/misc/e-attachment-handler-image.c9
-rw-r--r--widgets/misc/e-attachment-store.c2
-rw-r--r--widgets/misc/e-attachment-store.h2
-rw-r--r--widgets/misc/e-attachment-tree-view.c4
-rw-r--r--widgets/misc/e-attachment-view.c22
-rw-r--r--widgets/misc/e-attachment-view.h3
-rw-r--r--widgets/misc/e-attachment.c10
10 files changed, 203 insertions, 41 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index d2226e4d2a..9926b8cea2 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -95,7 +95,7 @@ struct _CompEditorPrivate {
GtkNotebook *notebook;
/* Attachment handling */
- GtkWidget *attachment_paned;
+ GtkWidget *attachment_view;
/* Manages menus and toolbars */
GtkUIManager *manager;
@@ -234,7 +234,7 @@ drag_data_received (CompEditor *editor,
{
EAttachmentView *view;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
e_attachment_view_drag_data_received (
view, context, x, y, selection, info, time);
@@ -249,7 +249,7 @@ drag_motion (CompEditor *editor,
{
EAttachmentView *view;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
return e_attachment_view_drag_motion (view, context, x, y, time);
}
@@ -269,7 +269,7 @@ get_attachment_list (CompEditor *editor)
e_cal_component_get_uid (editor->priv->comp, &comp_uid);
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
model = GTK_TREE_MODEL (store);
@@ -677,7 +677,7 @@ action_attach_cb (GtkAction *action,
EAttachmentStore *store;
EAttachmentView *view;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
e_attachment_store_run_load_dialog (store, GTK_WINDOW (editor));
@@ -813,7 +813,7 @@ action_save_cb (GtkAction *action,
gboolean read_only, correct = FALSE;
ECalComponent *comp;
- view = E_ATTACHMENT_VIEW (priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (priv->attachment_view);
store = e_attachment_view_get_store (view);
if (e_attachment_store_get_num_loading (store) > 0) {
@@ -1600,11 +1600,11 @@ comp_editor_init (CompEditor *editor)
widget = e_attachment_paned_new ();
gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
- priv->attachment_paned = g_object_ref (widget);
+ priv->attachment_view = g_object_ref (widget);
gtk_widget_show (widget);
container = e_attachment_paned_get_content_area (
- E_ATTACHMENT_PANED (priv->attachment_paned));
+ E_ATTACHMENT_PANED (priv->attachment_view));
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
@@ -1614,7 +1614,7 @@ comp_editor_init (CompEditor *editor)
/* Add a GtkRecentAction to the "individual" action group. */
action_group = comp_editor_get_action_group (editor, "individual");
- view = E_ATTACHMENT_VIEW (priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (priv->attachment_view);
action = e_attachment_view_recent_action_new (
view, "attach-recent", _("Recent _Documents"));
gtk_action_group_add_action (action_group, action);
@@ -2242,7 +2242,7 @@ set_attachment_list (CompEditor *editor, GSList *attach_list)
EAttachmentView *view;
GSList *iter = NULL;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
if (e_attachment_store_get_num_attachments (store) > 0) {
@@ -2274,7 +2274,7 @@ fill_widgets (CompEditor *editor)
CompEditorPrivate *priv;
GList *l;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
priv = editor->priv;
@@ -2622,7 +2622,7 @@ comp_editor_get_mime_attach_list (CompEditor *editor)
GSList *attach_list = NULL;
gboolean valid;
- view = E_ATTACHMENT_VIEW (editor->priv->attachment_paned);
+ view = E_ATTACHMENT_VIEW (editor->priv->attachment_view);
store = e_attachment_view_get_store (view);
model = GTK_TREE_MODEL (store);
diff --git a/calendar/gui/e-attachment-handler-calendar.c b/calendar/gui/e-attachment-handler-calendar.c
index a3ad62cfab..5beb6e07d3 100644
--- a/calendar/gui/e-attachment-handler-calendar.c
+++ b/calendar/gui/e-attachment-handler-calendar.c
@@ -21,7 +21,6 @@
#include "e-attachment-handler-calendar.h"
-#include <config.h>
#include <glib/gi18n.h>
#include <libical/ical.h>
#include <libecal/e-cal.h>
@@ -438,7 +437,6 @@ attachment_handler_calendar_constructed (GObject *object)
EAttachmentView *view;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- const gchar *domain = GETTEXT_PACKAGE;
GError *error = NULL;
handler = E_ATTACHMENT_HANDLER (object);
@@ -447,16 +445,13 @@ attachment_handler_calendar_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
view = e_attachment_handler_get_view (handler);
- ui_manager = e_attachment_view_get_ui_manager (view);
- action_group = gtk_action_group_new ("calendar");
- gtk_action_group_set_translation_domain (action_group, domain);
+ action_group = e_attachment_view_add_action_group (view, "calendar");
gtk_action_group_add_actions (
action_group, standard_entries,
G_N_ELEMENTS (standard_entries), handler);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
+ ui_manager = e_attachment_view_get_ui_manager (view);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
if (error != NULL) {
diff --git a/mail/e-attachment-handler-mail.c b/mail/e-attachment-handler-mail.c
index b7be3b6b38..df4c0a9e3e 100644
--- a/mail/e-attachment-handler-mail.c
+++ b/mail/e-attachment-handler-mail.c
@@ -21,11 +21,13 @@
#include "e-attachment-handler-mail.h"
-#include <config.h>
#include <glib/gi18n.h>
+#include <camel/camel-folder.h>
#include <camel/camel-stream-mem.h>
+#include "e-util/e-error.h"
#include "mail/em-composer-utils.h"
+#include "mail/mail-tools.h"
#define E_ATTACHMENT_HANDLER_MAIL_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -220,6 +222,21 @@ attachment_handler_mail_x_uid_list (EAttachmentView *view,
guint time)
{
static GdkAtom atom = GDK_NONE;
+ CamelException ex = CAMEL_EXCEPTION_INITIALISER;
+ CamelDataWrapper *wrapper;
+ CamelMimeMessage *message;
+ CamelMultipart *multipart;
+ CamelMimePart *mime_part;
+ CamelFolder *folder = NULL;
+ EAttachment *attachment;
+ EAttachmentStore *store;
+ GPtrArray *uids;
+ const gchar *data;
+ const gchar *cp, *end;
+ gchar *description;
+ gpointer parent;
+ gint length;
+ guint ii;
if (G_UNLIKELY (atom == GDK_NONE))
atom = gdk_atom_intern_static_string ("x-uid-list");
@@ -227,7 +244,137 @@ attachment_handler_mail_x_uid_list (EAttachmentView *view,
if (gtk_selection_data_get_target (selection_data) != atom)
return;
- return; /* REMOVE ME */
+ store = e_attachment_view_get_store (view);
+
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL;
+
+ uids = g_ptr_array_new ();
+
+ data = (const gchar *) gtk_selection_data_get_data (selection_data);
+ length = gtk_selection_data_get_length (selection_data);
+
+ /* The UID list is delimited by NUL characters.
+ * Brilliant. So we can't use g_strsplit(). */
+
+ cp = data;
+ end = data + length;
+
+ while (cp < end) {
+ const gchar *start = cp;
+
+ while (cp < end && *cp != '\0')
+ cp++;
+
+ /* Skip the first string. */
+ if (start > data)
+ g_ptr_array_add (uids, g_strndup (start, cp - start));
+
+ cp++;
+ }
+
+ if (uids->len == 0)
+ goto exit;
+
+ /* The first string is the folder URI. */
+ folder = mail_tool_uri_to_folder (data, 0, &ex);
+ if (folder == NULL)
+ goto exit;
+
+ /* Handle one message. */
+ if (uids->len == 1) {
+ message = camel_folder_get_message (
+ folder, uids->pdata[0], &ex);
+ if (message == NULL)
+ goto exit;
+
+ attachment = e_attachment_new_for_message (message);
+ e_attachment_store_add_attachment (store, attachment);
+ e_attachment_load_async (
+ attachment, (GAsyncReadyCallback)
+ e_attachment_load_handle_error, parent);
+ g_object_unref (attachment);
+
+ camel_object_unref (message);
+ goto exit;
+ }
+
+ /* Build a multipart/digest message out of the UIDs. */
+
+ multipart = camel_multipart_new ();
+ wrapper = CAMEL_DATA_WRAPPER (multipart);
+ camel_data_wrapper_set_mime_type (wrapper, "multipart/digest");
+ camel_multipart_set_boundary (multipart, NULL);
+
+ for (ii = 0; ii < uids->len; ii++) {
+ message = camel_folder_get_message (
+ folder, uids->pdata[ii], &ex);
+ if (message == NULL) {
+ camel_object_unref (multipart);
+ goto exit;
+ }
+
+ mime_part = camel_mime_part_new ();
+ wrapper = CAMEL_DATA_WRAPPER (message);
+ camel_mime_part_set_disposition (mime_part, "inline");
+ camel_medium_set_content_object (
+ CAMEL_MEDIUM (mime_part), wrapper);
+ camel_mime_part_set_content_type (mime_part, "message/rfc822");
+ camel_multipart_add_part (multipart, mime_part);
+ camel_object_unref (mime_part);
+
+ camel_object_unref (message);
+ }
+
+ mime_part = camel_mime_part_new ();
+ wrapper = CAMEL_DATA_WRAPPER (multipart);
+ camel_medium_set_content_object (CAMEL_MEDIUM (mime_part), wrapper);
+
+ /* Translators: This is only for multiple messages. */
+ description = g_strdup_printf (_("%d attached messages"), uids->len);
+ camel_mime_part_set_description (mime_part, description);
+ g_free (description);
+
+ attachment = e_attachment_new ();
+ e_attachment_set_mime_part (attachment, mime_part);
+ e_attachment_store_add_attachment (store, attachment);
+ e_attachment_load_async (
+ attachment, (GAsyncReadyCallback)
+ e_attachment_load_handle_error, parent);
+ g_object_unref (attachment);
+
+ camel_object_unref (mime_part);
+ camel_object_unref (multipart);
+
+exit:
+ if (camel_exception_is_set (&ex)) {
+ gchar *folder_name;
+
+ if (folder != NULL)
+ camel_object_get (
+ folder, NULL, CAMEL_FOLDER_NAME,
+ &folder_name, NULL);
+ else
+ folder_name = g_strdup (data);
+
+ e_error_run (
+ parent, "mail-composer:attach-nomessages",
+ folder_name, camel_exception_get_description (&ex),
+ NULL);
+
+ if (folder != NULL)
+ camel_object_free (
+ folder, CAMEL_FOLDER_NAME, folder_name);
+ else
+ g_free (folder_name);
+
+ camel_exception_clear (&ex);
+ }
+
+ if (folder != NULL)
+ camel_object_unref (folder);
+
+ g_ptr_array_free (uids, TRUE);
g_signal_stop_emission_by_name (view, "drag-data-received");
}
@@ -272,7 +419,6 @@ attachment_handler_mail_constructed (GObject *object)
EAttachmentView *view;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- const gchar *domain = GETTEXT_PACKAGE;
GError *error = NULL;
handler = E_ATTACHMENT_HANDLER (object);
@@ -281,16 +427,13 @@ attachment_handler_mail_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
view = e_attachment_handler_get_view (handler);
- ui_manager = e_attachment_view_get_ui_manager (view);
- action_group = gtk_action_group_new ("mail");
- gtk_action_group_set_translation_domain (action_group, domain);
+ action_group = e_attachment_view_add_action_group (view, "mail");
gtk_action_group_add_actions (
action_group, standard_entries,
G_N_ELEMENTS (standard_entries), view);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
+ ui_manager = e_attachment_view_get_ui_manager (view);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
if (error != NULL) {
diff --git a/widgets/misc/e-attachment-handler-image.c b/widgets/misc/e-attachment-handler-image.c
index 02357facc9..ba5f8d759c 100644
--- a/widgets/misc/e-attachment-handler-image.c
+++ b/widgets/misc/e-attachment-handler-image.c
@@ -21,7 +21,6 @@
#include "e-attachment-handler-image.h"
-#include <config.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
@@ -205,7 +204,6 @@ attachment_handler_image_constructed (GObject *object)
EAttachmentView *view;
GtkActionGroup *action_group;
GtkUIManager *ui_manager;
- const gchar *domain = GETTEXT_PACKAGE;
GError *error = NULL;
handler = E_ATTACHMENT_HANDLER (object);
@@ -215,16 +213,13 @@ attachment_handler_image_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object);
view = e_attachment_handler_get_view (handler);
- ui_manager = e_attachment_view_get_ui_manager (view);
- action_group = gtk_action_group_new ("image");
- gtk_action_group_set_translation_domain (action_group, domain);
+ action_group = e_attachment_view_add_action_group (view, "image");
gtk_action_group_add_actions (
action_group, standard_entries,
G_N_ELEMENTS (standard_entries), object);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group);
+ ui_manager = e_attachment_view_get_ui_manager (view);
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
if (error != NULL) {
diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c
index 24cc89b366..4a74bab915 100644
--- a/widgets/misc/e-attachment-store.c
+++ b/widgets/misc/e-attachment-store.c
@@ -213,7 +213,7 @@ attachment_store_init (EAttachmentStore *store)
types[column++] = E_TYPE_ATTACHMENT; /* COLUMN_ATTACHMENT */
types[column++] = G_TYPE_STRING; /* COLUMN_CAPTION */
types[column++] = G_TYPE_STRING; /* COLUMN_CONTENT_TYPE */
- types[column++] = G_TYPE_STRING; /* COLUMN_DISPLAY_NAME */
+ types[column++] = G_TYPE_STRING; /* COLUMN_DESCRIPTION */
types[column++] = G_TYPE_ICON; /* COLUMN_ICON */
types[column++] = G_TYPE_BOOLEAN; /* COLUMN_LOADING */
types[column++] = G_TYPE_INT; /* COLUMN_PERCENT */
diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h
index a6dd702b97..5d2271cba0 100644
--- a/widgets/misc/e-attachment-store.h
+++ b/widgets/misc/e-attachment-store.h
@@ -63,7 +63,7 @@ enum {
E_ATTACHMENT_STORE_COLUMN_ATTACHMENT, /* E_TYPE_ATTACHMENT */
E_ATTACHMENT_STORE_COLUMN_CAPTION, /* G_TYPE_STRING */
E_ATTACHMENT_STORE_COLUMN_CONTENT_TYPE, /* G_TYPE_STRING */
- E_ATTACHMENT_STORE_COLUMN_DISPLAY_NAME, /* G_TYPE_STRING */
+ E_ATTACHMENT_STORE_COLUMN_DESCRIPTION, /* G_TYPE_STRING */
E_ATTACHMENT_STORE_COLUMN_ICON, /* G_TYPE_ICON */
E_ATTACHMENT_STORE_COLUMN_LOADING, /* G_TYPE_BOOLEAN */
E_ATTACHMENT_STORE_COLUMN_PERCENT, /* G_TYPE_INT */
diff --git a/widgets/misc/e-attachment-tree-view.c b/widgets/misc/e-attachment-tree-view.c
index f8a74d293f..f2c17cb078 100644
--- a/widgets/misc/e-attachment-tree-view.c
+++ b/widgets/misc/e-attachment-tree-view.c
@@ -493,7 +493,7 @@ attachment_tree_view_init (EAttachmentTreeView *tree_view)
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_column_set_spacing (column, 3);
- gtk_tree_view_column_set_title (column, _("Name"));
+ gtk_tree_view_column_set_title (column, _("Description"));
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
renderer = gtk_cell_renderer_pixbuf_new ();
@@ -511,7 +511,7 @@ attachment_tree_view_init (EAttachmentTreeView *tree_view)
gtk_tree_view_column_add_attribute (
column, renderer, "text",
- E_ATTACHMENT_STORE_COLUMN_DISPLAY_NAME);
+ E_ATTACHMENT_STORE_COLUMN_DESCRIPTION);
renderer = gtk_cell_renderer_progress_new ();
g_object_set (renderer, "text", _("Loading"), NULL);
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c
index 5c7acd4561..f976b71483 100644
--- a/widgets/misc/e-attachment-view.c
+++ b/widgets/misc/e-attachment-view.c
@@ -1456,6 +1456,28 @@ e_attachment_view_get_action (EAttachmentView *view,
}
GtkActionGroup *
+e_attachment_view_add_action_group (EAttachmentView *view,
+ const gchar *group_name)
+{
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ const gchar *domain;
+
+ g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
+ g_return_val_if_fail (group_name != NULL, NULL);
+
+ ui_manager = e_attachment_view_get_ui_manager (view);
+ domain = GETTEXT_PACKAGE;
+
+ action_group = gtk_action_group_new (group_name);
+ gtk_action_group_set_translation_domain (action_group, domain);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ g_object_unref (action_group);
+
+ return action_group;
+}
+
+GtkActionGroup *
e_attachment_view_get_action_group (EAttachmentView *view,
const gchar *group_name)
{
diff --git a/widgets/misc/e-attachment-view.h b/widgets/misc/e-attachment-view.h
index 8285928c5b..8d1bd328dd 100644
--- a/widgets/misc/e-attachment-view.h
+++ b/widgets/misc/e-attachment-view.h
@@ -206,6 +206,9 @@ void e_attachment_view_drag_data_received
/* Popup Menu Management */
GtkAction * e_attachment_view_get_action (EAttachmentView *view,
const gchar *action_name);
+GtkActionGroup *e_attachment_view_add_action_group
+ (EAttachmentView *view,
+ const gchar *group_name);
GtkActionGroup *e_attachment_view_get_action_group
(EAttachmentView *view,
const gchar *group_name);
diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c
index 16bd9fd26c..a97ea1e70f 100644
--- a/widgets/misc/e-attachment.c
+++ b/widgets/misc/e-attachment.c
@@ -136,6 +136,7 @@ attachment_update_file_info_columns (EAttachment *attachment)
GtkTreeIter iter;
GFileInfo *file_info;
const gchar *content_type;
+ const gchar *description;
const gchar *display_name;
gchar *content_desc;
gchar *display_size;
@@ -162,17 +163,20 @@ attachment_update_file_info_columns (EAttachment *attachment)
content_desc = g_content_type_get_description (content_type);
display_size = g_format_size_for_display (size);
+ description = e_attachment_get_description (attachment);
+ description = (description != NULL) ? description : display_name;
+
if (size > 0)
caption = g_strdup_printf (
- "%s\n(%s)", display_name, display_size);
+ "%s\n(%s)", description, display_size);
else
- caption = g_strdup (display_name);
+ caption = g_strdup (description);
gtk_list_store_set (
GTK_LIST_STORE (model), &iter,
E_ATTACHMENT_STORE_COLUMN_CAPTION, caption,
E_ATTACHMENT_STORE_COLUMN_CONTENT_TYPE, content_desc,
- E_ATTACHMENT_STORE_COLUMN_DISPLAY_NAME, display_name,
+ E_ATTACHMENT_STORE_COLUMN_DESCRIPTION, description,
E_ATTACHMENT_STORE_COLUMN_SIZE, size,
-1);