changeset 8729:7024b9145357

[gaim-migrate @ 9484] (16:29:26) marv: The patch adds a gtk_imhtml_scroll_to_bottom, and makes the history plugin use it. gtk_text_view_scroll_to_iter bad, gtk_text_view_scroll_to_mark good committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 20 Apr 2004 20:31:11 +0000
parents 268461757fd6
children 8b935eddeb10
files plugins/history.c src/gtkimhtml.c src/gtkimhtml.h
diffstat 3 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/history.c	Tue Apr 20 20:28:55 2004 +0000
+++ b/plugins/history.c	Tue Apr 20 20:31:11 2004 +0000
@@ -24,7 +24,6 @@
 	char *history = NULL;
 	guint flags;
 	GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS;
-	GtkTextIter end;
 	GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c),
 			gaim_conversation_get_account(c));
 
@@ -36,10 +35,7 @@
 		options |= GTK_IMHTML_NO_NEWLINE;
 	gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options);
 	gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options);
-	gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->imhtml)->text_buffer,
-			&end);
-	gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0,
-			TRUE, 0, 0);
+	gtk_imhtml_scroll_to_end(GTK_IMHTML(gtkconv->imhtml));
 	g_free(history);
 	while (logs) {
 		GaimLog *log = logs->data;
--- a/src/gtkimhtml.c	Tue Apr 20 20:28:55 2004 +0000
+++ b/src/gtkimhtml.c	Tue Apr 20 20:31:11 2004 +0000
@@ -1747,19 +1747,26 @@
 	}
 
 	if (!(options & GTK_IMHTML_NO_SCROLL)) {
-		/* If this seems backwards at first glance, well it's not.
-		 * It means scroll such that the mark is closest to the top,
-		 * and closest to the right as possible. Remember kids, you have
-		 * to scroll left to move a given spot closest to the right,
-		 * and scroll down to move a spot closest to the top.
-		 */
-		gtk_text_iter_set_line_offset(&iter, 0);
-		gtk_text_buffer_move_mark(imhtml->text_buffer, imhtml->scrollpoint, &iter);
-		gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), imhtml->scrollpoint,
-		                             0, TRUE, 1.0, 0.0);
+		gtk_imhtml_scroll_to_end(imhtml);
 	}
 }
 
+void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml)
+{
+	GtkTextIter iter;
+	/* If this seems backwards at first glance, well it's not.
+	 * It means scroll such that the mark is closest to the top,
+	 * and closest to the right as possible. Remember kids, you have
+	 * to scroll left to move a given spot closest to the right,
+	 * and scroll down to move a spot closest to the top.
+	 */
+	gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter);
+	gtk_text_iter_set_line_offset(&iter, 0);
+	gtk_text_buffer_move_mark(imhtml->text_buffer, imhtml->scrollpoint, &iter);
+	gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), imhtml->scrollpoint,
+	                             0, TRUE, 1.0, 0.0);
+}
+
 void gtk_imhtml_insert_html_at_iter(GtkIMHtml        *imhtml,
                                     const gchar      *text,
                                     GtkIMHtmlOptions  options,
--- a/src/gtkimhtml.h	Tue Apr 20 20:28:55 2004 +0000
+++ b/src/gtkimhtml.h	Tue Apr 20 20:31:11 2004 +0000
@@ -209,6 +209,7 @@
                                     const gchar      *text,
                                     GtkIMHtmlOptions  options,
                                     GtkTextIter      *iter);
+void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml);
 void       gtk_imhtml_clear            (GtkIMHtml *imhtml);
 void       gtk_imhtml_page_up          (GtkIMHtml *imhtml);
 void       gtk_imhtml_page_down        (GtkIMHtml *imhtml);