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
This commit is contained in:
parent
4a85bdfa85
commit
5ec9e5b228
@ -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.
|
||||
|
@ -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;
|
||||
GMimeContentField *content_type;
|
||||
|
||||
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);
|
||||
content_type = camel_mime_part_get_content_type (attachment->body);
|
||||
|
||||
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;
|
||||
/* 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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
/* Kludge a bit on CTE. For now, we set QP for text/ and message/
|
||||
* and B64 for all else. FIXME.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <gnome.h>
|
||||
#include <camel/camel.h>
|
||||
|
||||
#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 ());
|
||||
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));
|
||||
|
||||
new->editor_gui = NULL;
|
||||
part = camel_mime_part_new ();
|
||||
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
|
||||
gtk_object_unref (GTK_OBJECT (wrapper));
|
||||
|
||||
new->file_name = g_strdup (file_name);
|
||||
new->description = g_strdup (g_basename (new->file_name));
|
||||
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;
|
||||
|
||||
init_mime_type (new);
|
||||
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;
|
||||
|
||||
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)
|
||||
@ -372,32 +293,30 @@ close_cb (GtkWidget *widget,
|
||||
destroy_dialog_data (dialog_data);
|
||||
}
|
||||
|
||||
static void
|
||||
apply_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
DialogData *dialog_data;
|
||||
|
||||
dialog_data = (DialogData *) data;
|
||||
apply (dialog_data);
|
||||
}
|
||||
|
||||
static void
|
||||
ok_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
apply_cb (widget, data);
|
||||
close_cb (widget, data);
|
||||
}
|
||||
|
||||
static void
|
||||
browse_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
DialogData *dialog_data;
|
||||
EMsgComposerAttachment *attachment;
|
||||
|
||||
dialog_data = (DialogData *) data;
|
||||
browse (dialog_data);
|
||||
attachment = dialog_data->attachment;
|
||||
|
||||
camel_mime_part_set_filename (attachment->body, gtk_entry_get_text
|
||||
(dialog_data->file_name_entry));
|
||||
|
||||
camel_mime_part_set_description (attachment->body, gtk_entry_get_text
|
||||
(dialog_data->description_entry));
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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>
|
||||
@ -50,6 +39,41 @@
|
||||
<fill>True</fill>
|
||||
</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>
|
||||
@ -64,58 +88,6 @@
|
||||
<fill>True</fill>
|
||||
</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>
|
||||
@ -140,32 +112,6 @@
|
||||
</child>
|
||||
</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>
|
||||
@ -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>
|
||||
|
@ -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...");
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user