[kupfer] plugin.nautilusselection: Nautilus Current Selection
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.nautilusselection: Nautilus Current Selection
- Date: Sat, 29 Aug 2009 19:42:25 +0000 (UTC)
commit f70c47418a51a51dfd38511d9e7315124845b6fa
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Aug 29 20:18:15 2009 +0200
plugin.nautilusselection: Nautilus Current Selection
A plugin for the Current Selection in Nautilus!! This uses the kupfer
nautilus extension that has to be installed.
kupfer/plugin/nautilusselection.py | 57 ++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/nautilusselection.py b/kupfer/plugin/nautilusselection.py
new file mode 100644
index 0000000..de90875
--- /dev/null
+++ b/kupfer/plugin/nautilusselection.py
@@ -0,0 +1,57 @@
+import os
+
+import dbus
+
+from kupfer.objects import Source, Leaf, FileLeaf, SourceLeaf, PicklingHelperMixin
+from kupfer import objects
+
+__kupfer_name__ = _("Selected File")
+__kupfer_sources__ = ("SelectionSource", )
+__description__ = _("Provides current nautilus selection, using Kupfer's Nautilus Extension")
+__version__ = ""
+__author__ = "Ulrik Sverdrup <ulrik sverdrup gmail com>"
+
+class SelectedFile (FileLeaf):
+ def __init__(self, filepath):
+ """@filepath is unicode and can be safely used"""
+ basename = os.path.basename(filepath)
+ FileLeaf.__init__(self, filepath, _('Selected File "%s"') % basename)
+
+ def rank_key(self):
+ # return a constant rank key despite the changing name
+ return _("Selected File")
+
+class InvisibleSourceLeaf (SourceLeaf):
+ """Hack to hide this source"""
+ def is_valid(self):
+ return False
+
+class SelectionSource (Source, PicklingHelperMixin):
+ def __init__(self):
+ Source.__init__(self, _("Selected File"))
+ self.unpickle_finish()
+
+ def unpickle_finish(self):
+ session_bus = dbus.Bus()
+ session_bus.add_signal_receiver(self._selected_signal,
+ dbus_interface="se.kaizer.KupferNautilusPlugin")
+ self._selection = []
+
+ def _selected_signal(self, selection):
+ self._selection = selection
+ self.mark_for_update()
+
+ def _clipboard_owner_changed(self, clipboard, event):
+ self._text = clipboard.wait_for_text()
+ self.mark_for_update()
+
+ def get_items(self):
+ if len(self._selection) == 1:
+ yield SelectedFile(self._selection[0])
+
+ def get_description(self):
+ return None
+ def provides(self):
+ yield FileLeaf
+ def get_leaf_repr(self):
+ return InvisibleSourceLeaf(self)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]