dhk
Sat, 20 Feb 2010 10:01:31 -0800
Tristan Van Berkom wrote: > 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 <dhk...@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 >> >
Good point, I didn't think about the API's and the interface changing. Thanks, dhk _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list