[kupfer] Add plugin paste.py as KSSG's idea
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] Add plugin paste.py as KSSG's idea
- Date: Sat, 19 Mar 2011 01:21:22 +0000 (UTC)
commit f27a636e680cb004b4fdf9ff3943cc369a0f3d4f
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Mar 19 02:20:47 2011 +0100
Add plugin paste.py as KSSG's idea
Launchpad-bug: https://bugs.launchpad.net/kupfer/+bug/621453
kupfer/plugin/paste.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/paste.py b/kupfer/plugin/paste.py
new file mode 100644
index 0000000..881fef5
--- /dev/null
+++ b/kupfer/plugin/paste.py
@@ -0,0 +1,40 @@
+
+__kupfer_name__ = _("Paste")
+__kupfer_actions__ = (
+ "CopyAndPaste",
+ )
+__description__ = _("Copy to clipboard and send Ctrl+V to foreground window")
+__version__ = ""
+__author__ = ""
+
+import gtk
+
+from kupfer.objects import Leaf, Action, Source, OperationError
+from kupfer import pretty
+from kupfer import utils
+from kupfer import interface
+
+
+class CopyAndPaste (Action):
+ # rank down since it applies everywhere
+ rank_adjust = -2
+ def __init__(self):
+ Action.__init__(self, _("Paste to Foreground Window"))
+ def activate(self, leaf):
+ clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
+ interface.copy_to_clipboard(leaf, clip)
+ xte_paste_argv = ['xte', 'usleep 300000', 'keydown Control_L',
+ 'key v', 'keyup Control_L']
+ if not utils.spawn_async(xte_paste_argv):
+ raise OperationError(_("Command '%s' not found!") % ("xte", ))
+ def item_types(self):
+ yield Leaf
+ def valid_for_item(self, leaf):
+ try:
+ return bool(interface.get_text_representation(leaf))
+ except AttributeError:
+ pass
+ def get_description(self):
+ return __description__
+ def get_icon_name(self):
+ return "edit-paste"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]