changeset 15318:d928cf5ead1b

[gaim-migrate @ 18108] bug fix. Breaks 'don't scroll if you're not already scrolled at the bottom' and selecton. I'll look at those tomorrow, but amd committing it in case someone knowledgable wants to beat me to it. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 11 Jan 2007 08:43:34 +0000
parents a92c64f06995
children b17a907065cc
files gtk/gtkimhtml.c gtk/gtkimhtml.h
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkimhtml.c	Thu Jan 11 07:43:03 2007 +0000
+++ b/gtk/gtkimhtml.c	Thu Jan 11 08:43:34 2007 +0000
@@ -1220,6 +1220,8 @@
 	g_slist_free(imhtml->im_images);
 	g_free(imhtml->protocol_name);
 	g_free(imhtml->search_string);
+	g_object_unref(imhtml->empty_buffer);
+	g_object_unref(imhtml->text_buffer);
 	G_OBJECT_CLASS(parent_class)->finalize (object);
 }
 
@@ -1317,6 +1319,7 @@
 {
 	GtkTextIter iter;
 	imhtml->text_buffer = gtk_text_buffer_new(NULL);
+	imhtml->empty_buffer = gtk_text_buffer_new(NULL);
 	gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter);
 	gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer);
 	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
@@ -2355,12 +2358,21 @@
 	}
 }
 
+static gboolean
+set_adj_idle_cb(gpointer data)
+{
+	GtkIMHtml *imhtml = data;
+	gtk_adjustment_set_value(GTK_TEXT_VIEW(imhtml)->vadjustment, imhtml->adj);
+	return FALSE;
+}
+
 void gtk_imhtml_insert_html_at_iter(GtkIMHtml        *imhtml,
                                     const gchar      *text,
                                     GtkIMHtmlOptions  options,
                                     GtkTextIter      *iter)
 {
 	GdkRectangle rect;
+	GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment;
 	gint pos = 0;
 	gchar *ws;
 	gchar *tag;
@@ -2372,6 +2384,7 @@
 	gchar *amp;
 	gint len_protocol;
 
+
 	guint	bold = 0,
 		italics = 0,
 		underline = 0,
@@ -2395,6 +2408,9 @@
 	ws = g_malloc(len + 1);
 	ws[0] = 0;
 
+	imhtml->adj = gtk_adjustment_get_value(adj);
+	gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->empty_buffer);
+
 	while (pos < len) {
 		if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) {
 			c++;
@@ -3052,6 +3068,8 @@
 		gtk_imhtml_close_tags(imhtml, iter);
 
 	object = g_object_ref(G_OBJECT(imhtml));
+	gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer);
+	g_idle_add(set_adj_idle_cb, imhtml);
 	g_signal_emit(object, signals[UPDATE_FORMAT], 0);
 	g_object_unref(object);
 
--- a/gtk/gtkimhtml.h	Thu Jan 11 07:43:03 2007 +0000
+++ b/gtk/gtkimhtml.h	Thu Jan 11 08:43:34 2007 +0000
@@ -79,6 +79,7 @@
 struct _GtkIMHtml {
 	GtkTextView text_view;
 	GtkTextBuffer *text_buffer;
+	GtkTextBuffer *empty_buffer;
 	GdkCursor *hand_cursor;
 	GdkCursor *arrow_cursor;
 	GdkCursor *text_cursor;
@@ -87,6 +88,7 @@
 	char *protocol_name;
 	guint scroll_src;
 	GTimer *scroll_time;
+	gdouble adj;
 
 	gboolean show_comments;