Package: autokey-gtk
Version: 0.90.4-1
Severity: important
Tags: upstream, patch

autokey-gtk hangs when using the selection / clipboard functions as GTK wants a 
length argument added to set_text().
-1 means "use size() to find out yourself".

Sample autokey script:

clipboard.fill_clipboard("Debian rocks")
keyboard.send_keys("<ctrl>+v")

Sample error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/autokey/service.py", line 454, in 
execute
    exec script.code in scope
  File "<string>", line 11, in <module>
  File "/usr/lib/python2.7/dist-packages/autokey/scripting.py", line 837, in 
fill_clipboard
    self.clipBoard.set_text(contents.encode("utf-8"))
TypeError: set_text() takes exactly 3 arguments (2 given)

The bug is reported upstream:
https://code.google.com/archive/p/autokey/issues/212
https://code.google.com/archive/p/autokey/issues/197

Fedora has better info and a partial(*) patch:
https://bugzilla.redhat.com/show_bug.cgi?id=1089695
https://bugzilla.redhat.com/show_bug.cgi?id=1229371

(*) one of five lines that need fixing

A complete patch (that includes a lot of whitespace cleanup as well) is 
available at 
https://github.com/autokey/autokey/commit/cf466fb30422a5e9074e48063c7f7ca7d7533021
 .

grep -- "^diff\|set_text" cf466fb30422a5e9074e48063c7f7ca7d7533021.patch 

Subject: [PATCH] Add length arg to gtk clipboard set_text which is mandatory
* add -1 arg to Gtk.Clipboard.set_text
diff --git a/src/lib/interface.py b/src/lib/interface.py
-                self.clipBoard.set_text(self.__savedClipboard)
+                self.clipBoard.set_text(self.__savedClipboard, -1)
-            self.selection.set_text(string.encode("utf-8"))
+            self.selection.set_text(string.encode("utf-8"), -1)
-            self.clipBoard.set_text(string.encode("utf-8"))
+            self.clipBoard.set_text(string.encode("utf-8"), -1)
diff --git a/src/lib/scripting.py b/src/lib/scripting.py
-        self.selection.set_text(string.encode("utf-8"))
+        self.selection.set_text(string.encode("utf-8"), -1)
-        self.clipBoard.set_text(contents.encode("utf-8"))
+        self.clipBoard.set_text(contents.encode("utf-8"), -1)

^-- this is the gist of the patch

Reply via email to