From 5ec9e5b2287aef03893e0ce310013c99fe1dce4d Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 5 Jun 2000 21:14:32 +0000 Subject: New convenience function. * e-msg-composer.c (e_msg_composer_attach): New convenience function. * e-msg-composer-attachment.c: Store a CamelMimePart rather than filename/description/mime_type info. Also record whether we were told or guessed the MIME type. (e_msg_composer_attachment_new_from_mime_part): New constructor. (e_msg_composer_attachment_edit): Remove the "browse" button. (If the user wants to change the actual file that the attachment is based on, he should delete the attachment and create a new one...) Remove the "Apply" button, because it's not all that useful. Make the MIME type only track the filename if it was guessed rather than being provided. * e-msg-composer-attachment.glade: Remove "browse" and "apply" buttons. Make filename editable. * e-msg-composer-attachment-bar.c (sort): Removed. Send the attachments in the order the user attached them in. (text_changed): Removed, since we weren't enabling the relevant GnomeIconList functionality that would have used this. (update): Don't print the size if it's 0. (attach_to_multipart, etc): adjust for EMsgComposerAttachment changes. (attach_to_multipart): Use 7bit encoding for message/ subparts. (e_msg_composer_attachment_bar_attach_mime_part): New convenience function. svn path=/trunk/; revision=3430 --- composer/ChangeLog | 31 ++++ composer/e-msg-composer-attachment-bar.c | 160 +++++++------------ composer/e-msg-composer-attachment-bar.h | 1 + composer/e-msg-composer-attachment.c | 243 ++++++++++------------------- composer/e-msg-composer-attachment.glade | 241 ++++++++++++---------------- composer/e-msg-composer-attachment.glade.h | 3 +- composer/e-msg-composer-attachment.h | 8 +- composer/e-msg-composer.c | 20 +++ composer/e-msg-composer.h | 2 + 9 files changed, 301 insertions(+), 408 deletions(-) diff --git a/composer/ChangeLog b/composer/ChangeLog index 7abbec4006..8a26689642 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,34 @@ +2000-06-05 Dan Winship + + * e-msg-composer.c (e_msg_composer_attach): New convenience + function. + + * e-msg-composer-attachment.c: Store a CamelMimePart rather than + filename/description/mime_type info. Also record whether we were + told or guessed the MIME type. + (e_msg_composer_attachment_new_from_mime_part): New constructor. + (e_msg_composer_attachment_edit): Remove the "browse" button. (If + the user wants to change the actual file that the attachment is + based on, he should delete the attachment and create a new one...) + Remove the "Apply" button, because it's not all that useful. Make + the MIME type only track the filename if it was guessed rather + than being provided. + + * e-msg-composer-attachment.glade: Remove "browse" and "apply" + buttons. Make filename editable. + + * e-msg-composer-attachment-bar.c (sort): Removed. Send the + attachments in the order the user attached them in. + (text_changed): Removed, since we weren't enabling the relevant + GnomeIconList functionality that would have used this. + (update): Don't print the size if it's 0. + (attach_to_multipart, etc): adjust for EMsgComposerAttachment + changes. + (attach_to_multipart): Use 7bit encoding for message/ subparts. + (e_msg_composer_attachment_bar_attach_mime_part): New convenience + function. + + 2000-06-02 Christopher James Lahey * e-msg-composer.c: Added the ability to save plain text mail. diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c index 5041164d9b..d6749f72c4 100644 --- a/composer/e-msg-composer-attachment-bar.c +++ b/composer/e-msg-composer-attachment-bar.c @@ -98,32 +98,6 @@ size_to_string (gulong size) return size_string; } - -/* Sorting. */ - -static gint -attachment_sort_func (gconstpointer a, gconstpointer b) -{ - const EMsgComposerAttachment *attachment_a, *attachment_b; - - attachment_a = (EMsgComposerAttachment *) a; - attachment_b = (EMsgComposerAttachment *) b; - - return strcmp (attachment_a->description, attachment_b->description); -} - -static void -sort (EMsgComposerAttachmentBar *bar) -{ - EMsgComposerAttachmentBarPrivate *priv; - - priv = bar->priv; - - priv->attachments = g_list_sort (priv->attachments, - attachment_sort_func); -} - - /* Attachment handling functions. */ static void @@ -146,13 +120,9 @@ attachment_changed_cb (EMsgComposerAttachment *attachment, } static void -add_from_file (EMsgComposerAttachmentBar *bar, - const gchar *file_name) +add_common (EMsgComposerAttachmentBar *bar, + EMsgComposerAttachment *attachment) { - EMsgComposerAttachment *attachment; - - attachment = e_msg_composer_attachment_new (file_name); - gtk_signal_connect (GTK_OBJECT (attachment), "changed", GTK_SIGNAL_FUNC (attachment_changed_cb), bar); @@ -161,12 +131,25 @@ add_from_file (EMsgComposerAttachmentBar *bar, attachment); bar->priv->num_attachments++; - sort (bar); update (bar); gtk_signal_emit (GTK_OBJECT (bar), signals[CHANGED]); } +static void +add_from_mime_part (EMsgComposerAttachmentBar *bar, + CamelMimePart *part) +{ + add_common (bar, e_msg_composer_attachment_new_from_mime_part (part)); +} + +static void +add_from_file (EMsgComposerAttachmentBar *bar, + const gchar *file_name) +{ + add_common (bar, e_msg_composer_attachment_new (file_name)); +} + static void remove_attachment (EMsgComposerAttachmentBar *bar, EMsgComposerAttachment *attachment) @@ -201,30 +184,37 @@ update (EMsgComposerAttachmentBar *bar) for (p = priv->attachments; p != NULL; p = p->next) { EMsgComposerAttachment *attachment; - const gchar *icon_name; - gchar *size_string; - gchar *label; + const gchar *icon_name, *desc; + gchar *size_string, *label, *mime_type; + GMimeContentField *content_type; attachment = p->data; - icon_name = gnome_mime_get_value (attachment->mime_type, - "icon-filename"); + content_type = camel_mime_part_get_content_type (attachment->body); + mime_type = g_strdup_printf ("%s/%s", content_type->type, + content_type->subtype); + icon_name = gnome_mime_get_value (mime_type, "icon-filename"); + g_free (mime_type); /* FIXME we need some better default icon. */ if (icon_name == NULL) icon_name = gnome_mime_get_value ("text/plain", "icon-filename"); - size_string = size_to_string (attachment->size); + desc = camel_mime_part_get_description (attachment->body); + if (!desc) + desc = camel_mime_part_get_filename (attachment->body); + if (!desc) + desc = "attachment"; - /* FIXME: If GnomeIconList honoured "\n", the result would be a - lot better. */ - label = g_strconcat (attachment->description, "\n(", - size_string, ")", NULL); + if (attachment->size) { + size_string = size_to_string (attachment->size); + label = g_strdup_printf ("%s (%s)", desc, size_string); + g_free (size_string); + } else + label = g_strdup (desc); gnome_icon_list_append (icon_list, icon_name, label); - g_free (label); - g_free (size_string); } gnome_icon_list_thaw (icon_list); @@ -468,28 +458,6 @@ button_press_event (GtkWidget *widget, return TRUE; } - -/* GnomeIconList methods. */ - -static gboolean -text_changed (GnomeIconList *gil, - gint num, - const gchar *new_text) -{ - EMsgComposerAttachmentBar *bar; - EMsgComposerAttachment *attachment; - GList *p; - - bar = E_MSG_COMPOSER_ATTACHMENT_BAR (gil); - p = g_list_nth (bar->priv->attachments, num); - attachment = p->data; - - g_free (attachment->description); - attachment->description = g_strdup (new_text); - - return TRUE; -} - /* Initialization. */ @@ -510,8 +478,6 @@ class_init (EMsgComposerAttachmentBarClass *class) widget_class->button_press_event = button_press_event; - icon_list_class->text_changed = text_changed; - /* Setup signals. */ signals[CHANGED] = @@ -605,43 +571,23 @@ static void attach_to_multipart (CamelMultipart *multipart, EMsgComposerAttachment *attachment) { - CamelMimePart *part; - struct stat st; - int fd; - char *data; - - part = camel_mime_part_new (); - fd = open (attachment->file_name, O_RDONLY); - if (fd != -1 && fstat (fd, &st) != -1) { - data = g_malloc (st.st_size); - read (fd, data, st.st_size); - close (fd); - - camel_mime_part_set_content (part, data, st.st_size, - attachment->mime_type); - } else { - g_warning ("couldn't open %s", attachment->file_name); - gtk_object_sink (GTK_OBJECT (part)); - return; - } + GMimeContentField *content_type; - camel_mime_part_set_disposition (part, "attachment"); - camel_mime_part_set_filename (part, - g_basename (attachment->file_name)); - camel_mime_part_set_description (part, attachment->description); + content_type = camel_mime_part_get_content_type (attachment->body); - /* Kludge a bit on CTE. For now, we set QP for text/ and message/ - * and B64 for all else. FIXME. + /* Kludge a bit on CTE. For now, we set QP for text and B64 + * for all else except message (which must be 7bit, 8bit, or + * binary). FIXME. */ + if (!strcasecmp (content_type->type, "text")) { + camel_mime_part_set_encoding (attachment->body, + CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE); + } else if (strcasecmp (content_type->type, "message") != 0) { + camel_mime_part_set_encoding (attachment->body, + CAMEL_MIME_PART_ENCODING_BASE64); + } - if (!strncasecmp (attachment->mime_type, "text/", 5) || - !strncasecmp (attachment->mime_type, "message/", 8)) - camel_mime_part_set_encoding (part, CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE); - else - camel_mime_part_set_encoding (part, CAMEL_MIME_PART_ENCODING_BASE64); - - camel_multipart_add_part (multipart, part); - gtk_object_unref (GTK_OBJECT (part)); + camel_multipart_add_part (multipart, attachment->body); } void @@ -681,7 +627,6 @@ void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name) { - g_return_if_fail (bar != NULL); g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); if (file_name == NULL) @@ -689,3 +634,12 @@ e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, else add_from_file (bar, file_name); } + +void +e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, + CamelMimePart *part) +{ + g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar)); + + add_from_mime_part (bar, part); +} diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h index 803b51a954..1f331c2870 100644 --- a/composer/e-msg-composer-attachment-bar.h +++ b/composer/e-msg-composer-attachment-bar.h @@ -66,6 +66,7 @@ GtkWidget *e_msg_composer_attachment_bar_new (GtkAdjustment *adj); void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart); guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar); void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name); +void e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, CamelMimePart *part); #ifdef __cplusplus } diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index f4741d987f..a0d7398c25 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -30,6 +30,7 @@ #include #include +#include #include "e-msg-composer-attachment.h" @@ -57,19 +58,6 @@ get_mime_type (const gchar *file_name) return mime_type; } -static void -init_mime_type (EMsgComposerAttachment *attachment) -{ - attachment->mime_type = g_strdup (get_mime_type (attachment->file_name)); -} - -static void -set_mime_type (EMsgComposerAttachment *attachment) -{ - g_free (attachment->mime_type); - init_mime_type (attachment); -} - static void changed (EMsgComposerAttachment *attachment) { @@ -86,9 +74,7 @@ destroy (GtkObject *object) attachment = E_MSG_COMPOSER_ATTACHMENT (object); - g_free (attachment->file_name); - g_free (attachment->description); - g_free (attachment->mime_type); + gtk_object_unref (GTK_OBJECT (attachment->body)); } @@ -132,9 +118,7 @@ static void init (EMsgComposerAttachment *msg_composer_attachment) { msg_composer_attachment->editor_gui = NULL; - msg_composer_attachment->file_name = NULL; - msg_composer_attachment->description = NULL; - msg_composer_attachment->mime_type = NULL; + msg_composer_attachment->body = NULL; msg_composer_attachment->size = 0; } @@ -172,23 +156,62 @@ EMsgComposerAttachment * e_msg_composer_attachment_new (const gchar *file_name) { EMsgComposerAttachment *new; + CamelMimePart *part; + CamelDataWrapper *wrapper; + CamelStream *data; struct stat statbuf; g_return_val_if_fail (file_name != NULL, NULL); - new = gtk_type_new (e_msg_composer_attachment_get_type ()); - - new->editor_gui = NULL; - - new->file_name = g_strdup (file_name); - new->description = g_strdup (g_basename (new->file_name)); + data = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0); + if (!data) + return NULL; + wrapper = camel_data_wrapper_new (); + camel_data_wrapper_construct_from_stream (wrapper, data); + gtk_object_unref (GTK_OBJECT (data)); + camel_data_wrapper_set_mime_type (wrapper, get_mime_type (file_name)); + + part = camel_mime_part_new (); + camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); + gtk_object_unref (GTK_OBJECT (wrapper)); + + camel_mime_part_set_disposition (part, "attachment"); + if (strchr (file_name, '/')) + camel_mime_part_set_filename (part, strrchr (file_name, '/') + 1); + else + camel_mime_part_set_filename (part, file_name); + new = e_msg_composer_attachment_new_from_mime_part (part); if (stat (file_name, &statbuf) < 0) new->size = 0; else new->size = statbuf.st_size; + new->guessed_type = TRUE; + + return new; +} + + +/** + * e_msg_composer_attachment_new_from_mime_part: + * @part: a CamelMimePart + * + * Return value: a new EMsgComposerAttachment based on the mime part + **/ +EMsgComposerAttachment * +e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part) +{ + EMsgComposerAttachment *new; - init_mime_type (new); + g_return_val_if_fail (CAMEL_IS_MIME_PART (part), NULL); + + new = gtk_type_new (e_msg_composer_attachment_get_type ()); + + new->editor_gui = NULL; + new->body = part; + gtk_object_ref (GTK_OBJECT (part)); + new->guessed_type = FALSE; + new->size = 0; return new; } @@ -201,7 +224,6 @@ struct _DialogData { GtkEntry *file_name_entry; GtkEntry *description_entry; GtkEntry *mime_type_entry; - GtkWidget *browse_widget; EMsgComposerAttachment *attachment; }; typedef struct _DialogData DialogData; @@ -209,8 +231,6 @@ typedef struct _DialogData DialogData; static void destroy_dialog_data (DialogData *data) { - if (data->browse_widget != NULL) - gtk_widget_destroy (data->browse_widget); g_free (data); } @@ -220,66 +240,15 @@ update_mime_type (DialogData *data) const gchar *mime_type; const gchar *file_name; + if (!data->attachment->guessed_type) + return; + file_name = gtk_entry_get_text (data->file_name_entry); mime_type = get_mime_type (file_name); gtk_entry_set_text (data->mime_type_entry, mime_type); } -static void -browse_ok_cb (GtkWidget *widget, - gpointer data) -{ - GtkWidget *file_selection; - DialogData *dialog_data; - const gchar *file_name; - - dialog_data = (DialogData *) data; - file_selection = gtk_widget_get_toplevel (widget); - - file_name = gtk_file_selection_get_filename - (GTK_FILE_SELECTION (file_selection)); - - gtk_entry_set_text (dialog_data->file_name_entry, file_name); - - update_mime_type (dialog_data); - - gtk_widget_hide (file_selection); -} - -static void -browse (DialogData *data) -{ - if (data->browse_widget == NULL) { - GtkWidget *file_selection; - GtkWidget *cancel_button; - GtkWidget *ok_button; - - file_selection - = gtk_file_selection_new (_("Select attachment")); - gtk_window_set_position (GTK_WINDOW (file_selection), - GTK_WIN_POS_MOUSE); - gtk_window_set_transient_for (GTK_WINDOW (file_selection), - GTK_WINDOW (data->dialog)); - - ok_button = GTK_FILE_SELECTION (file_selection)->ok_button; - gtk_signal_connect (GTK_OBJECT (ok_button), - "clicked", GTK_SIGNAL_FUNC (browse_ok_cb), - data); - - cancel_button - = GTK_FILE_SELECTION (file_selection)->cancel_button; - gtk_signal_connect_object (GTK_OBJECT (cancel_button), - "clicked", - GTK_SIGNAL_FUNC (gtk_widget_hide), - GTK_OBJECT (file_selection)); - - data->browse_widget = file_selection; - } - - gtk_widget_show (GTK_WIDGET (data->browse_widget)); -} - static void set_entry (GladeXML *xml, const gchar *widget_name, @@ -290,19 +259,7 @@ set_entry (GladeXML *xml, entry = GTK_ENTRY (glade_xml_get_widget (xml, widget_name)); if (entry == NULL) g_warning ("Entry for `%s' not found.", widget_name); - gtk_entry_set_text (entry, value); -} - -static void -connect_entry_changed (GladeXML *gui, - const gchar *name, - GtkSignalFunc func, - gpointer data) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget (gui, name); - gtk_signal_connect (GTK_OBJECT (widget), "changed", func, data); + gtk_entry_set_text (entry, value ? value : ""); } static void @@ -318,42 +275,6 @@ connect_widget (GladeXML *gui, gtk_signal_connect (GTK_OBJECT (widget), signal_name, func, data); } -static void -apply (DialogData *data) -{ - EMsgComposerAttachment *attachment; - - attachment = data->attachment; - - g_free (attachment->file_name); - attachment->file_name = g_strdup (gtk_entry_get_text - (data->file_name_entry)); - - g_free (attachment->description); - attachment->description = g_strdup (gtk_entry_get_text - (data->description_entry)); - - g_free (attachment->mime_type); - attachment->mime_type = g_strdup (gtk_entry_get_text - (data->mime_type_entry)); - - changed (attachment); -} - -static void -entry_changed_cb (GtkWidget *widget, gpointer data) -{ - DialogData *dialog_data; - GladeXML *gui; - GtkWidget *apply_button; - - dialog_data = (DialogData *) data; - gui = dialog_data->attachment->editor_gui; - - apply_button = glade_xml_get_widget (gui, "apply_button"); - gtk_widget_set_sensitive (apply_button, TRUE); -} - static void close_cb (GtkWidget *widget, gpointer data) @@ -373,31 +294,29 @@ close_cb (GtkWidget *widget, } static void -apply_cb (GtkWidget *widget, - gpointer data) +ok_cb (GtkWidget *widget, + gpointer data) { DialogData *dialog_data; + EMsgComposerAttachment *attachment; dialog_data = (DialogData *) data; - apply (dialog_data); -} + attachment = dialog_data->attachment; -static void -ok_cb (GtkWidget *widget, - gpointer data) -{ - apply_cb (widget, data); - close_cb (widget, data); -} + camel_mime_part_set_filename (attachment->body, gtk_entry_get_text + (dialog_data->file_name_entry)); -static void -browse_cb (GtkWidget *widget, - gpointer data) -{ - DialogData *dialog_data; + camel_mime_part_set_description (attachment->body, gtk_entry_get_text + (dialog_data->description_entry)); - dialog_data = (DialogData *) data; - browse (dialog_data); + camel_mime_part_set_content_type (attachment->body, gtk_entry_get_text + (dialog_data->mime_type_entry)); + camel_data_wrapper_set_mime_type ( + camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body)), + gtk_entry_get_text (dialog_data->mime_type_entry)); + + changed (attachment); + close_cb (widget, data); } static void @@ -445,7 +364,6 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, GTK_WINDOW (gtk_widget_get_toplevel (parent))); dialog_data = g_new (DialogData, 1); - dialog_data->browse_widget = NULL; dialog_data->attachment = attachment; dialog_data->dialog = glade_xml_get_widget (editor_gui, "dialog"); dialog_data->file_name_entry = GTK_ENTRY (glade_xml_get_widget @@ -459,22 +377,23 @@ e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, "mime_type_entry")); if (attachment != NULL) { - set_entry (editor_gui, "file_name_entry", attachment->file_name); - set_entry (editor_gui, "description_entry", attachment->description); - set_entry (editor_gui, "mime_type_entry", attachment->mime_type); + GMimeContentField *content_type; + char *type; + + set_entry (editor_gui, "file_name_entry", + camel_mime_part_get_filename (attachment->body)); + set_entry (editor_gui, "description_entry", + camel_mime_part_get_description (attachment->body)); + content_type = camel_mime_part_get_content_type (attachment->body); + type = g_strdup_printf ("%s/%s", content_type->type, + content_type->subtype); + set_entry (editor_gui, "mime_type_entry", type); + g_free (type); } - connect_entry_changed (editor_gui, "file_name_entry", - entry_changed_cb, dialog_data); - connect_entry_changed (editor_gui, "description_entry", - entry_changed_cb, dialog_data); - connect_widget (editor_gui, "ok_button", "clicked", ok_cb, dialog_data); - connect_widget (editor_gui, "apply_button", "clicked", apply_cb, dialog_data); connect_widget (editor_gui, "close_button", "clicked", close_cb, dialog_data); - connect_widget (editor_gui, "browse_button", "clicked", browse_cb, dialog_data); - connect_widget (editor_gui, "file_name_entry", "focus_out_event", file_name_focus_out_cb, dialog_data); } diff --git a/composer/e-msg-composer-attachment.glade b/composer/e-msg-composer-attachment.glade index 43b38e2e47..a9717bef69 100644 --- a/composer/e-msg-composer-attachment.glade +++ b/composer/e-msg-composer-attachment.glade @@ -10,17 +10,6 @@ C True True - False - True - True - True - True - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h True e-msg-composer-attachment.glade.h @@ -50,6 +39,41 @@ True + + GtkHButtonBox + GnomeDialog:action_area + dialog-action_area1 + GTK_BUTTONBOX_END + 8 + 85 + 27 + 7 + 0 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + ok_button + True + True + True + GNOME_STOCK_BUTTON_OK + + + + GtkButton + close_button + True + True + GNOME_STOCK_BUTTON_CLOSE + + + GtkTable table1 @@ -64,58 +88,6 @@ True - - GtkLabel - label1 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - False - False - - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - False - False - - - GtkEntry description_entry @@ -140,32 +112,6 @@ - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - False - False - - - GtkHBox hbox3 @@ -201,19 +147,6 @@ True - - - GtkButton - browse_button - 80 - True - - - 0 - False - False - - @@ -240,49 +173,83 @@ False - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - GtkButton - ok_button - True - True - True - GNOME_STOCK_BUTTON_OK + GtkLabel + label3 + + GTK_JUSTIFY_LEFT + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + - GtkButton - apply_button - False - True - True - GNOME_STOCK_BUTTON_APPLY + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 1 + 2 + 0 + 0 + False + False + False + False + True + False + - GtkButton - close_button - True - True - GNOME_STOCK_BUTTON_CLOSE + GtkLabel + label2 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + diff --git a/composer/e-msg-composer-attachment.glade.h b/composer/e-msg-composer-attachment.glade.h index 965ce1b6d5..845aea9b32 100644 --- a/composer/e-msg-composer-attachment.glade.h +++ b/composer/e-msg-composer-attachment.glade.h @@ -5,7 +5,6 @@ */ gchar *s = N_("Attachment properties"); -gchar *s = N_("Description:"); gchar *s = N_("MIME type:"); +gchar *s = N_("Description:"); gchar *s = N_("File name:"); -gchar *s = N_("Browse..."); diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h index 7e3c88238b..e0cd2eb867 100644 --- a/composer/e-msg-composer-attachment.h +++ b/composer/e-msg-composer-attachment.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -46,10 +47,8 @@ struct _EMsgComposerAttachment { GladeXML *editor_gui; - gchar *file_name; - gchar *description; - gchar *mime_type; - + CamelMimePart *body; + gboolean guessed_type; gulong size; }; @@ -62,6 +61,7 @@ struct _EMsgComposerAttachmentClass { GtkType e_msg_composer_attachment_get_type (void); EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name); +EMsgComposerAttachment *e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part); void e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment, GtkWidget *parent); diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 6e77d4ec51..7be0994fa0 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1060,6 +1060,26 @@ e_msg_composer_add_header (EMsgComposer *composer, const char *name, } +/** + * e_msg_composer_attach: + * @composer: a composer object + * @attachment: the CamelMimePart to attach + * + * Attaches @attachment to the message being composed in the composer. + **/ +void +e_msg_composer_attach (EMsgComposer *composer, CamelMimePart *attachment) +{ + EMsgComposerAttachmentBar *bar; + + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + g_return_if_fail (CAMEL_IS_MIME_PART (attachment)); + + bar = E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar); + e_msg_composer_attachment_bar_attach_mime_part (bar, attachment); +} + + /** * e_msg_composer_get_message: * @composer: A message composer widget diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h index cc3826ab67..011db5f3c6 100644 --- a/composer/e-msg-composer.h +++ b/composer/e-msg-composer.h @@ -90,6 +90,8 @@ void e_msg_composer_set_body_text (EMsgComposer *composer, void e_msg_composer_add_header (EMsgComposer *composer, const char *name, const char *value); +void e_msg_composer_attach (EMsgComposer *composer, + CamelMimePart *attachment); CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer); -- cgit v1.2.3