diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c index f408c415a8..c260b51025 100644 --- a/gtk/gtksearchenginequartz.c +++ b/gtk/gtksearchenginequartz.c @@ -192,6 +192,8 @@ gtk_search_engine_quartz_set_query (GtkSearchEngine *engine, GtkQuery *query) { GtkSearchEngineQuartz *quartz; + const char* path = NULL; + GFile *location = NULL; QUARTZ_POOL_ALLOC; @@ -204,11 +206,28 @@ gtk_search_engine_quartz_set_query (GtkSearchEngine *engine, g_object_unref (quartz->priv->query); quartz->priv->query = query; + location = gtk_query_get_location (query); + + if (location) + path = g_file_peek_path (location); /* We create a query to look for ".*text.*" in the text contents of * all indexed files. (Should we also search for text in file and folder * names?). */ + + if (path) + { + NSString *ns_path = [[NSString string] initWithUTF8String:path]; + [quartz->priv->ns_query setSearchScopes:@[ns_path]]; + } + else + { + [quartz->priv->ns_query setSearchScopes:@[NSMetadataQueryLocalComputerScope]]; + } + + [quartz->priv->ns_query setSearchItems:@[(NSString*)kMDItemTextContent, + (NSString*)kMDItemFSName]]; [quartz->priv->ns_query setPredicate: [NSPredicate predicateWithFormat: [NSString stringWithFormat:@"(kMDItemTextContent LIKE[cd] \"*%s*\")",