summaryrefslogtreecommitdiff
path: root/gtk/gtktreeselection.c
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2001-10-10 05:35:12 +0000
committerJonathan Blandford <jrb@src.gnome.org>2001-10-10 05:35:12 +0000
commit57cc0e955633b06e3a610479e8b7ebcfa501a322 (patch)
treec6cd8cb59c2f2c633267c28ef0fbe8e32d72d730 /gtk/gtktreeselection.c
parentb48389f36f9756ff75969ab3cb10ee520e3a0bfb (diff)
downloadgtk+-57cc0e955633b06e3a610479e8b7ebcfa501a322.tar.gz
new function, #61923 (gtk_tree_selection_path_is_selected): Ditto
Wed Oct 10 01:19:04 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreeselection.c (gtk_tree_selection_iter_is_selected): new function, #61923 (gtk_tree_selection_path_is_selected): Ditto
Diffstat (limited to 'gtk/gtktreeselection.c')
-rw-r--r--gtk/gtktreeselection.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c
index cbf2c43a5b..947c27ef5b 100644
--- a/gtk/gtktreeselection.c
+++ b/gtk/gtktreeselection.c
@@ -604,6 +604,71 @@ gtk_tree_selection_unselect_iter (GtkTreeSelection *selection,
gtk_tree_path_free (path);
}
+/**
+ * gtk_tree_selection_path_is_selected:
+ * @selection: A #GtkTreeSelection.
+ * @path: A #GtkTreePath to check selection on.
+ *
+ * Returns %TRUE if the row pointed to by @path is currently selected. If @path
+ * does not point to a valid location, %FALSE is returned
+ *
+ * Return value: %TRUE if @path is selected.
+ **/
+gboolean
+gtk_tree_selection_path_is_selected (GtkTreeSelection *selection,
+ GtkTreePath *path)
+{
+ GtkRBNode *node;
+ GtkRBTree *tree;
+
+ g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (selection->tree_view != NULL, FALSE);
+ g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
+
+ _gtk_tree_view_find_node (selection->tree_view,
+ path,
+ &tree,
+ &node);
+
+ if ((node == NULL) || !GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
+ return FALSE;
+
+ return TRUE;
+}
+
+/**
+ * gtk_tree_selection_iter_is_selected:
+ * @selection: A #GtkTreeSelection
+ * @iter: A valid #GtkTreeIter
+ *
+ * Returns %TRUE if the row pointed to by @path is currently selected.
+ *
+ * Return value: %TRUE, if @iter is selected
+ **/
+gboolean
+gtk_tree_selection_iter_is_selected (GtkTreeSelection *selection,
+ GtkTreeIter *iter)
+{
+ GtkTreePath *path;
+ gboolean retval;
+
+ g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
+ g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (selection->tree_view != NULL, FALSE);
+ g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
+
+ path = gtk_tree_model_get_path (selection->tree_view->priv->model, iter);
+ if (path == NULL)
+ return FALSE;
+
+ retval = gtk_tree_selection_path_is_selected (selection, path);
+ gtk_tree_path_free (path);
+
+ return retval;
+}
+
+
/* Wish I was in python, right now... */
struct _TempTuple {
GtkTreeSelection *selection;