Added entry used to reset filter
authorEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 18:22:35 +0000 (18:22 +0000)
committerEnrico Zini <enrico@enricozini.org>
Mon, 14 Dec 2009 18:22:35 +0000 (18:22 +0000)
gtkfisheyelist/gtkfisheyelistview.vala

index 10b790f5d055502bff347f98d4475f7129f1854d..4918269893e022b871e0cc0e1aa6d51d7b6b214a 100644 (file)
@@ -209,11 +209,17 @@ public class FisheyeListView : Gtk.DrawingArea
                int x = (int)event.x;
                if (x < allocation.width / 3)
                {
-                       Gtk.TreeIter iter;
-                       if (model.iter_nth_child(out iter, null, label_cache[cur_el].index))
+                       if (label_cache[cur_el].index == -1)
                        {
-                               Gtk.TreePath path = model.get_path(iter);
-                               row_activated(path);
+                               // The case of "reset filter"
+                               prefix_filter = null;
+                       } else {
+                               Gtk.TreeIter iter;
+                               if (model.iter_nth_child(out iter, null, label_cache[cur_el].index))
+                               {
+                                       Gtk.TreePath path = model.get_path(iter);
+                                       row_activated(path);
+                               }
                        }
                } else if (cur_pfx != null && x > allocation.width * 2 / 3) {
                        //stderr.printf("Mouse released on prefix %s\n", cur_pfx.prefix);
@@ -327,7 +333,7 @@ public class FisheyeListView : Gtk.DrawingArea
                        else
                        {
                                int count = model.iter_n_children(null);
-                               label_cache = new LabelInfo[count];
+                               label_cache = new LabelInfo[count + 1];
 
                                int lc_idx = 0;
                                int model_idx = 0;
@@ -351,6 +357,12 @@ public class FisheyeListView : Gtk.DrawingArea
                                        }
                                        ++model_idx;
                                } while (model.iter_next(ref iter));
+                               if (_prefix_filter != null)
+                               {
+                                       label_cache[lc_idx].label = "(reset prefix)";
+                                       label_cache[lc_idx].index = -1;
+                                       ++lc_idx;
+                               }
                                prefixes.append(pi);
                                label_count = lc_idx;
                        }