[tracker/tracker-0.10] tracker-needle: Bring icon view back to life



commit 222ea308dfa602dd324490b44a544d5f5e1e3340
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 22 18:47:08 2011 +0100

    tracker-needle: Bring icon view back to life
    
    It is now an image view

 src/tracker-needle/tracker-needle.ui         |    2 +-
 src/tracker-needle/tracker-needle.vala       |   22 +++++++++++++++++-----
 src/tracker-needle/tracker-result-store.vala |   10 ++++++++--
 src/tracker-needle/tracker-view.vala         |    4 ++--
 4 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.ui b/src/tracker-needle/tracker-needle.ui
index 543e467..7abba00 100644
--- a/src/tracker-needle/tracker-needle.ui
+++ b/src/tracker-needle/tracker-needle.ui
@@ -46,7 +46,7 @@
             <child>
               <object class="GtkRadioToolButton" id="toolbutton_view_icons">
                 <property name="visible">True</property>
-                <property name="tooltip_text" translatable="yes">Display results by files found in a grid view</property>
+                <property name="tooltip_text" translatable="yes">Display found images</property>
                 <property name="is_important">True</property>
                 <property name="use_underline">True</property>
                 <property name="icon_name">emblem-photos</property>
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 3105a62..9b479be 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -57,6 +57,7 @@ public class Tracker.Needle {
 	private ResultStore categories_model;
 	private ResultStore files_model;
 	private ResultStore files_in_title_model;
+	private ResultStore images_model;
 
 	private void create_models () {
 		// Categories model
@@ -133,6 +134,17 @@ public class Tracker.Needle {
 		                                "nfo:fileSize(?urn)",
 		                                "nfo:fileLastModified(?urn)",
 		                                "nie:url(?urn)");
+
+		// Images model
+		images_model = new ResultStore (6);
+		images_model.icon_size = 48;
+		images_model.add_query (Tracker.Query.Type.IMAGES,
+		                        "?urn",
+		                        "nie:url(?urn)",
+		                        "tracker:coalesce(nie:title(?urn), nfo:fileName(?urn))",
+		                        "nfo:fileSize(?urn)",
+		                        "nfo:fileLastModified(?urn)",
+		                        "nie:url(?urn)");
 	}
 
 	public Needle () {
@@ -258,10 +270,10 @@ public class Tracker.Needle {
 		treeview.row_activated.connect (view_row_selected);
 		view.pack_start (sw_filelist, true, true, 0);
 
-		// sw_icons = new Tracker.View (Tracker.View.Display.FILE_ICONS, null);
-		// iconview = (IconView) sw_icons.get_child ();
-		// iconview.item_activated.connect (icon_item_selected);
-		// view.pack_start (sw_icons, true, true, 0);
+		sw_icons = new Tracker.View (Tracker.View.Display.FILE_ICONS, images_model);
+		iconview = (IconView) sw_icons.get_child ();
+		iconview.item_activated.connect (icon_item_selected);
+		view.pack_start (sw_icons, true, true, 0);
 
 		// Set up taglist
 		taglist = new Tracker.TagList ();
@@ -617,7 +629,7 @@ public class Tracker.Needle {
 
 		if (view_icons.active) {
 			sw_icons.show ();
-			store = sw_icons.store;
+			store = images_model;
 		} else {
 			sw_icons.hide ();
 		}
diff --git a/src/tracker-needle/tracker-result-store.vala b/src/tracker-needle/tracker-result-store.vala
index 7248eaf..d13ab78 100644
--- a/src/tracker-needle/tracker-result-store.vala
+++ b/src/tracker-needle/tracker-result-store.vala
@@ -50,6 +50,11 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
 	private int n_columns;
 	private int timestamp;
 
+	public int icon_size {
+		get;
+		set;
+	}
+
 	private Operation * find_operation (GenericArray<Operation>  array,
 					    CategoryNode            *node,
 					    int                      offset) {
@@ -473,7 +478,7 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
 
 		try {
 			if (thumb_path != null) {
-				pixbuf = new Gdk.Pixbuf.from_file_at_size (thumb_path, 24, 24);
+				pixbuf = new Gdk.Pixbuf.from_file_at_size (thumb_path, icon_size, icon_size);
 			} else {
 				icon = (GLib.Icon) info.get_attribute_object ("standard::icon");
 
@@ -482,7 +487,7 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
 				}
 
 				var theme = IconTheme.get_for_screen (Gdk.Screen.get_default ());
-				icon_info = theme.lookup_by_gicon (icon, 24, 0);
+				icon_info = theme.lookup_by_gicon (icon, icon_size, 0);
 
 				if (icon_info == null) {
 					return;
@@ -789,6 +794,7 @@ public class Tracker.ResultStore : Gtk.TreeModel, GLib.Object {
 		// Add an extra one for the pixbuf
 		n_columns = _n_columns + 1;
 		timestamp = 1;
+		icon_size = 24;
 	}
 
 	public void add_query (Tracker.Query.Type type, ...) {
diff --git a/src/tracker-needle/tracker-view.vala b/src/tracker-needle/tracker-view.vala
index 96f3cd3..8d18c42 100644
--- a/src/tracker-needle/tracker-view.vala
+++ b/src/tracker-needle/tracker-view.vala
@@ -131,8 +131,8 @@ public class Tracker.View : ScrolledWindow {
 			iv.set_model (store);
 			iv.set_item_width (96);
 			iv.set_selection_mode (SelectionMode.SINGLE);
-			iv.set_pixbuf_column (1);
-			iv.set_text_column (4);
+			iv.set_pixbuf_column (6);
+			iv.set_text_column (2);
 
 			break;
 		}



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