* Changes in the autotools stuff affecting a lot of platform dependent
[modest] / src / widgets / modest-scroll-text.c
index 59875fd..a2b2c93 100644 (file)
@@ -80,43 +80,53 @@ size_request (GtkWidget *widget,
        guint line_limit;
        GdkRectangle iter_rectangle;
        GtkAdjustment *adj = NULL;
        guint line_limit;
        GdkRectangle iter_rectangle;
        GtkAdjustment *adj = NULL;
+       GtkTextMark *insert_mark;
+       GtkTextIter insert_iter;
 
        text_view = modest_scroll_text_get_text_view (MODEST_SCROLL_TEXT (widget));
        line_limit = priv->line_limit;
 
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
 
 
        text_view = modest_scroll_text_get_text_view (MODEST_SCROLL_TEXT (widget));
        line_limit = priv->line_limit;
 
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
 
+       insert_mark = gtk_text_buffer_get_insert (buffer);
+       gtk_text_buffer_get_iter_at_mark (buffer, &insert_iter, insert_mark);
+
        /* get the first line and the height of the line */
        gtk_text_buffer_get_start_iter (buffer, &iter);
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (text_view), &iter, &iter_rectangle);
 
        /* Count lines in text view */
        for (line = 0; line < line_limit; line++) {
        /* get the first line and the height of the line */
        gtk_text_buffer_get_start_iter (buffer, &iter);
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (text_view), &iter, &iter_rectangle);
 
        /* Count lines in text view */
        for (line = 0; line < line_limit; line++) {
-               if (!gtk_text_view_forward_display_line (GTK_TEXT_VIEW (text_view), &iter))
+               if (!gtk_text_view_forward_display_line_end (GTK_TEXT_VIEW (text_view), &iter))
                        break;
                        break;
+               else 
+                       gtk_text_view_forward_display_line (GTK_TEXT_VIEW (text_view), &iter);
        }
 
        }
 
-       /* Put again the cursor in the first character. Also scroll to first line */
-       gtk_text_buffer_get_start_iter (buffer, &iter);
-       gtk_text_buffer_place_cursor (buffer, &iter);
-       gtk_text_view_place_cursor_onscreen (GTK_TEXT_VIEW (text_view));
-
        /* Change the adjustment properties for one line per step behavior */
        adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (widget));
        if (adj != NULL) {
        /* Change the adjustment properties for one line per step behavior */
        adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (widget));
        if (adj != NULL) {
-               g_object_set (G_OBJECT (adj), "page-increment", (gdouble) iter_rectangle.height, "step-increment", (gdouble) iter_rectangle.height, NULL);
+               g_object_set (G_OBJECT (adj), "page-increment", (gdouble) iter_rectangle.height + 1, "step-increment", (gdouble) iter_rectangle.height + 1, NULL);
                gtk_adjustment_changed (adj);
        }
 
        /* Set the requisition height to the get the limit of lines or less */
        if (line > 0) {
                gtk_adjustment_changed (adj);
        }
 
        /* Set the requisition height to the get the limit of lines or less */
        if (line > 0) {
-               requisition->height = iter_rectangle.height * MAX (line, line_limit);
+               requisition->height = iter_rectangle.height * MIN (line + 1, line_limit);
        } else {
                requisition->height = iter_rectangle.height;
        }
 
        } else {
                requisition->height = iter_rectangle.height;
        }
 
+       if (gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (widget)) != GTK_SHADOW_NONE) {
+               requisition->height += GTK_WIDGET (widget)->style->ythickness * 2;
+       }
+               
        priv->line_height = iter_rectangle.height;
 
        priv->line_height = iter_rectangle.height;
 
+       /* Put again the cursor in the first character. Also scroll to first line */
+       gtk_text_buffer_place_cursor (buffer, &insert_iter);
+       gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (text_view), insert_mark);
+
 }
 
 static void
 }
 
 static void
@@ -164,6 +174,7 @@ modest_scroll_text_set_text_view (ModestScrollText *scroll_text,
                                  GtkTextView *text_view)
 {
        ModestScrollTextPriv *priv = MODEST_SCROLL_TEXT_GET_PRIVATE (scroll_text);
                                  GtkTextView *text_view)
 {
        ModestScrollTextPriv *priv = MODEST_SCROLL_TEXT_GET_PRIVATE (scroll_text);
+       GtkStyle *style;
 
        g_return_if_fail (MODEST_IS_SCROLL_TEXT (scroll_text));
        if (text_view == NULL) {
 
        g_return_if_fail (MODEST_IS_SCROLL_TEXT (scroll_text));
        if (text_view == NULL) {
@@ -189,6 +200,9 @@ modest_scroll_text_set_text_view (ModestScrollText *scroll_text,
        gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->text_view), 0);
        gtk_text_view_set_right_margin (GTK_TEXT_VIEW (priv->text_view), 0);
 
        gtk_text_view_set_left_margin (GTK_TEXT_VIEW (priv->text_view), 0);
        gtk_text_view_set_right_margin (GTK_TEXT_VIEW (priv->text_view), 0);
 
+       style = gtk_rc_get_style (GTK_WIDGET (scroll_text));
+       gtk_widget_modify_base (priv->text_view, GTK_STATE_NORMAL, & (style->bg[GTK_STATE_NORMAL]));
+
        gtk_container_add (GTK_CONTAINER (scroll_text), priv->text_view);
 
        if (GTK_WIDGET_REALIZED (scroll_text)) {
        gtk_container_add (GTK_CONTAINER (scroll_text), priv->text_view);
 
        if (GTK_WIDGET_REALIZED (scroll_text)) {