Auto-generate bindings for GObject based libraries at run time using FFI
Clone or download
mvz Merge pull request #118 from mvz/update-rubocop
Update for rubocop 0.60.0
Latest commit 25a58f4 Nov 5, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add documentation about subclassing Sep 17, 2015
examples Add Clutter photo wall example Feb 9, 2016
features Autocorrect Style/EmptyLineAfterMagicComment Mar 27, 2017
lib Configure and autocorrect Layout/AlignHash Nov 5, 2018
tasks Autocorrect Layout/EmptyLineAfterGuardClause Sep 11, 2018
test Add enum values as constants in the enum module Sep 26, 2018
yard-plugin Autocorrect Style/EmptyLineAfterMagicComment Mar 27, 2017
.dockerignore Add Dockerfile to run tests on plain Debian Jessie Oct 18, 2016
.gitignore Provide config.h for test libs Oct 1, 2014
.hound.yml Tell Hound to use local RuboCop config Mar 24, 2018
.pullreview.yml Add configuration for PullReview Oct 5, 2014
.reek.yml Fix more cases of InstanceVariableAssumption Sep 22, 2018
.rubocop.yml Configure and autocorrect Layout/AlignHash Nov 5, 2018
.rubocop_todo.yml Update RuboCop TODO list for 0.60.0 Nov 5, 2018
.travis.yml Drop support for Ruby 2.1 Jul 9, 2018
.yardopts Ensure documentation is properly generated and linked Sep 17, 2015
COPYING.LIB Setup library package infrastructure and boilerplate. Nov 9, 2009 Prepare version 0.14.1 for release Sep 27, 2018 Explain new object initialization in the DESIGN document Oct 9, 2015
Dockerfile Add Dockerfile to run tests on plain Debian Jessie Oct 18, 2016
Gemfile Auto-update pry to 0.12.0 Nov 5, 2018 Drop support for Ruby 2.1 Jul 9, 2018
Rakefile Fix RuboCop offenses in Rakefile and gemspec Sep 27, 2017 Update derived class example Apr 20, 2017
exceptions.reek Remove trailing whitespace Mar 5, 2016
gir_ffi.gemspec Revert "Upgrade to Cucumber 4 release candidate" Oct 1, 2018


by Matijs van Zuijlen


Ruby bindings for GNOME using the GObject Introspection Repository.


Gem Version Depfu Build Status Code Climate Coverage Status Documentation Status


  • Create bindings to any GObject-based library.
  • Bindings are generated at runtime.
  • Provides overridden bindings for selected methods.
  • Install gir_ffi-gtk and require gir_ffi-gtk2 or gir_ffi-gtk3 to load overrides for Gtk2 or Gtk3.


require 'gir_ffi'

# Set up the namespace you wish to use
GirFFI.setup :Gio

# Create an object
inet_address = Gio::InetAddress.new_from_string ""

# Call some methods on the object
inet_address.is_loopback    # => true
inet_address.is_multicast   # => false

# Call a function in the namespace
Gio.dbus_is_name "foo"   # => false

See the documentation for more usage information.


Have a look in the examples/ directory for some simple examples. More examples can be found in gir_ffi-gtk and gir_ffi-gst.


gem install gir_ffi


GirFFI is supported on CRuby 2.2, 2.3, 2.4 and 2.5, and JRuby 9.1 and 9.2

You will also need gobject-introspection installed with some introspection data.

Depending on the GIR data, GirFFI needs the actual libraries to be available under the name ending in plain .so. If GirFFI complains that it cannot find the library, try installing development packages for those libraries.

GirFFI should work with gobject-introspection 1.32.0 and up.

On Debian and Ubuntu, installing libgirepository1.0-1 and gir1.2-glib-2.0 should be enough to use GirFFI in your application.

To run the tests, you should additionally install libgirepository1.0-dev, libcairo2-dev, gobject-introspection, gir1.2-gtop-2.0, gir1.2-gtk-3.0, gir1.2-pango-1.0, gir1.2-secret-1 and gir1.2-gstreamer-1.0. This should be enough to get rake test working.

GirFFI has not been tested on Mac OS X or Microsoft Windows. YMMV.


Sometimes, the GIR data is incorrect, or not detailed enough, and a reasonable binding cannot be created automatically. For these cases, overrides can be defined. The following gems with overrides already exist:

  • gir_ffi-gtk: overrides for Gtk+ 2 and 3.
  • gir_ffi-gnome_keyring: overrides for GnomeKeyring
  • gir_ffi-cairo: overrides for Cairo
  • gir_ffi-pango: overrides for Pango
  • gir_ffi-tracker: overrides for Tracker
  • gir_ffi-gst: overrides for GStreamer

Hacking and contributing

Please feel free to file bugs or send pull requests!

If you just want to help out but don't know where to start, have a look at, and check the notes in the code (e.g., using dnote).

If you want to send pull requests or patches, please try to follow these instructions. If you get stuck, make a pull request anyway and I'll try to help out.

  • Make sure rake test runs without reporting any failures.
  • Add tests for your feature. Otherwise, I can't see if it works or if I break it later.
  • Make sure latest master merges cleanly with your branch. Things might have moved around since you forked.
  • Try not to include changes that are irrelevant to your feature in the same commit.


The following people have contributed to GirFFI over the years:

  • John Cupitt
  • Marius Hanne
  • Antonio Terceiro
  • Matijs van Zuijlen


Copyright © 2009–2018 Matijs van Zuijlen

GirFFI is free software, distributed under the terms of the GNU Lesser General Public License, version 2.1 or later. See the file COPYING.LIB for more information.