mvz/ruby-gir-ffi — Issue #21: Create a class from a GInterface
Author: pmros
Created: 2011-12-27 22:18:59+00:00
State: open

Hello,
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):
http://git.gnome.org/browse/gtksourceview/tree/tests/test-completion.c
http://git.gnome.org/browse/gtksourceview/tree/tests/test-completion.py

Above is my wrong code.

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

```ruby
require 'gir_ffi'
require 'ffi-gtk3'

Gtk.init
GirFFI.setup :GtkSource

class TestProvider
include GtkSource::CompletionProvider
end

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

vbox = Gtk::VBox.new(false, 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 = TestProvider.new
completion = @source.get_completion
completion.add_provider provider

vbox.pack_start @source, true, true, 0

win.show_all
Gtk.main
```