Re: How to "extend" a widget?



Thanks. I will have a look into Vala, although for projects I have planned, I really want/need to be using C.

And while GTK is oriented-object, it is written in C and, AFAIK, there are no such things as classes in C? I believe the way to create a widget based on/extending another one is how I have done so far (based on the docs /tutorials I read), only I'm not sure how to properly do things like "overriding" functions to change behaviors or add features.

If Vala allows to do that easily and does produce C code though, I might try and see how it does/what code it produces, but I'm not sure learning a new language is something I wanna get into right now...

-jacky


On 12/16/2011 07:05 PM, Michael Torrie wrote:
On 12/16/2011 08:16 AM, jacky wrote:
As I said, I'm not sure this is the right way to do such a thing, so I
would appreciate any help/information on how one would do this
properly.

Since GTK is object oriented, you could just create a new class that
inherits from GtkCalender.  However this is C we're using, so it's not
quite as simple as in C++, Java, or Python.  If I recall correctly,
you'll end up with 3 files.  2 .C files and 1 .H  One C file will
contain the klass and vtable initialization stuff, one .C file of your
implementation, and one .H file with your public interfaces, cast
macros, and so forth.  At one time GTK people were using a tool called
"gob" to compile a single file of some object-oriented C-like syntax
into these files.

Seems to me, though, that you'd be well-served in doing this in Vala.
Vala itself defines a C-like (more C#-like) language that compiles into
C and GObject code.  You can take the output of Vala and use it in your
normal C development.  In fact the job you describe is just what Vala
was originally designed for, though Vala has gone far beyond just being
a GObject compiler.

Michael.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]