* src/widgets/modest-header-view-render.c:
[modest] / src / maemo / modest-progress-bar-widget.c
index 9cffb1a..33b54bd 100644 (file)
@@ -32,6 +32,7 @@
 #include <widgets/modest-combo-box.h>
 #include "modest-progress-bar-widget.h"
 #include <string.h>
+#include "modest-platform.h"
 
 /* 'private'/'protected' functions */
 static void modest_progress_bar_widget_class_init (ModestProgressBarWidgetClass *klass);
@@ -89,6 +90,9 @@ struct _ModestProgressBarWidgetPrivate {
 /* globals */
 static GtkContainerClass *parent_class = NULL;
 
+/* Flag to show or not show Recv cancellation banner */
+static gboolean f_receivingOngoing = FALSE;
+
 /* uncomment the following if you have defined any signals */
 /* static guint signals[LAST_SIGNAL] = {0}; */
 
@@ -232,19 +236,19 @@ modest_progress_bar_add_operation (ModestProgressObject *self,
                                                 "progress-changed",
                                                 G_CALLBACK (on_progress_changed),
                                                 me);
-       if (priv->observables == NULL) {
-               priv->current = mail_op;
-
-               /* Call progress_change handler to initialize progress message */
-               state = g_malloc0(sizeof(ModestMailOperationState));
-               state->done = 0;
-               state->total = 0;
-               state->op_type = modest_mail_operation_get_type_operation (mail_op);;
-               on_progress_changed (mail_op, state, me);
-               g_free(state);
-       }
-       priv->observables = g_slist_append (priv->observables, data);
-
+       /* Set curent operation */
+       priv->current = mail_op;
+
+       /* Call progress_change handler to initialize progress message */
+       state = g_malloc0(sizeof(ModestMailOperationState));
+       state->done = 0;
+       state->total = 0;
+       state->op_type = modest_mail_operation_get_type_operation (mail_op);;
+/*     on_progress_changed (mail_op, state, me); */
+       g_free(state);
+
+       /* Add operation to obserbable objects list */
+       priv->observables = g_slist_prepend (priv->observables, data);
 }
 
 static gint
@@ -323,9 +327,17 @@ modest_progress_bar_cancel_current_operation (ModestProgressObject *self)
        priv = MODEST_PROGRESS_BAR_WIDGET_GET_PRIVATE (me);
 
        if (priv->current == NULL) return;
-       modest_mail_operation_cancel (priv->current);
 
+       /* bug 59107: if received canceled we shall show banner */
+       if ( f_receivingOngoing )
+       {
+               f_receivingOngoing = FALSE;
+               modest_platform_information_banner (NULL, NULL, _("emev_ib_ui_pop3_msg_recv_cancel"));
+       }
+
+       modest_mail_operation_cancel (priv->current);
 }
+
 static void 
 on_progress_changed (ModestMailOperation  *mail_op, 
                     ModestMailOperationState *state,
@@ -334,6 +346,7 @@ on_progress_changed (ModestMailOperation  *mail_op,
        ModestProgressBarWidgetPrivate *priv;
        gboolean determined = FALSE;
 
+       f_receivingOngoing = FALSE;
        priv = MODEST_PROGRESS_BAR_WIDGET_GET_PRIVATE (self);
 
        /* If the mail operation is the currently shown one */
@@ -345,6 +358,7 @@ on_progress_changed (ModestMailOperation  *mail_op,
 
                switch (state->op_type) {
                case MODEST_MAIL_OPERATION_TYPE_RECEIVE:                
+                       f_receivingOngoing = TRUE;
                        if (determined)
                                msg = g_strdup_printf(_("mcen_me_receiving"),
                                                      state->done, state->total); 
@@ -355,7 +369,7 @@ on_progress_changed (ModestMailOperation  *mail_op,
                        if (determined)
                                msg = g_strdup_printf(_("mcen_me_sending"), state->done,
                                                      state->total);
-                       else 
+                       else
                                msg = g_strdup(_("mail_me_sending"));
                        break;
                        
@@ -391,12 +405,7 @@ progressbar_clean (GtkProgressBar *bar)
 GtkWidget*
 modest_progress_bar_widget_new ()
 {
-       GtkWidget *progress_bar;
-
-       progress_bar = GTK_WIDGET (g_object_new (MODEST_TYPE_PROGRESS_BAR_WIDGET, NULL));
-       gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (progress_bar), 0.25);
-
-       return progress_bar;
+       return GTK_WIDGET (g_object_new (MODEST_TYPE_PROGRESS_BAR_WIDGET, NULL));
 }