Commit 6b6e6763 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Replaced with GTK_TREE_SELECTION_OLD to prevent conflict with

2000-10-05  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
	GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
	* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
	* gtk/gtktreeselection.[ch]: Replaced
	"node_selected"/"node_unselected" signal with "selection_changed"
	signal.
parent 98c0e909
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
2000-10-04 <jrb@redhat.com>
2000-10-05 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktree.h (GTK_TREE_SELECTION): Replaced with
GTK_TREE_SELECTION_OLD to prevent conflict with gtktreeselection.c
* gtk/testgtk.c: s/GTK_TREE_SELECTION/GTK_TREE_SELECTION_OLD/
* gtk/gtktreeselection.[ch]: Replaced
"node_selected"/"node_unselected" signal with "selection_changed"
signal.
2000-10-04 Jonathan Blandford <jrb@redhat.com>
* gtk/gtk{tree,cell}?*.[ch]: Checked in initial draft of the new
tree widget.
......
......@@ -74,6 +74,11 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkcontainer.h \
gtkctree.h \
gtkcurve.h \
gtkcellrenderer.h \
gtkcellrenderertext.h \
gtkcellrenderertextpixbuf.h \
gtkcellrenderertoggle.h \
gtkcellrendererpixbuf.h \
gtkdata.h \
gtkdebug.h \
gtkdialog.h \
......@@ -110,6 +115,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtklayout.h \
gtklist.h \
gtklistitem.h \
gtkliststore.h \
gtkmain.h \
gtkmenu.h \
gtkmenubar.h \
......@@ -117,6 +123,7 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkmenuitem.h \
gtkmenushell.h \
gtkmisc.h \
gtkmodelsimple.h \
gtknotebook.h \
gtkobject.h \
gtkoptionmenu.h \
......@@ -162,6 +169,11 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtktooltips.h \
gtktree.h \
gtktreeitem.h \
gtktreemodel.h \
gtktreeselection.h \
gtktreestore.h \
gtktreeview.h \
gtktreeviewcolumn.h \
gtktypeutils.h \
gtkvbbox.h \
gtkvbox.h \
......@@ -189,6 +201,7 @@ gtk_semipublic_h_sources = @STRIP_BEGIN@ \
# GTK+ header files that don't get installed
gtk_private_h_sources = @STRIP_BEGIN@ \
gtkrbtree.h \
gtktextbtree.h \
gtktextchildprivate.h \
gtktextsegment.h \
......@@ -196,8 +209,12 @@ gtk_private_h_sources = @STRIP_BEGIN@ \
gtktextiterprivate.h \
gtktextmarkprivate.h \
gtktexttagprivate.h \
gtktreeprivate.h \
@STRIP_END@
# GTK+ C sources to build the library from
gtk_c_sources = @STRIP_BEGIN@ \
gtkaccelgroup.c \
......@@ -213,6 +230,11 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkbox.c \
gtkbutton.c \
gtkcalendar.c \
gtkcellrenderer.c \
gtkcellrenderertext.c \
gtkcellrenderertextpixbuf.c \
gtkcellrenderertoggle.c \
gtkcellrendererpixbuf.c \
gtkcheckbutton.c \
gtkcheckmenuitem.c \
gtkclipboard.c \
......@@ -260,6 +282,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtklayout.c \
gtklist.c \
gtklistitem.c \
gtkliststore.c \
gtkmain.c \
gtkmarshal.c \
gtkmenu.c \
......@@ -268,6 +291,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkmenuitem.c \
gtkmenushell.c \
gtkmisc.c \
gtkmodelsimple.c \
gtknotebook.c \
gtkobject.c \
gtkoptionmenu.c \
......@@ -281,6 +305,7 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkradiobutton.c \
gtkradiomenuitem.c \
gtkrange.c \
gtkrbtree.c \
gtkrc.c \
gtkruler.c \
gtkscale.c \
......@@ -318,6 +343,12 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtktooltips.c \
gtktree.c \
gtktreeitem.c \
gtktreedatalist.c \
gtktreemodel.c \
gtktreeselection.c \
gtktreestore.c \
gtktreeview.c \
gtktreeviewcolumn.c \
gtktypeutils.c \
gtkvbbox.c \
gtkvbox.c \
......@@ -530,7 +561,7 @@ uninstall-local:
#
# test programs, not to be installed
#
noinst_PROGRAMS = testgtk testcalendar testinput testselection testrgb testdnd testtext simple testtextbuffer # testthreads
noinst_PROGRAMS = testgtk testcalendar testinput testselection testrgb testdnd testtext simple treestoretest testtextbuffer # testthreads
DEPS = @gtktargetlib@ $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-1.3.la $(top_builddir)/gdk/@gdktargetlib@
LDADDS = @STRIP_BEGIN@ \
@gtktargetlib@ \
......@@ -550,6 +581,7 @@ testinput_DEPENDENCIES = $(DEPS)
testselection_DEPENDENCIES = $(DEPS)
testrgb_DEPENDENCIES = $(DEPS)
testtext_DEPENDENCIES = $(DEPS)
treestoretest_DEPENDENCIES = $(DEPS)
testdnd_DEPENDENCIES = $(DEPS)
simple_DEPENDENCIES = $(DEPS)
#testthreads_DEPENDENCIES = $(DEPS)
......@@ -558,6 +590,7 @@ testgtk_LDADD = $(LDADDS)
testinput_LDADD = $(LDADDS)
testselection_LDADD = $(LDADDS)
testtext_LDADD = $(LDADDS)
treestoretest_LDADD = $(LDADDS)
testtextbuffer_LDADD = $(LDADDS)
testrgb_LDADD = $(LDADDS)
testdnd_LDADD = $(LDADDS)
......
......@@ -42,6 +42,11 @@
#include <gtk/gtkbbox.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcalendar.h>
#include <gtk/gtkcellrenderer.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkcellrenderertextpixbuf.h>
#include <gtk/gtkcellrenderertoggle.h>
#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkclipboard.h>
......@@ -87,6 +92,7 @@
#include <gtk/gtklayout.h>
#include <gtk/gtklist.h>
#include <gtk/gtklistitem.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenubar.h>
......@@ -94,6 +100,7 @@
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkmenushell.h>
#include <gtk/gtkmisc.h>
#include <gtk/gtkmodelsimple.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtkobject.h>
#include <gtk/gtkoptionmenu.h>
......@@ -132,6 +139,12 @@
#include <gtk/gtktooltips.h>
#include <gtk/gtktree.h>
#include <gtk/gtktreeitem.h>
#include <gtk/gtktreedatalist.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtktreestore.h>
#include <gtk/gtktreeview.h>
#include <gtk/gtktreeviewcolumn.h>
#include <gtk/gtktypeutils.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkvbbox.h>
......
......@@ -49,7 +49,7 @@ extern "C" {
#define GTK_IS_ROOT_TREE(obj) ((GtkObject*) GTK_TREE(obj)->root_tree == (GtkObject*)obj)
#define GTK_TREE_ROOT_TREE(obj) (GTK_TREE(obj)->root_tree ? GTK_TREE(obj)->root_tree : GTK_TREE(obj))
#define GTK_TREE_SELECTION(obj) (GTK_TREE_ROOT_TREE(obj)->selection)
#define GTK_TREE_SELECTION_OLD(obj) (GTK_TREE_ROOT_TREE(obj)->selection)
typedef enum
{
......
......@@ -22,49 +22,23 @@
#include "gtkrbtree.h"
#include "gtksignal.h"
static void gtk_tree_selection_init (GtkTreeSelection *selection);
static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class);
static void gtk_tree_selection_init (GtkTreeSelection *selection);
static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class);
static gint gtk_tree_selection_real_select_all (GtkTreeSelection *selection);
static gint gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection);
static gint gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
GtkRBTree *tree,
GtkRBNode *node,
gboolean select);
enum {
ROW_SELECTED,
ROW_UNSELECTED,
SELECTION_CHANGED,
LAST_SIGNAL
};
static GtkObjectClass *parent_class = NULL;
static guint tree_selection_signals[LAST_SIGNAL] = { 0 };
static void
gtk_tree_selection_real_select_node (GtkTreeSelection *selection, GtkRBTree *tree, GtkRBNode *node, gboolean select)
{
gboolean selected = FALSE;
GtkTreePath *path = NULL;
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
{
path = _gtk_tree_view_find_path (selection->tree_view, tree, node);
if (selection->user_func)
{
if ((*selection->user_func) (selection, selection->tree_view->priv->model, path, selection->user_data))
selected = TRUE;
}
else
selected = TRUE;
}
if (selected == TRUE)
{
GtkTreeNode tree_node;
tree_node = gtk_tree_model_get_node (selection->tree_view->priv->model, path);
node->flags ^= GTK_RBNODE_IS_SELECTED;
if (select)
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[ROW_SELECTED], selection->tree_view->priv->model, tree_node);
else
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[ROW_UNSELECTED], selection->tree_view->priv->model, tree_node);
gtk_widget_queue_draw (GTK_WIDGET (selection->tree_view));
}
}
GtkType
gtk_tree_selection_get_type (void)
{
......@@ -99,40 +73,23 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
object_class = (GtkObjectClass*) class;
parent_class = g_type_class_peek_parent (class);
tree_selection_signals[ROW_SELECTED] =
gtk_signal_new ("row_selected",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeSelectionClass, row_selected),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
tree_selection_signals[ROW_UNSELECTED] =
gtk_signal_new ("row_unselected",
tree_selection_signals[SELECTION_CHANGED] =
gtk_signal_new ("selection_changed",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkTreeSelectionClass, row_unselected),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2,
GTK_TYPE_POINTER,
GTK_TYPE_POINTER);
GTK_SIGNAL_OFFSET (GtkTreeSelectionClass, selection_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, tree_selection_signals, LAST_SIGNAL);
class->row_selected = NULL;
class->row_unselected = NULL;
class->selection_changed = NULL;
}
static void
gtk_tree_selection_init (GtkTreeSelection *selection)
{
selection->type = GTK_TREE_SELECTION_MULTI;
selection->user_func = NULL;
selection->user_data = NULL;
selection->user_func = NULL;
selection->tree_view = NULL;
selection->type = GTK_TREE_SELECTION_SINGLE;
}
GtkObject *
......@@ -459,29 +416,48 @@ select_all_helper (GtkRBTree *tree,
data);
if (!GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
{
gtk_tree_selection_real_select_node (tuple->selection, tree, node, TRUE);
tuple->dirty = TRUE;
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, TRUE) || tuple->dirty;
}
}
void
gtk_tree_selection_select_all (GtkTreeSelection *selection)
/* We have a real_{un,}select_all function that doesn't emit the signal, so we
* can use it in other places without fear of the signal being emitted.
*/
static gint
gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
{
struct _TempTuple *tuple;
g_return_if_fail (selection != NULL);
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->tree != NULL);
if (selection->tree_view->priv->tree == NULL)
return FALSE;
if (selection->type == GTK_TREE_SELECTION_SINGLE)
{
GtkRBTree *tree;
GtkRBNode *node;
node = selection->tree_view->priv->tree->root;
gint dirty;
dirty = gtk_tree_selection_real_unselect_all (selection);
while (node->right != selection->tree_view->priv->tree->nil)
node = node->right;
return;
tree = selection->tree_view->priv->tree;
node = tree->root;
do
{
while (node->right != selection->tree_view->priv->tree->nil)
node = node->right;
if (node->children)
{
tree = node->children;
node = tree->root;
}
else
break;
} while (TRUE);
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
return dirty;
}
tuple = g_new (struct _TempTuple, 1);
......@@ -494,8 +470,24 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
select_all_helper,
tuple);
if (tuple->dirty)
gtk_widget_queue_draw (GTK_WIDGET (selection->tree_view));
{
g_free (tuple);
return TRUE;
}
g_free (tuple);
return FALSE;
}
void
gtk_tree_selection_select_all (GtkTreeSelection *selection)
{
g_return_if_fail (selection != NULL);
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->tree != NULL);
if (gtk_tree_selection_real_select_all (selection))
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[SELECTION_CHANGED]);
}
static void
......@@ -513,36 +505,32 @@ unselect_all_helper (GtkRBTree *tree,
data);
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
{
gtk_tree_selection_real_select_node (tuple->selection, tree, node, FALSE);
tuple->dirty = TRUE;
tuple->dirty = gtk_tree_selection_real_select_node (tuple->selection, tree, node, FALSE) || tuple->dirty;
}
}
void
gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
static gint
gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
{
struct _TempTuple *tuple;
g_return_if_fail (selection != NULL);
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
if (selection->tree_view->priv->tree == NULL)
return;
if (selection->type == GTK_TREE_SELECTION_SINGLE)
{
GtkRBTree *tree = NULL;
GtkRBNode *node = NULL;
if (selection->tree_view->priv->anchor == NULL)
return;
return FALSE;
_gtk_tree_view_find_node (selection->tree_view,
selection->tree_view->priv->anchor,
&tree,
&node);
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
return;
{
gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
return TRUE;
}
return FALSE;
}
tuple = g_new (struct _TempTuple, 1);
......@@ -554,22 +542,38 @@ gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
G_PRE_ORDER,
unselect_all_helper,
tuple);
if (tuple->dirty)
gtk_widget_queue_draw (GTK_WIDGET (selection->tree_view));
{
g_free (tuple);
return TRUE;
}
g_free (tuple);
return FALSE;
}
void
gtk_tree_selection_select_range (GtkTreeSelection *selection,
GtkTreePath *start_path,
GtkTreePath *end_path)
gtk_tree_selection_unselect_all (GtkTreeSelection *selection)
{
GtkRBNode *start_node, *end_node;
GtkRBTree *start_tree, *end_tree;
g_return_if_fail (selection != NULL);
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
g_return_if_fail (selection->tree_view->priv->tree != NULL);
if (selection->tree_view->priv->tree == NULL)
return;
if (gtk_tree_selection_real_unselect_all (selection))
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[SELECTION_CHANGED]);
}
static gint
gtk_tree_selection_real_select_range (GtkTreeSelection *selection,
GtkTreePath *start_path,
GtkTreePath *end_path)
{
GtkRBNode *start_node, *end_node;
GtkRBTree *start_tree, *end_tree;
gboolean dirty = FALSE;
switch (gtk_tree_path_compare (start_path, end_path))
{
......@@ -603,15 +607,18 @@ gtk_tree_selection_select_range (GtkTreeSelection *selection,
break;
}
g_return_if_fail (start_node != NULL);
g_return_if_fail (end_node != NULL);
g_return_val_if_fail (start_node != NULL, FALSE);
g_return_val_if_fail (end_node != NULL, FALSE);
do
{
gtk_tree_selection_real_select_node (selection, start_tree, start_node, TRUE);
if (GTK_RBNODE_FLAG_SET (start_node, GTK_RBNODE_IS_SELECTED))
{
dirty = gtk_tree_selection_real_select_node (selection, start_tree, start_node, FALSE);
}
if (start_node == end_node)
return;
break;
if (start_node->children)
{
......@@ -637,19 +644,32 @@ gtk_tree_selection_select_range (GtkTreeSelection *selection,
if (start_tree == NULL)
/* we've run out of tree */
/* This means we never found end node!! */
return;
break;
}
}
while (!done);
}
}
while (TRUE);
return dirty;
}
void
gtk_tree_selection_select_range (GtkTreeSelection *selection,
GtkTreePath *start_path,
GtkTreePath *end_path)
{
g_return_if_fail (selection != NULL);
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
g_return_if_fail (selection->tree_view != NULL);
/* Called internally by gtktree_view. It handles actually selecting
* the tree. This should almost certainly ever be called by
* anywhere else */
if (gtk_tree_selection_real_select_range (selection, start_path, end_path))
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[SELECTION_CHANGED]);
}
/* Called internally by gtktreeview.c It handles actually selecting the tree.
* This should almost certainly ever be called by anywhere else.
*/
void
_gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
GtkRBNode *node,
......@@ -658,11 +678,12 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
GdkModifierType state)
{
gint flags;
gint dirty = FALSE;
if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (selection->tree_view->priv->anchor == NULL))
{
selection->tree_view->priv->anchor = gtk_tree_path_copy (path);
gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
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))
{
......@@ -674,29 +695,69 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
{
flags = node->flags;
if (selection->type == GTK_TREE_SELECTION_SINGLE)
gtk_tree_selection_unselect_all (selection);
dirty = gtk_tree_selection_real_unselect_all (selection);
if (selection->tree_view->priv->anchor)
gtk_tree_path_free (selection->tree_view->priv->anchor);
selection->tree_view->priv->anchor = gtk_tree_path_copy (path);
if ((flags & GTK_RBNODE_IS_SELECTED) == GTK_RBNODE_IS_SELECTED)
gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, FALSE);
else
gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
}
else if ((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
{
gtk_tree_selection_unselect_all (selection);
gtk_tree_selection_select_range (selection,
selection->tree_view->priv->anchor,
path);
dirty = gtk_tree_selection_real_unselect_all (selection);
dirty |= gtk_tree_selection_real_select_range (selection,
selection->tree_view->priv->anchor,
path);
}
else
{
gtk_tree_selection_unselect_all (selection);
dirty = gtk_tree_selection_real_unselect_all (selection);
if (selection->tree_view->priv->anchor)
gtk_tree_path_free (selection->tree_view->priv->anchor);
selection->tree_view->priv->anchor = gtk_tree_path_copy (path);
gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
dirty |= gtk_tree_selection_real_select_node (selection, tree, node, TRUE);
}
if (dirty)
gtk_signal_emit (GTK_OBJECT (selection), tree_selection_signals[SELECTION_CHANGED]);
}
static gint
gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
GtkRBTree *tree,
GtkRBNode *node,
gboolean select)
{
gboolean selected = FALSE;
GtkTreePath *path = NULL;
if (GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED) != select)
{
path = _gtk_tree_view_find_path (selection->tree_view, tree, node);
if (selection->user_func)
{
if ((*selection->user_func) (selection, selection->tree_view->priv->model, path, selection->user_data))
selected = TRUE;
}
else
selected = TRUE;
}
if (selected == TRUE)
{
GtkTreeNode tree_node;
tree_node = gtk_tree_model_get_node (selection->tree_view->priv->model, path);
node->flags ^= GTK_RBNODE_IS_SELECTED;
/* FIXME: just draw the one node*/
gtk_widget_queue_draw (GTK_WIDGET (selection->tree_view));
return TRUE;
}
return FALSE;
}
......@@ -28,9 +28,6 @@
extern "C" {
#endif /* __cplusplus */
#warning "Die GTK_TREE_SELECTION, DIE"
#undef GTK_TREE_SELECTION
#define GTK_TYPE_TREE_SELECTION (gtk_tree_selection_get_type ())
#define GTK_TREE_SELECTION(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TREE_SELECTION, GtkTreeSelection))
#define GTK_TREE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_SELECTION, GtkTreeSelectionClass))
......@@ -65,12 +62,7 @@ struct _GtkTreeSelectionClass
{
GtkObjectClass parent_class;
void (* row_selected) (GtkTreeView *tree_view,
GtkTreeModel *tree_model,
GtkTreeNode *node);
void (* row_unselected) (GtkTreeView *tree_view,
GtkTreeModel *tree_model,
GtkTreeNode *node);
void (* selection_changed) (GtkTreeView *tree_view);
};
......
......@@ -2114,16 +2114,20 @@ gtk_tree_view_node_deleted (GtkTreeModel *model,
return;
/* next, update the selection */
#if 0
if (tree_view->priv->anchor)
{
gint i;
gint *select_indices = gtk_tree_path_get_indices (tree_view->priv->anchor);
gint depth = gtk_tree_path_get_indices (path);
gint *indices = gtk_tree_path_get_depth (path);
gint select_depth = gtk_tree_path_get_depth (tree_view->priv->anchor);
gint *select_indices = gtk_tree_path_get_indices (tree_view->priv->anchor);