From f9bd7bb035d6e5df573cd9530e381bf2a1d33c76 Mon Sep 17 00:00:00 2001 From: Margaux Clerc Date: Thu, 16 May 2013 12:25:53 +0200 Subject: [PATCH] scroll to the end when load chat history --- gtk/chat.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gtk/chat.c b/gtk/chat.c index a58f443d..13c14061 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -129,6 +129,15 @@ void udpate_tab_chat_header(GtkWidget *chat_view,const LinphoneAddress *uri,Linp gtk_widget_show_all(w); } +static gboolean scroll_to_end(GtkTextView *w){ + GtkTextBuffer *buffer=gtk_text_view_get_buffer(w); + GtkTextIter iter; + gtk_text_buffer_get_end_iter(buffer,&iter); + GtkTextMark *mark=gtk_text_buffer_create_mark(buffer,NULL,&iter,FALSE); + gtk_text_view_scroll_mark_onscreen(w,mark); + return FALSE; +} + void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, gboolean me,LinphoneChatRoom *cr,LinphoneChatMessage *msg, gboolean hist){ GtkTextView *text=GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textview")); @@ -199,8 +208,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, } gtk_text_buffer_get_end_iter(buffer,&iter); gtk_text_buffer_insert(buffer,&iter,"\n",-1); - GtkTextMark *mark=gtk_text_buffer_create_mark(buffer,NULL,&iter,FALSE); - gtk_text_view_scroll_mark_onscreen(text,mark); + g_idle_add((GSourceFunc)scroll_to_end,text); ms_free(from_str); } -- 2.39.2