GNOME Bugzilla – Bug 586635
gtk_info_bar_add_button() should return GtkButton*
Last modified: 2011-01-26 09:34:00 UTC
It would be nice if gtk_info_bar_add_button()'s return type was GtkButton*, if that's really what it always returns, instead of a GtkWidget*. http://library.gnome.org/devel/gtk/unstable/GtkInfoBar.html#gtk-info-bar-add-button
That would be inconsistent with gtk_dialog_add_button(). [which leads me to wonder whether there should be a common interface for these widgets]
We(In reply to comment #1) > That would be inconsistent with gtk_dialog_add_button(). Well, that's wrong too, but I saw if when it was too late to change the API.
There is nothing wrong here. Widgets are typed as GtkWidget* and the API user has to cast to specific types, that is almost everywhere in GTK+ the case except for few exceptions.
That's unfortunate. Then the documentation should at least make clear that it's a GtkButton rather than just some generic "button" widget.
I agree with Christian here that internal consistency is more important here. We are also not going to start changing all our constructors to return something other than GtkWidget*... I don't know how the docs can be much clearer about what is returned (after all, they are just a straight copy of the dialog_add_button docs). Murray, any concrete proposal for the docs ?
Moved to doc component
Murray: ping
(In reply to comment #5) > I don't know how the docs can be much clearer about what is returned (after > all, they are just a straight copy of the dialog_add_button docs). > > Murray, any concrete proposal for the docs ? The documentation for these kinds of functions should name the type more exactly. For instance, it should say "GtkButton" instead of just "button". The ambiguity is unnecessary, and there's no reason to make the reader guess if that's what you really mean. I guess that there should be some introspection annotation for this too, so that real OO languages can return the most specific type, but I don't see anything here: http://live.gnome.org/GObjectIntrospection/Annotations
Created attachment 157295 [details] [review] State that _add_button functions return a "#GtkButton widget" Changed gtk_dialog_add_button and gtk_info_bar_add_button to state that they return a "#GtkButton widget".
Comment on attachment 157295 [details] [review] State that _add_button functions return a "#GtkButton widget" looks good for me
It's a bit more confusing for me this way, because it's not a GtkButton what's returned. But maybe it's just me.
(In reply to comment #11) > It's a bit more confusing for me this way, because it's not a GtkButton what's > returned. But maybe it's just me. Do you just mean that GtkButton* is not the type in the C function's signature, or do you mean that the instance is not a GtkButton?
I meant the former. But now I had a quick look to some _new() methods and I see that it's stated in a similar way to this, so I guess it's fine.
So, I guess this patch is OK to commit, right?
Created attachment 171040 [details] [review] State that _add_button functions return a "#GtkButton widget" #2 Updated to git master.
Thanks. Is there any reason that I shouldn't push that?
Not sure how significant the clarification is between 'button' and '#GtkButton', but sure, feel free to commit it.