Commit acce60b7 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

The "big treeview focus patch". Fixes several issues and adds some

Sun May  5 16:42:32 2002  Kristian Rietveld  <kris@gtk.org>

        The "big treeview focus patch". Fixes several issues and adds some
        goodies. Related bugs: #73676, #73734, #78660.

        * gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell

        * gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
        if applicable,
        (gtk_tree_view_bin_expose): set_cell_data before iterating columns,
        add support for row-spanning focus rectangles,
        (gtk_tree_view_has_special_cell): new function,
        (gtk_tree_view_move_cursor_left_right): add support for multiple
        focusable cells in one column,
        (gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
        (gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
        with focus_cell parameter,
        (gtk_tree_view_search_iter): removed unused column variable,
        (gtk_tree_view_start_editing): add neighbor size code to allow
        for multiple editable cells in one column.

        * gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
        in_editing_mode field,
        (gtk_tree_view_column_get_edited_cell): new function, removed
        _get_editable_cell,
        (_gtk_tree_view_column_get_cell_at_pos): new function,
        (gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
        (gtk_tree_view_column_cell_process_action): loads of changes to get
        it right and to allow for multiple special cells, etc,
        (gtk_tree_view_column_cell_first): new function,
        (gtk_tree_view_column_cell_last): ditto,
        (gtk_tree_view_column_cell_next): ditto,
        (gtk_tree_view_column_cell_prev): ditto,
        (gtk_tree_view_column_cell_focus): add left and right parameters,
        allow for multiple special cells,
        (gtk_tree_view_column_cell_is_visible): add assertion,
        (gtk_tree_view_column_focus_cell): new function,
        (gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
        (_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
        correctly

        * gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell

        * gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
        _gtk_tree_view_column_get_cell_at_pos, add new parameters to
        _gtk_tree_view_column_cell_focus.

        * tests/testtreeedit.c: add some cells in order to test new code.
parent d269c210
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
Sun May 5 16:42:32 2002 Kristian Rietveld <kris@gtk.org>
The "big treeview focus patch". Fixes several issues and adds some
goodies. Related bugs: #73676, #73734, #78660.
* gtk/gtktreeview.h: add gtk_tree_view_set_cursor_on_cell
* gtk/gtktreeview.c (gtk_tree_view_button_press): focus on a cell
if applicable,
(gtk_tree_view_bin_expose): set_cell_data before iterating columns,
add support for row-spanning focus rectangles,
(gtk_tree_view_has_special_cell): new function,
(gtk_tree_view_move_cursor_left_right): add support for multiple
focusable cells in one column,
(gtk_tree_view_set_cursor): call _set_cursor_on_cell now,
(gtk_tree_view_set_cursor_on_cell): copy of _set_cursor, extended
with focus_cell parameter,
(gtk_tree_view_search_iter): removed unused column variable,
(gtk_tree_view_start_editing): add neighbor size code to allow
for multiple editable cells in one column.
* gtk/gtktreeviewcolumn.c (_GtkTreeViewColumnCellInfo): add
in_editing_mode field,
(gtk_tree_view_column_get_edited_cell): new function, removed
_get_editable_cell,
(_gtk_tree_view_column_get_cell_at_pos): new function,
(gtk_tree_view_column_pack_end): s/g_new/g_new0/ ...,
(gtk_tree_view_column_cell_process_action): loads of changes to get
it right and to allow for multiple special cells, etc,
(gtk_tree_view_column_cell_first): new function,
(gtk_tree_view_column_cell_last): ditto,
(gtk_tree_view_column_cell_next): ditto,
(gtk_tree_view_column_cell_prev): ditto,
(gtk_tree_view_column_cell_focus): add left and right parameters,
allow for multiple special cells,
(gtk_tree_view_column_cell_is_visible): add assertion,
(gtk_tree_view_column_focus_cell): new function,
(gtk_tree_view_column_stop_editing): unset in_editing_mode flag,
(_gtk_tree_view_column_get_neighbor_sizes): iterate through cells
correctly
* gtk/gtktreeviewcolumn.h: add gtk_tree_view_column_focus_cell
* gtk/gtktreeprivate.h: s/_get_editable_cell/_get_edited_cell/, add
_gtk_tree_view_column_get_cell_at_pos, add new parameters to
_gtk_tree_view_column_cell_focus.
* tests/testtreeedit.c: add some cells in order to test new code.
Sun May 5 02:22:59 2002 Soeren Sandmann <sandmann@daimi.au.dk>
* tests/test-images/*: image files for testing pixbuf loaders
......
......@@ -316,8 +316,10 @@ void _gtk_tree_view_column_autosize (GtkTreeView *tre
GtkTreeViewColumn *column);
gboolean _gtk_tree_view_column_has_editable_cell (GtkTreeViewColumn *column);
GtkCellRenderer *_gtk_tree_view_column_get_editable_cell (GtkTreeViewColumn *column);
GtkCellRenderer *_gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column);
gint _gtk_tree_view_column_count_special_cells (GtkTreeViewColumn *column);
GtkCellRenderer *_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
gint x);
GtkTreeSelection* _gtk_tree_selection_new (void);
GtkTreeSelection* _gtk_tree_selection_new_with_tree_view (GtkTreeView *tree_view);
......@@ -331,7 +333,9 @@ void _gtk_tree_view_column_cell_render (GtkTreeViewColumn *tree_column,
GdkRectangle *expose_area,
guint flags);
gboolean _gtk_tree_view_column_cell_focus (GtkTreeViewColumn *tree_column,
gint direction);
gint direction,
gboolean left,
gboolean right);
void _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
GdkWindow *window,
GdkRectangle *background_area,
......
......@@ -347,6 +347,7 @@ static void gtk_tree_view_real_set_cursor (GtkTreeView
GtkTreePath *path,
gboolean clear_and_select,
gboolean clamp_node);
static gboolean gtk_tree_view_has_special_cell (GtkTreeView *tree_view);
/* interactive search */
static void gtk_tree_view_search_dialog_destroy (GtkWidget *search_dialog,
......@@ -1709,6 +1710,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
gint dval;
gint pre_val, aft_val;
GtkTreeViewColumn *column = NULL;
GtkCellRenderer *focus_cell = NULL;
gint column_handled_click = FALSE;
gboolean emit_row_activated = FALSE;
......@@ -1829,7 +1831,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
GdkRectangle area;
area = cell_area;
_gtk_tree_view_column_get_neighbor_sizes (column, _gtk_tree_view_column_get_editable_cell (column), &left, &right);
_gtk_tree_view_column_get_neighbor_sizes (column, _gtk_tree_view_column_get_edited_cell (column), &left, &right);
area.x += left;
area.width -= right + left;
......@@ -1857,6 +1859,10 @@ gtk_tree_view_button_press (GtkWidget *widget,
pre_val = tree_view->priv->vadjustment->value;
tree_view->priv->focus_column = column;
focus_cell = _gtk_tree_view_column_get_cell_at_pos (column, event->x - background_area.x);
if (focus_cell)
gtk_tree_view_column_focus_cell (column, focus_cell);
if (event->state & GDK_CONTROL_MASK)
{
gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE);
......@@ -2727,7 +2733,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
GList *last_column;
gint vertical_separator;
gint horizontal_separator;
gint focus_line_width;
gboolean allow_rules;
gboolean has_special_cell;
g_return_val_if_fail (GTK_IS_TREE_VIEW (widget), FALSE);
......@@ -2737,6 +2745,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
"horizontal_separator", &horizontal_separator,
"vertical_separator", &vertical_separator,
"allow_rules", &allow_rules,
"focus-line-width", &focus_line_width,
NULL);
if (tree_view->priv->tree == NULL)
......@@ -2822,6 +2831,18 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
parity = _gtk_rbtree_node_find_parity (tree, node);
for (list = tree_view->priv->columns; list; list = list->next)
{
GtkTreeViewColumn *column = list->data;
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
}
has_special_cell = gtk_tree_view_has_special_cell (tree_view);
for (list = tree_view->priv->columns; list; list = list->next)
{
GtkTreeViewColumn *column = list->data;
......@@ -2843,13 +2864,6 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
flags &= ~GTK_CELL_RENDERER_SORTED;
gtk_tree_view_column_cell_set_cell_data (column,
tree_view->priv->model,
&iter,
GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_PARENT),
node->children?TRUE:FALSE);
background_area.x = cell_offset;
background_area.width = column->width;
......@@ -2954,7 +2968,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
&event->area,
flags);
}
if (node == cursor &&
if (node == cursor && has_special_cell &&
((column == tree_view->priv->focus_column &&
GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS) &&
GTK_WIDGET_HAS_FOCUS (widget)) ||
......@@ -3027,6 +3041,35 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
}
/* draw the big row-spanning focus rectangle, if needed */
if (!has_special_cell && node == cursor &&
GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS) &&
GTK_WIDGET_HAS_FOCUS (widget))
{
gint width;
GtkStateType focus_rect_state;
focus_rect_state =
flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
(flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
(flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE :
GTK_STATE_NORMAL));
gdk_drawable_get_size (tree_view->priv->bin_window,
&width, NULL);
gtk_paint_focus (widget->style,
tree_view->priv->bin_window,
focus_rect_state,
NULL,
widget,
"treeview",
0,
BACKGROUND_FIRST_PIXEL (tree_view, tree, node),
width,
MAX (BACKGROUND_HEIGHT (node),
tree_view->priv->expander_size));
}
y_offset += max_height;
if (node->children)
{
......@@ -5192,6 +5235,25 @@ gtk_tree_view_forall (GtkContainer *container,
}
}
/* Returns TRUE if the treeview contains no "special" (editable or activatable)
* cells. If so we draw one big row-spanning focus rectangle.
*/
static gboolean
gtk_tree_view_has_special_cell (GtkTreeView *tree_view)
{
GList *list;
for (list = tree_view->priv->columns; list; list = list->next)
{
if (!((GtkTreeViewColumn *)list->data)->visible)
continue;
if (_gtk_tree_view_column_count_special_cells (list->data))
return TRUE;
}
return FALSE;
}
/* Returns TRUE if the focus is within the headers, after the focus operation is
* done
*/
......@@ -7076,7 +7138,9 @@ 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))
if (_gtk_tree_view_column_cell_focus (column, count,
list->prev?TRUE:FALSE,
list->next?TRUE:FALSE))
{
tree_view->priv->focus_column = column;
found_column = TRUE;
......@@ -7091,10 +7155,11 @@ gtk_tree_view_move_cursor_left_right (GtkTreeView *tree_view,
if (found_column)
{
_gtk_tree_view_queue_draw_node (tree_view,
cursor_tree,
cursor_node,
NULL);
if (!gtk_tree_view_has_special_cell (tree_view))
_gtk_tree_view_queue_draw_node (tree_view,
cursor_tree,
cursor_node,
NULL);
g_signal_emit (G_OBJECT (tree_view), tree_view_signals[CURSOR_CHANGED], 0);
}
gtk_tree_view_clamp_column_visible (tree_view, tree_view->priv->focus_column);
......@@ -9246,11 +9311,47 @@ gtk_tree_view_set_cursor (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
gboolean start_editing)
{
gtk_tree_view_set_cursor_on_cell (tree_view, path, focus_column,
NULL, start_editing);
}
/**
* gtk_tree_view_set_cursor_on_cell:
* @tree_view: A #GtkTreeView
* @path: A #GtkTreePath
* @focus_column: A #GtkTreeViewColumn, or %NULL
* @focus_cell: A #GtkCellRenderer, or %NULL
* @start_editing: %TRUE if the specified cell should start being edited.
*
* Sets the current keyboard focus to be at @path, and selects it. This is
* useful when you want to focus the user's attention on a particular row. If
* @focus_column is not %NULL, then focus is given to the column specified by
* it. If @focus_column and @focus_cell are not %NULL, and @focus_column
* contains 2 or more editable or activatable cells, then focus is given to
* the cell specified by @focus_cell. Additionally, if @focus_column is
* specified, and @start_editing is %TRUE, then editing should be started in
* the specified cell. This function is often followed by
* @gtk_widget_grab_focus (@tree_view) in order to give keyboard focus to the
* widget. Please note that editing can only happen when the widget is
* realized.
**/
void
gtk_tree_view_set_cursor_on_cell (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
GtkCellRenderer *focus_cell,
gboolean start_editing)
{
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
g_return_if_fail (path != NULL);
if (focus_column)
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (focus_column));
if (focus_cell)
{
g_return_if_fail (focus_column);
g_return_if_fail (GTK_IS_CELL_RENDERER (focus_cell));
}
gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
......@@ -9267,12 +9368,13 @@ gtk_tree_view_set_cursor (GtkTreeView *tree_view,
}
g_return_if_fail (column_in_tree);
tree_view->priv->focus_column = focus_column;
if (focus_cell)
gtk_tree_view_column_focus_cell (focus_column, focus_cell);
if (start_editing)
gtk_tree_view_start_editing (tree_view, path);
}
}
/**
* gtk_tree_view_get_bin_window:
* @tree_view: A #GtkTreeView
......@@ -10418,8 +10520,6 @@ gtk_tree_view_search_iter (GtkTreeModel *model,
GtkTreePath *path;
GtkTreeView *tree_view = gtk_tree_selection_get_tree_view (selection);
GtkTreeViewColumn *column =
gtk_tree_view_get_column (tree_view, tree_view->priv->search_column);
path = gtk_tree_model_get_path (model, iter);
_gtk_tree_view_find_node (tree_view, path, &tree, &node);
......@@ -10634,11 +10734,22 @@ gtk_tree_view_start_editing (GtkTreeView *tree_view,
retval = TRUE;
if (editable_widget != NULL)
{
gint left, right;
GdkRectangle area;
GtkCellRenderer *cell;
area = cell_area;
cell = _gtk_tree_view_column_get_edited_cell (tree_view->priv->focus_column);
_gtk_tree_view_column_get_neighbor_sizes (tree_view->priv->focus_column, cell, &left, &right);
area.x += left;
area.width -= right + left;
gtk_tree_view_real_start_editing (tree_view,
tree_view->priv->focus_column,
cursor_path,
editable_widget,
&cell_area,
&area,
NULL,
flags);
}
......
......@@ -218,6 +218,11 @@ void gtk_tree_view_set_cursor (GtkTreeView
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
gboolean start_editing);
void gtk_tree_view_set_cursor_on_cell (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *focus_column,
GtkCellRenderer *focus_cell,
gboolean start_editing);
void gtk_tree_view_get_cursor (GtkTreeView *tree_view,
GtkTreePath **path,
GtkTreeViewColumn **focus_column);
......
......@@ -68,6 +68,7 @@ struct _GtkTreeViewColumnCellInfo
guint expand : 1;
guint pack : 1;
guint has_focus : 1;
guint in_editing_mode : 1;
};
/* Type methods */
......@@ -113,6 +114,13 @@ static void gtk_tree_view_column_set_attributesv (GtkTreeViewColum
static GtkTreeViewColumnCellInfo *gtk_tree_view_column_get_cell_info (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell_renderer);
/* cell list manipulation */
static GList *gtk_tree_view_column_cell_first (GtkTreeViewColumn *tree_column);
static GList *gtk_tree_view_column_cell_last (GtkTreeViewColumn *tree_column);
static GList *gtk_tree_view_column_cell_next (GtkTreeViewColumn *tree_column,
GList *current);
static GList *gtk_tree_view_column_cell_prev (GtkTreeViewColumn *tree_column,
GList *current);
static GtkObjectClass *parent_class = NULL;
......@@ -1054,14 +1062,14 @@ _gtk_tree_view_column_has_editable_cell (GtkTreeViewColumn *column)
return FALSE;
}
/* gets cell being edited */
GtkCellRenderer *
_gtk_tree_view_column_get_editable_cell (GtkTreeViewColumn *column)
_gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column)
{
GList *list;
for (list = column->cell_list; list; list = list->next)
if (((GtkTreeViewColumnCellInfo *)list->data)->cell->mode ==
GTK_CELL_RENDERER_MODE_EDITABLE)
if (((GtkTreeViewColumnCellInfo *)list->data)->in_editing_mode)
return ((GtkTreeViewColumnCellInfo *)list->data)->cell;
return NULL;
......@@ -1085,6 +1093,25 @@ _gtk_tree_view_column_count_special_cells (GtkTreeViewColumn *column)
return i;
}
GtkCellRenderer *
_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
gint x)
{
GList *list;
gint current_x = 0;
list = gtk_tree_view_column_cell_first (column);
for (; list; list = gtk_tree_view_column_cell_next (column, list))
{
GtkTreeViewColumnCellInfo *cellinfo = list->data;
if (current_x <= x && x <= current_x + cellinfo->real_width)
return cellinfo->cell;
current_x += cellinfo->real_width;
}
return NULL;
}
/* Public Functions */
......@@ -1222,7 +1249,7 @@ gtk_tree_view_column_pack_end (GtkTreeViewColumn *tree_column,
g_object_ref (G_OBJECT (cell));
gtk_object_sink (GTK_OBJECT (cell));
cell_info = g_new (GtkTreeViewColumnCellInfo, 1);
cell_info = g_new0 (GtkTreeViewColumnCellInfo, 1);
cell_info->cell = cell;
cell_info->expand = expand ? TRUE : FALSE;
cell_info->pack = GTK_PACK_END;
......@@ -2351,23 +2378,53 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
gint min_x, min_y, max_x, max_y;
gint focus_line_width;
gint dx;
gint special_cells;
min_x = G_MAXINT;
min_y = G_MAXINT;
max_x = 0;