Skip to content

Loading…

Create a class from a GInterface #21

Open
pmros opened this Issue · 4 comments

2 participants

@pmros

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!)

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
@mvz
Owner

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

@pmros

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
Owner
mvz commented

GObject.define_type and friends are not quite done yet.

@mvz mvz added the ready label
@mvz
Owner

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.