unity-lens-recoll with category filtering usable
This commit is contained in:
parent
c15a32d26f
commit
7e442fdde1
@ -62,12 +62,12 @@ def create_lens ():
|
||||
|
||||
|
||||
# Populate filters
|
||||
lens.props.filters = []
|
||||
filters = []
|
||||
|
||||
# We should get the categories from the config but the python
|
||||
# module currently has no code for this.
|
||||
# module currently has no code for this. CheckOption or RadioOption?
|
||||
filter = Unity.RadioOptionFilter.new("rclcat", "Category",
|
||||
Gio.ThemedIcon.new(""), False)
|
||||
Gio.ThemedIcon.new("input-keyboard-symbolic"), False)
|
||||
|
||||
filter.add_option("text", "Text", None);
|
||||
filter.add_option("spreadsheet", "Spreadsheet", None);
|
||||
@ -76,7 +76,9 @@ def create_lens ():
|
||||
filter.add_option("message", "Message", None);
|
||||
filter.add_option("other", "Other", None);
|
||||
|
||||
lens.props.filters.append(filter)
|
||||
filters.append(filter)
|
||||
|
||||
lens.props.filters = filters
|
||||
return lens
|
||||
|
||||
lens = create_lens ()
|
||||
|
||||
@ -22,8 +22,9 @@ class Scope (Unity.Scope):
|
||||
Unity.Scope.__init__ (self, dbus_path="/org/recoll/unitylensrecoll/scope/main")
|
||||
|
||||
# Listen for changes and requests
|
||||
self.connect ("notify::active-search", self._on_search_changed)
|
||||
self.connect ("notify::active-global-search", self._on_global_search_changed)
|
||||
self.connect("notify::active-search", self._on_search_changed)
|
||||
self.connect("notify::active-global-search", self._on_global_search_changed)
|
||||
self.connect("filters-changed", self._on_search_changed);
|
||||
|
||||
# Bliss loaded the apps_tree menu here, let's connect to
|
||||
# the index
|
||||
@ -55,7 +56,7 @@ class Scope (Unity.Scope):
|
||||
self._do_browse (self.props.results_model)
|
||||
self._do_browse (self.props.global_results_model)
|
||||
|
||||
def _on_search_changed (self, scope, param_spec):
|
||||
def _on_search_changed (self, scope, param_spec=None):
|
||||
search = self.get_search_string()
|
||||
results = scope.props.results_model
|
||||
|
||||
@ -115,6 +116,11 @@ class Scope (Unity.Scope):
|
||||
if search_string == "":
|
||||
return True
|
||||
|
||||
fcat = self.get_filter("rclcat")
|
||||
for option in fcat.options:
|
||||
if option.props.active:
|
||||
search_string += " rclcat:" + option.props.id
|
||||
|
||||
# Do the recoll thing
|
||||
query = self.db.query()
|
||||
try:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user