recoll scope checkpoint
This commit is contained in:
parent
dd1bb62b82
commit
97f85d934b
0
src/desktop/unity-scope-recoll/__init__.py
Normal file
0
src/desktop/unity-scope-recoll/__init__.py
Normal file
@ -6,7 +6,7 @@ ModuleType=python3
|
||||
Icon=/usr/share/icons/unity-icon-theme/places/svg/service-recoll.svg
|
||||
Keywords=recoll;doc;text;
|
||||
Loader=/usr/share/unity-scopes/recoll/unity_recoll_daemon
|
||||
RequiredMetadata=author[s];shared[b];starred[b];updated[i]
|
||||
RequiredMetadata=
|
||||
OptionalMetadata=
|
||||
RemoteContent=false
|
||||
Type=file
|
||||
|
||||
275
src/desktop/unity-scope-recoll/service-recoll.svg
Normal file
275
src/desktop/unity-scope-recoll/service-recoll.svg
Normal file
@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="744.09448819"
|
||||
height="1052.3622047"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.3.1 r9886"
|
||||
sodipodi:docname="New document 1">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="2.8"
|
||||
inkscape:cx="317.26408"
|
||||
inkscape:cy="545.1161"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="1148"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="30"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<g
|
||||
id="g3184"
|
||||
transform="translate(0,-0.75762939)">
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="272.99374"
|
||||
y="480.11078" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="272.99374"
|
||||
y="507.88995" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-7"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="272.99374"
|
||||
y="535.66913" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-4"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="272.99374"
|
||||
y="563.4483" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-76"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="272.99374"
|
||||
y="591.22754" />
|
||||
</g>
|
||||
<g
|
||||
id="g3212"
|
||||
transform="translate(-10.101563,0)">
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-4"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="398.25266"
|
||||
y="479.35315" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-9"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="398.25266"
|
||||
y="507.13232" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-7-2"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="398.25266"
|
||||
y="534.9115" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-4-7"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="398.25266"
|
||||
y="562.69067" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-76-1"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="398.25266"
|
||||
y="590.46991" />
|
||||
</g>
|
||||
<g
|
||||
id="g3198"
|
||||
transform="translate(-7.0710754,-1.5258789e-5)">
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-30"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="337.64349"
|
||||
y="479.35318" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-3"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="337.64349"
|
||||
y="507.13235" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-7-6"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="337.64349"
|
||||
y="534.9115" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-4-9"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="337.64349"
|
||||
y="562.69067" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-76-4"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="337.64349"
|
||||
y="590.46991" />
|
||||
</g>
|
||||
<g
|
||||
id="g3191"
|
||||
transform="translate(-0.50506592,-0.50506592)">
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-20"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="302.28815"
|
||||
y="479.85822" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-7-0"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="302.28815"
|
||||
y="507.63739" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#7676db;fill-opacity:1"
|
||||
id="rect3002-3-4-8"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="302.28815"
|
||||
y="535.41656" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-76-5"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="302.28815"
|
||||
y="563.19574" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-20-2"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="302.28815"
|
||||
y="590.97498" />
|
||||
</g>
|
||||
<g
|
||||
id="g3205"
|
||||
transform="translate(-8.5863037,-0.50508118)">
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-20-22"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="367.94806"
|
||||
y="479.85825" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-7-0-7"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="367.94806"
|
||||
y="507.63742" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-4-8-0"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="367.94806"
|
||||
y="535.41656" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#94d966;fill-opacity:1"
|
||||
id="rect3002-76-5-9"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="367.94806"
|
||||
y="563.19574" />
|
||||
<rect
|
||||
ry="0"
|
||||
style="fill:#e88233;fill-opacity:1"
|
||||
id="rect3002-3-20-2-6"
|
||||
width="28.789337"
|
||||
height="27.779184"
|
||||
x="367.94806"
|
||||
y="590.97498" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.9 KiB |
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
from distutils.core import setup
|
||||
from DistUtilsExtra.command import build_extra
|
||||
import subprocess
|
||||
#import build_i18n_ext as build_i18n
|
||||
|
||||
@ -13,8 +12,10 @@ setup(name="unity-scope-recoll",
|
||||
license="GNU General Public License v3 (GPLv3)",
|
||||
data_files=[
|
||||
('share/unity-scopes/recoll', ['unity_recoll_daemon.py']),
|
||||
('share/unity-scopes/recoll', ['__init__.py']),
|
||||
('share/applications', ['unity-scope-recoll.desktop']),
|
||||
('share/dbus-1/services', ['unity-scope-recoll.service']),
|
||||
('share/icons/hicolor/48x48/apps', ['unity-scope-recoll.png']),
|
||||
('share/unity/scopes/files', ['recoll.scope']),
|
||||
], cmdclass={"build": build_extra.build_extra,})
|
||||
('share/icons/unity-icon-theme/places/svg', ['service-recoll.svg']),
|
||||
])
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#! /usr/bin/python3
|
||||
# -*- mode: python; python-indent: 2 -*-
|
||||
#
|
||||
# Copyright 2012 Canonical Ltd. 2013 Jean-Francois Dockes
|
||||
#
|
||||
@ -33,13 +34,14 @@ if not hasrclconfig:
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
from recoll import recoll
|
||||
from recoll import rclextract
|
||||
hasextract = True
|
||||
except:
|
||||
import recoll
|
||||
hasextract = False
|
||||
#try:
|
||||
#from recoll import recoll
|
||||
from recoll import rclextract
|
||||
hasextract = True
|
||||
#except:
|
||||
# import recoll
|
||||
# hasextract = False
|
||||
print("Recoll scope: hasrclconfig %d hasextract %d\n" % (hasrclconfig, hasextract))
|
||||
|
||||
APP_NAME = "unity-scope-recoll"
|
||||
LOCAL_PATH = "/usr/share/locale/"
|
||||
@ -81,9 +83,9 @@ def _get_thumbnail_path(url):
|
||||
try:
|
||||
path = "file://" + urllib.quote(path)
|
||||
except:
|
||||
#print "_get_thumbnail_path: urllib.quote failed"
|
||||
#print("_get_thumbnail_path: urllib.quote failed")
|
||||
return None
|
||||
#print "_get_thumbnail: encoded path: [%s]" % (path,)
|
||||
#print("_get_thumbnail: encoded path: [%s]" % (path,))
|
||||
thumbname = hashlib.md5(path).hexdigest() + ".png"
|
||||
|
||||
# If the "new style" directory exists, we should stop looking in
|
||||
@ -95,11 +97,11 @@ def _get_thumbnail_path(url):
|
||||
THUMBDIRS = THUMBDIRS[0:1]
|
||||
|
||||
# Check in appropriate directories to see if the thumbnail file exists
|
||||
#print "_get_thumbnail: thumbname: [%s]" % (thumbname,)
|
||||
#print("_get_thumbnail: thumbname: [%s]" % (thumbname,))
|
||||
for topdir in THUMBDIRS:
|
||||
for dir in ("large", "normal"):
|
||||
tpath = os.path.join(topdir, dir, thumbname)
|
||||
# print "Testing [%s]" % (tpath,)
|
||||
# print("Testing [%s]" % (tpath,))
|
||||
if os.path.exists(tpath):
|
||||
return tpath
|
||||
|
||||
@ -114,33 +116,20 @@ class RecollScope(Unity.AbstractScope):
|
||||
self.search_in_global = True;
|
||||
|
||||
lng, self.localecharset = locale.getdefaultlocale()
|
||||
if hasrclconfig:
|
||||
self.config = rclconfig.RclConfig()
|
||||
self.last_connect_time = 0
|
||||
|
||||
def _connect_db(self):
|
||||
#print "Connecting to db"
|
||||
self.db = None
|
||||
dblist = []
|
||||
if hasrclconfig:
|
||||
extradbs = rclconfig.RclExtraDbs(self.config)
|
||||
dblist = extradbs.getActDbs()
|
||||
try:
|
||||
self.db = recoll.connect(extra_dbs=dblist)
|
||||
self.db.setAbstractParams(maxchars=200, contextwords=4)
|
||||
except Exception, s:
|
||||
print >> sys.stderr, "recoll-lens: Error connecting to db:", s
|
||||
return
|
||||
print("RecollScope: __init__ done", file=sys.stderr)
|
||||
|
||||
def do_get_group_name(self):
|
||||
# The primary bus name we grab *must* match what we specify in our
|
||||
# .scope file
|
||||
print("RecollScope: do_get_group_name", file=sys.stderr)
|
||||
return "org.recoll.Unity.Scope.File.Recoll"
|
||||
|
||||
def do_get_unique_name(self):
|
||||
print("RecollScope: do_get_unique_name", file=sys.stderr)
|
||||
return "/org/recoll/unity/scope/file/recoll"
|
||||
|
||||
def do_get_filters(self):
|
||||
print("RecollScope: do_get_filters", file=sys.stderr)
|
||||
filters = Unity.FilterSet.new()
|
||||
f = Unity.RadioOptionFilter.new ("modified", _("Last modified"), Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
|
||||
f.add_option ("last-7-days", _("Last 7 days"), None)
|
||||
@ -158,6 +147,7 @@ class RecollScope(Unity.AbstractScope):
|
||||
return filters
|
||||
|
||||
def do_get_categories(self):
|
||||
print("RecollScope: do_get_categories", file=sys.stderr)
|
||||
cats = Unity.CategorySet.new()
|
||||
cats.add (Unity.Category.new ('global',
|
||||
_("Files & Folders"),
|
||||
@ -177,19 +167,45 @@ class RecollScope(Unity.AbstractScope):
|
||||
Unity.CategoryRenderer.VERTICAL_TILE))
|
||||
return cats
|
||||
|
||||
def do_get_schema (self):
|
||||
'''
|
||||
Adds specific metadata fields
|
||||
'''
|
||||
print("RecollScope: do_get_schema", file=sys.stderr)
|
||||
schema = Unity.Schema.new ()
|
||||
return schema
|
||||
|
||||
def do_create_search_for_query(self, search_context):
|
||||
return RecollScopeSearch(search_context, self.db)
|
||||
print("RecollScope: do_create_search_for query", file=sys.stderr)
|
||||
return RecollScopeSearch(search_context)
|
||||
|
||||
|
||||
class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
__g_type_name__ = "RecollScopeSearch"
|
||||
|
||||
def __init__(self, search_context, db):
|
||||
def __init__(self, search_context):
|
||||
super(RecollScopeSearch, self).__init__()
|
||||
self.set_search_context(search_context)
|
||||
self._gdocs_accounts = accounts
|
||||
if hasrclconfig:
|
||||
self.config = rclconfig.RclConfig()
|
||||
print("RecollScopeSearch: __init__ done", file=sys.stderr)
|
||||
|
||||
def connect_db(self):
|
||||
print("RecollScopeSearch: Connecting to db", file=sys.stderr)
|
||||
self.db = None
|
||||
dblist = []
|
||||
if hasrclconfig:
|
||||
extradbs = rclconfig.RclExtraDbs(self.config)
|
||||
dblist = extradbs.getActDbs()
|
||||
try:
|
||||
self.db = recoll.connect(extra_dbs=dblist)
|
||||
self.db.setAbstractParams(maxchars=200, contextwords=4)
|
||||
except Exception as s:
|
||||
print("RecollScope: Error connecting to db: %s" % s, file=sys.stderr)
|
||||
return
|
||||
|
||||
def do_run(self):
|
||||
print("RecollScopeSearch: do_run", file=sys.stderr)
|
||||
context = self.search_context
|
||||
filters = context.filter_state
|
||||
search_string = context.search_query
|
||||
@ -198,10 +214,7 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
|
||||
# Get the list of documents
|
||||
is_global = context.search_type == Unity.SearchType.GLOBAL
|
||||
current_time = time.time()
|
||||
if current_time - self.last_connect_time > 10:
|
||||
self._connect_db()
|
||||
self.last_connect_time = current_time
|
||||
self.connect_db()
|
||||
|
||||
# We do not want filters to effect global results
|
||||
catgf = ""
|
||||
@ -215,8 +228,8 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
try:
|
||||
query = self.db.query()
|
||||
nres = query.execute(search_string.decode(self.localecharset))
|
||||
except:
|
||||
print("recoll query execute error")
|
||||
except Exception as msg:
|
||||
print("recoll query execute error: %s" % msg)
|
||||
return
|
||||
|
||||
actual_results = 0
|
||||
@ -231,7 +244,7 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
|
||||
# Results with an ipath get a special mime type so that they
|
||||
# get opened by starting a recoll instance.
|
||||
mimetype, iconname = self.icon_for_type (doc):
|
||||
mimetype, iconname = self.icon_for_type (doc)
|
||||
|
||||
try:
|
||||
abstract = self.db.makeDocAbstract(doc, query).encode('utf-8')
|
||||
@ -243,7 +256,7 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
category = 0
|
||||
else:
|
||||
if doc.mimetype == "inode/directory" or \
|
||||
doc.mimetype = "application/x-fsdirectory":
|
||||
"application/x-fsdirectory":
|
||||
category = 3
|
||||
else:
|
||||
category = 1
|
||||
@ -264,11 +277,11 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
|
||||
|
||||
def date_filter (self, filters):
|
||||
dateopt = ""
|
||||
f = filters.get_filter_by_id("modified")
|
||||
if f != None:
|
||||
o = f.get_active_option()
|
||||
if o != None:
|
||||
dateopt = ""
|
||||
if o.props.id == "last-year":
|
||||
dateopt="P365D/"
|
||||
elif o.props.id == "last-30-days":
|
||||
@ -327,3 +340,4 @@ class RecollScopeSearch(Unity.ScopeSearchBase):
|
||||
|
||||
def load_scope():
|
||||
return RecollScope()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user