aboutsummaryrefslogtreecommitdiff
path: root/src/gtkutils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-22 08:47:30 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-09-22 08:47:30 +0000
commit39a1d4cf0bd2ae39c2300b12f9c826514acd560e (patch)
tree7a998a377493ad15ee9ac478d19b056535ec3a5f /src/gtkutils.c
parentab756417b394ba20a43b6836db5e01469584df23 (diff)
summaryview.c: align selected row to center when reached to the edge on key operation.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@600 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/gtkutils.c')
-rw-r--r--src/gtkutils.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/gtkutils.c b/src/gtkutils.c
index 71674a33..54091314 100644
--- a/src/gtkutils.c
+++ b/src/gtkutils.c
@@ -555,7 +555,8 @@ void gtkut_tree_view_vertical_autoscroll(GtkTreeView *treeview)
}
/* modified version of gtk_tree_view_scroll_to_cell */
-void gtkut_tree_view_scroll_to_cell(GtkTreeView *treeview, GtkTreePath *path)
+void gtkut_tree_view_scroll_to_cell(GtkTreeView *treeview, GtkTreePath *path,
+ gboolean align_center)
{
GdkRectangle cell_rect;
GdkRectangle vis_rect;
@@ -575,14 +576,24 @@ void gtkut_tree_view_scroll_to_cell(GtkTreeView *treeview, GtkTreePath *path)
/* add margin */
if (cell_rect.height * 2 < vis_rect.height)
- margin = cell_rect.height + 2;
+ margin = cell_rect.height + (align_center ? 0 : 2);
- if (cell_rect.y < vis_rect.y + margin)
- dest_y = cell_rect.y - margin;
+ if (cell_rect.y < vis_rect.y + margin) {
+ if (align_center)
+ dest_y = cell_rect.y -
+ (vis_rect.height - cell_rect.height) / 2;
+ else
+ dest_y = cell_rect.y - margin;
+ }
if (cell_rect.y + cell_rect.height >
- vis_rect.y + vis_rect.height - margin)
- dest_y = cell_rect.y + cell_rect.height - vis_rect.height +
- margin;
+ vis_rect.y + vis_rect.height - margin) {
+ if (align_center)
+ dest_y = cell_rect.y -
+ (vis_rect.height - cell_rect.height) / 2;
+ else
+ dest_y = cell_rect.y + cell_rect.height -
+ vis_rect.height + margin;
+ }
gtk_tree_view_scroll_to_point(treeview, dest_x, dest_y);
}