Unity Lens: better workaround for activate_uri
This commit is contained in:
parent
ba65253f8d
commit
aef5b80d6b
@ -67,32 +67,36 @@ class Scope (Unity.Scope):
|
|||||||
search = self.props.active_global_search
|
search = self.props.active_global_search
|
||||||
if search:
|
if search:
|
||||||
search.emit("finished")
|
search.emit("finished")
|
||||||
|
|
||||||
def reset (self):
|
def reset (self):
|
||||||
self._do_browse (self.props.results_model)
|
self._do_browse (self.props.results_model)
|
||||||
self._do_browse (self.props.global_results_model)
|
self._do_browse (self.props.global_results_model)
|
||||||
|
|
||||||
def _on_filters_changed (self, scope):
|
def _on_filters_changed (self, scope):
|
||||||
# print "_on_filters_changed()"
|
#print "_on_filters_changed()"
|
||||||
self.queue_search_changed(Unity.SearchType.DEFAULT)
|
self.queue_search_changed(Unity.SearchType.DEFAULT)
|
||||||
|
|
||||||
if Unity._version == "4.0":
|
if Unity._version == "4.0":
|
||||||
def _on_search_changed (self, scope, param_spec=None):
|
def _on_search_changed (self, scope, param_spec=None):
|
||||||
search_string = self.get_search_string()
|
search_string = self.get_search_string()
|
||||||
results = scope.props.results_model
|
results = scope.props.results_model
|
||||||
# print "Search 4.0 changed to: '%s'" % search_string
|
#print "Search 4.0 changed to: '%s'" % search_string
|
||||||
self._update_results_model (search_string, results)
|
self._update_results_model (search_string, results)
|
||||||
else:
|
else:
|
||||||
def _on_search_changed (self, scope, search, search_type, cancellable):
|
def _on_search_changed (self, scope, search, search_type, cancellable):
|
||||||
search_string = search.props.search_string
|
search_string = search.props.search_string
|
||||||
results = search.props.results_model
|
results = search.props.results_model
|
||||||
# print "Search 5.0 changed to: '%s'" % search_string
|
#print "Search 5.0 changed to: '%s'" % search_string
|
||||||
self._update_results_model (search_string, results)
|
if search_string:
|
||||||
|
self._update_results_model (search_string, results)
|
||||||
|
else:
|
||||||
|
search.props.results_model.clear()
|
||||||
|
|
||||||
def _on_global_search_changed (self, scope, param_spec):
|
def _on_global_search_changed (self, scope, param_spec):
|
||||||
search = self.get_global_search_string()
|
search = self.get_global_search_string()
|
||||||
results = scope.props.global_results_model
|
results = scope.props.global_results_model
|
||||||
|
|
||||||
# print "Global search changed to: '%s'" % search
|
#print "Global search changed to: '%s'" % search
|
||||||
|
|
||||||
self._update_results_model (search, results)
|
self._update_results_model (search, results)
|
||||||
|
|
||||||
@ -134,7 +138,7 @@ class Scope (Unity.Scope):
|
|||||||
search_string, model)
|
search_string, model)
|
||||||
|
|
||||||
def _really_do_search(self, search_string, model):
|
def _really_do_search(self, search_string, model):
|
||||||
# print "really_do_search:[", search_string, "]"
|
#print "really_do_search:", "[" + search_string + "]"
|
||||||
|
|
||||||
model.clear ()
|
model.clear ()
|
||||||
if search_string == "":
|
if search_string == "":
|
||||||
@ -168,7 +172,7 @@ class Scope (Unity.Scope):
|
|||||||
mimetype = doc.mimetype
|
mimetype = doc.mimetype
|
||||||
url = doc.url
|
url = doc.url
|
||||||
|
|
||||||
# print "Recoll Lens: Using MIMETYPE", mimetype, " URL", url
|
#print "Recoll Lens: Using MIMETYPE", mimetype, " URL", url
|
||||||
|
|
||||||
titleorfilename = doc.title
|
titleorfilename = doc.title
|
||||||
if titleorfilename == "":
|
if titleorfilename == "":
|
||||||
@ -199,31 +203,39 @@ class Scope (Unity.Scope):
|
|||||||
# https://bugs.launchpad.net/unity/+bug/893688
|
# https://bugs.launchpad.net/unity/+bug/893688
|
||||||
# Then, the default url activation takes place
|
# Then, the default url activation takes place
|
||||||
# which is not at all what we want.
|
# which is not at all what we want.
|
||||||
# So, in the recoll case, we just exit, the lens will be restarted.
|
# First workaround:
|
||||||
# In the regular case, we return, and activation works exactly once for
|
# In the recoll case, we just exit, the lens will be restarted.
|
||||||
# 2 calls...
|
# In the regular case, we return, and activation works exactly once for
|
||||||
|
# 2 calls on oneiric and mostly for precise...
|
||||||
|
# New workaround, suggested somewhere on the net and kept: other
|
||||||
|
# construction method
|
||||||
def activate_uri (self, scope, uri):
|
def activate_uri (self, scope, uri):
|
||||||
"""Activation handler for uri"""
|
"""Activation handler for uri"""
|
||||||
|
|
||||||
print "Activate: %s" % uri
|
#print "Activate: %s" % uri
|
||||||
|
|
||||||
# Pass all uri without fragments to the desktop handler
|
# Pass all uri without fragments to the desktop handler
|
||||||
if uri.find("#") == -1:
|
if uri.find("#") == -1:
|
||||||
# Reset browsing state when an app is launched
|
# Reset browsing state when an app is launched
|
||||||
if Unity._version == "4.0":
|
if Unity._version == "4.0":
|
||||||
self.reset ()
|
self.reset ()
|
||||||
return Unity.ActivationResponse.new(Unity.HandledType.NOT_HANDLED,
|
ret = Unity.ActivationResponse(handled=Unity.HandledType.NOT_HANDLED,
|
||||||
uri)
|
goto_uri=uri)
|
||||||
|
return ret
|
||||||
|
|
||||||
# Pass all others to recoll
|
# Pass all others to recoll
|
||||||
proc = subprocess.Popen(["recoll", uri])
|
proc = subprocess.Popen(["recoll", uri])
|
||||||
print "Subprocess returned, going back to unity"
|
#print "Subprocess returned, going back to unity"
|
||||||
|
|
||||||
scope.props.results_model.clear();
|
scope.props.results_model.clear();
|
||||||
scope.props.global_results_model.clear();
|
scope.props.global_results_model.clear();
|
||||||
sys.exit(0)
|
# Old workaround:
|
||||||
|
#sys.exit(0)
|
||||||
|
|
||||||
#return Unity.ActivationResponse.new(Unity.HandledType.HIDE_DASH,
|
# New and better:
|
||||||
# "baduri")
|
# The goto_uri thing is a workaround suggested somewhere instead of
|
||||||
|
# passing the string. Does fix the issue
|
||||||
|
#return Unity.ActivationResponse.new(Unity.HandledType.HIDE_DASH,''
|
||||||
|
ret = Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH,
|
||||||
|
goto_uri='')
|
||||||
|
return ret
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user