On Tue, Sep 8, 2009 at 12:54 PM, Emmanuel
Touzery<emmanuel.touz...@free.fr> wrote:
> Hi,
>>
>> Whatever type is returned, you'll have to do lots of casts, so whatever
>> convention is used, there's no avoiding that. And returning GtkWidget*
>> is just the current convention.
>> I personally would prefer correct types to be used in the API, just to
>> show exactly what type to expect at runtime. But that's a separate
>> issue.
>>
>
> Thank you for the answer. If it doesn't make a technical difference I think
> returning the actual type would be much more useful, for documentation
> purposes. In the case of gtk_menu_shell_append() from the prototype you
> would think that it can take any GtkWidget and only the comment tells you
> that only GtkMenuItem* will do.
>

There is a technical difference when writing GTK+ code in C; for instance
its quite often that you will access methods on the GtkWidgetClass
(like show()/hide()/set_sensitive() etc), also many other apis take GtkWidget *
argument, namely GtkContainer apis which operate on child widgets.

>From this standpoint its alot more convenient to cast all your widget variables
as GtkWidget * (this way you keep casting to a minimum in your code) so GTK+
is only helping you by returning GtkWidget *, if only for a simple and
practical
reason to save you a little casting/typing.

Cheers,
       -Tristan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to