[tracker/needle: 29/33] tracker-needle: Make use of column2 for size/duration/page count/etc



commit 523e992baf2979ee1ec1220ffcdaf6fc7731c844
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Aug 16 10:16:41 2010 +0100

    tracker-needle: Make use of column2 for size/duration/page count/etc

 src/tracker-needle/tracker-needle.vala |   36 +++++++++++++++++++++++--------
 src/tracker-needle/tracker-query.vala  |    9 +++++++-
 src/tracker-needle/tracker-utils.vala  |    6 ++--
 3 files changed, 37 insertions(+), 14 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index c35a2f4..592c15f 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -122,8 +122,8 @@ public class TrackerNeedle {
 		                       typeof (string),      // URL
 		                       typeof (string),      // Title
 		                       typeof (string),      // Subtitle
-		                       typeof (string),      // File last changed
-		                       typeof (string),      // File size
+		                       typeof (string),      // Column 2
+		                       typeof (string),      // Column 3
 		                       typeof (string));     // Tooltip
 		treeview.set_model (store);
 		treeview.set_tooltip_column (8);
@@ -225,8 +225,8 @@ public class TrackerNeedle {
 					       3, _file,        // URL
 					       4, title,        // Title
 					       5, null,         // Subtitle
-					       6, file_time,    // Time
-					       7, file_size,    // Size
+					       6, file_time,    // Column2: Time
+					       7, file_size,    // Column3: Size
 					       8, tooltip,      // Tooltip
 					       -1);
 			}
@@ -282,13 +282,21 @@ public class TrackerNeedle {
 					string _file = cursor.get_string (1);
 					string title = cursor.get_string (2);
 					string subtitle = null;
-					string tooltip = cursor.get_string (4);
+					string column2 = null;
+					string column3 = null;
+					string tooltip = cursor.get_string (5);
 					Gdk.Pixbuf pixbuf_small = tracker_pixbuf_new_from_file (theme, _file, size_medium, is_image);
 
 					// Special cases
 					switch (type) {
+					case Tracker.Query.Type.MUSIC:
+						column2 = tracker_time_format_from_seconds (cursor.get_string (4));
+						break;
+					case Tracker.Query.Type.IMAGES:
+						column2 = GLib.format_size_for_display (cursor.get_string (4).to_int ());
+						break;
 					case Tracker.Query.Type.VIDEOS:
-						subtitle = tracker_time_format_from_seconds (cursor.get_string (3));
+						column2 = tracker_time_format_from_seconds (cursor.get_string (4));
 						break;
 						
 					default:
@@ -299,6 +307,10 @@ public class TrackerNeedle {
 						subtitle = cursor.get_string (3);
 					}
 
+					if (column2 == null) {
+						column2 = cursor.get_string (4);
+					}
+
 					// Insert into model
 					TreeIter iter;
 					store.append (out iter);
@@ -311,8 +323,8 @@ public class TrackerNeedle {
 							   3, _file,        // URL
 							   4, title,        // Title
 							   5, subtitle,     // Subtitle
-							   6, null,         // Time
-							   7, null,         // Size
+							   6, column2,      // Column2
+							   7, column3,      // Column3
 							   8, tooltip,      // Tooltip
 							   -1);
 				}
@@ -326,6 +338,10 @@ public class TrackerNeedle {
 	private bool search_run () {
 		last_search_id = 0;
 
+		if (search.get_text ().length < 1) {
+			return false;
+		}
+
 		if (view_details.active) {
 			search_detailed ();
 		} else {
@@ -351,13 +367,13 @@ public class TrackerNeedle {
 			debug ("View toggled to 'list' or 'details'");
 			
 			if (view_details.active) {
-				treeview.get_column (1).visible = false;
+				treeview.set_grid_lines (Gtk.TreeViewGridLines.NONE);
 				treeview.get_column (2).visible = false;
 				treeview.set_headers_visible (false);
 				find_in_contents.sensitive = false;
 				find_in_titles.sensitive = false;
 			} else {
-				treeview.get_column (1).visible = true;
+				treeview.set_grid_lines (Gtk.TreeViewGridLines.VERTICAL);
 				treeview.get_column (2).visible = true;
 				treeview.set_headers_visible (true);
 				find_in_contents.sensitive = true;
diff --git a/src/tracker-needle/tracker-query.vala b/src/tracker-needle/tracker-query.vala
index 3909b5a..0f5a39c 100644
--- a/src/tracker-needle/tracker-query.vala
+++ b/src/tracker-needle/tracker-query.vala
@@ -80,7 +80,6 @@ public class Tracker.Query {
 			          nie:url(?urn) 
 			          tracker:coalesce(nie:title(?urn), nfo:fileName(?urn), \"Unknown\") 
 			          nie:comment(?urn)
-			          nfo:softwareCmdLine (?urn)
 			        WHERE {
 			          ?urn a nfo:Software .
 			          ?urn fts:match \"$criteria_escaped\" .
@@ -97,6 +96,7 @@ public class Tracker.Query {
 			          nie:url(?urn) 
 			          tracker:coalesce(nie:title(?urn), nfo:fileName(?urn), \"Unknown\") 
 			          fn:string-join((?performer, ?album), \" - \") 
+			          nfo:duration(?urn)
 			          ?tooltip
 			        WHERE {
 			          ?urn a nfo:Audio ;
@@ -117,6 +117,7 @@ public class Tracker.Query {
 			          nie:url(?urn) 
 			          tracker:coalesce(nie:title(?urn), nfo:fileName(?urn), \"Unknown\") 
 			          fn:string-join((nfo:height(?urn), nfo:width(?urn)), \" x \") 
+			          nfo:fileSize(?urn)
 			          ?tooltip
 			        WHERE {
 			          ?urn a nfo:Image ;
@@ -134,6 +135,7 @@ public class Tracker.Query {
 			          ?urn 
 			          nie:url(?urn) 
 			          tracker:coalesce(nie:title(?urn), nfo:fileName(?urn), \"Unknown\") 
+			          \"\"
 			          nfo:duration(?urn)
 			          ?tooltip
 			        WHERE {
@@ -148,14 +150,19 @@ public class Tracker.Query {
 
 		case Type.DOCUMENTS:
 //			          fn:concat(nco:pageCount(?urn), \" pages\")
+			string pages = _("Pages");
+			
 			query = @"
 			        SELECT
 			          ?urn 
 			          nie:url(?urn) 
 			          tracker:coalesce(nie:title(?urn), nfo:fileName(?urn), \"Unknown\") 
+			          ?creator
+			          fn:concat(nfo:pageCount(?urn), \" $pages\")
 			          ?tooltip
 			        WHERE {
 			          ?urn a nfo:Document ;
+			          nco:creator [ nco:fullname ?creator ] ;
 			          nfo:belongsToContainer [ nie:url ?tooltip ] .
 			          ?urn fts:match \"$criteria_escaped\" .
 			        }
diff --git a/src/tracker-needle/tracker-utils.vala b/src/tracker-needle/tracker-utils.vala
index 335ec85..c24809c 100644
--- a/src/tracker-needle/tracker-utils.vala
+++ b/src/tracker-needle/tracker-utils.vala
@@ -91,15 +91,15 @@ public string tracker_time_format_from_seconds (string seconds_str) {
 	}
 
 	if (h > 0) {
-		output.append (" %2.2dh".printf (h));
+		output.append (" %.2d".printf (h));
 	}
 
 	if (m > 0) {
-		output.append (" %2.2dm".printf (m));
+		output.append ("%s%.2d".printf (h > 0 ? ":" : "", m));
 	}
 
 	if (s > 0) {
-		output.append (" %2.2ds".printf (s));
+		output.append ("%s%.2d".printf (m > 0 ? ":" : "0:", s));
 	}
 
 	if (output.len < 1) {



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