Bug#301610: Acknowledgement (libgtk2.0-0: The number of selected
rows is incorrect in "cursor-changed" callback.)
Igor Belyi
Igor Belyi <belyi@users.sourceforge.net>, 301610@bugs.debian.org
Mon, 28 Mar 2005 12:38:09 -0500
This is a multi-part message in MIME format.
--------------070204060106010208050703
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
OK, attached is the patch which does make the problem go away.
Here's the justification for upstream developers:
According to what I saw in the code functions
gtk_tree_view_real_toggle_cursor_row(tree_view) and
gtk_tree_view_real_select_cursor_row(tree_view, FALSE) /* note the FALSE
for start_editing */ do approximately the same thing as
gtk_tree_view_real_set_cursor(tree_view, path, TRUE, TRUE) does. The
only problem with using this last one was a condition
(!tree_view->priv->ctrl_pressed) preventing
_gtk_tree_selection_internal_select_node() to be called.
Taking this into account I've updated GDK_BUTTON_PRESS event handling to
call gtk_tree_view_real_set_cursor(tree_view, path, TRUE, TRUE) even
when modifiers present and removed !tree_view->priv->ctrl_pressed from
the condition in this call. The side effect of this change is that other
invocations of this function with the third argument equal TRUE also
call _gtk_tree_selection_internal_select_node() even with Ctrl held. To
give them their original behavior I've changed this third TRUE in these
calls to (!tree_view->priv->ctrl_pressed). The end result is that
handling of GDK_BUTTON_PRESS event got fixed and all other calls behave
as they did previously.
I do hope it helps,
Igor
--------------070204060106010208050703
Content-Type: text/x-patch;
name="gtktreeview-cursor_changed-new.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="gtktreeview-cursor_changed-new.patch"
--- gtk+-2.6.2/gtk/gtktreeview.c.orig 2005-03-28 11:30:56.000000000 -0500
+++ gtk+-2.6.2/gtk/gtktreeview.c 2005-03-28 11:31:09.000000000 -0500
@@ -2368,20 +2368,7 @@
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);
- gtk_tree_view_real_toggle_cursor_row (tree_view);
- }
- else if (event->state & GDK_SHIFT_MASK)
- {
- gtk_tree_view_real_set_cursor (tree_view, path, FALSE, TRUE);
- gtk_tree_view_real_select_cursor_row (tree_view, FALSE);
- }
- else
- {
- gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
- }
+ gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
tree_view->priv->ctrl_pressed = FALSE;
tree_view->priv->shift_pressed = FALSE;
@@ -8365,7 +8352,7 @@
if (tree_view->priv->selection->type == GTK_SELECTION_MULTIPLE)
gtk_tree_view_real_set_cursor (tree_view, cursor_path, FALSE, FALSE);
else
- gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, FALSE);
+ gtk_tree_view_real_set_cursor (tree_view, cursor_path, !tree_view->priv->ctrl_pressed, FALSE);
}
gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL);
gtk_tree_path_free (cursor_path);
@@ -8445,7 +8432,7 @@
if (new_cursor_node)
{
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_view_real_set_cursor (tree_view, cursor_path, !tree_view->priv->ctrl_pressed, TRUE);
gtk_tree_path_free (cursor_path);
}
else
@@ -8500,7 +8487,7 @@
_gtk_rbtree_find_offset (tree_view->priv->tree, y, &cursor_tree, &cursor_node);
cursor_path = _gtk_tree_view_find_path (tree_view, cursor_tree, cursor_node);
g_return_if_fail (cursor_path != NULL);
- gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE, TRUE);
+ gtk_tree_view_real_set_cursor (tree_view, cursor_path, !tree_view->priv->ctrl_pressed, TRUE);
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
gtk_tree_path_free (cursor_path);
}
@@ -8624,7 +8611,7 @@
}
path = _gtk_tree_view_find_path (tree_view, cursor_tree, cursor_node);
- gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
+ gtk_tree_view_real_set_cursor (tree_view, path, !tree_view->priv->ctrl_pressed, TRUE);
gtk_tree_path_free (path);
}
@@ -11070,7 +11057,7 @@
GtkRBTree *new_tree = NULL;
GtkRBNode *new_node = NULL;
- if (clear_and_select && !tree_view->priv->ctrl_pressed)
+ if (clear_and_select)
{
GtkTreeSelectMode mode = 0;
@@ -11207,7 +11194,7 @@
tree_view->priv->edited_column->editable_widget)
gtk_tree_view_stop_editing (tree_view, TRUE);
- gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
+ gtk_tree_view_real_set_cursor (tree_view, path, !tree_view->priv->ctrl_pressed, TRUE);
if (focus_column && focus_column->visible)
{
--------------070204060106010208050703--