Re: How to "extend" a widget?



On 12/16/2011 02:52 PM, jjacky wrote:
And while GTK is oriented-object, it is written in C and, AFAIK, there 
are no such things as classes in C?

As always, read the docs.  Here is the documentation describing how to
create new GObjects, and inherit from existing ones, implement virtual
methods, etc.  So if you find that you really do need to make your own
subclass of the GtkCalendar you can easily do it, though as the other
poster talks about, a composite widget might be the ticket too.  Just
remember how relationships in OOP work: The "is a" relationship means
inheritance.  the "has a" relationship means composite widgets.  If your
widget simply has a calender, then the composite widget is the way to
go.  If it actually is a calendar, albeit a special one, inheritance is
the way to go.

http://developer.gnome.org/gobject/stable/

The GOB thing I was referring to earlier:
http://www.jirka.org/gob.html

a specific example of using gob to extend GtkButton:
http://www.jirka.org/gtk-button-count.gob.html

The GOB examples you should be able to compile to straight C and use
that boilerplate to implement your own pure-C extension of GtkCalendar.



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