Skip to content


Create a class from a GInterface #21

pmros opened this Issue · 4 comments

2 participants


I've tried but I can't. I just wanna create a class TestProvider that implments CompletionProvider (a GInterface). But when I pass my new provider I get this error:

in `gtk_source_completion_add_provider': :pointer argument is not a valid pointer (ArgumentError)

I suposse I need some kind of GObject wrapper but I can't find it. In Python you have GObject.type_register.

I wanna get something like this (same sample, coded in C and Python):

Above is my wrong code.

(Thank you! ruby-gir-ffi is great!)

require 'gir_ffi'
require 'ffi-gtk3'

GirFFI.setup :GtkSource

class TestProvider 
  include GtkSource::CompletionProvider

win = :toplevel
GObject.signal_connect(win, "destroy") { Gtk.main_quit }

vbox =, 0)
win.add vbox

lm = GtkSource::LanguageManager.get_default
lang = lm.get_language "ruby"
buffer = GtkSource::Buffer.new_with_language lang
@source = GtkSource::View.new_with_buffer buffer

provider =
completion = @source.get_completion
completion.add_provider provider

vbox.pack_start @source, true, true, 0


I will need to implement a type_register method that does the right thing, using the g_type_register_static function.


Hi again,
I can see you have implemented GObject.define_type which use g_type_register_static. However I'm not be able to make my code work yet. Now I've install_property but I can't define a Gobject method.
I don't know exactly what else I need now.

Thank you again.

mvz commented

GObject.define_type and friends are not quite done yet.

@mvz mvz added the ready label

Once #63 is implemented, this can be done in a nicer way since we won't need to store the properties in the C struct.

GObject methods can be defined with install_vfunc_implementation. The intent is for these to auto-register somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.