I’m working on some bindings, but I’ve hit a couple of issues.
Issue #1: how do I deal with “regular” structures that aren’t quite GTK+
Essentially, I have a structure that’s returned from an already wrapped
method, but I need to turn the wrapped structure into an appropriate
Ruby object. I’m sure there’s already examples of this in the existing
code, but I’m not familiar enough with the GTK+ C API to know where this
has already been necessary.
It has a destroy function, but it doesn’t have any of the rest of the
type information necessary to use the normal macros, e.g. there isn’t a
Can someone please help by either giving an example or pointing me to
the appropriate place in the source?
Issue #2: what’s the best way to wrap a structure of function pointers
so that I can allow them to be implemented by a Ruby object?
GtkWidget * (* create_widget) (ContainerWidgetType *widget, …)
void widget_set_foo_callbacks(ContainerWidgetType *widget, foo
*callbacks, gpointer data)
I’d like to end up with the following:
cw = ContainerWidget.new
cbw = MyCallbacks.new
cw.callbacks = cbw
Is this possible? Has something similar already been done somewhere?
BTW, I figured out the answer to my earlier question when I found how
the sort functions work for the list store. The example is in there.
66 static gint
67 sort_func(model, a, b, func)
68 GtkTreeModel *model;
69 GtkTreeIter *a, *b;
70 gpointer func;
72 a->user_data3 = model;
73 b->user_data3 = model;
74 return NUM2INT(rb_funcall((VALUE)func, id_call, 2,
78 static VALUE
79 treesortable_set_sort_func(self, sort_column_id)
80 VALUE self, sort_column_id;
82 volatile VALUE func = rb_block_proc();
83 G_RELATIVE(self, func);
86 (gpointer)func, NULL);
87 return self;
Thanks in advance,