evolution r37513 - in branches/kill-bonobo: calendar/gui calendar/gui/dialogs mail widgets/misc
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r37513 - in branches/kill-bonobo: calendar/gui calendar/gui/dialogs mail widgets/misc
- Date: Sat, 11 Apr 2009 00:14:51 +0000 (UTC)
Author: mbarnes
Date: Sat Apr 11 00:14:51 2009
New Revision: 37513
URL: http://svn.gnome.org/viewvc/evolution?rev=37513&view=rev
Log:
Bug fixes and formerly unfinished bits of the attachment rewrite.
Modified:
branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c
branches/kill-bonobo/calendar/gui/e-attachment-handler-calendar.c
branches/kill-bonobo/mail/e-attachment-handler-mail.c
branches/kill-bonobo/widgets/misc/e-attachment-handler-image.c
branches/kill-bonobo/widgets/misc/e-attachment-store.c
branches/kill-bonobo/widgets/misc/e-attachment-store.h
branches/kill-bonobo/widgets/misc/e-attachment-tree-view.c
branches/kill-bonobo/widgets/misc/e-attachment-view.c
branches/kill-bonobo/widgets/misc/e-attachment-view.h
branches/kill-bonobo/widgets/misc/e-attachment.c
Modified: branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c
==============================================================================
--- branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c (original)
+++ branches/kill-bonobo/calendar/gui/dialogs/comp-editor.c Sat Apr 11 00:14:51 2009
@@ -95,7 +95,7 @@
GtkNotebook *notebook;
/* Attachment handling */
- GtkWidget *attachment_paned;
+ GtkWidget *attachment_view;
/* Manages menus and toolbars */
GtkUIManager *manager;
@@ -234,7 +234,7 @@
{
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
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);
Modified: branches/kill-bonobo/calendar/gui/e-attachment-handler-calendar.c
==============================================================================
--- branches/kill-bonobo/calendar/gui/e-attachment-handler-calendar.c (original)
+++ branches/kill-bonobo/calendar/gui/e-attachment-handler-calendar.c Sat Apr 11 00:14:51 2009
@@ -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 @@
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 @@
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) {
Modified: branches/kill-bonobo/mail/e-attachment-handler-mail.c
==============================================================================
--- branches/kill-bonobo/mail/e-attachment-handler-mail.c (original)
+++ branches/kill-bonobo/mail/e-attachment-handler-mail.c Sat Apr 11 00:14:51 2009
@@ -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 @@
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 @@
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 @@
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 @@
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) {
Modified: branches/kill-bonobo/widgets/misc/e-attachment-handler-image.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-handler-image.c (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-handler-image.c Sat Apr 11 00:14:51 2009
@@ -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 @@
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 @@
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) {
Modified: branches/kill-bonobo/widgets/misc/e-attachment-store.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-store.c (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-store.c Sat Apr 11 00:14:51 2009
@@ -213,7 +213,7 @@
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 */
Modified: branches/kill-bonobo/widgets/misc/e-attachment-store.h
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-store.h (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-store.h Sat Apr 11 00:14:51 2009
@@ -63,7 +63,7 @@
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 */
Modified: branches/kill-bonobo/widgets/misc/e-attachment-tree-view.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-tree-view.c (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-tree-view.c Sat Apr 11 00:14:51 2009
@@ -493,7 +493,7 @@
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 @@
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);
Modified: branches/kill-bonobo/widgets/misc/e-attachment-view.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-view.c (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-view.c Sat Apr 11 00:14:51 2009
@@ -1456,6 +1456,28 @@
}
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)
{
Modified: branches/kill-bonobo/widgets/misc/e-attachment-view.h
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment-view.h (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment-view.h Sat Apr 11 00:14:51 2009
@@ -206,6 +206,9 @@
/* 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);
Modified: branches/kill-bonobo/widgets/misc/e-attachment.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-attachment.c (original)
+++ branches/kill-bonobo/widgets/misc/e-attachment.c Sat Apr 11 00:14:51 2009
@@ -136,6 +136,7 @@
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 @@
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]