| 2543 } |
2543 } |
| 2544 |
2544 |
| 2545 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); |
2545 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); |
| 2546 |
2546 |
| 2547 height = 0; |
2547 height = 0; |
| 2548 wrapped_lines = 1; |
2548 display_lines = 1; |
| 2549 gtk_text_buffer_get_start_iter(buffer, &iter); |
2549 gtk_text_buffer_get_start_iter(buffer, &iter); |
| 2550 do { |
2550 do { |
| 2551 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline); |
2551 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline); |
| 2552 height += oneline.height; |
2552 height += oneline.height; |
| 2553 wrapped_lines++; |
2553 display_lines++; |
| 2554 if (wrapped_lines > 4) |
2554 } while (display_lines <= 4 && |
| 2555 break; |
2555 gtk_text_view_forward_display_line(GTK_TEXT_VIEW(status_box->imhtml), &iter)); |
| 2556 } while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(status_box->imhtml), &iter)); |
|
| 2557 |
2556 |
| 2558 /* |
2557 /* |
| 2559 * This check fixes the case where the last character entered is a |
2558 * This check fixes the case where the last character entered is a |
| 2560 * newline (shift+return). For some reason the |
2559 * newline (shift+return). For some reason the |
| 2561 * gtk_text_view_forward_display_line() function doesn't treat this |
2560 * gtk_text_view_forward_display_line() function doesn't treat this |
| 2562 * like a new line, and so we think the input box only needs to be |
2561 * like a new line, and so we think the input box only needs to be |
| 2563 * two lines instead of three, for example. So we check if the |
2562 * two lines instead of three, for example. So we check if the |
| 2564 * last character was a newline and add some extra height if so. |
2563 * last character was a newline and add some extra height if so. |
| 2565 */ |
2564 */ |
| 2566 if (wrapped_lines <= 4 |
2565 if (display_lines <= 4 |
| 2567 && gtk_text_iter_backward_char(&iter) |
2566 && gtk_text_iter_backward_char(&iter) |
| 2568 && gtk_text_iter_get_char(&iter) == '\n') |
2567 && gtk_text_iter_get_char(&iter) == '\n') |
| 2569 { |
2568 { |
| 2570 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline); |
2569 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline); |
| 2571 height += oneline.height; |
2570 height += oneline.height; |
| 2573 |
2572 |
| 2574 lines = gtk_text_buffer_get_line_count(buffer); |
2573 lines = gtk_text_buffer_get_line_count(buffer); |
| 2575 |
2574 |
| 2576 /* Show a maximum of 4 lines */ |
2575 /* Show a maximum of 4 lines */ |
| 2577 lines = MIN(lines, 4); |
2576 lines = MIN(lines, 4); |
| 2578 wrapped_lines = MIN(wrapped_lines, 4); |
2577 display_lines = MIN(display_lines, 4); |
| 2579 |
2578 |
| 2580 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(status_box->imhtml)); |
2579 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(status_box->imhtml)); |
| 2581 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(status_box->imhtml)); |
2580 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(status_box->imhtml)); |
| 2582 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(status_box->imhtml)); |
2581 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(status_box->imhtml)); |
| 2583 |
2582 |
| 2584 height += (pad_top + pad_bottom) * lines; |
2583 height += (pad_top + pad_bottom) * lines; |
| 2585 height += (pad_inside) * (wrapped_lines - lines); |
2584 height += (pad_inside) * (display_lines - lines); |
| 2586 |
2585 |
| 2587 gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE); |
2586 gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE); |
| 2588 } |
2587 } |
| 2589 |
2588 |
| 2590 static void remove_typing_cb(PidginStatusBox *status_box) |
2589 static void remove_typing_cb(PidginStatusBox *status_box) |