commit 882461e83e8b28f1a70de02dca2bf2e6623c8e61
Author: Szilárd Pfeiffer <mailbox@pfeifferszilard.hu>
Date:   Mon Aug 16 12:42:42 2010 +0200

    Implemented iter_prev function for filter model.

diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index 5530443..cdda1cf 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -184,6 +184,8 @@ static void         gtk_tree_model_filter_get_value                       (GtkTr
                                                                            GValue                 *value);
 static gboolean     gtk_tree_model_filter_iter_next                       (GtkTreeModel           *model,
                                                                            GtkTreeIter            *iter);
+static gboolean     gtk_tree_model_filter_iter_prev                       (GtkTreeModel           *model,
+                                                                           GtkTreeIter            *iter);
 static gboolean     gtk_tree_model_filter_iter_children                   (GtkTreeModel           *model,
                                                                            GtkTreeIter            *iter,
                                                                            GtkTreeIter            *parent);
@@ -354,6 +356,7 @@ gtk_tree_model_filter_tree_model_init (GtkTreeModelIface *iface)
   iface->get_path = gtk_tree_model_filter_get_path;
   iface->get_value = gtk_tree_model_filter_get_value;
   iface->iter_next = gtk_tree_model_filter_iter_next;
+  iface->iter_prev = gtk_tree_model_filter_iter_prev;
   iface->iter_children = gtk_tree_model_filter_iter_children;
   iface->iter_has_child = gtk_tree_model_filter_iter_has_child;
   iface->iter_n_children = gtk_tree_model_filter_iter_n_children;
@@ -2452,7 +2455,6 @@ static gboolean
 gtk_tree_model_filter_iter_next (GtkTreeModel *model,
                                  GtkTreeIter  *iter)
 {
-  int i;
   FilterLevel *level;
   FilterElt *elt;
 
@@ -2463,11 +2465,8 @@ gtk_tree_model_filter_iter_next (GtkTreeModel *model,
   level = iter->user_data;
   elt = iter->user_data2;
 
-  i = elt - FILTER_ELT (level->array->data);
-
-  while (i < level->array->len - 1)
+  while (elt < FILTER_ELT(level->array->data + level->array->len - 1))
     {
-      i++;
       elt++;
 
       if (elt->visible)
@@ -2484,6 +2483,37 @@ gtk_tree_model_filter_iter_next (GtkTreeModel *model,
 }
 
 static gboolean
+gtk_tree_model_filter_iter_prev (GtkTreeModel *model,
+                                 GtkTreeIter  *iter)
+{
+  FilterLevel *level;
+  FilterElt *elt;
+
+  g_return_val_if_fail (GTK_IS_TREE_MODEL_FILTER (model), FALSE);
+  g_return_val_if_fail (GTK_TREE_MODEL_FILTER (model)->priv->child_model != NULL, FALSE);
+  g_return_val_if_fail (GTK_TREE_MODEL_FILTER (model)->priv->stamp == iter->stamp, FALSE);
+
+  level = iter->user_data;
+  elt = iter->user_data2;
+
+  while (elt > FILTER_ELT(level->array->data))
+    {
+      elt--;
+
+      if (elt->visible)
+        {
+          iter->user_data2 = elt;
+          return TRUE;
+        }
+    }
+
+  /* no previous visible iter */
+  iter->stamp = 0;
+
+  return FALSE;
+}
+
+static gboolean
 gtk_tree_model_filter_iter_children (GtkTreeModel *model,
                                      GtkTreeIter  *iter,
                                      GtkTreeIter  *parent)
