aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkristoffer.lunden <kristoffer.lunden@dd23f896-6e2b-0410-bc3e-d184d5eb269a>2010-10-01 14:30:44 (GMT)
committerkristoffer.lunden <kristoffer.lunden@dd23f896-6e2b-0410-bc3e-d184d5eb269a>2010-10-01 14:30:44 (GMT)
commit4db806f75c0fb5e19d389465962b2ebcf96546fc (patch)
tree1d835f29253a6f283a8903f2a79024dd8370c778
parent96505d4c1e3d5614ae77398f7cec34858246b9d9 (diff)
downloadgedit-autotab-4db806f75c0fb5e19d389465962b2ebcf96546fc.zip
gedit-autotab-4db806f75c0fb5e19d389465962b2ebcf96546fc.tar.gz
gedit-autotab-4db806f75c0fb5e19d389465962b2ebcf96546fc.tar.bz2
beginnig of capture paste
git-svn-id: http://gedit-autotab.googlecode.com/svn/trunk@30 dd23f896-6e2b-0410-bc3e-d184d5eb269a
-rw-r--r--autotab.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/autotab.py b/autotab.py
index 6e179ac..52a771c 100644
--- a/autotab.py
+++ b/autotab.py
@@ -111,15 +111,42 @@ class AutoTab(gedit.Plugin):
# thing first.
loaded_id = doc.connect_after("loaded", self.auto_tab, view)
saved_id = doc.connect_after("saved", self.auto_tab, view)
- doc.set_data("AutoTabPluginHandlerIds", (loaded_id, saved_id))
+ pasted_id = view.connect("paste-clipboard", self.on_paste)
+ doc.set_data("AutoTabPluginHandlerIds", (loaded_id, saved_id, pasted_id))
def disconnect_handlers(self, view):
doc = view.get_buffer()
- loaded_id, saved_id = doc.get_data("AutoTabPluginHandlerIds")
+ loaded_id, saved_id, pasted_id = doc.get_data("AutoTabPluginHandlerIds")
doc.disconnect(loaded_id)
doc.disconnect(saved_id)
+ view.disconnect(pasted_id)
doc.set_data("AutoTabPluginHandlerIds", None)
+ # capture paste
+ def on_paste(self, view):
+ clipboard = view.get_clipboard(selection="CLIPBOARD")
+ view.stop_emission('paste-clipboard')
+
+ doc = view.get_buffer()
+
+ text = clipboard.wait_for_text()
+
+ if text is None:
+ # nothing on clipboard
+ return
+
+ iter = doc.get_iter_at_mark(doc.get_insert())
+
+ # just testing that we are here
+ # text = '*****' + text
+
+ doc.begin_user_action()
+ doc.delete_selection(False, True)
+ doc.insert_at_cursor(text)
+ doc.end_user_action()
+
+ view.scroll_mark_onscreen(doc.get_insert())
+
# If default tab size changes
def new_tabs_size(self, client, id=None, entry=None, data=None):
self.tabs_width = client.get_int("/apps/gedit-2/preferences/editor/tabs/tabs_size")