refactor to work correctly in RTL mode.

2006-05-28  Kristian Rietveld  <kris@gtk.org>

	* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_cell_focus): refactor
	to work correctly in RTL mode.

	* gtk/gtktreeview.c (gtk_tree_view_move_cursor_left_right): make
	cursor movement to left/right work correctly in RTL mode.
This commit is contained in:
Kristian Rietveld 2006-05-28 21:51:04 +00:00 committed by Kristian Rietveld
parent 9ed04de455
commit 3c6fb8881c
4 changed files with 75 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2006-05-28 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_cell_focus): refactor
to work correctly in RTL mode.
* gtk/gtktreeview.c (gtk_tree_view_move_cursor_left_right): make
cursor movement to left/right work correctly in RTL mode.
2006-05-28 Behdad Esfahbod <behdad@gnome.org>
* gdk/gdkrectangle.c (gdk_rectangle_union, gdk_rectangle_intersect):

View File

@ -1,3 +1,11 @@
2006-05-28 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeviewcolumn.c (_gtk_tree_view_column_cell_focus): refactor
to work correctly in RTL mode.
* gtk/gtktreeview.c (gtk_tree_view_move_cursor_left_right): make
cursor movement to left/right work correctly in RTL mode.
2006-05-28 Behdad Esfahbod <behdad@gnome.org>
* gdk/gdkrectangle.c (gdk_rectangle_union, gdk_rectangle_intersect):

View File

@ -8905,10 +8905,10 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
}
gtk_tree_path_free (cursor_path);
list = tree_view->priv->columns;
list = rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns);
if (tree_view->priv->focus_column)
{
for (list = tree_view->priv->columns; list; list = list->next)
for (; list; list = (rtl ? list->prev : list->next))
{
if (list->data == tree_view->priv->focus_column)
break;
@ -8917,6 +8917,8 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
while (list)
{
gboolean left, right;
column = list->data;
if (column->visible == FALSE)
goto loop_end;
@ -8926,9 +8928,19 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
&iter,
GTK_RBNODE_FLAG_SET (cursor_node, GTK_RBNODE_IS_PARENT),
cursor_node->children?TRUE:FALSE);
if (_gtk_tree_view_column_cell_focus (column, count,
list->prev?TRUE:FALSE,
list->next?TRUE:FALSE))
if (rtl)
{
right = list->prev ? TRUE : FALSE;
left = list->next ? TRUE : FALSE;
}
else
{
left = list->prev ? TRUE : FALSE;
right = list->next ? TRUE : FALSE;
}
if (_gtk_tree_view_column_cell_focus (column, count, left, right))
{
tree_view->priv->focus_column = column;
found_column = TRUE;

View File

@ -3250,8 +3250,10 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
gboolean right)
{
gint count;
gboolean rtl;
count = _gtk_tree_view_column_count_special_cells (tree_column);
rtl = gtk_widget_get_direction (GTK_WIDGET (tree_column->tree_view)) == GTK_TEXT_DIR_RTL;
/* if we are the current focus column and have multiple editable cells,
* try to select the next one, else move the focus to the next column
@ -3276,8 +3278,16 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
if (!list || !info || !info->has_focus)
return FALSE;
next = gtk_tree_view_column_cell_next (tree_column, list);
prev = gtk_tree_view_column_cell_prev (tree_column, list);
if (rtl)
{
prev = gtk_tree_view_column_cell_next (tree_column, list);
next = gtk_tree_view_column_cell_prev (tree_column, list);
}
else
{
next = gtk_tree_view_column_cell_next (tree_column, list);
prev = gtk_tree_view_column_cell_prev (tree_column, list);
}
info->has_focus = FALSE;
if (direction > 0 && next)
@ -3288,8 +3298,12 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
}
else if (direction > 0 && !next && !right)
{
/* keep focus on latest cell */
info = gtk_tree_view_column_cell_last (tree_column)->data;
/* keep focus on last cell */
if (rtl)
info = gtk_tree_view_column_cell_first (tree_column)->data;
else
info = gtk_tree_view_column_cell_last (tree_column)->data;
info->has_focus = TRUE;
return TRUE;
}
@ -3302,7 +3316,11 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
else if (direction < 0 && !prev && !left)
{
/* keep focus on first cell */
info = gtk_tree_view_column_cell_first (tree_column)->data;
if (rtl)
info = gtk_tree_view_column_cell_last (tree_column)->data;
else
info = gtk_tree_view_column_cell_first (tree_column)->data;
info->has_focus = TRUE;
return TRUE;
}
@ -3325,11 +3343,26 @@ _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
info->has_focus = FALSE;
}
if (direction > 0)
((GtkTreeViewColumnCellInfo *)gtk_tree_view_column_cell_first (tree_column)->data)->has_focus = TRUE;
else if (direction < 0)
((GtkTreeViewColumnCellInfo *)gtk_tree_view_column_cell_last (tree_column)->data)->has_focus = TRUE;
list = NULL;
if (rtl)
{
if (direction > 0)
list = gtk_tree_view_column_cell_last (tree_column);
else if (direction < 0)
list = gtk_tree_view_column_cell_first (tree_column);
}
else
{
if (direction > 0)
list = gtk_tree_view_column_cell_first (tree_column);
else if (direction < 0)
list = gtk_tree_view_column_cell_last (tree_column);
}
if (list)
((GtkTreeViewColumnCellInfo *) list->data)->has_focus = TRUE;
}
return TRUE;
}