#include <widgets/modest-isearch-view.h>
#include <widgets/modest-ui-constants.h>
#include <modest-icon-names.h>
+#include <tny-camel-bs-mime-part.h>
/* FIXNE: we should have no maemo-deps in widgets/ */
#ifndef MODEST_TOOLKIT_GTK
/* id handler for dragged scroll */
guint idle_motion_id;
+ /* idle changes count */
+ gint idle_changes_count;
+ guint idle_readjust_scroll_id;
+ guint idle_resize_children_id;
+
/* zoom */
gdouble current_zoom;
/* link click management */
gchar *last_url;
+
+ gboolean has_blocked_bs_images;
};
#define MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
allocation->height != widget->allocation.height))
gdk_window_invalidate_rect (widget->window, NULL, FALSE);
- if (widget->allocation.width != allocation->width) {
+ if (priv->idle_readjust_scroll_id == 0 && priv->idle_changes_count < 5 && widget->allocation.width != allocation->width) {
g_object_ref (self);
- g_idle_add ((GSourceFunc) idle_readjust_scroll, self);
+ priv->idle_readjust_scroll_id = g_idle_add ((GSourceFunc) idle_readjust_scroll, self);
+ priv->idle_changes_count ++;
}
widget->allocation = *allocation;
html_vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->html_scroll));
html_allocation.x = 0;
- html_allocation.y = headers_allocation.height;
+ html_allocation.y = MAX (0, headers_allocation.height - priv->vadj->value);
html_allocation.width = view_allocation.width;
- html_allocation.height = MAX ((gint) html_vadj->upper, (gint)(priv->vadj->upper - headers_allocation.height));
+ if (html_vadj->upper < allocation->height) {
+ html_allocation.height = MAX (html_vadj->upper, allocation->height - headers_allocation.height);
+ } else {
+ html_allocation.height = allocation->height;
+ }
+ /* html_allocation.height = MAX ((gint) html_vadj->upper, (gint)(priv->vadj->upper - headers_allocation.height)); */
if (GTK_WIDGET_REALIZED (widget)) {
gdk_window_move_resize (widget->window,
headers_allocation.height);
gdk_window_move_resize (priv->html_window,
(gint) (- priv->hadj->value),
- (gint) (html_allocation.y - priv->vadj->value),
+ (gint) html_allocation.y,
(gint) priv->hadj->upper,
html_allocation.height);
}
html_allocation.x = 0;
html_allocation.y = 0;
html_allocation.width = (gint) priv->hadj->upper;
- html_allocation.height = (gint) priv->vadj->upper - headers_allocation.height;
gtk_widget_size_allocate (priv->html_scroll, &html_allocation);
+ if (html_vadj->page_size != html_allocation.height) {
+ html_vadj->page_size = html_allocation.height;
+ gtk_adjustment_changed (html_vadj);
+ }
}
gtk_adjustment_changed (priv->hadj);
gtk_adjustment_changed (priv->vadj);
if (priv->html_scroll && GTK_WIDGET_VISIBLE (priv->html_scroll)) {
gint old_x, old_y;
gint new_x, new_y;
+ gint new_internal_vvalue;
gdk_window_get_position (priv->html_window, &old_x, &old_y);
new_x = -hadj->value;
- new_y = headers_offset - vadj->value;
+
+ new_internal_vvalue = MAX (0, vadj->value - headers_offset);
+ gtk_adjustment_set_value (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->html_scroll)),
+ new_internal_vvalue);
+
+ new_y = MAX (0, headers_offset - vadj->value);
if (new_x != old_x || new_y != old_y) {
gdk_window_move (priv->html_window, new_x, new_y);
}
}
+static gboolean
+resize_children_idle (GtkContainer *cont)
+{
+ ModestGtkhtmlMsgViewPrivate *priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (cont);
+ if (GTK_WIDGET_DRAWABLE (cont)) {
+ gtk_container_resize_children (cont);
+ }
+ priv->idle_resize_children_id = 0;
+
+ return FALSE;
+}
+
static void
html_adjustment_changed (GtkAdjustment *adj,
gpointer userdata)
g_signal_stop_emission_by_name (G_OBJECT (adj), "changed");
priv->html_scroll->requisition.height = html_vadj->upper;
- if (html_vadj->upper == priv->html_scroll->allocation.height)
+ if ((priv->vadj != NULL && (html_vadj->upper == (priv->vadj->upper - GTK_WIDGET (priv->headers_box)->allocation.height)))
+ && html_vadj->page_size == priv->html_scroll->allocation.height)
return;
- priv->html_scroll->allocation.height = html_vadj->upper;
set_vadjustment_values (self, &vadj_changed);
- new_height = MAX ((gint) html_vadj->upper, (gint) (priv->vadj->upper - priv->headers_box->allocation.height));
+ if (html_vadj->upper < GTK_WIDGET (self)->allocation.height) {
+ new_height = MAX (html_vadj->upper,
+ GTK_WIDGET (self)->allocation.height - GTK_WIDGET(priv->headers_box)->allocation.height);
+ } else {
+ new_height = GTK_WIDGET (self)->allocation.height;
+ }
gtk_adjustment_changed (priv->vadj);
if (GTK_WIDGET_DRAWABLE (priv->html_scroll)) {
gdk_window_resize (priv->html_window, (gint) priv->hadj->upper, (gint) new_height);
gdk_window_process_updates (priv->view_window, TRUE);
- gtk_container_resize_children (GTK_CONTAINER (self));
+ if (priv->idle_resize_children_id == 0)
+ priv->idle_resize_children_id = gdk_threads_add_idle ((GSourceFunc) resize_children_idle, self);
}
}
gboolean
idle_readjust_scroll (ModestGtkhtmlMsgView *self)
{
+ ModestGtkhtmlMsgViewPrivate *priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (self);
/* We're out the main lock */
gdk_threads_enter ();
if (GTK_WIDGET_DRAWABLE (self)) {
- ModestGtkhtmlMsgViewPrivate *priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (self);
GtkAdjustment *html_vadj;
GtkAdjustment *html_hadj;
gtk_adjustment_set_value (priv->vadj, 0.0);
}
+ priv->idle_readjust_scroll_id = 0;
g_object_unref (G_OBJECT (self));
-
gdk_threads_leave ();
return FALSE;
priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE(obj);
+ priv->has_blocked_bs_images = FALSE;
+
+ priv->idle_changes_count = 0;
+ priv->idle_readjust_scroll_id = 0;
+ priv->idle_resize_children_id = 0;
priv->current_zoom = 1.0;
priv->hadj = NULL;
priv->msg = NULL;
}
+ if (priv->idle_resize_children_id > 0) {
+ g_source_remove (priv->idle_resize_children_id);
+ priv->idle_resize_children_id = 0;
+ }
+
+ if (priv->idle_readjust_scroll_id > 0) {
+ g_source_remove (priv->idle_readjust_scroll_id);
+ priv->idle_readjust_scroll_id = 0;
+ }
+
if (priv->idle_motion_id > 0) {
g_source_remove (priv->idle_motion_id);
priv->idle_motion_id = 0;
{
ModestGtkhtmlMsgViewPrivate *priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (self);
- return (modest_mime_part_view_has_external_images (MODEST_MIME_PART_VIEW (priv->body_view)) &&
+ return ((modest_mime_part_view_has_external_images (MODEST_MIME_PART_VIEW (priv->body_view)) ||
+ (priv->has_blocked_bs_images)) &&
!modest_mime_part_view_get_view_images (MODEST_MIME_PART_VIEW (priv->body_view)));
}
} else {
return FALSE;
}
+ } else if (TNY_IS_CAMEL_BS_MIME_PART (part) &&
+ !tny_camel_bs_mime_part_is_fetched (TNY_CAMEL_BS_MIME_PART (part))){
+ if (!modest_mime_part_view_get_view_images (MODEST_MIME_PART_VIEW (priv->body_view))) {
+ priv->has_blocked_bs_images = TRUE;
+ tny_stream_close (stream);
+ return TRUE;
+ }
}
tny_mime_part_decode_to_stream ((TnyMimePart*)part, stream, NULL);
g_return_if_fail (self);
priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE(self);
+ priv->has_blocked_bs_images = FALSE;
modest_mail_header_view_set_loading (MODEST_MAIL_HEADER_VIEW (priv->mail_header_view), FALSE);
gtk_widget_set_no_show_all (priv->mail_header_view, FALSE);
modest_mime_part_view_set_view_images (MODEST_MIME_PART_VIEW (priv->body_view), FALSE);
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), 1, 1);
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), -1, -1);
+ priv->idle_changes_count = 0;
gtk_widget_queue_resize (GTK_WIDGET (priv->body_view));
gtk_widget_queue_resize (GTK_WIDGET(self));
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), 1, 1);
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), -1, -1);
+ priv->idle_changes_count = 0;
gtk_widget_queue_resize (GTK_WIDGET (priv->body_view));
gtk_widget_queue_resize (GTK_WIDGET(self));
/* This is a hack to force reallocation of scroll after drawing all the stuff. This
* makes the html view get the proper and expected size and prevent being able to scroll
* the buffer when it shouldn't be scrollable */
- g_object_ref (self);
- g_idle_add ((GSourceFunc) idle_readjust_scroll, self);
+ if (priv->idle_readjust_scroll_id == 0) {
+ g_object_ref (self);
+ priv->idle_readjust_scroll_id = g_idle_add ((GSourceFunc) idle_readjust_scroll, self);
+ }
}
static void
}
priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE(self);
+ priv->has_blocked_bs_images = FALSE;
modest_mail_header_view_set_loading (MODEST_MAIL_HEADER_VIEW (priv->mail_header_view), TRUE);
gtk_widget_set_no_show_all (priv->mail_header_view, FALSE);
modest_mime_part_view_set_view_images (MODEST_MIME_PART_VIEW (priv->body_view), FALSE);
html_hadj->page_size = 0;
g_signal_emit_by_name (G_OBJECT (html_hadj), "changed");
+ priv->idle_changes_count = 0;
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), 1, 1);
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), -1, -1);
gtk_widget_queue_resize (GTK_WIDGET (priv->body_view));
#endif
gtk_widget_set_no_show_all (priv->mail_header_view, TRUE);
tny_mime_part_view_clear (TNY_MIME_PART_VIEW (priv->body_view));
+ priv->idle_changes_count = 0;
gtk_widget_queue_resize (GTK_WIDGET(self));
gtk_widget_queue_draw (GTK_WIDGET(self));
}
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), 1, 1);
gtk_widget_set_size_request (GTK_WIDGET (priv->body_view), -1, -1);
+ priv->idle_changes_count = 0;
gtk_widget_queue_resize (priv->body_view);
}