|
a/src/desktop/unity-scope-recoll/unity_recoll_daemon.py |
|
b/src/desktop/unity-scope-recoll/unity_recoll_daemon.py |
|
... |
|
... |
84 |
try:
|
84 |
try:
|
85 |
path = "file://" + urllib.parse.quote_from_bytes(path)
|
85 |
path = "file://" + urllib.parse.quote_from_bytes(path)
|
86 |
except Exception as msg:
|
86 |
except Exception as msg:
|
87 |
print("_get_thumbnail_path: urllib.parse.quote failed: %s" % msg,
|
87 |
print("_get_thumbnail_path: urllib.parse.quote failed: %s" % msg,
|
88 |
file=sys.stderr)
|
88 |
file=sys.stderr)
|
89 |
return None
|
89 |
return ""
|
90 |
#print("_get_thumbnail: encoded path: [%s]" % path, file=sys.stderr)
|
90 |
#print("_get_thumbnail: encoded path: [%s]" % path, file=sys.stderr)
|
91 |
thumbname = hashlib.md5(path.encode('utf-8')).hexdigest() + ".png"
|
91 |
thumbname = hashlib.md5(path.encode('utf-8')).hexdigest() + ".png"
|
92 |
|
92 |
|
93 |
# If the "new style" directory exists, we should stop looking in
|
93 |
# If the "new style" directory exists, we should stop looking in
|
94 |
# the "old style" one (there might be interesting files in there,
|
94 |
# the "old style" one (there might be interesting files in there,
|
|
... |
|
... |
105 |
tpath = os.path.join(topdir, dir, thumbname)
|
105 |
tpath = os.path.join(topdir, dir, thumbname)
|
106 |
#print("Testing [%s]" % (tpath,))
|
106 |
#print("Testing [%s]" % (tpath,))
|
107 |
if os.path.exists(tpath):
|
107 |
if os.path.exists(tpath):
|
108 |
return tpath
|
108 |
return tpath
|
109 |
|
109 |
|
110 |
return None
|
110 |
return ""
|
111 |
|
111 |
|
112 |
|
112 |
|
113 |
class RecollScope(Unity.AbstractScope):
|
113 |
class RecollScope(Unity.AbstractScope):
|
114 |
__g_type_name__ = "RecollScope"
|
114 |
__g_type_name__ = "RecollScope"
|
115 |
|
115 |
|
|
... |
|
... |
234 |
doc = query.fetchone()
|
234 |
doc = query.fetchone()
|
235 |
except:
|
235 |
except:
|
236 |
break
|
236 |
break
|
237 |
|
237 |
|
238 |
titleorfilename = doc.title
|
238 |
titleorfilename = doc.title
|
239 |
if titleorfilename == "":
|
239 |
if titleorfilename is None or titleorfilename == "":
|
240 |
titleorfilename = doc.filename
|
240 |
titleorfilename = doc.filename
|
|
|
241 |
if titleorfilename is None:
|
|
|
242 |
titleorfilename = "doc.title and doc.filename are none !"
|
241 |
|
243 |
|
242 |
# Results with an ipath get a special mime type so that they
|
244 |
# Results with an ipath get a special mime type so that they
|
243 |
# get opened by starting a recoll instance.
|
245 |
# get opened by starting a recoll instance.
|
244 |
url, mimetype, iconname = self.icon_for_type (doc)
|
246 |
url, mimetype, iconname = self.icon_for_type (doc)
|
245 |
|
247 |
|
|
... |
|
... |
255 |
if doc.mimetype == "inode/directory" or \
|
257 |
if doc.mimetype == "inode/directory" or \
|
256 |
"application/x-fsdirectory":
|
258 |
"application/x-fsdirectory":
|
257 |
category = 3
|
259 |
category = 3
|
258 |
else:
|
260 |
else:
|
259 |
category = 1
|
261 |
category = 1
|
|
|
262 |
|
|
|
263 |
#print({"uri":url,"icon":iconname,"category":category,
|
|
|
264 |
#"mimetype":mimetype, "title":titleorfilename,
|
|
|
265 |
#"comment":abstract,
|
|
|
266 |
#"dnd_uri":doc.url})
|
260 |
|
267 |
|
261 |
result_set.add_result(
|
268 |
result_set.add_result(
|
262 |
uri=url,
|
269 |
uri=url,
|
263 |
icon=iconname,
|
270 |
icon=iconname,
|
264 |
category=category,
|
271 |
category=category,
|
|
... |
|
... |
305 |
# Send back a useful icon depending on the document type
|
312 |
# Send back a useful icon depending on the document type
|
306 |
def icon_for_type (self, doc):
|
313 |
def icon_for_type (self, doc):
|
307 |
iconname = "text-x-preview"
|
314 |
iconname = "text-x-preview"
|
308 |
# Results with an ipath get a special mime type so that they
|
315 |
# Results with an ipath get a special mime type so that they
|
309 |
# get opened by starting a recoll instance.
|
316 |
# get opened by starting a recoll instance.
|
310 |
thumbnail = None
|
317 |
thumbnail = ""
|
311 |
if doc.ipath != "":
|
318 |
if doc.ipath != "":
|
312 |
mimetype = "application/x-recoll"
|
319 |
mimetype = "application/x-recoll"
|
313 |
url = doc.url + "#" + doc.ipath
|
320 |
url = doc.url + "#" + doc.ipath
|
314 |
else:
|
321 |
else:
|
315 |
mimetype = doc.mimetype
|
322 |
mimetype = doc.mimetype
|
316 |
url = doc.url
|
323 |
url = doc.url
|
317 |
# doc.url is a unicode string which is badly wrong.
|
324 |
# doc.url is a unicode string which is badly wrong.
|
318 |
# Retrieve the binary path for thumbnail access.
|
325 |
# Retrieve the binary path for thumbnail access.
|
319 |
thumbnail = _get_thumbnail_path(doc.getbinurl())
|
326 |
thumbnail = _get_thumbnail_path(doc.getbinurl())
|
320 |
|
327 |
|
321 |
iconname = None
|
328 |
iconname = ""
|
322 |
if thumbnail:
|
329 |
if thumbnail:
|
323 |
iconname = thumbnail
|
330 |
iconname = thumbnail
|
324 |
else:
|
331 |
else:
|
325 |
if doc.mimetype in SPEC_MIME_ICONS:
|
332 |
if doc.mimetype in SPEC_MIME_ICONS:
|
326 |
iconname = SPEC_MIME_ICONS[doc.mimetype]
|
333 |
iconname = SPEC_MIME_ICONS[doc.mimetype]
|