comparison pidgin/gtkstatusbox.c @ 25428:17168b8379f2

Fix a bug that's bothered me for a while. When pressing shift+enter in the status box to insert a newline, grow the box an extra line. Previously it didn't increase the height until you started typing, so you'd see the text scroll when you hit enter, then you'd see stuff jump around when you typed text. So the auto-expanding is a little less sucky now.
author Mark Doliner <mark@kingant.net>
date Wed, 28 Jan 2009 09:57:19 +0000
parents 584063555949
children 4c610616e018
comparison
equal deleted inserted replaced
25427:2cf7d6a20e68 25428:17168b8379f2
2553 wrapped_lines++; 2553 wrapped_lines++;
2554 if (wrapped_lines > 4) 2554 if (wrapped_lines > 4)
2555 break; 2555 break;
2556 } while (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 2557
2558 /*
2559 * This check fixes the case where the last character entered is a
2560 * newline (shift+return). For some reason the
2561 * 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
2563 * 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.
2565 */
2566 if (wrapped_lines <= 4
2567 && gtk_text_iter_backward_char(&iter)
2568 && gtk_text_iter_get_char(&iter) == '\n')
2569 {
2570 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline);
2571 height += oneline.height;
2572 }
2573
2558 lines = gtk_text_buffer_get_line_count(buffer); 2574 lines = gtk_text_buffer_get_line_count(buffer);
2559 2575
2560 /* Show a maximum of 4 lines */ 2576 /* Show a maximum of 4 lines */
2561 lines = MIN(lines, 4); 2577 lines = MIN(lines, 4);
2562 wrapped_lines = MIN(wrapped_lines, 4); 2578 wrapped_lines = MIN(wrapped_lines, 4);