[kupfer] data: Add DataController.find_object(url)



commit a76c6ab6c2fbaeccfa437e69dbe1e6e459037f18
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Sep 10 02:41:05 2009 +0200

    data: Add DataController.find_object(url)
    
    find_object(..) will find the given qfurl in the catalog, if possible,
    and select it in the source pane.

 kupfer/data.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index 9a47160..b177f9d 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -14,6 +14,8 @@ from . import objects
 from . import search, learn
 from . import config, pretty, scheduler, task
 
+from kupfer import qfurl
+
 # "Enums"
 # Which pane
 SourcePane, ActionPane, ObjectPane = (1,2,3)
@@ -1001,6 +1003,14 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 			self._task_runner.add_task(ret)
 		self.emit("launched-action", SourceActionMode, leaf, action)
 
+	def find_object(self, url):
+		"""Find object with URI @url and select it in the first pane"""
+		sc = GetSourceController()
+		qf = qfurl.qfurl(url=url)
+		found = qf.resolve_in_catalog(sc.sources)
+		if found:
+			self.emit("pane-reset", SourcePane, search.wrap_rankable(found))
+
 # pane cleared or set with new item
 # pane, item
 gobject.signal_new("pane-reset", DataController, gobject.SIGNAL_RUN_LAST,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]