* Renamed one method in modest UI actions
[modest] / src / widgets / modest-msg-view.c
index c3f5aff..ee39e2e 100644 (file)
@@ -86,6 +86,7 @@ static void adjustment_value_changed (GtkAdjustment *adj, gpointer data);
 static void html_adjustment_changed (GtkAdjustment *adj, gpointer data);
 static void disconnect_vadjustment (ModestMsgView *obj);
 static void disconnect_hadjustment (ModestMsgView *obj);
+static gboolean idle_readjust_scroll (ModestMsgView *obj);
 
 /* GtkContainer methods */
 static void forall (GtkContainer *container, gboolean include_internals,
@@ -830,7 +831,11 @@ html_adjustment_changed (GtkAdjustment *adj,
        gboolean vadj_changed;
        gint new_height;
 
+       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)
+               return;
        priv->html_scroll->allocation.height = html_vadj->upper;
 
        set_vadjustment_values (msg_view, &vadj_changed);
@@ -1090,10 +1095,15 @@ modest_msg_view_new (TnyMsg *msg)
                gtk_box_pack_start (GTK_BOX(priv->headers_box), priv->mail_header_view, FALSE, FALSE, 0);
        
        if (priv->attachments_view) {
-               priv->attachments_box = (GtkWidget *) modest_mail_header_view_add_custom_header (MODEST_MAIL_HEADER_VIEW (priv->mail_header_view),
-                                                                                                _("Attachments:"), priv->attachments_view,
-                                                                                                FALSE, FALSE);
+               gchar *att_label = g_strconcat (_("mcen_me_viewer_attachments"), ":", NULL);
+
+               priv->attachments_box = (GtkWidget *)
+                       modest_mail_header_view_add_custom_header (MODEST_MAIL_HEADER_VIEW (priv->mail_header_view),
+                                                                  att_label,
+                                                                  priv->attachments_view,
+                                                                  FALSE, FALSE);
                gtk_widget_hide_all (priv->attachments_box);
+               g_free (att_label);
 /*             gtk_widget_set_no_show_all (priv->attachments_box, TRUE); */
        }
 
@@ -1335,6 +1345,7 @@ modest_msg_view_set_message (ModestMsgView *self, TnyMsg *msg)
        TnyMimePart *body;
        ModestMsgViewPrivate *priv;
        TnyHeader *header;
+       GtkAdjustment *html_vadj;
        
        g_return_if_fail (self);
        
@@ -1405,6 +1416,15 @@ modest_msg_view_set_message (ModestMsgView *self, TnyMsg *msg)
        if (priv->vadj != NULL)
                priv->vadj->value = 0.0;
 
+       html_vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->html_scroll));
+
+       g_signal_emit_by_name (G_OBJECT (html_vadj), "changed");
+
+       /* 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_timeout_add (250, (GSourceFunc) idle_readjust_scroll, self);
 }
 
 
@@ -1467,10 +1487,10 @@ modest_msg_view_search (ModestMsgView *self, const gchar *search)
        gtk_layout_set_vadjustment (GTK_LAYOUT (priv->gtkhtml), tmp_vadj);
        result = gtk_html_engine_search (GTK_HTML (priv->gtkhtml),
                                         search,
-                                        FALSE, TRUE, TRUE);
+                                        FALSE,   /* case sensitive */
+                                        TRUE,    /* forward */
+                                        FALSE);  /* regexp */
 
-// wait for the updated gtkhtml (w27) to enable this
-#if 0
        if (result) {
                gint x, y, w, h;
                gdouble offset_top, offset_bottom;
@@ -1484,7 +1504,6 @@ modest_msg_view_search (ModestMsgView *self, const gchar *search)
                else if (offset_bottom > adj->value + adj->page_increment)
                        gtk_adjustment_set_value (adj, offset_bottom - adj->page_increment);
        }
-#endif 
 
        y_offset = tmp_vadj->value;
        gtk_layout_set_vadjustment (GTK_LAYOUT (priv->gtkhtml), vadj);
@@ -1504,8 +1523,6 @@ modest_msg_view_search_next (ModestMsgView *self)
        priv = MODEST_MSG_VIEW_GET_PRIVATE (self);
        result = gtk_html_engine_search_next (GTK_HTML (priv->gtkhtml));
 
-// fixme wait for new gtkhtml
-#if 0
        if (result) {
                gint x, y, w, h;
                gdouble offset_top, offset_bottom;
@@ -1520,7 +1537,6 @@ modest_msg_view_search_next (ModestMsgView *self)
                else if (offset_bottom > adj->value + adj->page_increment)
                        gtk_adjustment_set_value (adj, offset_bottom - adj->page_increment);
        }
-#endif
        return result;
 }
 
@@ -1626,3 +1642,25 @@ modest_msg_view_remove_attachment (ModestMsgView *view, TnyMimePart *attachment)
                                                   attachment);
        
 }
+
+gboolean
+idle_readjust_scroll (ModestMsgView *view)
+{
+       if (GTK_WIDGET_DRAWABLE (view)) {
+               ModestMsgViewPrivate *priv = MODEST_MSG_VIEW_GET_PRIVATE (view);
+               GtkAdjustment *html_vadj;
+               html_vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->html_scroll));
+               html_vadj->page_size = html_vadj->upper;
+               gtk_adjustment_changed (html_vadj);
+               gtk_widget_queue_resize (GTK_WIDGET (view));
+               gtk_widget_queue_draw (GTK_WIDGET (view));
+
+               /* Just another hack for making readjust really work. This forces an update
+                * of the scroll, and then, make the scroll really update properly the
+                * the size and not corrupt scrollable area */
+               gtk_adjustment_set_value (priv->vadj, 1.0);
+               gtk_adjustment_set_value (priv->vadj, 0.0);
+       }
+       g_object_unref (G_OBJECT (view));
+       return FALSE;
+}