From: John L. <jo...@la...> - 2017-02-28 11:36:54
|
On 27/02/17 16:56, cedlemo wrote: > > Maybe look here https://github.com/ruby-gnome2/ggit this is a loader for > the gobject-libgit2. It is very simple, it should be a good starting point. > > Look in the ruby-gnome2 gems too; the atk gem, for example, has been > recently updated in order to use gobject-introspection instead of the C > bindings. > Hey Cedelmo, well I have something partially working with GI! I know the library is hooked up because I have a call that works and it outputs text that is in the library. However, this: Keybinder.bind('Menu', Callback, 'Key pressed') fails with this error: /usr/lib/ruby/gems/2.3.0/gems/gobject-introspection-3.1.1/lib/gobject-introspection/loader.rb:651:in `validate_arguments': Keybinder.bind: wrong number of arguments (3 for 1) (ArgumentError) I have looked at the source[1] and studied the annotation documentation[2]. I can see that the actual bind function is skipped but `keybinder_bind_full` is renamed to `keybinder_bind`. The header for that function shows four parameters of which the last is optional, so my call passing three parameters ought to be ok: /** * keybinder_bind_full: (rename-to keybinder_bind) * @keystring: an accelerator description (gtk_accelerator_parse() format) * @handler: (scope notified): callback function * @user_data: (closure) (allow-none): data to pass to @handler * @notify: (allow-none): called when @handler is unregistered * * Grab a key combination globally and register a callback to be called each * time the key combination is pressed. * * Since: 0.3.0 * * Returns: %TRUE if the accelerator could be grabbed */ gboolean keybinder_bind_full (const char *keystring, KeybinderHandler handler, void *user_data, GDestroyNotify notify) So I must have done something wrong, but I actually did very little. Here's my GI module: module Keybinder class Loader < GObjectIntrospection::Loader end loader = Loader.new(self) loader.load("Keybinder") end I'm not sure where to go from here... Thanks for your help, John [1] https://github.com/kupferlauncher/keybinder/blob/master/libkeybinder/bind.c#L547 [2] https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations |