[anjal] Status/response for downloading attachment.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjal] Status/response for downloading attachment.
- Date: Wed, 26 Aug 2009 08:53:20 +0000 (UTC)
commit 129d832ba0964a878d647d05a7ab036a2500d679
Author: Srinivasa Ragavan <sragavan novell com>
Date: Wed Aug 26 14:22:42 2009 +0530
Status/response for downloading attachment.
src/em-format-mail-display.c | 92 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 90 insertions(+), 2 deletions(-)
---
diff --git a/src/em-format-mail-display.c b/src/em-format-mail-display.c
index c974949..c0a5fa8 100644
--- a/src/em-format-mail-display.c
+++ b/src/em-format-mail-display.c
@@ -77,6 +77,7 @@
#include "mail/em-utils.h"
#include "mail/em-popup.h"
#include "misc/e-icon-entry.h"
+#include "misc/e-spinner.h"
#include "mail-message-view.h"
#include "mail-utils.h"
#include "mail/mail-mt.h"
@@ -1497,6 +1498,71 @@ efhd_attachment_image(EMFormatMail *efh, GtkWidget *eb, EMFormatMailPObject *pob
}
static void
+efmd_attachment_save_handle_error (EAttachment *attachment,
+ GAsyncResult *result,
+ GtkWindow *parent)
+{
+ GFile *file;
+ GFileInfo *file_info;
+ GtkWidget *dialog;
+ const gchar *display_name;
+ const gchar *primary_text;
+ GError *error = NULL;
+ GtkWidget *label, *box, *button;
+
+ box = g_object_get_data ((GObject *)attachment, "box");
+ label= g_object_get_data ((GObject *)attachment, "label");
+ button = g_object_get_data ((GObject *)attachment, "button");
+
+ g_return_if_fail (E_IS_ATTACHMENT (attachment));
+ g_return_if_fail (G_IS_ASYNC_RESULT (result));
+ g_return_if_fail (GTK_IS_WINDOW (parent));
+
+ file = e_attachment_save_finish (attachment, result, &error);
+
+ if (file != NULL) {
+ g_object_unref (file);
+ gtk_widget_hide_all (box);
+ gtk_widget_show (box);
+ gtk_label_set_text ((GtkLabel *)label, _("Saved"));
+ gtk_widget_show (label);
+ gtk_widget_set_sensitive(button, FALSE);
+ return;
+ }
+
+ /* Ignore cancellations. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ return;
+
+ file_info = e_attachment_get_file_info (attachment);
+
+ if (file_info != NULL)
+ display_name = g_file_info_get_display_name (file_info);
+ else
+ display_name = NULL;
+
+ if (display_name != NULL)
+ primary_text = g_strdup_printf (
+ _("Could not save '%s'"), display_name);
+ else
+ primary_text = g_strdup_printf (
+ _("Could not save the attachment"));
+
+ dialog = gtk_message_dialog_new_with_markup (
+ parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ "<big><b>%s</b></big>", primary_text);
+
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (dialog);
+ g_error_free (error);
+}
+
+static void
emfd_save_attachment (GtkButton *button, EAttachment *attachment)
{
char *path;
@@ -1505,6 +1571,10 @@ emfd_save_attachment (GtkButton *button, EAttachment *attachment)
GFile *dest;
int i = 1;
const char *download_dir = g_get_user_special_dir(G_USER_DIRECTORY_DOWNLOAD);
+ GtkWidget *label, *box;
+
+ box = g_object_get_data ((GObject *)button, "box");
+ label= g_object_get_data ((GObject *)button, "label");
file_info = e_attachment_get_file_info (attachment);
if (file_info != NULL)
@@ -1529,9 +1599,15 @@ emfd_save_attachment (GtkButton *button, EAttachment *attachment)
}
dest = g_file_new_for_path (path);
+ gtk_label_set_text ((GtkLabel *)label, _("Saving..."));
+ gtk_widget_show_all (box);
+
+ g_object_set_data((GObject *)attachment, "box", box);
+ g_object_set_data((GObject *)attachment, "label", label);
+ g_object_set_data((GObject *)attachment, "button", button);
e_attachment_save_async (
attachment, dest, (GAsyncReadyCallback)
- e_attachment_save_handle_error, gtk_widget_get_toplevel((GtkWidget *)button));
+ efmd_attachment_save_handle_error, gtk_widget_get_toplevel((GtkWidget *)button));
g_object_unref (dest);
g_free(path);
}
@@ -1545,7 +1621,7 @@ efhd_attachment_button(EMFormatMail *efh, GtkWidget *eb, EMFormatMailPObject *po
EAttachmentView *view;
EAttachmentStore *store;
EAttachment *attachment;
- GtkWidget *widget, *mainbox, *topbox, *tmp;
+ GtkWidget *widget, *mainbox, *topbox, *tmp, *label;
gpointer parent = NULL;
char *txt;
@@ -1622,9 +1698,21 @@ efhd_attachment_button(EMFormatMail *efh, GtkWidget *eb, EMFormatMailPObject *po
gtk_container_add ((GtkContainer *)widget, tmp);
gtk_widget_show_all (widget);
gtk_box_pack_start ((GtkBox *)mainbox, widget, FALSE, FALSE, 6);
+
+ tmp = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start ((GtkBox *)tmp, (GtkWidget *)e_spinner_new_spinning_small_shown (), FALSE, FALSE, 0);
+ label = gtk_label_new (NULL);
+ gtk_box_pack_start ((GtkBox *)tmp, label, FALSE, FALSE, 0);
+ gtk_widget_show_all (tmp);
+ gtk_widget_hide (tmp);
+ gtk_box_pack_start ((GtkBox *)mainbox, tmp, FALSE, FALSE, 6);
+ g_object_set_data((GObject *)widget, "box", tmp);
+ g_object_set_data((GObject *)widget, "label", label);
gtk_box_pack_start ((GtkBox *)eb, mainbox, FALSE, FALSE, 0);
gtk_widget_show_all(mainbox);
+ gtk_widget_hide (tmp);
+
if (info->child_box)
gtk_box_pack_start ((GtkBox *)eb, info->child_box, FALSE, FALSE, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]