# HG changeset patch # User Richard Laager # Date 1135166931 0 # Node ID 842b3b897cde8e70911bf8104a500a691e17e81b # Parent 037a673ba86240b723ec392b37fe8882c177b8a8 [gaim-migrate @ 14927] SF Patch #1357805 from Sadrul "Statusbox: resize This patch resizes the statusbox-entry after the entry. It shows a max. of 4 lines, otherwise resizes the height so that there's no empty place. Try it now!!" This one has lots of changes from me. It works over here. committer: Tailor Script diff -r 037a673ba862 -r 842b3b897cde src/gtkstatusbox.c --- a/src/gtkstatusbox.c Wed Dec 21 10:56:07 2005 +0000 +++ b/src/gtkstatusbox.c Wed Dec 21 12:08:51 2005 +0000 @@ -43,6 +43,7 @@ static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); static void imhtml_format_changed_cb(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons, void *data); static void remove_typing_cb(GtkGaimStatusBox *box); +static void update_size (GtkGaimStatusBox *box); static void gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box); static void gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box); @@ -328,6 +329,7 @@ gtk_tree_path_free(path); g_free(text); + update_size(status_box); } /** @@ -1030,6 +1032,55 @@ g_free(message); } +static void update_size(GtkGaimStatusBox *status_box) +{ + GtkTextBuffer *buffer; + GtkTextIter iter; + int wrapped_lines; + int lines; + GdkRectangle oneline; + int height; + int pad_top, pad_inside, pad_bottom; + + if (!status_box->imhtml_visible) + { + gtk_widget_set_size_request(status_box->vbox, -1, -1); + return; + } + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); + + wrapped_lines = 1; + gtk_text_buffer_get_start_iter(buffer, &iter); + while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(status_box->imhtml), &iter)) + wrapped_lines++; + + lines = gtk_text_buffer_get_line_count(buffer); + + /* Show a maximum of 4 lines */ + lines = MIN(lines, 4); + wrapped_lines = MIN(wrapped_lines, 4); + + gtk_text_buffer_get_start_iter(buffer, &iter); + gtk_text_view_get_iter_location(GTK_TEXT_VIEW(status_box->imhtml), &iter, &oneline); + + pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(status_box->imhtml)); + pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(status_box->imhtml)); + pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(status_box->imhtml)); + + height = (oneline.height + pad_top + pad_bottom) * lines; + height += (oneline.height + pad_inside) * (wrapped_lines - lines); + + if (status_box->typing) { + GtkRequisition requisition; + + gtk_widget_size_request(status_box->toolbar, &requisition); + height += requisition.height; + } + + gtk_widget_set_size_request(GTK_WIDGET(status_box->vbox), -1, height); +} + static void remove_typing_cb(GtkGaimStatusBox *status_box) { activate_currently_selected_status(status_box);