Re: How to "extend" a widget?




Thanks, I do need to do some more reading on the gobject docs, great stuff there.

What I'm looking for is inheritance, and I see how it could be done yes. However, that would require the original widget to be done using virtual public methods, and I'm afraid this isn't the case unfortunately...

-j

On 12/17/2011 12:21 AM, Michael Torrie wrote:
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.
_______________________________________________
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]