On Sat, 2010-04-17 at 17:25 +1000, Roman Joost wrote:

> My understanding so far, if I would inherit from my GtkEntry widget, I
> wouldn't be able to "overwrite" my implementation so I can display a
> GtkTextView. I also thought about inheriting from a more basic widget
> and somehow use a GtkEntry or GtkTextView as a property. That didn't
> really worked well either.
> Now I have a similar implementation working with a GtkTextView as a base
> class including "borrowed" code from my GtkEntry. I would like to
> "merge" both to something more flexible, but I can't really think of a
> better architecture.

How much code does the TextView class actually borrow from the Entry
class? What does this code do? There are certainly ways to share most of
this code, but probably not by inheritance. Some utility functions
called from both classes might be sufficient, or you use composition and
embed a common object in your TextView and Entry objects.

> Maybe the clue is to overwrite the constructor which returns either a
> GtkEntry, a GtkTextView or ...?

No, that wouldn't work. The constructor can't change the type of object
it returns.


Gimp-developer mailing list

Reply via email to