-
Notifications
You must be signed in to change notification settings - Fork 0
Home
geoffyoungs edited this page Sep 14, 2010
·
2 revisions
Not much in the way of docs yet, but here’s a sample binding for a class.
- Ruby-GNOME2 (including headers – ie. devel package if you installed via deb/rpm)
- Ruby (equally including headers)
- C Compiler (only tested with GCC)
$ rubber-generate --configure --generate --build vte.cr
Which will generate an extconf.rb file, .rd file and a .c file containing the code.
The syntax is a kind of C/Ruby-style hybrid. e.g.
%pkg-config gtk+-2.0 %pkg-config clutter-1.0 %pkg-config clutter-gtk-0.10 %pkg-config cairo %include clutter/clutter.h %include clutter-gtk/clutter-gtk.h %include rb_cairo.h %name clutter module Clutter array BUILD_VERSION = [ CLUTTER_MAJOR_VERSION, CLUTTER_MINOR_VERSION, CLUTTER_MICRO_VERSION ] array BINDING_VERSION = [ 0, 9, 0 ] string FLAVOUR = CLUTTER_FLAVOUR string COGL = CLUTTER_COGL gobject Gtk < GTK_CLUTTER_TYPE_EMBED @type GtkClutterEmbed def self.init gtk_clutter_init(0,NULL); end def initialize() RBGTK_INITIALIZE(self, gtk_clutter_embed_new()); end def ClutterActor*:stage return gtk_clutter_embed_get_stage(_self); end end enum Gravity (CLUTTER_GRAVITY_NONE, CLUTTER_GRAVITY_NORTH, CLUTTER_GRAVITY_NORTH_EAST, CLUTTER_GRAVITY_EAST, CLUTTER_GRAVITY_SOUTH_EAST, CLUTTER_GRAVITY_SOUTH, CLUTTER_GRAVITY_SOUTH_WEST, CLUTTER_GRAVITY_WEST, CLUTTER_GRAVITY_NORTH_WEST, CLUTTER_GRAVITY_CENTER) end
which will produce something along the lines (although it’s in C, not ruby)
module Clutter BUILD_VERSION = [ 1, 0, 0 ] BINDING_VERSION = [ 0, 9, 0 ] FLAVOUR = "glx" COGL = "gl" class Gtk < Gtk::Widget def self.init # init clutter end def initialize() # initialize object end def stage # return clutter stage end end class Gravity < RubberEnum NONE = 0 NORTH = 1 NORTH_EAST = 2 EAST = 3 SOUTH_EAST = 4 SOUTH = 5 SOUTH_WEST = 6 WEST = 7 NORTH_WEST = 8 CENTER = 9 end end