Commit 43d99929 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

Merge from stable.

Mon Aug 25 23:21:43 2003  Kristian Rietveld  <kris@gtk.org>

	Merge from stable.

	Fixes #115871, reported by Michael Natterer.

	* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
	added ctrl_pressed and shift_pressed bitfields,
	(_gtk_tree_selection_internal_select_node): replace GdkModifierType
	arg with GtkTreeSelectMode.

	* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
	(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
	(_gtk_tree_selection_internal_select_node): all updated for
	GdkModifierType -> GtkTreeSelectMode move.

	* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
	and shift_pressed around selection handling block,
	(gtk_tree_view_real_select_cursor_row),
	(gtk_tree_view_real_toggle_cursor_row),
	(gtk_tree_view_real_selection_cursor_parent),
	(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
	instead of checking the event state. And also updates for the
	GdkModifierType -> GtkTreeSelectMode move.
parent fb6914ef
Mon Aug 25 23:21:43 2003 Kristian Rietveld <kris@gtk.org>
Merge from stable.
Fixes #115871, reported by Michael Natterer.
* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
added ctrl_pressed and shift_pressed bitfields,
(_gtk_tree_selection_internal_select_node): replace GdkModifierType
arg with GtkTreeSelectMode.
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
(_gtk_tree_selection_internal_select_node): all updated for
GdkModifierType -> GtkTreeSelectMode move.
* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
and shift_pressed around selection handling block,
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_selection_cursor_parent),
(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
instead of checking the event state. And also updates for the
GdkModifierType -> GtkTreeSelectMode move.
Wed Aug 20 21:26:49 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.c (gtk_plug_focus): Send the focus on
......
Mon Aug 25 23:21:43 2003 Kristian Rietveld <kris@gtk.org>
Merge from stable.
Fixes #115871, reported by Michael Natterer.
* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
added ctrl_pressed and shift_pressed bitfields,
(_gtk_tree_selection_internal_select_node): replace GdkModifierType
arg with GtkTreeSelectMode.
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
(_gtk_tree_selection_internal_select_node): all updated for
GdkModifierType -> GtkTreeSelectMode move.
* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
and shift_pressed around selection handling block,
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_selection_cursor_parent),
(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
instead of checking the event state. And also updates for the
GdkModifierType -> GtkTreeSelectMode move.
Wed Aug 20 21:26:49 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.c (gtk_plug_focus): Send the focus on
......
Mon Aug 25 23:21:43 2003 Kristian Rietveld <kris@gtk.org>
Merge from stable.
Fixes #115871, reported by Michael Natterer.
* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
added ctrl_pressed and shift_pressed bitfields,
(_gtk_tree_selection_internal_select_node): replace GdkModifierType
arg with GtkTreeSelectMode.
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
(_gtk_tree_selection_internal_select_node): all updated for
GdkModifierType -> GtkTreeSelectMode move.
* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
and shift_pressed around selection handling block,
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_selection_cursor_parent),
(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
instead of checking the event state. And also updates for the
GdkModifierType -> GtkTreeSelectMode move.
Wed Aug 20 21:26:49 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.c (gtk_plug_focus): Send the focus on
......
Mon Aug 25 23:21:43 2003 Kristian Rietveld <kris@gtk.org>
Merge from stable.
Fixes #115871, reported by Michael Natterer.
* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
added ctrl_pressed and shift_pressed bitfields,
(_gtk_tree_selection_internal_select_node): replace GdkModifierType
arg with GtkTreeSelectMode.
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
(_gtk_tree_selection_internal_select_node): all updated for
GdkModifierType -> GtkTreeSelectMode move.
* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
and shift_pressed around selection handling block,
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_selection_cursor_parent),
(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
instead of checking the event state. And also updates for the
GdkModifierType -> GtkTreeSelectMode move.
Wed Aug 20 21:26:49 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.c (gtk_plug_focus): Send the focus on
......
Mon Aug 25 23:21:43 2003 Kristian Rietveld <kris@gtk.org>
Merge from stable.
Fixes #115871, reported by Michael Natterer.
* gtk/gtktreeprivate.h: added GtkTreeSelectMode enum,
added ctrl_pressed and shift_pressed bitfields,
(_gtk_tree_selection_internal_select_node): replace GdkModifierType
arg with GtkTreeSelectMode.
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode),
(gtk_tree_selection_select_path), (gtk_tree_selection_unselect_path),
(_gtk_tree_selection_internal_select_node): all updated for
GdkModifierType -> GtkTreeSelectMode move.
* gtk/gtktreeview.c (gtk_tree_view_button_press): set ctrl_pressed
and shift_pressed around selection handling block,
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_selection_cursor_parent),
(gtk_tree_view_real_set_cursor): use ctrl_pressed and shift_pressed,
instead of checking the event state. And also updates for the
GdkModifierType -> GtkTreeSelectMode move.
Wed Aug 20 21:26:49 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkplug.c (gtk_plug_focus): Send the focus on
......
......@@ -43,6 +43,13 @@ typedef enum
GTK_TREE_VIEW_IN_COLUMN_DRAG = 1 << 7
} GtkTreeViewFlags;
typedef enum
{
GTK_TREE_SELECT_MODE_TOGGLE = 1 << 0,
GTK_TREE_SELECT_MODE_EXTEND = 1 << 1
}
GtkTreeSelectMode;
enum
{
DRAG_COLUMN_WINDOW_STATE_UNSET = 0,
......@@ -184,6 +191,9 @@ struct _GtkTreeViewPrivate
/* hint to display rows in alternating colors */
guint has_rules : 1;
guint mark_rows_col_dirty : 1;
guint ctrl_pressed : 1;
guint shift_pressed : 1;
/* interactive search */
guint enable_search : 1;
......@@ -287,7 +297,7 @@ void _gtk_tree_selection_internal_select_node (GtkTreeSelection *select
GtkRBNode *node,
GtkRBTree *tree,
GtkTreePath *path,
GdkModifierType state,
GtkTreeSelectMode mode,
gboolean override_browse_mode);
gboolean _gtk_tree_view_find_node (GtkTreeView *tree_view,
GtkTreePath *path,
......
......@@ -241,7 +241,7 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
node,
tree,
anchor_path,
0,
0,
FALSE);
if (anchor_path)
gtk_tree_path_free (anchor_path);
......@@ -771,8 +771,8 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection,
{
GtkRBNode *node;
GtkRBTree *tree;
GdkModifierType state = 0;
gboolean ret;
GtkTreeSelectMode mode = 0;
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
......@@ -788,13 +788,13 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection,
return;
if (selection->type == GTK_SELECTION_MULTIPLE)
state = GDK_CONTROL_MASK;
mode = GTK_TREE_SELECT_MODE_TOGGLE;
_gtk_tree_selection_internal_select_node (selection,
node,
tree,
path,
state,
mode,
FALSE);
}
......@@ -830,7 +830,7 @@ gtk_tree_selection_unselect_path (GtkTreeSelection *selection,
node,
tree,
path,
GDK_CONTROL_MASK,
GTK_TREE_SELECT_MODE_TOGGLE,
TRUE);
}
......@@ -1289,7 +1289,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
GtkRBNode *node,
GtkRBTree *tree,
GtkTreePath *path,
GdkModifierType state,
GtkTreeSelectMode mode,
gboolean override_browse_mode)
{
gint flags;
......@@ -1314,7 +1314,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
else if (selection->type == GTK_SELECTION_SINGLE &&
anchor_path && gtk_tree_path_compare (path, anchor_path) == 0)
{
if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
if ((mode & GTK_TREE_SELECT_MODE_TOGGLE) == GTK_TREE_SELECT_MODE_TOGGLE)
{
dirty = gtk_tree_selection_real_unselect_all (selection);
}
......@@ -1376,7 +1376,8 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
}
else if (selection->type == GTK_SELECTION_MULTIPLE)
{
if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (anchor_path == NULL))
if ((mode & GTK_TREE_SELECT_MODE_EXTEND) == GTK_TREE_SELECT_MODE_EXTEND
&& (anchor_path == NULL))
{
if (selection->tree_view->priv->anchor)
gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
......@@ -1385,13 +1386,13 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
gtk_tree_row_reference_new_proxy (G_OBJECT (selection->tree_view), selection->tree_view->priv->model, path);
dirty = gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
}
else if ((state & (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) == (GDK_SHIFT_MASK|GDK_CONTROL_MASK))
else if ((mode & (GTK_TREE_SELECT_MODE_EXTEND | GTK_TREE_SELECT_MODE_TOGGLE)) == (GTK_TREE_SELECT_MODE_EXTEND | GTK_TREE_SELECT_MODE_TOGGLE))
{
gtk_tree_selection_select_range (selection,
anchor_path,
path);
}
else if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
else if ((mode & GTK_TREE_SELECT_MODE_TOGGLE) == GTK_TREE_SELECT_MODE_TOGGLE)
{
flags = node->flags;
if (selection->tree_view->priv->anchor)
......@@ -1405,7 +1406,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
else
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
}
else if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
else if ((mode & GTK_TREE_SELECT_MODE_EXTEND) == GTK_TREE_SELECT_MODE_EXTEND)
{
dirty = gtk_tree_selection_real_unselect_all (selection);
dirty |= gtk_tree_selection_real_modify_range (selection,
......
......@@ -2146,6 +2146,11 @@ gtk_tree_view_button_press (GtkWidget *widget,
*/
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
{
if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
tree_view->priv->ctrl_pressed = TRUE;
if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
tree_view->priv->shift_pressed = TRUE;
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);
......@@ -2164,6 +2169,9 @@ gtk_tree_view_button_press (GtkWidget *widget,
{
gtk_tree_view_real_set_cursor (tree_view, path, TRUE, TRUE);
}
tree_view->priv->ctrl_pressed = FALSE;
tree_view->priv->shift_pressed = FALSE;
}
/* the treeview may have been scrolled because of _set_cursor,
......@@ -7825,8 +7833,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
GtkRBTree *cursor_tree = NULL;
GtkRBNode *cursor_node = NULL;
GtkTreePath *cursor_path = NULL;
GdkModifierType state = 0;
cursor_path = NULL;
GtkTreeSelectMode mode = 0;
if (! GTK_WIDGET_HAS_FOCUS (tree_view))
return FALSE;
......@@ -7846,10 +7853,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
return FALSE;
}
gtk_get_current_event_state (&state);
if (! (state & GDK_SHIFT_MASK) &&
start_editing &&
if (!tree_view->priv->shift_pressed && start_editing &&
tree_view->priv->focus_column)
{
if (gtk_tree_view_start_editing (tree_view, cursor_path))
......@@ -7858,11 +7862,17 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
return TRUE;
}
}
if (tree_view->priv->ctrl_pressed)
mode |= GTK_TREE_SELECT_MODE_TOGGLE;
if (tree_view->priv->shift_pressed)
mode |= GTK_TREE_SELECT_MODE_EXTEND;
_gtk_tree_selection_internal_select_node (tree_view->priv->selection,
cursor_node,
cursor_tree,
cursor_path,
state,
mode,
FALSE);
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
......@@ -7870,8 +7880,9 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view,
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
_gtk_tree_view_queue_draw_node (tree_view, cursor_tree, cursor_node, NULL);
if (! (state & GDK_SHIFT_MASK))
gtk_tree_view_row_activated (tree_view, cursor_path, tree_view->priv->focus_column);
if (!tree_view->priv->shift_pressed)
gtk_tree_view_row_activated (tree_view, cursor_path,
tree_view->priv->focus_column);
gtk_tree_path_free (cursor_path);
......@@ -7907,7 +7918,7 @@ gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view)
cursor_node,
cursor_tree,
cursor_path,
GDK_CONTROL_MASK,
GTK_TREE_SELECT_MODE_TOGGLE,
FALSE);
gtk_tree_view_clamp_node_visible (tree_view, cursor_tree, cursor_node);
......@@ -7993,7 +8004,7 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view)
cursor_node,
cursor_tree,
cursor_path,
0,
0,
FALSE);
}
......@@ -9989,7 +10000,6 @@ gtk_tree_view_real_set_cursor (GtkTreeView *tree_view,
{
GtkRBTree *tree = NULL;
GtkRBNode *node = NULL;
GdkModifierType state = 0;
if (gtk_tree_row_reference_valid (tree_view->priv->cursor))
{
......@@ -10000,7 +10010,6 @@ gtk_tree_view_real_set_cursor (GtkTreeView *tree_view,
}
gtk_tree_row_reference_free (tree_view->priv->cursor);
gtk_get_current_event_state (&state);
tree_view->priv->cursor = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view),
tree_view->priv->model,
......@@ -10011,10 +10020,19 @@ gtk_tree_view_real_set_cursor (GtkTreeView *tree_view,
GtkRBTree *new_tree = NULL;
GtkRBNode *new_node = NULL;
if (clear_and_select && !((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK))
_gtk_tree_selection_internal_select_node (tree_view->priv->selection,
node, tree, path,
state, FALSE);
if (clear_and_select && !tree_view->priv->ctrl_pressed)
{
GtkTreeSelectMode mode = 0;
if (tree_view->priv->ctrl_pressed)
mode |= GTK_TREE_SELECT_MODE_TOGGLE;
if (tree_view->priv->shift_pressed)
mode |= GTK_TREE_SELECT_MODE_EXTEND;
_gtk_tree_selection_internal_select_node (tree_view->priv->selection,
node, tree, path, mode,
FALSE);
}
/* We have to re-find tree and node here again, somebody might have
* cleared the node or the whole tree in the GtkTreeSelection::changed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment