X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-tny-stream-gtkhtml.c;h=3bdd6b3339c534888b40818b8773258a461f46d7;hb=fcc836f3307ad7605580274e241cbcd456ad28be;hp=c8ec30cae0171e072aea8245423f76df6f40c8ea;hpb=d40a430dac40ff506c3095b5f94eeec596969588;p=modest diff --git a/src/widgets/modest-tny-stream-gtkhtml.c b/src/widgets/modest-tny-stream-gtkhtml.c index c8ec30c..3bdd6b3 100644 --- a/src/widgets/modest-tny-stream-gtkhtml.c +++ b/src/widgets/modest-tny-stream-gtkhtml.c @@ -204,14 +204,20 @@ gtkhtml_write (TnyStream *self, const char *buffer, size_t n) /* We only use the maximum size for write method, and even we * ignore and fake as we would do a successfull read */ - if (priv->current_size > priv->max_size) + if (priv->current_size >= priv->max_size) return n; if (priv->current_size + n > priv->max_size) n = priv->max_size - priv->current_size; } + if (!g_main_context_is_owner (NULL)) + gdk_threads_enter (); + gtk_html_stream_write (priv->stream, buffer, n); + + if (!g_main_context_is_owner (NULL)) + gdk_threads_leave (); priv->current_size += n; return n; /* hmmm */ @@ -233,7 +239,14 @@ gtkhtml_close (TnyStream *self) priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE(self); if (priv->html && GTK_WIDGET_VISIBLE (priv->html)) { + if (!g_main_context_is_owner (NULL)) + gdk_threads_enter (); + gtk_html_stream_close (priv->stream, GTK_HTML_STREAM_OK); + + if (!g_main_context_is_owner (NULL)) + gdk_threads_leave (); + } priv->stream = NULL; if (priv->html && priv->stop_streams_id > 0) { @@ -313,6 +326,17 @@ modest_tny_stream_gtkhtml_get_max_size (ModestTnyStreamGtkhtml *stream) return priv->max_size; } +gboolean +modest_tny_stream_gtkhtml_limit_reached (ModestTnyStreamGtkhtml *self) +{ + ModestTnyStreamGtkhtmlPrivate *priv; + + g_return_val_if_fail (MODEST_IS_TNY_STREAM_GTKHTML (self), 0); + priv = MODEST_TNY_STREAM_GTKHTML_GET_PRIVATE (self); + + return (priv->max_size > 0) && (priv->current_size >= priv->max_size); +} + static void modest_tny_stream_gtkhml_iface_init (gpointer g_iface, gpointer iface_data) {