GtkWidget *prev_toolitem;
GtkWidget *next_toolitem;
gboolean progress_hint;
+ gint fetching_images;
/* Optimized view enabled */
gboolean optimized_view;
GdkEvent *event,
gpointer userdata);
+
/* list my signals */
enum {
MSG_CHANGED_SIGNAL,
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;
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)
/* 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);
}
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;
}
mailbox, attachment_uid);
modest_window_set_zoom (MODEST_WINDOW (msg_win),
modest_window_get_zoom (MODEST_WINDOW (window)));
- modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window));
- gtk_widget_show_all (GTK_WIDGET (msg_win));
+ if (modest_window_mgr_register_window (mgr, msg_win, MODEST_WINDOW (window)))
+ gtk_widget_show_all (GTK_WIDGET (msg_win));
+ else
+ gtk_widget_destroy (GTK_WIDGET (msg_win));
}
}
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"));
}
gchar *cache_id;
TnyStream *output_stream;
GtkWidget *msg_view;
+ GtkWidget *window;
} FetchImageData;
gboolean
{
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;
}
TnyStreamCache *cache;
TnyStream *cache_stream;
- gdk_threads_enter ();
cache = modest_runtime_get_images_cache ();
cache_stream =
tny_stream_cache_get_stream (cache,
g_free (fidata->uri);
if (cache_stream != NULL) {
- tny_stream_write_to_stream (cache_stream, fidata->output_stream);
+ char buffer[4096];
+
+ while (G_LIKELY (!tny_stream_is_eos (cache_stream))) {
+ gssize nb_read;
+
+ nb_read = tny_stream_read (cache_stream, buffer, sizeof (buffer));
+ if (G_UNLIKELY (nb_read < 0)) {
+ break;
+ } else if (G_LIKELY (nb_read > 0)) {
+ gssize nb_written = 0;
+
+ while (G_UNLIKELY (nb_written < nb_read)) {
+ gssize len;
+
+ len = tny_stream_write (fidata->output_stream, buffer + nb_written,
+ nb_read - nb_written);
+ if (G_UNLIKELY (len < 0))
+ break;
+ nb_written += len;
+ }
+ }
+ }
tny_stream_close (cache_stream);
g_object_unref (cache_stream);
}
tny_stream_close (fidata->output_stream);
g_object_unref (fidata->output_stream);
- gdk_threads_leave ();
g_idle_add (on_fetch_image_idle_refresh_view, fidata);
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);
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;
}
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
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));
+}