diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-22 08:47:30 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-09-22 08:47:30 +0000 |
commit | 39a1d4cf0bd2ae39c2300b12f9c826514acd560e (patch) | |
tree | 7a998a377493ad15ee9ac478d19b056535ec3a5f /src | |
parent | ab756417b394ba20a43b6836db5e01469584df23 (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')
-rw-r--r-- | src/gtkutils.c | 25 | ||||
-rw-r--r-- | src/gtkutils.h | 3 | ||||
-rw-r--r-- | src/summaryview.c | 13 | ||||
-rw-r--r-- | src/summaryview.h | 2 |
4 files changed, 32 insertions, 11 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); } diff --git a/src/gtkutils.h b/src/gtkutils.h index 2a867660..efd6802f 100644 --- a/src/gtkutils.h +++ b/src/gtkutils.h @@ -155,7 +155,8 @@ void gtkut_tree_view_expand_parent_all (GtkTreeView *treeview, void gtkut_tree_view_vertical_autoscroll(GtkTreeView *treeview); void gtkut_tree_view_scroll_to_cell (GtkTreeView *treeview, - GtkTreePath *path); + GtkTreePath *path, + gboolean align_center); void gtkut_combo_set_items (GtkCombo *combo, const gchar *str1, ...); diff --git a/src/summaryview.c b/src/summaryview.c index 01e2b409..d2372398 100644 --- a/src/summaryview.c +++ b/src/summaryview.c @@ -789,6 +789,7 @@ void summary_clear_list(SummaryView *summaryview) } summaryview->filtered = 0; + summaryview->on_button_press = FALSE; summaryview->can_toggle_selection = TRUE; summaryview->on_drag = FALSE; if (summaryview->pressed_path) { @@ -1288,7 +1289,8 @@ void summary_select_row(SummaryView *summaryview, GtkTreeIter *iter, path, NULL, TRUE, 0.5, 0.0); } else { gtkut_tree_view_scroll_to_cell - (GTK_TREE_VIEW(summaryview->treeview), path); + (GTK_TREE_VIEW(summaryview->treeview), path, + !summaryview->on_button_press); } gtk_tree_path_free(path); @@ -1310,7 +1312,8 @@ static void summary_scroll_to_selected(SummaryView *summaryview, path, NULL, TRUE, 0.5, 0.0); else gtkut_tree_view_scroll_to_cell - (GTK_TREE_VIEW(summaryview->treeview), path); + (GTK_TREE_VIEW(summaryview->treeview), path, + FALSE); gtk_tree_path_free(path); } } @@ -2230,7 +2233,8 @@ static void summary_display_msg_full(SummaryView *summaryview, (GTK_NOTEBOOK(msgview->notebook)) == 0))) gtk_widget_grab_focus(summaryview->treeview); gtkut_tree_view_scroll_to_cell - (GTK_TREE_VIEW(summaryview->treeview), path); + (GTK_TREE_VIEW(summaryview->treeview), path, + !summaryview->on_button_press); gtk_tree_path_free(path); } @@ -4540,6 +4544,8 @@ static gboolean summary_button_pressed(GtkWidget *treeview, } if (event->button == 1) { + summaryview->on_button_press = TRUE; + if (summary_get_selection_type(summaryview) == SUMMARY_SELECTED_MULTIPLE && is_selected && !mod_pressed) { @@ -4588,6 +4594,7 @@ static gboolean summary_button_released(GtkWidget *treeview, NULL, FALSE); } + summaryview->on_button_press = FALSE; summaryview->can_toggle_selection = TRUE; summaryview->on_drag = FALSE; if (summaryview->pressed_path) { diff --git a/src/summaryview.h b/src/summaryview.h index d2ba350c..1711c704 100644 --- a/src/summaryview.h +++ b/src/summaryview.h @@ -122,6 +122,8 @@ private: /* counter for filtering */ gint filtered; + gboolean on_button_press; + /* for DnD */ gboolean can_toggle_selection; gboolean on_drag; |