Commit 892496c8 authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

Use the GTK selection types rather than GtkTreeSelectionMode.

Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>

	* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
	GTK selection types rather than GtkTreeSelectionMode.

	* docs/Changes-2.0: Add comment about selection change.
parent d70c0b40
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
Mon Aug 27 15:18:14 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.
* docs/Changes-2.0: Add comment about selection change.
Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com> Mon Aug 27 14:21:30 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtkenums.h (GtkSelectionMode): deprecate * gtk/gtkenums.h (GtkSelectionMode): deprecate
......
...@@ -454,3 +454,8 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0: ...@@ -454,3 +454,8 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
* gtk_image_new() now takes no arguments and creates an empty GtkImage * gtk_image_new() now takes no arguments and creates an empty GtkImage
widget. To create a GtkImage widget from a GdkImage (the least widget. To create a GtkImage widget from a GdkImage (the least
common usage of GdkImage), use gtk_image_new_from_image. common usage of GdkImage), use gtk_image_new_from_image.
* GTK_SELECTION_EXTENDED is now deprecated, and neither the
GtkList/GtkTree nor the GtkCList/GtkCTree support
GTK_SELECTION_EXTENDED anymore. However, the old extended behavior
replaces MULTIPLE behavior.
...@@ -320,7 +320,7 @@ typedef enum ...@@ -320,7 +320,7 @@ typedef enum
GTK_SELECTION_SINGLE, GTK_SELECTION_SINGLE,
GTK_SELECTION_BROWSE, GTK_SELECTION_BROWSE,
GTK_SELECTION_MULTIPLE, GTK_SELECTION_MULTIPLE,
GTK_SELECTION_EXTENDED == GTK_SELECTION_MULTIPLE /* Deprecated */ GTK_SELECTION_EXTENDED = GTK_SELECTION_MULTIPLE /* Deprecated */
} GtkSelectionMode; } GtkSelectionMode;
/* Shadow types */ /* Shadow types */
......
...@@ -91,7 +91,7 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class) ...@@ -91,7 +91,7 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
static void static void
gtk_tree_selection_init (GtkTreeSelection *selection) gtk_tree_selection_init (GtkTreeSelection *selection)
{ {
selection->type = GTK_TREE_SELECTION_SINGLE; selection->type = GTK_SELECTION_SINGLE;
} }
static void static void
...@@ -169,19 +169,20 @@ _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection, ...@@ -169,19 +169,20 @@ _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
* @type: The selection mode * @type: The selection mode
* *
* Sets the selection mode of the @selection. If the previous type was * Sets the selection mode of the @selection. If the previous type was
* #GTK_TREE_SELECTION_MULTI and @type is #GTK_TREE_SELECTION_SINGLE, then * #GTK_SELECTION_MULTIPLE and, then the anchor is kept selected, if it was
* the anchor is kept selected, if it was previously selected. * previously selected.
**/ **/
void void
gtk_tree_selection_set_mode (GtkTreeSelection *selection, gtk_tree_selection_set_mode (GtkTreeSelection *selection,
GtkTreeSelectionMode type) GtkSelectionMode type)
{ {
g_return_if_fail (GTK_IS_TREE_SELECTION (selection)); g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
if (selection->type == type) if (selection->type == type)
return; return;
if (type == GTK_TREE_SELECTION_SINGLE) if (type == GTK_SELECTION_SINGLE ||
type == GTK_SELECTION_BROWSE)
{ {
GtkRBTree *tree = NULL; GtkRBTree *tree = NULL;
GtkRBNode *node = NULL; GtkRBNode *node = NULL;
...@@ -227,10 +228,10 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection, ...@@ -227,10 +228,10 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
* *
* Return value: the current selection mode * Return value: the current selection mode
**/ **/
GtkTreeSelectionMode GtkSelectionMode
gtk_tree_selection_get_mode (GtkTreeSelection *selection) gtk_tree_selection_get_mode (GtkTreeSelection *selection)
{ {
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), GTK_TREE_SELECTION_SINGLE); g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), GTK_SELECTION_SINGLE);
return selection->type; return selection->type;
} }
...@@ -290,10 +291,10 @@ gtk_tree_selection_get_tree_view (GtkTreeSelection *selection) ...@@ -290,10 +291,10 @@ gtk_tree_selection_get_tree_view (GtkTreeSelection *selection)
* @iter: The #GtkTreeIter, or NULL. * @iter: The #GtkTreeIter, or NULL.
* *
* Sets @iter to the currently selected node if @selection is set to * Sets @iter to the currently selected node if @selection is set to
* #GTK_TREE_SELECTION_SINGLE. @iter may be NULL if you just want to test if * #GTK_SELECTION_SINGLE or #GTK_SELECTION_BROWSE. @iter may be NULL if you
* @selection has any selected nodes. @model is filled with the current model * just want to test if @selection has any selected nodes. @model is filled
* as a convenience. This function will not work if you use @selection is * with the current model as a convenience. This function will not work if you
* #GTK_TREE_SELECTION_MULTI. * use @selection is #GTK_SELECTION_MULTIPLE.
* *
* Return value: TRUE, if there is a selected node. * Return value: TRUE, if there is a selected node.
**/ **/
...@@ -308,7 +309,7 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection, ...@@ -308,7 +309,7 @@ gtk_tree_selection_get_selected (GtkTreeSelection *selection,
gboolean retval; gboolean retval;
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE); g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
g_return_val_if_fail (selection->type == GTK_TREE_SELECTION_SINGLE, FALSE); g_return_val_if_fail (selection->type != GTK_SELECTION_MULTIPLE, FALSE);
g_return_val_if_fail (selection->tree_view != NULL, FALSE); g_return_val_if_fail (selection->tree_view != NULL, FALSE);
g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE); g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
...@@ -380,7 +381,8 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection, ...@@ -380,7 +381,8 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection *selection,
selection->tree_view->priv->tree->root == NULL) selection->tree_view->priv->tree->root == NULL)
return; return;
if (selection->type == GTK_TREE_SELECTION_SINGLE) if (selection->type == GTK_SELECTION_SINGLE ||
selection->type == GTK_SELECTION_BROWSE)
{ {
if (gtk_tree_row_reference_valid (selection->tree_view->priv->anchor)) if (gtk_tree_row_reference_valid (selection->tree_view->priv->anchor))
{ {
...@@ -492,7 +494,7 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection, ...@@ -492,7 +494,7 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection,
if (node == NULL || GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED)) if (node == NULL || GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
return; return;
if (selection->type == GTK_TREE_SELECTION_MULTI) if (selection->type == GTK_SELECTION_MULTIPLE)
state = GDK_CONTROL_MASK; state = GDK_CONTROL_MASK;
_gtk_tree_selection_internal_select_node (selection, _gtk_tree_selection_internal_select_node (selection,
...@@ -652,8 +654,8 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection) ...@@ -652,8 +654,8 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
* gtk_tree_selection_select_all: * gtk_tree_selection_select_all:
* @selection: A #GtkTreeSelection. * @selection: A #GtkTreeSelection.
* *
* Selects all the nodes. @selection is must be set to * Selects all the nodes. @selection is must be set to #GTK_SELECTION_MULTIPLE
* #GTK_TREE_SELECTION_MULTI mode. * mode.
**/ **/
void void
gtk_tree_selection_select_all (GtkTreeSelection *selection) gtk_tree_selection_select_all (GtkTreeSelection *selection)
...@@ -662,7 +664,7 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection) ...@@ -662,7 +664,7 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
g_return_if_fail (selection->tree_view != NULL); g_return_if_fail (selection->tree_view != NULL);
if (selection->tree_view->priv->tree == NULL) if (selection->tree_view->priv->tree == NULL)
return; return;
g_return_if_fail (selection->type != GTK_TREE_SELECTION_MULTI); g_return_if_fail (selection->type != GTK_SELECTION_MULTIPLE);
if (gtk_tree_selection_real_select_all (selection)) if (gtk_tree_selection_real_select_all (selection))
g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0); g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
...@@ -692,7 +694,8 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection) ...@@ -692,7 +694,8 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
{ {
struct _TempTuple *tuple; struct _TempTuple *tuple;
if (selection->type == GTK_TREE_SELECTION_SINGLE) if (selection->type == GTK_SELECTION_SINGLE ||
selection->type == GTK_SELECTION_BROWSE)
{ {
GtkRBTree *tree = NULL; GtkRBTree *tree = NULL;
GtkRBNode *node = NULL; GtkRBNode *node = NULL;
...@@ -881,10 +884,12 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection, ...@@ -881,10 +884,12 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
if (selection->tree_view->priv->anchor) if (selection->tree_view->priv->anchor)
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor); anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
if (selection->type == GTK_TREE_SELECTION_SINGLE) if (selection->type == GTK_SELECTION_SINGLE ||
selection->type == GTK_SELECTION_BROWSE)
{ {
/* Did we try to select the same node again? */ /* Did we try to select the same node again? */
if (anchor_path && gtk_tree_path_compare (path, anchor_path) == 0) 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 ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
{ {
...@@ -921,7 +926,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection, ...@@ -921,7 +926,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
} }
} }
} }
else if (selection->type == GTK_TREE_SELECTION_MULTI) else if (selection->type == GTK_SELECTION_MULTIPLE)
{ {
if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (anchor_path == NULL)) if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (anchor_path == NULL))
{ {
...@@ -983,12 +988,6 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection, ...@@ -983,12 +988,6 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
/* NOTE: Any {un,}selection ever done _MUST_ be done through this function! /* NOTE: Any {un,}selection ever done _MUST_ be done through this function!
*/ */
/* FIXME: user_func can screw up GTK_TREE_SELECTION_SINGLE. If it prevents
* unselection of a node, it can keep more then one node selected.
*/
/* Perhaps the correct solution is to prevent selecting the new node, if
* we fail to unselect the old node.
*/
static gint static gint
gtk_tree_selection_real_select_node (GtkTreeSelection *selection, gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
GtkRBTree *tree, GtkRBTree *tree,
......
...@@ -34,12 +34,6 @@ extern "C" { ...@@ -34,12 +34,6 @@ extern "C" {
#define GTK_IS_TREE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_SELECTION)) #define GTK_IS_TREE_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_SELECTION))
#define GTK_TREE_SELECTION_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TREE_SELECTION, GtkTreeSelectionClass)) #define GTK_TREE_SELECTION_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TREE_SELECTION, GtkTreeSelectionClass))
typedef enum
{
GTK_TREE_SELECTION_SINGLE,
GTK_TREE_SELECTION_MULTI
} GtkTreeSelectionMode;
typedef gboolean (* GtkTreeSelectionFunc) (GtkTreeSelection *selection, typedef gboolean (* GtkTreeSelectionFunc) (GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreeModel *model,
GtkTreePath *path, GtkTreePath *path,
...@@ -56,7 +50,7 @@ struct _GtkTreeSelection ...@@ -56,7 +50,7 @@ struct _GtkTreeSelection
/*< private >*/ /*< private >*/
GtkTreeView *tree_view; GtkTreeView *tree_view;
GtkTreeSelectionMode type; GtkSelectionMode type;
GtkTreeSelectionFunc user_func; GtkTreeSelectionFunc user_func;
gpointer user_data; gpointer user_data;
GtkDestroyNotify destroy; GtkDestroyNotify destroy;
...@@ -73,8 +67,8 @@ struct _GtkTreeSelectionClass ...@@ -73,8 +67,8 @@ struct _GtkTreeSelectionClass
GtkType gtk_tree_selection_get_type (void); GtkType gtk_tree_selection_get_type (void);
void gtk_tree_selection_set_mode (GtkTreeSelection *selection, void gtk_tree_selection_set_mode (GtkTreeSelection *selection,
GtkTreeSelectionMode type); GtkSelectionMode type);
GtkTreeSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection); GtkSelectionMode gtk_tree_selection_get_mode (GtkTreeSelection *selection);
void gtk_tree_selection_set_select_function (GtkTreeSelection *selection, void gtk_tree_selection_set_select_function (GtkTreeSelection *selection,
GtkTreeSelectionFunc func, GtkTreeSelectionFunc func,
gpointer data, gpointer data,
......
...@@ -5693,10 +5693,10 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view) ...@@ -5693,10 +5693,10 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
cursor_path = gtk_tree_path_new_root (); cursor_path = gtk_tree_path_new_root ();
gtk_tree_row_reference_free (tree_view->priv->cursor); gtk_tree_row_reference_free (tree_view->priv->cursor);
if (tree_view->priv->selection->type == GTK_TREE_SELECTION_SINGLE) if (tree_view->priv->selection->type == GTK_SELECTION_MULTIPLE)
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE);
else
gtk_tree_view_real_set_cursor (tree_view, cursor_path, FALSE); gtk_tree_view_real_set_cursor (tree_view, cursor_path, FALSE);
else
gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE);
} }
gtk_tree_path_free (cursor_path); gtk_tree_path_free (cursor_path);
} }
......
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