Re: Getting a Widget Choice
- From: Tristan Van Berkom <tvb gnome org>
- To: dhk <dhkuhl optonline net>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Getting a Widget Choice
- Date: Sat, 20 Feb 2010 12:53:56 -0500
You should always prefer using either gtk_builder_get_object(), or
also using trustable API's like gtk_button_get_image_widget() for instance.
(not sure if thats an existing api, but you get the idea).
I.e. the composition of opaque composite widgets from GTK+ can
change, possibly breaking unwary code which walks through the
hierarchy checking widget types.
Also, the composition of your GtkBuilder file may change, if you always
access the elements by the keys you provide (i.e. the name field right now)
then you wont run into trouble when changing your interface in the future.
Cheers,
-Tristan
On Sat, Feb 20, 2010 at 9:04 AM, dhk <dhkuhl optonline net> wrote:
When a widget can be gotten by using GTK builder functions or GTK Widget
functions, does it make a difference, or is one way better than the
other, for finding the widget.
For example when I can get the same widget using either of the following
two calls, which one should I use and why?
GtkWidget *nb=NULL; /* A notebook widget */
/* Call 1 */
nb=GTK_WIDGET(gtk_builder_get_object(gtk_builder, "notebook_name"));
/* Call 2 */
nb=gtk_widget_get_ancestor(widget, GTK_TYPE_NOTEBOOK);
Thanks,
dhk
_______________________________________________
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]