aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-06 05:14:32 +0800
committerDan Winship <danw@src.gnome.org>2000-06-06 05:14:32 +0800
commit5ec9e5b2287aef03893e0ce310013c99fe1dce4d (patch)
treedc296b5a1c41c4424aa0585f76b0b9d7672d227e
parent4a85bdfa85217a08bf415e2dcb3a688bf0254d71 (diff)
downloadgsoc2013-evolution-5ec9e5b2287aef03893e0ce310013c99fe1dce4d.tar.gz
gsoc2013-evolution-5ec9e5b2287aef03893e0ce310013c99fe1dce4d.tar.zst
gsoc2013-evolution-5ec9e5b2287aef03893e0ce310013c99fe1dce4d.zip
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
-rw-r--r--composer/ChangeLog31
-rw-r--r--composer/e-msg-composer-attachment-bar.c160
-rw-r--r--composer/e-msg-composer-attachment-bar.h1
-rw-r--r--composer/e-msg-composer-attachment.c243
-rw-r--r--composer/e-msg-composer-attachment.glade241
-rw-r--r--composer/e-msg-composer-attachment.glade.h3
-rw-r--r--composer/e-msg-composer-attachment.h8
-rw-r--r--composer/e-msg-composer.c20
-rw-r--r--composer/e-msg-composer.h2
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 <danw@helixcode.com>
+
+ * 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 <clahey@helixcode.com>
* 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,13 +131,26 @@ 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);
@@ -469,28 +459,6 @@ button_press_event (GtkWidget *widget,
}
-/* 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. */
static void
@@ -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 <sys/stat.h>
#include <gnome.h>
+#include <camel/camel.h>
#include "e-msg-composer-attachment.h"
@@ -58,19 +59,6 @@ get_mime_type (const gchar *file_name)
}
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)
{
gtk_signal_emit (GTK_OBJECT (attachment), signals[CHANGED]);
@@ -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,6 +240,9 @@ 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);
@@ -227,60 +250,6 @@ update_mime_type (DialogData *data)
}
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,
const gchar *value)
@@ -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
@@ -319,42 +276,6 @@ connect_widget (GladeXML *gui,
}
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 @@
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
- <use_widget_names>False</use_widget_names>
- <output_main_file>True</output_main_file>
- <output_support_files>True</output_support_files>
- <output_build_files>True</output_build_files>
- <backup_source_files>True</backup_source_files>
- <main_source_file>interface.c</main_source_file>
- <main_header_file>interface.h</main_header_file>
- <handler_source_file>callbacks.c</handler_source_file>
- <handler_header_file>callbacks.h</handler_header_file>
- <support_source_file>support.c</support_source_file>
- <support_header_file>support.h</support_header_file>
<output_translatable_strings>True</output_translatable_strings>
<translatable_strings_file>e-msg-composer-attachment.glade.h</translatable_strings_file>
</project>
@@ -51,6 +40,41 @@
</child>
<widget>
+ <class>GtkHButtonBox</class>
+ <child_name>GnomeDialog:action_area</child_name>
+ <name>dialog-action_area1</name>
+ <layout_style>GTK_BUTTONBOX_END</layout_style>
+ <spacing>8</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>7</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ <pack>GTK_PACK_END</pack>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>ok_button</name>
+ <can_default>True</can_default>
+ <has_default>True</has_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>close_button</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
+ </widget>
+ </widget>
+
+ <widget>
<class>GtkTable</class>
<name>table1</name>
<rows>3</rows>
@@ -65,58 +89,6 @@
</child>
<widget>
- <class>GtkLabel</class>
- <name>label1</name>
- <label>Description:</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0.5</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <left_attach>0</left_attach>
- <right_attach>1</right_attach>
- <top_attach>1</top_attach>
- <bottom_attach>2</bottom_attach>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <xexpand>False</xexpand>
- <yexpand>False</yexpand>
- <xshrink>False</xshrink>
- <yshrink>False</yshrink>
- <xfill>False</xfill>
- <yfill>False</yfill>
- </child>
- </widget>
-
- <widget>
- <class>GtkLabel</class>
- <name>label3</name>
- <label>MIME type:</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0.5</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <left_attach>0</left_attach>
- <right_attach>1</right_attach>
- <top_attach>2</top_attach>
- <bottom_attach>3</bottom_attach>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <xexpand>False</xexpand>
- <yexpand>False</yexpand>
- <xshrink>False</xshrink>
- <yshrink>False</yshrink>
- <xfill>False</xfill>
- <yfill>False</yfill>
- </child>
- </widget>
-
- <widget>
<class>GtkEntry</class>
<name>description_entry</name>
<can_focus>True</can_focus>
@@ -141,32 +113,6 @@
</widget>
<widget>
- <class>GtkLabel</class>
- <name>label2</name>
- <label>File name:</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0.5</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <child>
- <left_attach>0</left_attach>
- <right_attach>1</right_attach>
- <top_attach>0</top_attach>
- <bottom_attach>1</bottom_attach>
- <xpad>0</xpad>
- <ypad>0</ypad>
- <xexpand>False</xexpand>
- <yexpand>False</yexpand>
- <xshrink>False</xshrink>
- <yshrink>False</yshrink>
- <xfill>False</xfill>
- <yfill>False</yfill>
- </child>
- </widget>
-
- <widget>
<class>GtkHBox</class>
<name>hbox3</name>
<homogeneous>False</homogeneous>
@@ -201,19 +147,6 @@
<fill>True</fill>
</child>
</widget>
-
- <widget>
- <class>GtkButton</class>
- <name>browse_button</name>
- <width>80</width>
- <can_focus>True</can_focus>
- <label>Browse...</label>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>False</fill>
- </child>
- </widget>
</widget>
<widget>
@@ -240,49 +173,83 @@
<yfill>False</yfill>
</child>
</widget>
- </widget>
-
- <widget>
- <class>GtkHButtonBox</class>
- <child_name>GnomeDialog:action_area</child_name>
- <name>dialog-action_area1</name>
- <layout_style>GTK_BUTTONBOX_END</layout_style>
- <spacing>8</spacing>
- <child_min_width>85</child_min_width>
- <child_min_height>27</child_min_height>
- <child_ipad_x>7</child_ipad_x>
- <child_ipad_y>0</child_ipad_y>
- <child>
- <padding>0</padding>
- <expand>False</expand>
- <fill>True</fill>
- <pack>GTK_PACK_END</pack>
- </child>
<widget>
- <class>GtkButton</class>
- <name>ok_button</name>
- <can_default>True</can_default>
- <has_default>True</has_default>
- <can_focus>True</can_focus>
- <stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
+ <class>GtkLabel</class>
+ <name>label3</name>
+ <label>MIME type:</label>
+ <justify>GTK_JUSTIFY_LEFT</justify>
+ <wrap>False</wrap>
+ <xalign>1</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>2</top_attach>
+ <bottom_attach>3</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>False</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
</widget>
<widget>
- <class>GtkButton</class>
- <name>apply_button</name>
- <sensitive>False</sensitive>
- <can_default>True</can_default>
- <can_focus>True</can_focus>
- <stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
+ <class>GtkLabel</class>
+ <name>label1</name>
+ <label>Description:</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>1</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>False</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
</widget>
<widget>
- <class>GtkButton</class>
- <name>close_button</name>
- <can_default>True</can_default>
- <can_focus>True</can_focus>
- <stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
+ <class>GtkLabel</class>
+ <name>label2</name>
+ <label>File name:</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>1</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>0</top_attach>
+ <bottom_attach>1</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>False</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
</widget>
</widget>
</widget>
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 <gnome.h>
#include <glade/glade-xml.h>
+#include <camel/camel-mime-part.h>
#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
@@ -1061,6 +1061,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);