From 2bec9e15edfdc196dd9bc9999d1c29046764c63d Mon Sep 17 00:00:00 2001 From: hiro Date: Wed, 16 Aug 2006 04:56:20 +0000 Subject: sourcewindow.c: fixed scrolling problem on first click. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1126 ee746299-78ed-0310-b773-934348b2243d --- src/sourcewindow.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/sourcewindow.c') diff --git a/src/sourcewindow.c b/src/sourcewindow.c index a135899a..b1926fe7 100644 --- a/src/sourcewindow.c +++ b/src/sourcewindow.c @@ -47,6 +47,9 @@ static gboolean key_pressed (GtkWidget *widget, GdkEventKey *event, SourceWindow *sourcewin); +static void adj_value_changed (GtkAdjustment *adj, + SourceWindow *sourcewin); + static void source_window_init() { } @@ -96,6 +99,10 @@ SourceWindow *source_window_create(void) gtk_container_add(GTK_CONTAINER(scrolledwin), text); gtk_widget_show(text); + g_signal_connect(G_OBJECT(GTK_TEXT_VIEW(text)->vadjustment), + "value-changed", + G_CALLBACK(adj_value_changed), sourcewin); + sourcewin->window = window; sourcewin->scrolledwin = scrolledwin; sourcewin->text = text; @@ -122,6 +129,8 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo) gchar *title; FILE *fp; gchar buf[BUFFSIZE]; + GtkTextBuffer *buffer; + GtkTextIter iter; g_return_if_fail(msginfo != NULL); @@ -145,6 +154,10 @@ void source_window_show_msg(SourceWindow *sourcewin, MsgInfo *msginfo) source_window_append(sourcewin, buf); fclose(fp); + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sourcewin->text)); + gtk_text_buffer_get_start_iter(buffer, &iter); + gtk_text_buffer_place_cursor(buffer, &iter); } void source_window_append(SourceWindow *sourcewin, const gchar *str) @@ -187,3 +200,13 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, } return FALSE; } + +static void adj_value_changed(GtkAdjustment *adj, SourceWindow *sourcewin) +{ + GtkTextBuffer *buffer; + + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sourcewin->text)); + if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) + return; + gtk_text_view_place_cursor_onscreen(GTK_TEXT_VIEW(sourcewin->text)); +} -- cgit v1.2.3