summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2001-10-31 20:20:12 +0000
committerJonathan Blandford <jrb@src.gnome.org>2001-10-31 20:20:12 +0000
commit30f9fab4b418b1adc94bd4a49a987477481a460a (patch)
treedd5ea3e0d4d503d6742cbd748a552c0b9643b31e /gtk
parentc49351c86bfb7168561a7a813a4d9e65e8d69cd9 (diff)
downloadgtk+-30f9fab4b418b1adc94bd4a49a987477481a460a.tar.gz
Add GTK_SELECTION_NONE enum, #61695
Wed Oct 31 14:45:08 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtkenums.h (enum): Add GTK_SELECTION_NONE enum, #61695 * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Handle new GTK_SELECTION_NONE enum. (_gtk_tree_selection_internal_select_node): ditto * gtk/gtkcellrenderer.h (struct _GtkCellRendererClass): add constness. * gtk/gtkcellrenderertoggle.c: more yummy constness. * gtk/gtkclist.c (gtk_clist_set_selection_mode): g_return_if_fail if mode == GTK_SELECTION_NONE
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcellrenderer.h2
-rw-r--r--gtk/gtkcellrenderertoggle.c2
-rw-r--r--gtk/gtkclist.c10
-rw-r--r--gtk/gtkenums.h1
-rw-r--r--gtk/gtktreeselection.c39
5 files changed, 42 insertions, 12 deletions
diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h
index 7bfe468854..47fa367d52 100644
--- a/gtk/gtkcellrenderer.h
+++ b/gtk/gtkcellrenderer.h
@@ -93,7 +93,7 @@ struct _GtkCellRendererClass
gboolean (* activate) (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
- gchar *path,
+ const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GtkCellRendererState flags);
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 0a19e71fa9..3f7b054d73 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -49,7 +49,7 @@ static void gtk_cell_renderer_toggle_render (GtkCellRenderer *cel
static gboolean gtk_cell_renderer_toggle_activate (GtkCellRenderer *cell,
GdkEvent *event,
GtkWidget *widget,
- const gchar *path,
+ const gchar *path,
GdkRectangle *background_area,
GdkRectangle *cell_area,
guint flags);
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index 0e1c467e0e..602850186f 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -1276,6 +1276,7 @@ gtk_clist_set_selection_mode (GtkCList *clist,
GtkSelectionMode mode)
{
g_return_if_fail (GTK_IS_CLIST (clist));
+ g_return_if_fail (mode != GTK_SELECTION_NONE);
if (mode == clist->selection_mode)
return;
@@ -1299,6 +1300,9 @@ gtk_clist_set_selection_mode (GtkCList *clist,
case GTK_SELECTION_SINGLE:
gtk_clist_unselect_all (clist);
break;
+ default:
+ /* Someone set it by hand */
+ g_assert_not_reached ();
}
}
@@ -3594,6 +3598,8 @@ toggle_row (GtkCList *clist,
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
row, column, event);
break;
+ default:
+ g_assert_not_reached ();
}
}
@@ -3814,6 +3820,8 @@ real_select_all (GtkCList *clist)
update_extended_selection (clist, clist->rows);
GTK_CLIST_GET_CLASS (clist)->resync_selection (clist, NULL);
return;
+ default:
+ g_assert_not_reached ();
}
}
@@ -7390,6 +7398,8 @@ gtk_clist_drag_begin (GtkWidget *widget,
clist->anchor = -1;
case GTK_SELECTION_BROWSE:
break;
+ default:
+ g_assert_not_reached ();
}
info = g_dataset_get_data (context, "gtk-clist-drag-source");
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index aac459b4d3..2cfcf83851 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -317,6 +317,7 @@ typedef enum
/* list selection modes */
typedef enum
{
+ GTK_SELECTION_NONE, /* Nothing can be selected */
GTK_SELECTION_SINGLE,
GTK_SELECTION_BROWSE,
GTK_SELECTION_MULTIPLE,
diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c
index 6e67d72d4f..01ec82dac3 100644
--- a/gtk/gtktreeselection.c
+++ b/gtk/gtktreeselection.c
@@ -176,22 +176,33 @@ void
gtk_tree_selection_set_mode (GtkTreeSelection *selection,
GtkSelectionMode type)
{
+ GtkTreeSelectionFunc tmp_func;
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
if (selection->type == type)
return;
- if (type == GTK_SELECTION_SINGLE ||
- type == GTK_SELECTION_BROWSE)
+
+ if (type == GTK_SELECTION_NONE)
+ {
+ gtk_tree_row_reference_free (selection->tree_view->priv->anchor);
+ /* We do this so that we unconditionally unset all rows
+ */
+ tmp_func = selection->user_func;
+ selection->user_func = NULL;
+ gtk_tree_selection_unselect_all (selection);
+ selection->user_func = tmp_func;
+ }
+ else if (type == GTK_SELECTION_SINGLE ||
+ type == GTK_SELECTION_BROWSE)
{
GtkRBTree *tree = NULL;
GtkRBNode *node = NULL;
gint selected = FALSE;
+ GtkTreePath *anchor_path = NULL;
if (selection->tree_view->priv->anchor)
{
- GtkTreePath *anchor_path;
-
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
if (anchor_path)
@@ -203,19 +214,25 @@ gtk_tree_selection_set_mode (GtkTreeSelection *selection,
if (node && GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
selected = TRUE;
-
- gtk_tree_path_free (anchor_path);
}
}
- /* FIXME: if user_func is set, then it needs to unconditionally unselect
- * all.
+
+ /* We do this so that we unconditionally unset all rows
*/
+ tmp_func = selection->user_func;
+ selection->user_func = NULL;
gtk_tree_selection_unselect_all (selection);
+ selection->user_func = tmp_func;
- /* FIXME are we properly emitting the selection_changed signal here? */
if (node && selected)
- GTK_RBNODE_SET_FLAG (node, GTK_RBNODE_IS_SELECTED);
+ _gtk_tree_selection_internal_select_node (selection,
+ node,
+ tree,
+ anchor_path,
+ 0);
+ gtk_tree_path_free (anchor_path);
}
+
selection->type = type;
}
@@ -955,6 +972,8 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
gint dirty = FALSE;
GtkTreePath *anchor_path = NULL;
+ if (selection->type == GTK_SELECTION_NONE)
+ return;
if (selection->tree_view->priv->anchor)
anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);