[kupfer] clipboard: optionally gather selection



commit b61704d76195095dc7197817ce74fa29379933cb
Author: Karol BÄ?dkowski <karol bedkowski gmail com>
Date:   Fri Feb 26 18:51:00 2010 +0100

    clipboard: optionally gather selection
    
    Add selection to the clipboards
    Add configuration option to include selections (default False)

 kupfer/plugin/clipboard.py |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/clipboard.py b/kupfer/plugin/clipboard.py
index 9bebd7c..f8057dd 100644
--- a/kupfer/plugin/clipboard.py
+++ b/kupfer/plugin/clipboard.py
@@ -8,8 +8,8 @@ from collections import deque
 
 import gtk
 
-from kupfer.objects import Source, Action, TextLeaf, Leaf
-from kupfer import utils, plugin_support
+from kupfer.objects import Source, TextLeaf
+from kupfer import plugin_support
 from kupfer.weaklib import gobject_connect_weakly
 
 
@@ -20,6 +20,12 @@ __kupfer_settings__ = plugin_support.PluginSettings(
 		"type": int,
 		"value": 10,
 	},
+	{
+		"key" : "use_selection",
+		"label": _("Include recent selections"),
+		"type": bool,
+		"value": False,
+	},
 )
 
 class ClipboardText (TextLeaf):
@@ -40,8 +46,14 @@ class ClipboardSource (Source):
 	def initialize(self):
 		clip = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
 		gobject_connect_weakly(clip, "owner-change", self._clipboard_changed)
+		clip = gtk.clipboard_get(gtk.gdk.SELECTION_PRIMARY)
+		gobject_connect_weakly(clip, "owner-change", self._clipboard_changed)
+
+	def _clipboard_changed(self, clip, event, *args):
+		is_selection = (event.selection == gtk.gdk.SELECTION_PRIMARY)
+		if is_selection and not __kupfer_settings__["use_selection"]:
+			return
 
-	def _clipboard_changed(self, clip, *args):
 		max_len = __kupfer_settings__["max"]
 		newtext = clip.wait_for_text()
 		if not (newtext and newtext.strip()):



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