Mercurial > pidgin
diff src/gtkconv.c @ 11224:409d6a11da51
[gaim-migrate @ 13360]
Restrict the conversation scrollback. Current default is 4000 lines. This also fixes the IM images not actually being cleared by gtk_imhtml_clear().
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 10 Aug 2005 21:13:44 +0000 |
parents | e552095ec599 |
children | 8b3d1b2c2c43 |
line wrap: on
line diff
--- a/src/gtkconv.c Wed Aug 10 05:45:17 2005 +0000 +++ b/src/gtkconv.c Wed Aug 10 21:13:44 2005 +0000 @@ -4964,6 +4964,9 @@ GaimConvWindow *win; GaimConnection *gc; int gtk_font_options = 0; + int max_scrollback_lines = gaim_prefs_get_int( + "/gaim/gtk/conversations/scrollback_lines"); + int line_count; char buf2[BUF_LONG]; char mdate[64]; char color[10]; @@ -4978,6 +4981,24 @@ win = gaim_conversation_get_window(conv); + line_count = gtk_text_buffer_get_line_count( + gtk_text_view_get_buffer(GTK_TEXT_VIEW( + gtkconv->imhtml))); +printf("writing to conv - max_scrollback_lines = %d our lines = %d\n", max_scrollback_lines, line_count); + /* If we're sitting at more than 100 lines more than the + max scrollback, trim down to max scrollback */ + if (max_scrollback_lines > 0 + && line_count > (max_scrollback_lines + 100)) { + GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( + GTK_TEXT_VIEW(gtkconv->imhtml)); + GtkTextIter start, end; + + gtk_text_buffer_get_start_iter(text_buffer, &start); + gtk_text_buffer_get_iter_at_line(text_buffer, &end, + (line_count - max_scrollback_lines)); + gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); + } + if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); @@ -6222,6 +6243,7 @@ gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); gaim_prefs_add_bool("/gaim/gtk/conversations/warn_on_unread_close", TRUE); + gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); /* Conversations -> Chat */ gaim_prefs_add_none("/gaim/gtk/conversations/chat");