Re: How to "extend" a widget?



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.



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