Which keybinder package do I need for GTK3?

Asked by Dave on 2016-02-12

I have built the gtk3 terminator package but when I start terminator the following is output:

ERROR:root:Could not find any typelib for Gnome
layout creation failed, creating a window ("Namespace Keybinder not available for version 3.0")
Traceback (most recent call last):
  File "/usr/bin/terminator", line 123, in <module>
    TERMINATOR.new_window()
  File "/usr/lib64/python2.7/site-packages/terminatorlib/terminator.py", line 207, in new_window
    window = maker.make('Window')
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 94, in make
    output = func(**kwargs)
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 100, in make_window
    import window
  File "/usr/lib64/python2.7/site-packages/terminatorlib/window.py", line 23, in <module>
    gi.require_version('Keybinder', '3.0')
  File "/usr/lib64/python2.7/site-packages/gi/__init__.py", line 80, in require_version
    (namespace, version))
ValueError: Namespace Keybinder not available for version 3.0

The only slackware package that I've found is python-keybinder 0.3.0

Is this not the correct one?
If not, could someone please link me to the correct source?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Terminator Edit question
Assignee:
No assignee Edit question
Solved by:
Dave
Solved:
2016-02-14
Last query:
2016-02-14
Last reply:
2016-02-14

GTK3 cannot use the GTK2 compatible python-keybinder 0.3.0. Instead it has to use the newer GIR version. Ensure the following is installed:
    gir1.2-keybinder-3.0
    libkeybinder-3.0-0

Those however are Ubuntu packages. I have no idea what they are named (or even if they are available) under Slackware.

Dave (dave-unrealize) said : #2

I found libkeybinder-3.0 on git hub and it's installed. I can't seem to find gir1.2-keybinder-3.0 though, but looking at the files installed by libkeybinder it looks like it's part of the same package?

File list:

usr/include/keybinder-3.0/keybinder.h
usr/share/gir-1.0/Keybinder-3.0.gir
usr/lib64/libkeybinder-3.0.la
usr/lib64/libkeybinder-3.0.so.0.0.0
usr/lib64/girepository-1.0/Keybinder-3.0.typelib
usr/lib64/pkgconfig/keybinder-3.0.pc

New error:

ERROR:root:Could not find any typelib for Gnome
Traceback (most recent call last):
  File "/usr/bin/terminator", line 120, in <module>
    TERMINATOR.create_layout(OPTIONS.layout)
  File "/usr/lib64/python2.7/site-packages/terminatorlib/terminator.py", line 283, in create_layout
    window, terminal = self.new_window()
  File "/usr/lib64/python2.7/site-packages/terminatorlib/terminator.py", line 207, in new_window
    window = maker.make('Window')
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 94, in make
    output = func(**kwargs)
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 101, in make_window
    return(window.Window(**kwargs))
  File "/usr/lib64/python2.7/site-packages/terminatorlib/window.py", line 70, in __init__
    self.register_callbacks()
  File "/usr/lib64/python2.7/site-packages/terminatorlib/window.py", line 127, in register_callbacks
    self.hidebound = Keybinder.bind(
  File "/usr/lib64/python2.7/site-packages/gi/module.py", line 313, in __getattr__
    return getattr(self._introspection_module, name)
  File "/usr/lib64/python2.7/site-packages/gi/module.py", line 134, in __getattr__
    self.__name__, name))
AttributeError: 'gi.repository.Keybinder' object has no attribute 'bind'

What do you think?

Very strange. The GIR stuff is a little bit "magical", but I don't see anything obvious that is wrong. Start Python (make sure it's 2.7) and run the following, and paste the output here.

    >>> from gi.repository import Keybinder
    >>> dir(Keybinder)
    [ You will get a list of methods/attributes. One of these should be 'bind'. ]
    >>> print Keybinder._version
    [ Hopefully this will print "3.0" ]

The .gir file is compiled to produce the .typelib file. On my Ubuntu system I don't have the .gir file, just the .typelib for this particular package, but in the .gir file the classes/methods/params etc. are defined with XML. You could try having a look at that file and see if you can find a bind method. If it's not there, then the .gir is wrong. If it is there then the .typelib does not reflect the .gir file.

Dave (dave-unrealize) said : #4

No bind attribute:

> python
Python 2.7.5 (default, May 29 2013, 02:28:51)
[GCC 4.8.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Keybinder
>>> dir(Keybinder)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__file__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__loader__', '__module__', '__name__', '__new__', '__path__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_introspection_module', '_load', '_namespace', '_overrides_module', '_version', 'bind_full', 'get_current_event_time', 'init', 'set_use_cooked_accelerators', 'unbind_all']
>>> print Keybinder._version
3.0

Dave (dave-unrealize) said : #5

I've just checked out and built keybinder-3.0-v0.3.0 (previously I was trying keybinder-3.0-v0.3.1).

Now a different error:

ERROR:root:Could not find any typelib for Gnome
Traceback (most recent call last):
  File "/usr/bin/terminator", line 120, in <module>
    TERMINATOR.create_layout(OPTIONS.layout)
  File "/usr/lib64/python2.7/site-packages/terminatorlib/terminator.py", line 283, in create_layout
    window, terminal = self.new_window()
  File "/usr/lib64/python2.7/site-packages/terminatorlib/terminator.py", line 207, in new_window
    window = maker.make('Window')
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 94, in make
    output = func(**kwargs)
  File "/usr/lib64/python2.7/site-packages/terminatorlib/factory.py", line 101, in make_window
    return(window.Window(**kwargs))
  File "/usr/lib64/python2.7/site-packages/terminatorlib/window.py", line 70, in __init__
    self.register_callbacks()
  File "/usr/lib64/python2.7/site-packages/terminatorlib/window.py", line 129, in register_callbacks
    self.on_hide_window)
TypeError: bind() takes exactly 3 arguments (2 given)

OK, That's super strange. The source package for Ubuntu *says* that bind is deprecated in favour of bind_full. But it still creates gir entry for bind, but also the bind_full. Somehow it seems like the "skip" marking is ignored by my version of the gir->typelib tools. For the record for Ubuntu it is the following package:
gobject-introspection 1.40.0-1ubuntu0.2

However the Ubuntu repository binary package does *not* contain bind_full. I can only assume the source used to build the binary package was retrieved before the bind_full was added, and has never been updated. You should try updating the Terminator code to use bind_full and see if it starts working. If it does we can probably come up with a try/except clause to try one then the other. There is an additional parameter to the bind_full call - I'm not sure if it is optional but I don't think so - of type GDestroyNotify. It appears to be a callback for when a binding is unregistered. You might be able to a) omit it, b) pass None, or c) create a dumb function to immediately return.

Let me know how you get on. It might be an idea to turn this Question into a bug now ("Create bug report" just above the new comment box)

Ah. My comment was being written before I saw your two followups.

Seems like the API of the Keybinder library changes more often than my socks!

I would suggest going back to your newer 0.3.1, and try to get the newer bind_full working. You can also just comment out that code if it's annoying you too much :-) It is only used to bind the single global shortcut to show/hide the window, so if that feature is not important to you, you can workaround it for now.

Dave (dave-unrealize) said : #8

OK some more progress, I commented out that block of code, but now my vte is too old and I can't compile a newer version because my glib is too old...

I'll have to leave this until the next slackware release, which should be coming soon.

Thanks for the help

Just an FYI, the GTK3 code was developed with libvte 0.38, and should work up till 0.40 at least. You might be able to build an older version with your older glib.