If the attachment fails, report the error to the user.

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.

svn path=/trunk/; revision=13537
This commit is contained in:
Jeffrey Stedfast
2001-10-10 00:10:02 +00:00
committed by Jeffrey Stedfast
parent b457da9a98
commit 45a3bf8c45
4 changed files with 57 additions and 14 deletions

View File

@ -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.

View File

@ -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

View File

@ -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));

View File

@ -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);