Extending from GTKWidget

New to FreeBASIC? Post your questions here.
Post Reply
lisoformio
Posts: 9
Joined: Sep 16, 2015 15:57

Extending from GTKWidget

Post by lisoformio »

Hi all,

do you have example, links to examples of FreeBasic code about deriving/extending from GTKWidgets?

I only found these two examples, not in FreeBasic:

http://openfracas.blogspot.it/2008/01/c ... ustom.html
http://php-gtk.eu/it/code-snippets/exte ... ted-graphs

thanks!
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Extending from GTKWidget

Post by dkl »

Hi,

as it would happen I worked on a custom GTK widget recently, although not in FB, but it's easy enough to translate. So I've added the result to FB's examples directory:

customgtkwidget.bas
customgtkwidget.bi

Some links I've found helpful in this regard:
lisoformio
Posts: 9
Joined: Sep 16, 2015 15:57

Re: Extending from GTKWidget

Post by lisoformio »

OK! That's what I didn't find in my quest :) Thank you very much.

In the last two day I used the gtk.bi to understand how to manage extending from gtkwidget.
lisoformio
Posts: 9
Joined: Sep 16, 2015 15:57

Re: Extending from GTKWidget

Post by lisoformio »

In customwidget.bi I find:

declare function mycustomwidget_get_type() as GType
declare function mycustomwidget_new() as GtkWidget ptr

In customwidget.bas I find:

function mycustomwidget_new() as GtkWidget ptr
return GTK_WIDGET(g_object_new(mycustomwidget_get_type(), NULL))
end function

but no code for

mycustomwidget_get_type()

Am I in misunderstanding?
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Extending from GTKWidget

Post by dkl »

Looks like it is declared by the G_DEFINE_TYPE() macro.

Code: Select all

G_DEFINE_TYPE(MyCustomWidget, mycustomwidget, GTK_TYPE_WIDGET)
lisoformio
Posts: 9
Joined: Sep 16, 2015 15:57

Re: Extending from GTKWidget

Post by lisoformio »

OK!
Post Reply