diff options
author | Larry Ewing <lewing@ximian.com> | 2002-10-02 04:22:11 +0800 |
---|---|---|
committer | Larry Ewing <lewing@src.gnome.org> | 2002-10-02 04:22:11 +0800 |
commit | c876eb6b4bff1b10cc56bfd11c6244f779914794 (patch) | |
tree | d3e1c0fd9146fadb9f059c3a883947b33d775c1c | |
parent | e165cce8759d45fb5bee6735d54697e384cdcbe5 (diff) | |
download | gsoc2013-evolution-c876eb6b4bff1b10cc56bfd11c6244f779914794.tar.gz gsoc2013-evolution-c876eb6b4bff1b10cc56bfd11c6244f779914794.tar.zst gsoc2013-evolution-c876eb6b4bff1b10cc56bfd11c6244f779914794.zip |
add support for dragging the content type directly.
2002-10-01 Larry Ewing <lewing@ximian.com>
* mail-display.c (drag_data_get_cb): add support for dragging the
content type directly.
(do_attachment_header): add the target for the mime type to the
drag source.
svn path=/trunk/; revision=18288
-rw-r--r-- | mail/ChangeLog | 7 | ||||
-rw-r--r-- | mail/mail-display.c | 40 |
2 files changed, 44 insertions, 3 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 69d2cf5cd8..0d584ee783 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2002-10-01 Larry Ewing <lewing@ximian.com> + + * mail-display.c (drag_data_get_cb): add support for dragging the + content type directly. + (do_attachment_header): add the target for the mime type to the + drag source. + 2002-10-01 Jeffrey Stedfast <fejj@ximian.com> * mail-config-druid.c (get_fn): Connect to the changed signal for diff --git a/mail/mail-display.c b/mail/mail-display.c index 4865c11909..3cfb5bf4e7 100644 --- a/mail/mail-display.c +++ b/mail/mail-display.c @@ -149,10 +149,12 @@ static GHashTable *thumbnail_cache = NULL; enum DndTargetType { DND_TARGET_TYPE_TEXT_URI_LIST, + DND_TARGET_TYPE_PART_MIME_TYPE }; static GtkTargetEntry drag_types[] = { { TEXT_URI_LIST_TYPE, 0, DND_TARGET_TYPE_TEXT_URI_LIST }, + { NULL, 0, DND_TARGET_TYPE_PART_MIME_TYPE } }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); @@ -868,7 +870,7 @@ drag_data_get_cb (GtkWidget *widget, CamelMimePart *part = user_data; const char *filename, *tmpdir; char *uri_list; - + switch (info) { case DND_TARGET_TYPE_TEXT_URI_LIST: /* Kludge around Nautilus requesting the same data many times */ @@ -903,8 +905,34 @@ drag_data_get_cb (GtkWidget *widget, gtk_selection_data_set (selection_data, selection_data->target, 8, uri_list, strlen (uri_list)); - gtk_object_set_data_full (GTK_OBJECT (widget), "uri-list", uri_list, g_free); + gtk_object_set_data_full (GTK_OBJECT (widget), "uri-list", uri_list, g_free); + break; + case DND_TARGET_TYPE_PART_MIME_TYPE: + if (header_content_type_is (part->content_type, "text", "*")) { + GByteArray *ba; + + ba = mail_format_get_data_wrapper_text (part, NULL); + if (ba) { + gtk_selection_data_set (selection_data, selection_data->target, 8, + ba->data, ba->len); + g_byte_array_free (ba, TRUE); + } + } else { + CamelDataWrapper *wrapper; + CamelStream *cstream; + GByteArray *ba; + ba = g_byte_array_new (); + + cstream = camel_stream_mem_new_with_byte_array (ba); + wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + camel_data_wrapper_write_to_stream (wrapper, cstream); + + gtk_selection_data_set (selection_data, selection_data->target, 8, + ba->data, ba->len); + + camel_object_unref (CAMEL_OBJECT (cstream)); + } break; default: g_assert_not_reached (); @@ -971,14 +999,20 @@ do_attachment_header (GtkHTML *html, GtkHTMLEmbedded *eb, gtk_widget_set_sensitive (button, FALSE); /* Drag & Drop */ + drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = header_content_type_simple(part->content_type); + g_strdown (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); + gtk_drag_source_set (button, GDK_BUTTON1_MASK, drag_types, num_drag_types, - GDK_ACTION_MOVE); + GDK_ACTION_COPY); gtk_signal_connect (GTK_OBJECT (button), "drag-data-get", drag_data_get_cb, part); gtk_signal_connect (GTK_OBJECT (button), "drag-data-delete", drag_data_delete_cb, part); + g_free (drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target); + drag_types[DND_TARGET_TYPE_PART_MIME_TYPE].target = NULL; + hbox = gtk_hbox_new (FALSE, 2); gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); |