cheese r674 - in branches/cheese-vala: . src



Author: jhaitsma
Date: Tue Apr 22 00:35:03 2008
New Revision: 674
URL: http://svn.gnome.org/viewvc/cheese?rev=674&view=rev

Log:
Implement get_all_thumbs and get_selected_thumbs


Modified:
   branches/cheese-vala/   (props changed)
   branches/cheese-vala/src/cheese-thumb-view.vala

Modified: branches/cheese-vala/src/cheese-thumb-view.vala
==============================================================================
--- branches/cheese-vala/src/cheese-thumb-view.vala	(original)
+++ branches/cheese-vala/src/cheese-thumb-view.vala	Tue Apr 22 00:35:03 2008
@@ -94,17 +94,16 @@
 
 	void remove_thumb (File file) {
 		TreeIter iter;
-		TreeModel model = store;
 		store.get_iter_first (out iter);
 		
 		/* check if the selected item is the first, else go through the store */
 		string path;
-		store.get (iter, Column.URL, path);
+		store.get (iter, Column.URL, out path);
 
 		var filename = file.get_path ();
 		if (filename != path) {
 			while (store.iter_next (ref iter)) {
-				store.get (iter, Column.URL, path);
+				store.get (iter, Column.URL, out path);
 				if (filename == path)
 					break;
 			}
@@ -115,12 +114,43 @@
 		}
 	}
 
-	ArrayList <string> get_all_thumbs () {
-		return null;
+	public ArrayList<string> get_all_thumbs () {
+		var filename_list = new ArrayList<string> ();
+		TreeIter iter;
+
+		if (store.get_iter_first (out iter)) {
+			do {
+				string path;
+				store.get (iter, Column.URL, out path);
+				filename_list.add (path);			
+			} while (store.iter_next (ref iter));
+		}
+		return filename_list;
 	}
 
-	ArrayList <string> get_selected_thumbs () {
-		return null;
+
+	string get_filename_from_tree_path (TreePath path) {
+		TreeModel model = get_model ();
+		TreeIter iter;
+		string filename;
+
+		model.get_iter (out iter, path);
+		model.get (iter, Column.URL, filename);
+		return filename;
+	}
+
+	public ArrayList<string> get_selected_thumbs () {
+		var filename_list = new ArrayList<string> ();
+		weak GLib.List<TreePath> l;
+		l = get_selected_items ();
+
+		for (int i; i < l.length (); i++) {
+			weak TreePath tree_path = l.nth_data (i);
+			var filename = get_filename_from_tree_path (tree_path);
+			filename_list.add (filename);
+		}
+
+		return filename_list;
 	}
 
 	void on_file_changed (FileMonitor sender, File file, File other_file, FileMonitorEvent event_type) {
@@ -141,7 +171,6 @@
 	}
 
 	void load_existing_thumbs () {
-		store.clear (); // FIXME: is this necessary
 		try {
 			string name;
 
@@ -159,6 +188,7 @@
 			// FIXME
 		}
 	}
+
 	construct {
 		store = new ListStore (2, typeof (Pixbuf), typeof (string));
 		set_model (store);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]