Re: Quick question on Glib style/design




On Aug 4, 2004, at 1:57 AM, Jan Kratochvil wrote:

On Wed, 04 Aug 2004 04:21:31 +0200, muppet wrote:
...
not quite.  notice that most gtk+ constructors return GtkWidget*?

I do not much understand why. GLib functions expect C type of the most far ancestor type they need to access to be as general as possible. They usually return the most far descendant class they create. Just why GTK+ has a style where the constructor gtk_button_new() returns (GtkWidget *) and not its native class (GtkButton *)? It is not much systematic this way.

i'm getting a bit out of my depth here, as i didn't design the API (/me looks at the devs) and all i can do is wave my hands around a lot, but there are reasons.

if the style factory methods returned the most-descended class, you'd be unable to have private style types or even style factories. when i create a GtkStyle, it's returned as a GtkStyle and i deal with it as a GtkStyle, but it's actually a BlueCurveStyle. same thing for the GdkPixbufLoaders.

i'm sure there are historical reasons, too; wasn't GtkWidget the root of the hierarchy in The Old Days?



--
Holy crap, dude, we have kids!
	-- Elysse, six days after giving birth to twins




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