Unity Lens: better workaround for activate_uri

This commit is contained in:
Jean-Francois Dockes 2012-03-27 15:39:09 +02:00
parent ba65253f8d
commit aef5b80d6b

View File

@ -67,6 +67,7 @@ class Scope (Unity.Scope):
search = self.props.active_global_search
if search:
search.emit("finished")
def reset (self):
self._do_browse (self.props.results_model)
self._do_browse (self.props.global_results_model)
@ -86,7 +87,10 @@ class Scope (Unity.Scope):
search_string = search.props.search_string
results = search.props.results_model
#print "Search 5.0 changed to: '%s'" % search_string
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):
search = self.get_global_search_string()
@ -134,7 +138,7 @@ class Scope (Unity.Scope):
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 ()
if search_string == "":
@ -199,31 +203,39 @@ class Scope (Unity.Scope):
# https://bugs.launchpad.net/unity/+bug/893688
# Then, the default url activation takes place
# 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 recoll case, we just exit, the lens will be restarted.
# In the regular case, we return, and activation works exactly once for
# 2 calls...
# 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):
"""Activation handler for uri"""
print "Activate: %s" % uri
#print "Activate: %s" % uri
# Pass all uri without fragments to the desktop handler
if uri.find("#") == -1:
# Reset browsing state when an app is launched
if Unity._version == "4.0":
self.reset ()
return Unity.ActivationResponse.new(Unity.HandledType.NOT_HANDLED,
uri)
ret = Unity.ActivationResponse(handled=Unity.HandledType.NOT_HANDLED,
goto_uri=uri)
return ret
# Pass all others to recoll
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.global_results_model.clear();
sys.exit(0)
#return Unity.ActivationResponse.new(Unity.HandledType.HIDE_DASH,
# "baduri")
# Old workaround:
#sys.exit(0)
# New and better:
# 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