[tracker] Tracker-Search-Tool: Fix categories, crasher and added smart wildcards



commit 19d0e9bc0eb312666d6e7632d0bb989ff5e4e4e1
Author: Jamie McCracken <jamiemcc gnome org>
Date:   Fri Oct 2 00:30:41 2009 -0400

    Tracker-Search-Tool: Fix categories, crasher and added smart wildcards
    
    Made category selector work properly
    Fixed crasher when selecting a category
    Now add wildcard search when last character is not a space

 src/tracker-search-tool/tracker-entry.gs |    2 +-
 src/tracker-search-tool/tracker-query.gs |   17 +++++++++++++----
 src/tracker-search-tool/tracker-utils.gs |   12 +++++++++---
 3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/tracker-search-tool/tracker-entry.gs b/src/tracker-search-tool/tracker-entry.gs
index c3bf751..211f6d8 100644
--- a/src/tracker-search-tool/tracker-entry.gs
+++ b/src/tracker-search-tool/tracker-entry.gs
@@ -47,7 +47,7 @@ class TrackerSearchEntry  : Gtk.Entry
                 Query.SearchTerms = ""
             else
                 set_icon_sensitive (EntryIconPosition.SECONDARY, true)
-                Query.SearchTerms = EscapeSparql (text)
+                Query.SearchTerms = EscapeSparql (text, true)
         
     
     
diff --git a/src/tracker-search-tool/tracker-query.gs b/src/tracker-search-tool/tracker-query.gs
index 43c74bb..e504da2 100644
--- a/src/tracker-search-tool/tracker-query.gs
+++ b/src/tracker-search-tool/tracker-query.gs
@@ -29,11 +29,18 @@ interface Resources : GLib.Object
 class TrackerQuery : Object
 
     tracker : Resources;
+    _SearchTerms : string
 
     event SearchSettingsChanged ()   
     event ClearSearchResults () 
 
     prop SearchTerms : string
+        get
+            return  _SearchTerms
+        set
+            if value is not null
+                _SearchTerms = value
+                 
     prop Category : string
     prop SortField : string
     prop Fields : array of string
@@ -47,7 +54,7 @@ class TrackerQuery : Object
                 SearchSettingsChanged ()
             else 
                 if propety.name is "SearchTerms" 
-                    if SearchTerms is null or SearchTerms.length < 3    
+                    if SearchTerms is null or SearchTerms.length < 3   
                         ClearSearchResults ()
                     else 
                         SearchSettingsChanged ()
@@ -67,12 +74,14 @@ class TrackerQuery : Object
        
     def Search () : array of string[,] 
     
-        query : string
+        cat, query : string
     
         if Category is null or Category is "All"    
-            query = "SELECT ?s WHERE { ?s fts:match \"%s\". ?s a nie:InformationElement } limit 100 ".printf(SearchTerms)
+            cat = "nfo:FileDataObject"
         else
-            query = "SELECT ?s WHERE { ?s fts:match \"%s\". ?s a %s} limit 100 ".printf(SearchTerms, Category)   
+            cat = Category
+            
+        query = "SELECT ?s WHERE { ?s fts:match \"%s\". ?s a %s } limit 100 ".printf (SearchTerms, cat)   
 
         // to do : add Fields, Category and SortField
         try
diff --git a/src/tracker-search-tool/tracker-utils.gs b/src/tracker-search-tool/tracker-utils.gs
index 821fc79..33835db 100644
--- a/src/tracker-search-tool/tracker-utils.gs
+++ b/src/tracker-search-tool/tracker-utils.gs
@@ -51,7 +51,7 @@ const  extern static  SRCDIR : string
 class TrackerUtils
 /* static methods only as this is a utility class that wont ever get substantiated */
 
-    def static EscapeSparql (sparql : string) : string
+    def static EscapeSparql (sparql : string, add_wildcard : bool) : string
         var str = new StringBuilder ()
         
         if sparql is null
@@ -72,8 +72,14 @@ class TrackerUtils
             else
                 str.append_c (*p)
             p++
-
-        return str.str
+          
+        if add_wildcard    
+            p--
+            if *p is not ' '
+                str.append_c ('*')
+                
+                            
+        return str.str     
 		
 
 



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