pidgin/gtkstatusbox.c

changeset 26378
e85d894af8a5
parent 25903
7a2258038ceb
child 26753
a8dca8faae69
equal deleted inserted replaced
26377:9124a345ed3a 26378:e85d894af8a5
1644 status_box->popup_in_progress && 1644 status_box->popup_in_progress &&
1645 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (status_box->toggle_button))) { 1645 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (status_box->toggle_button))) {
1646 pidgin_status_box_popdown (status_box); 1646 pidgin_status_box_popdown (status_box);
1647 return TRUE; 1647 return TRUE;
1648 } else if (ewidget == status_box->toggle_button) { 1648 } else if (ewidget == status_box->toggle_button) {
1649 status_box->popup_in_progress = TRUE; 1649 status_box->popup_in_progress = TRUE;
1650 } 1650 }
1651 1651
1652 /* released outside treeview */ 1652 /* released outside treeview */
1653 if (ewidget != status_box->toggle_button) { 1653 if (ewidget != status_box->toggle_button) {
1654 pidgin_status_box_popdown (status_box); 1654 pidgin_status_box_popdown (status_box);
1696 ret = FALSE; 1696 ret = FALSE;
1697 1697
1698 gtk_tree_path_free (path); 1698 gtk_tree_path_free (path);
1699 return ret; 1699 return ret;
1700 } 1700 }
1701 } 1701 }
1702 } 1702 }
1703 return FALSE; 1703 return FALSE;
1704 } 1704 }
1705 1705
1706 static void 1706 static void
1775 status_box->hbox = gtk_hbox_new(FALSE, 6); 1775 status_box->hbox = gtk_hbox_new(FALSE, 6);
1776 status_box->cell_view = gtk_cell_view_new(); 1776 status_box->cell_view = gtk_cell_view_new();
1777 status_box->vsep = gtk_vseparator_new(); 1777 status_box->vsep = gtk_vseparator_new();
1778 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); 1778 status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
1779 1779
1780 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, 1780 status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING,
1781 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN); 1781 G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN);
1782 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, 1782 status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING,
1783 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); 1783 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN);
1784 1784
1785 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); 1785 gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store));
1786 gtk_list_store_append(status_box->store, &(status_box->iter)); 1786 gtk_list_store_append(status_box->store, &(status_box->iter));
1787 1787
2527 2527
2528 static void update_size(PidginStatusBox *status_box) 2528 static void update_size(PidginStatusBox *status_box)
2529 { 2529 {
2530 GtkTextBuffer *buffer; 2530 GtkTextBuffer *buffer;
2531 GtkTextIter iter; 2531 GtkTextIter iter;
2532 int wrapped_lines; 2532 int display_lines;
2533 int lines; 2533 int lines;
2534 GdkRectangle oneline; 2534 GdkRectangle oneline;
2535 int height; 2535 int height;
2536 int pad_top, pad_inside, pad_bottom; 2536 int pad_top, pad_inside, pad_bottom;
2537 2537
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)); 2556
2557 /*
2558 * This check fixes the case where the last character entered is a
2559 * newline (shift+return). For some reason the
2560 * gtk_text_view_forward_display_line() function doesn't treat this
2561 * like a new line, and so we think the input box only needs to be
2562 * two lines instead of three, for example. So we check if the
2563 * last character was a newline and add some extra height if so.
2564 */
2565 if (display_lines <= 4
2566 && gtk_text_iter_backward_char(&iter)
2567 && gtk_text_iter_get_char(&iter) == '\n')
2568 {
2569 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline);
2570 height += oneline.height;
2571 display_lines++;
2572 }
2557 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 display_lines = MIN(display_lines, 4);
2563 2579
2564 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(status_box->imhtml)); 2580 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(status_box->imhtml));
2565 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(status_box->imhtml)); 2581 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(status_box->imhtml));
2566 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(status_box->imhtml)); 2582 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(status_box->imhtml));
2567 2583
2568 height += (pad_top + pad_bottom) * lines; 2584 height += (pad_top + pad_bottom) * lines;
2569 height += (pad_inside) * (wrapped_lines - lines); 2585 height += (pad_inside) * (display_lines - lines);
2570 2586
2571 gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE); 2587 gtk_widget_set_size_request(status_box->vbox, -1, height + PIDGIN_HIG_BOX_SPACE);
2572 } 2588 }
2573 2589
2574 static void remove_typing_cb(PidginStatusBox *status_box) 2590 static void remove_typing_cb(PidginStatusBox *status_box)

mercurial