Split label for time in two parts in header view
[modest] / src / hildon2 / modest-msg-view-window.c
index 2ae8df1..ab94245 100644 (file)
@@ -85,6 +85,7 @@ struct _ModestMsgViewWindowPrivate {
        GtkWidget   *prev_toolitem;
        GtkWidget   *next_toolitem;
        gboolean    progress_hint;
+       gint        fetching_images;
 
        /* Optimized view enabled */
        gboolean optimized_view;
@@ -226,6 +227,7 @@ static gboolean _modest_msg_view_window_map_event (GtkWidget *widget,
                                                   GdkEvent *event,
                                                   gpointer userdata);
 
+
 /* list my signals */
 enum {
        MSG_CHANGED_SIGNAL,
@@ -440,6 +442,7 @@ modest_msg_view_window_init (ModestMsgViewWindow *obj)
        priv->row_inserted_handler = 0;
        priv->rows_reordered_handler = 0;
        priv->progress_hint = FALSE;
+       priv->fetching_images = 0;
 
        priv->optimized_view  = FALSE;
        priv->purge_timeout = 0;
@@ -478,6 +481,18 @@ set_toolbar_transfer_mode (ModestMsgViewWindow *self)
        return FALSE;
 }
 
+static void
+update_progress_hint (ModestMsgViewWindow *self)
+{
+       ModestMsgViewWindowPrivate *priv;
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
+
+       if (GTK_WIDGET_VISIBLE (self)) {
+               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), 
+                                                         (priv->progress_hint || (priv->fetching_images > 0))?1:0);
+       }
+}
+
 static void 
 set_progress_hint (ModestMsgViewWindow *self, 
                   gboolean enabled)
@@ -493,9 +508,7 @@ set_progress_hint (ModestMsgViewWindow *self,
        /* Sets current progress hint */
        priv->progress_hint = enabled;
 
-       if (GTK_WIDGET_VISIBLE (self)) {
-               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), enabled?1:0);
-       }
+       update_progress_hint (self);
 
 }
 
@@ -2433,8 +2446,9 @@ on_decode_to_stream_async_handler (TnyMimePart *mime_part,
 
        if (cancelled || err) {
                if (err) {
-                       modest_platform_information_banner (NULL, NULL,
-                                                           _KR("cerm_device_memory_full"));
+                       gchar *msg = g_strdup_printf (_KR("cerm_device_memory_full"), "");
+                       modest_platform_information_banner (NULL, NULL, msg);
+                       g_free (msg);
                }
                goto free;
        }
@@ -2620,8 +2634,9 @@ idle_save_mime_part_show_result (SaveMimePartInfo *info)
                if (info->result == GNOME_VFS_OK) {
                        hildon_banner_show_information (NULL, NULL, _CS("sfil_ib_saved"));
                } else if (info->result == GNOME_VFS_ERROR_NO_SPACE) {
-                       hildon_banner_show_information (NULL, NULL, 
-                                                       _KR("cerm_device_memory_full"));
+                       gchar *msg = g_strdup_printf (_KR("cerm_device_memory_full"), "");
+                       modest_platform_information_banner (NULL, NULL, msg);
+                       g_free (msg);
                } else {
                        hildon_banner_show_information (NULL, NULL, _("mail_ib_file_operation_failed"));
                }
@@ -3073,6 +3088,7 @@ typedef struct {
        gchar *cache_id;
        TnyStream *output_stream;
        GtkWidget *msg_view;
+       GtkWidget *window;
 } FetchImageData;
 
 gboolean
@@ -3080,16 +3096,20 @@ on_fetch_image_idle_refresh_view (gpointer userdata)
 {
 
        FetchImageData *fidata = (FetchImageData *) userdata;
-       g_message ("REFRESH VIEW");
 
        gdk_threads_enter ();
        if (GTK_WIDGET_DRAWABLE (fidata->msg_view)) {
-               g_message ("QUEUING DRAW");
+               ModestMsgViewWindowPrivate *priv;
+
+               priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (fidata->window);
+               priv->fetching_images--;
                gtk_widget_queue_draw (fidata->msg_view);
+               update_progress_hint (MODEST_MSG_VIEW_WINDOW (fidata->window));
        }
        gdk_threads_leave ();
 
        g_object_unref (fidata->msg_view);
+       g_object_unref (fidata->window);
        g_slice_free (FetchImageData, fidata);
        return FALSE;
 }
@@ -3161,10 +3181,12 @@ on_fetch_image (ModestMsgView *msgview,
 
        fidata = g_slice_new0 (FetchImageData);
        fidata->msg_view = g_object_ref (msgview);
+       fidata->window = g_object_ref (window);
        fidata->uri = g_strdup (uri);
        fidata->cache_id = modest_images_cache_get_id (current_account, uri);
        fidata->output_stream = g_object_ref (stream);
 
+       priv->fetching_images++;
        if (g_thread_create (on_fetch_image_thread, fidata, FALSE, NULL) == NULL) {
                g_object_unref (fidata->output_stream);
                g_free (fidata->cache_id);
@@ -3172,8 +3194,11 @@ on_fetch_image (ModestMsgView *msgview,
                g_object_unref (fidata->msg_view);
                g_slice_free (FetchImageData, fidata);
                tny_stream_close (stream);
+               priv->fetching_images--;
+               update_progress_hint (window);
                return FALSE;
        }
+       update_progress_hint (window);
 
        return TRUE;
 }
@@ -3211,6 +3236,13 @@ setup_menu (ModestMsgViewWindow *self)
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_addtocontacts"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_add_to_contacts),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts));
+
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mail_bd_external_images"), NULL,
+                                          APP_MENU_CALLBACK (modest_ui_actions_on_fetch_images),
+                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_fetch_images));
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_ti_message_properties"), NULL,
+                                          APP_MENU_CALLBACK (modest_ui_actions_on_details),
+                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_details));
 }
 
 void
@@ -3289,11 +3321,28 @@ _modest_msg_view_window_map_event (GtkWidget *widget,
                                   gpointer userdata)
 {
        ModestMsgViewWindow *self = (ModestMsgViewWindow *) userdata;
-       ModestMsgViewWindowPrivate *priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
 
-       if (priv->progress_hint) {
-               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
-       }
+       update_progress_hint (self);
 
        return FALSE;
 }
+
+void
+modest_msg_view_window_fetch_images (ModestMsgViewWindow *self)
+{
+       ModestMsgViewWindowPrivate *priv;
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+
+       modest_msg_view_request_fetch_images (MODEST_MSG_VIEW (priv->msg_view));
+}
+
+gboolean 
+modest_msg_view_window_has_blocked_external_images (ModestMsgViewWindow *self)
+{
+       ModestMsgViewWindowPrivate *priv;
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (self), FALSE);
+
+       return modest_msg_view_has_blocked_external_images (MODEST_MSG_VIEW (priv->msg_view));
+}