unity scope: scope is called and returns results.

This commit is contained in:
Jean-Francois Dockes 2013-11-07 15:04:49 +01:00
parent 8cde199b84
commit 51ce8736fc

View File

@ -86,7 +86,7 @@ def _get_thumbnail_path(url):
except Exception as msg: except Exception as msg:
print("_get_thumbnail_path: urllib.parse.quote failed: %s" % msg, print("_get_thumbnail_path: urllib.parse.quote failed: %s" % msg,
file=sys.stderr) file=sys.stderr)
return None return ""
#print("_get_thumbnail: encoded path: [%s]" % path, file=sys.stderr) #print("_get_thumbnail: encoded path: [%s]" % path, file=sys.stderr)
thumbname = hashlib.md5(path.encode('utf-8')).hexdigest() + ".png" thumbname = hashlib.md5(path.encode('utf-8')).hexdigest() + ".png"
@ -107,7 +107,7 @@ def _get_thumbnail_path(url):
if os.path.exists(tpath): if os.path.exists(tpath):
return tpath return tpath
return None return ""
class RecollScope(Unity.AbstractScope): class RecollScope(Unity.AbstractScope):
@ -236,8 +236,10 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
break break
titleorfilename = doc.title titleorfilename = doc.title
if titleorfilename == "": if titleorfilename is None or titleorfilename == "":
titleorfilename = doc.filename titleorfilename = doc.filename
if titleorfilename is None:
titleorfilename = "doc.title and doc.filename are none !"
# Results with an ipath get a special mime type so that they # Results with an ipath get a special mime type so that they
# get opened by starting a recoll instance. # get opened by starting a recoll instance.
@ -258,6 +260,11 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
else: else:
category = 1 category = 1
#print({"uri":url,"icon":iconname,"category":category,
#"mimetype":mimetype, "title":titleorfilename,
#"comment":abstract,
#"dnd_uri":doc.url})
result_set.add_result( result_set.add_result(
uri=url, uri=url,
icon=iconname, icon=iconname,
@ -307,7 +314,7 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
iconname = "text-x-preview" iconname = "text-x-preview"
# Results with an ipath get a special mime type so that they # Results with an ipath get a special mime type so that they
# get opened by starting a recoll instance. # get opened by starting a recoll instance.
thumbnail = None thumbnail = ""
if doc.ipath != "": if doc.ipath != "":
mimetype = "application/x-recoll" mimetype = "application/x-recoll"
url = doc.url + "#" + doc.ipath url = doc.url + "#" + doc.ipath
@ -318,7 +325,7 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
# Retrieve the binary path for thumbnail access. # Retrieve the binary path for thumbnail access.
thumbnail = _get_thumbnail_path(doc.getbinurl()) thumbnail = _get_thumbnail_path(doc.getbinurl())
iconname = None iconname = ""
if thumbnail: if thumbnail:
iconname = thumbnail iconname = thumbnail
else: else: