|
a/src/desktop/unity-scope-recoll/unity_recoll_daemon.py |
|
b/src/desktop/unity-scope-recoll/unity_recoll_daemon.py |
|
... |
|
... |
52 |
gettext.textdomain(APP_NAME)
|
52 |
gettext.textdomain(APP_NAME)
|
53 |
_ = gettext.gettext
|
53 |
_ = gettext.gettext
|
54 |
|
54 |
|
55 |
THEME = "/usr/share/icons/unity-icon-theme/places/svg/"
|
55 |
THEME = "/usr/share/icons/unity-icon-theme/places/svg/"
|
56 |
|
56 |
|
|
|
57 |
UNITY_TYPE_TO_RECOLL_CLAUSE = {
|
|
|
58 |
"documents" : "rclcat:message rclcat:spreadsheet rclcat:text",
|
|
|
59 |
"folders" : "mime:inode/directory",
|
|
|
60 |
"images" : "rclcat:media",
|
|
|
61 |
"audio":"rclcat:media",
|
|
|
62 |
"videos":"rclcat:media",
|
|
|
63 |
"presentations" : "rclcat:presentation",
|
|
|
64 |
"other":"rclcat:other"
|
|
|
65 |
}
|
57 |
|
66 |
|
58 |
# Icon names for some recoll mime types which don't have standard icon by the
|
67 |
# Icon names for some recoll mime types which don't have standard icon by the
|
59 |
# normal method
|
68 |
# normal method
|
60 |
SPEC_MIME_ICONS = {'application/x-fsdirectory' : 'gnome-fs-directory.svg',
|
69 |
SPEC_MIME_ICONS = {'application/x-fsdirectory' : 'gnome-fs-directory.svg',
|
61 |
'inode/directory' : 'gnome-fs-directory.svg',
|
70 |
'inode/directory' : 'gnome-fs-directory.svg',
|
|
... |
|
... |
214 |
catgf = ""
|
223 |
catgf = ""
|
215 |
datef = ""
|
224 |
datef = ""
|
216 |
if not is_global:
|
225 |
if not is_global:
|
217 |
catgf = self.catg_filter(filters)
|
226 |
catgf = self.catg_filter(filters)
|
218 |
datef = self.date_filter(filters)
|
227 |
datef = self.date_filter(filters)
|
|
|
228 |
sizef = self.size_filter(filters)
|
219 |
" ".join((search_string, catgf, datef))
|
229 |
search_string = " ".join((search_string, catgf, datef, sizef))
|
220 |
|
230 |
|
221 |
print("RecollScopeSearch::do_run: Search: [%s]" % search_string)
|
231 |
print("RecollScopeSearch::do_run: Search: [%s]" % search_string)
|
222 |
|
232 |
|
223 |
# Do the recoll thing
|
233 |
# Do the recoll thing
|
224 |
try:
|
234 |
try:
|
225 |
query = self.db.query()
|
235 |
query = self.db.query()
|
|
... |
|
... |
279 |
if actual_results >= MAX_RESULTS:
|
289 |
if actual_results >= MAX_RESULTS:
|
280 |
break
|
290 |
break
|
281 |
|
291 |
|
282 |
|
292 |
|
283 |
def date_filter (self, filters):
|
293 |
def date_filter (self, filters):
|
284 |
print("RecollScopeSearch: date_filter")
|
294 |
#print("RecollScopeSearch: date_filter")
|
285 |
dateopt = ""
|
295 |
dateopt = ""
|
286 |
f = filters.get_filter_by_id("modified")
|
296 |
f = filters.get_filter_by_id("modified")
|
287 |
if f != None:
|
297 |
if f != None:
|
288 |
o = f.get_active_option()
|
298 |
o = f.get_active_option()
|
289 |
if o != None:
|
299 |
if o != None:
|
290 |
if o.props.id == "last-year":
|
300 |
if o.props.id == "last-year":
|
291 |
dateopt="P365D/"
|
301 |
dateopt="date:P1Y/"
|
292 |
elif o.props.id == "last-30-days":
|
302 |
elif o.props.id == "last-30-days":
|
293 |
dateopt = "P30D/"
|
303 |
dateopt = "date:P1M/"
|
294 |
elif o.props.id == "last-7-days":
|
304 |
elif o.props.id == "last-7-days":
|
295 |
dateopt = "P7D/"
|
305 |
dateopt = "date:P7D/"
|
296 |
print("RecollScopeSearch: date_filter: return %s", dateopt)
|
306 |
#print("RecollScopeSearch: date_filter: return [%s]" % dateopt)
|
|
|
307 |
# Until we fix the recoll bug:
|
297 |
return dateopt
|
308 |
# return dateopt
|
|
|
309 |
return ""
|
298 |
|
310 |
|
299 |
def catg_filter(self, filters):
|
311 |
def catg_filter(self, filters):
|
300 |
f = filters.get_filter_by_id("type")
|
312 |
f = filters.get_filter_by_id("type")
|
301 |
if not f: return ""
|
313 |
if not f: return ""
|
302 |
if not f.props.filtering:
|
314 |
if not f.props.filtering:
|
303 |
return ""
|
315 |
return ""
|
304 |
ss = ""
|
316 |
ss = ""
|
305 |
# ("media", "message", "presentation", "spreadsheet", "text", "other")
|
|
|
306 |
for ftype in f.options:
|
317 |
for fopt in f.options:
|
|
|
318 |
print(fopt.props.id, file=sys.stderr)
|
307 |
if f.get_option(ftype).props.active:
|
319 |
if fopt.props.active:
|
308 |
ss += " rclcat:" + option.props.id
|
320 |
if fopt.props.id in UNITY_TYPE_TO_RECOLL_CLAUSE:
|
|
|
321 |
ss += " " + UNITY_TYPE_TO_RECOLL_CLAUSE[fopt.props.id]
|
|
|
322 |
print("RecollScopSearch: catg_filter: [%s]" % ss)
|
|
|
323 |
return ss
|
309 |
|
324 |
|
|
|
325 |
def size_filter(self, filters):
|
|
|
326 |
print("size_filter", file=sys.stderr)
|
|
|
327 |
f = filters.get_filter_by_id("size")
|
|
|
328 |
if not f: return ""
|
|
|
329 |
print("size_filter got f", file=sys.stderr)
|
|
|
330 |
if not f.props.filtering:
|
|
|
331 |
return ""
|
|
|
332 |
print("size_filter f filtering", file=sys.stderr)
|
|
|
333 |
ss = ""
|
|
|
334 |
for fopt in f.options:
|
|
|
335 |
print(fopt.props.id, file=sys.stderr)
|
|
|
336 |
|
|
|
337 |
print("RecollScopeSearch: size_filter: [%s]" % ss)
|
310 |
return ss
|
338 |
return ss
|
311 |
|
339 |
|
312 |
# Send back a useful icon depending on the document type
|
340 |
# Send back a useful icon depending on the document type
|
313 |
def icon_for_type (self, doc):
|
341 |
def icon_for_type (self, doc):
|
314 |
iconname = "text-x-preview"
|
342 |
iconname = "text-x-preview"
|