aboutsummaryrefslogtreecommitdiff
path: root/src/sourcewindow.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-08-16 04:56:20 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-08-16 04:56:20 +0000
commit2bec9e15edfdc196dd9bc9999d1c29046764c63d (patch)
tree76d9b7f0dc35ef336241ba28546e057ac2a4fb4b /src/sourcewindow.c
parentfd4fa414a182c6ca1a75ec7244cc8e6ad409c56a (diff)
sourcewindow.c: fixed scrolling problem on first click.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1126 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/sourcewindow.c')
-rw-r--r--src/sourcewindow.c23
1 files changed, 23 insertions, 0 deletions
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));
+}