gtkd-developers/GtkD

Unable to implement CellRenderer with ImplementClass

MaeIsBad opened this issue · 2 comments

While attempting to compile the mixin will error out due to missing ObjectG import. If I import it manually it will instead error out because of a missing gtkCTypesGtkCellRendererClass identifier.
The code compiles if I don't override any functions but fails once I try to override render.
Minimal example:

import std.stdio;
import gtk.CellRenderer;
import cairo.Context;
import gtk.Widget;

class Foo: CellRenderer {
    import gtkd.Implement;
    import gobject.c.functions : g_object_newv;

    import gobject.ObjectG;

    mixin ImplementClass!GtkCellRenderer;
    this() {
       super(cast(GtkCellRenderer*)g_object_newv(getType(), 0, null), true);
    }

    override void render(Context cr, Widget widget, GdkRectangle* backgroundArea, GdkRectangle* cellArea, GtkCellRendererState flags) {
    }


}



void main()
{
        writeln("Edit source/app.d to start your project.");
}

Sorry if I've made some silly mistake, I'm just learning both gtk and D

Awesome work, keep it up

That makes the code compile but gtk complains that gtk_cell_renderer_render: assertion 'GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL' failed

import std.stdio;
import gtk.CellRenderer;
import cairo.Context;
import gtk.TreeView;
import gtk.TreeViewColumn;
import gtk.ListStore;
import gtk.Widget;
import gtk.Main;
import gtk.MainWindow;

class Renderer: CellRenderer {
    import gtkd.Implement;
    import gobject.c.functions : g_object_newv;

    mixin ImplementClass!GtkCellRenderer;
    this() {
       super(cast(GtkCellRenderer*)g_object_newv(getType(), 0, null), true);
    }

    override void render(Context cr, Widget widget, GdkRectangle* backgroundArea, GdkRectangle* cellArea, GtkCellRendererState flags) {
    }


}



void main(string[] args)
{
        Main.init(args);

	ListStore ls = new ListStore([GType.INT]);
	ls.setValue(ls.createIter(), 0, 0);

	Renderer r = new Renderer();
	TreeViewColumn col = new TreeViewColumn("test", r, "test", 0);

	TreeView view = new TreeView();
	view.setModel(ls);

	view.appendColumn(col);

        MainWindow win = new MainWindow("test");
	win.add(view);
	win.showAll();

        Main.run();
}