[gtk+/treeview-refactor-staging: 76/78] Modified gtk_tree_view_move_cursor_up_down to move focus inside the cell area
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor-staging: 76/78] Modified gtk_tree_view_move_cursor_up_down to move focus inside the cell area
- Date: Thu, 9 Dec 2010 09:16:16 +0000 (UTC)
commit ac3a4362f41f90c1a120f7dd810b5f17f7e395f9
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Dec 9 18:01:16 2010 +0900
Modified gtk_tree_view_move_cursor_up_down to move focus inside the cell area
This currently leaves us the problem of maintaining the right cell in
focus for horizontal areas, the solution for that comming in the
next patch.
gtk/gtktreeview.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 59573ce..3095fc7 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -10094,6 +10094,9 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view,
GtkTreePath *cursor_path = NULL;
gboolean grab_focus = TRUE;
gboolean selectable;
+ GtkDirectionType direction;
+ GtkCellArea *cell_area = NULL;
+ GtkTreeIter iter;
if (! gtk_widget_has_focus (GTK_WIDGET (tree_view)))
return;
@@ -10111,6 +10114,26 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view,
/* FIXME: we lost the cursor; should we get the first? */
return;
+ direction = count < 0 ? GTK_DIR_UP : GTK_DIR_DOWN;
+
+
+ if (tree_view->priv->focus_column)
+ cell_area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (tree_view->priv->focus_column));
+
+ /* If focus stays in the area for this row, then just return for this round */
+ if (cell_area && (count == -1 || count == 1) &&
+ gtk_tree_model_get_iter (tree_view->priv->model, &iter, cursor_path))
+ {
+ gtk_tree_view_column_cell_set_cell_data (tree_view->priv->focus_column,
+ tree_view->priv->model,
+ &iter,
+ GTK_RBNODE_FLAG_SET (cursor_node, GTK_RBNODE_IS_PARENT),
+ cursor_node->children?TRUE:FALSE);
+
+ if (gtk_cell_area_focus (cell_area, direction))
+ return;
+ }
+
selection_count = gtk_tree_selection_count_selected_rows (tree_view->priv->selection);
selectable = _gtk_tree_selection_row_is_selectable (tree_view->priv->selection,
cursor_node,
@@ -10182,6 +10205,10 @@ gtk_tree_view_move_cursor_up_down (GtkTreeView *tree_view,
cursor_path = _gtk_tree_view_find_path (tree_view, new_cursor_tree, new_cursor_node);
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, TRUE);
gtk_tree_path_free (cursor_path);
+
+ /* Give focus to the area in the new row */
+ if (cell_area)
+ gtk_cell_area_focus (cell_area, direction);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]