From: Kouhei S. <ko...@co...> - 2016-07-24 03:00:40
|
Hi, In <453...@ro...> "Re: [ruby-gnome2-devel-en] How-To Interfaces" on Sat, 23 Jul 2016 17:16:33 +0200, Thomas Martitz <ku...@ro...> wrote: >>Ruby-GNOME2 doesn't support implementing interface in >>Ruby. Because it needs interface specific C code. >> > > What do you mean with interface specific c code? From my > current observations it should be possible to extend rbg > (seems to be the general shorthand for ruby-gnome2 in the > code so I'll use that) such that you can create classes > (inheriting gobject) that implement gobject interfaces > purely in ruby. Do you know how to implement GObject interface in C? Here are codes that GtkSizeGroup implements GtkBuildable: https://git.gnome.org/browse/gtk+/tree/gtk/gtksizegroup.c#n150 https://git.gnome.org/browse/gtk+/tree/gtk/gtksizegroup.c#n273 You need to assign pointers of GObject interface functions like: iface->custom_tag_start = gtk_size_group_buildable_custom_tag_start; iface->custom_finished = gtk_size_group_buildable_custom_finished; https://git.gnome.org/browse/gtk+/tree/gtk/gtksizegroup.c#n276 The function type is GObject interface specific. So we need to create function for each GObject interface functions. How did you implement GObject interfaces purely in Ruby? > pygobject can do it after all. Could you show us how PyGObject do it? > That's clear. Before I implement a loader I need rbg to > meet the requirements for libpeas. That's mainly > supporting interfaces. The libpeas loader would look for > ruby classes that implement certain interfaces, and > instantiate them. You can use Ruby-GNOME2 when you implement the Ruby loader. > PS: I'm currently having a problem with "rgbobjects" being > initialized twice if I call g_type_interface_static() for > it g_type_register_static()? I don't know about the details of what you're doing but you should not call XXX_static() dynamically. Thanks, -- kou |