aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog6
-rw-r--r--composer/e-msg-composer-attachment-bar.c34
-rw-r--r--composer/e-msg-composer-attachment.c25
-rw-r--r--composer/e-msg-composer-attachment.h6
4 files changed, 57 insertions, 14 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index bd66c6f391..9bd36cfd7e 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,5 +1,11 @@
2001-10-09 Jeffrey Stedfast <fejj@ximian.com>
+ * e-msg-composer-attachment-bar.c (add_from_file): If the
+ attachment fails, report the error to the user.
+
+ * e-msg-composer-attachment.c (e_msg_composer_attachment_new): Now
+ takes a CamelException argument.
+
* e-msg-composer.c (setup_ui): Pass /menu/Edit as the menu path to
e_charset_picker thingy.
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 259d1709ec..14b0b39588 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -31,6 +31,8 @@
#include <libgnomeui/gnome-app.h>
#include <libgnomeui/gnome-app-helper.h>
#include <libgnomeui/gnome-popup-menu.h>
+#include <libgnomeui/gnome-dialog-util.h>
+#include <libgnomeui/gnome-dialog.h>
#include <glade/glade.h>
#include <libgnomevfs/gnome-vfs-mime-info.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -145,17 +147,17 @@ add_common (EMsgComposerAttachmentBar *bar,
EMsgComposerAttachment *attachment)
{
g_return_if_fail (attachment != NULL);
-
+
gtk_signal_connect (GTK_OBJECT (attachment), "changed",
GTK_SIGNAL_FUNC (attachment_changed_cb),
bar);
-
+
bar->priv->attachments = g_list_append (bar->priv->attachments,
attachment);
bar->priv->num_attachments++;
-
+
update (bar);
-
+
gtk_signal_emit (GTK_OBJECT (bar), signals[CHANGED]);
}
@@ -168,10 +170,28 @@ add_from_mime_part (EMsgComposerAttachmentBar *bar,
static void
add_from_file (EMsgComposerAttachmentBar *bar,
- const gchar *file_name,
- const gchar *disposition)
+ const char *file_name,
+ const char *disposition)
{
- add_common (bar, e_msg_composer_attachment_new (file_name, disposition));
+ EMsgComposerAttachment *attachment;
+ EMsgComposer *composer;
+ CamelException ex;
+ GtkWidget *dialog;
+
+ camel_exception_init (&ex);
+ attachment = e_msg_composer_attachment_new (file_name, disposition, &ex);
+ if (attachment) {
+ add_common (bar, attachment);
+ } else {
+ composer = E_MSG_COMPOSER (gtk_widget_get_toplevel (GTK_WIDGET (bar)));
+
+ dialog = gnome_error_dialog_parented (camel_exception_get_description (&ex),
+ GTK_WINDOW (composer));
+
+ gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+
+ camel_exception_clear (&ex);
+ }
}
static void
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index 49af8bc122..0b2d08aec9 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -28,6 +28,7 @@
attachment manually. */
#include <sys/stat.h>
+#include <errno.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtktogglebutton.h>
@@ -143,12 +144,14 @@ e_msg_composer_attachment_get_type (void)
* e_msg_composer_attachment_new:
* @file_name: filename to attach
* @disposition: Content-Disposition of the attachment
+ * @ex: exception
*
* Return value: the new attachment, or %NULL on error
**/
EMsgComposerAttachment *
-e_msg_composer_attachment_new (const gchar *file_name,
- const gchar *disposition)
+e_msg_composer_attachment_new (const char *file_name,
+ const char *disposition,
+ CamelException *ex)
{
EMsgComposerAttachment *new;
CamelMimePart *part;
@@ -160,16 +163,28 @@ e_msg_composer_attachment_new (const gchar *file_name,
g_return_val_if_fail (file_name != NULL, NULL);
- if (stat (file_name, &statbuf) < 0)
+ if (stat (file_name, &statbuf) < 0) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot attach file %s: %s"),
+ file_name, g_strerror (errno));
return NULL;
+ }
/* return if it's not a regular file */
- if (!S_ISREG (statbuf.st_mode))
+ if (!S_ISREG (statbuf.st_mode)) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot attach file %s: not a regular file"),
+ file_name);
return NULL;
+ }
stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0);
- if (!stream)
+ if (!stream) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Cannot attach file %s: %s"),
+ file_name, g_strerror (errno));
return NULL;
+ }
wrapper = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream (wrapper, stream);
camel_object_unref (CAMEL_OBJECT (stream));
diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h
index e51db41d73..5dda224153 100644
--- a/composer/e-msg-composer-attachment.h
+++ b/composer/e-msg-composer-attachment.h
@@ -26,6 +26,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glade/glade-xml.h>
#include <camel/camel-mime-part.h>
+#include <camel/camel-exception.h>
#ifdef __cplusplus
extern "C" {
@@ -62,8 +63,9 @@ struct _EMsgComposerAttachmentClass {
GtkType e_msg_composer_attachment_get_type (void);
-EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name,
- const gchar *disposition);
+EMsgComposerAttachment *e_msg_composer_attachment_new (const char *file_name,
+ const char *disposition,
+ CamelException *ex);
EMsgComposerAttachment *e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part);
void e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment,
GtkWidget *parent);