Source list view: add get_iter, get_selection and set_hildon_ui_mode methods
authorPhilipp Zabel <philipp.zabel@gmail.com>
Sat, 5 Dec 2009 08:57:24 +0000 (09:57 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 5 Jan 2010 18:38:28 +0000 (19:38 +0100)
These will be used in the catalog plugin settings to show a source list to
select active sources.

src/source-list-view.vala

index d243000..03fc33e 100644 (file)
@@ -97,6 +97,34 @@ public class SourceListView : PannableArea {
                }
        }
 
+       public bool get_iter (MovieSource source, out Gtk.TreeIter iter) {
+               if (store.get_iter_first (out iter)) do {
+                       MovieSource s = null;
+                       store.get (iter, 2, out s);
+                       if (s == source) {
+                               return true;
+                       }
+               } while (store.iter_next (ref iter));
+
+               return false;
+       }
+
+       public unowned TreeSelection get_selection () {
+               return tree.get_selection ();
+       }
+
+       public void set_hildon_ui_mode (UIMode mode) {
+               var selection = tree.get_selection ();
+
+               if (mode == UIMode.NORMAL) {
+                       selection.set_mode (SelectionMode.NONE);
+               }
+               Hildon.gtk_tree_view_set_ui_mode (tree, mode);
+               if (mode == UIMode.EDIT) {
+                       selection.set_mode (SelectionMode.MULTIPLE);
+               }
+       }
+
        private void on_row_activated (TreeView tree, TreePath path_, TreeViewColumn column) {
                TreePath path = path_.copy (); // FIXME - calling model.get_iter with path_ directly causes a C qualifier warning
                TreeModel model = tree.model;