Re: Finding a widget in a Glade interface
dhk wrote: Tristan Van Berkom wrote: On Wed, Jul 30, 2008 at 3:40 PM, Tristan Van Berkom [EMAIL PROTECTED] wrote: for future reference, this could easily have been pulled out of the docs/header files: glade_xml_get_widget() type libglade and feel lucky its right there. oops, I obviously meant in google here... I should have mentioned that by time I want to call glade_xml_get_widget() the GladeXML *xml created by xml = glade_xml_new(filename.glade, NULL, NULL); is out of scope. If I call open the file again to get the widget it has no affect on the running window. I need to get the widget from the running window from some callback. Any ideas? Make 'GladeXML *xml' static or otherwise accessible from all parts of the sourcecode. tom ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Finding a widget in a Glade interface
I should have mentioned that by time I want to call glade_xml_get_widget() the GladeXML *xml created by xml = glade_xml_new(filename.glade, NULL, NULL); is out of scope. If I call open the file again to get the widget it has no affect on the running window. I need to get the widget from the running window from some callback. Any ideas? Make 'GladeXML *xml' static or otherwise accessible from all parts of the sourcecode. tom Not a good idea. I had a similar question some time back, the xml structure returned by glade_xml_new is too heavyweight to be retained for a long time by your program, and it contains no useful information aside from being able to pull out pointers to widgets. A more apt way to do this would be to store pointers to all the widgets you need soon after glade_xml_new (perhaps as members of a struct), then dereference the GladeXML object. When you set up your callbacks, have this structure passed as the user pointer. Now all callbacks have access to the widgets in your window. In addition to the examples posted earlier, you can also download the source to any standard gtk program for additional examples. I used the devhelp source for this. -Jim ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Finding a widget in a Glade interface
Jim George wrote: I should have mentioned that by time I want to call glade_xml_get_widget() the GladeXML *xml created by xml = glade_xml_new(filename.glade, NULL, NULL); is out of scope. If I call open the file again to get the widget it has no affect on the running window. I need to get the widget from the running window from some callback. Any ideas? Make 'GladeXML *xml' static or otherwise accessible from all parts of the sourcecode. tom Not a good idea. I had a similar question some time back, the xml structure returned by glade_xml_new is too heavyweight to be retained for a long time by your program, and it contains no useful information aside from being able to pull out pointers to widgets. A more apt way to do this would be to store pointers to all the widgets you need soon after glade_xml_new (perhaps as members of a struct), then dereference the GladeXML object. When you set up your callbacks, have this structure passed as the user pointer. Now all callbacks have access to the widgets in your window. In addition to the examples posted earlier, you can also download the source to any standard gtk program for additional examples. I used the devhelp source for this. -Jim I wasn't a fan of keeping the GladeXml object around due to the resources it used. Even though it's not as efficient as storing pointer, I wish I could just traverse up and down the the object tree for my pointer. I guess I'll be storing the pointers that I need. That would mean that after calling glade_xml_new() I need to call glade_xml_get_widget() on each object I will need and then save that pointer . . . right? Thanks, dave ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Finding a widget in a Glade interface
dhk wrote: I should have mentioned that by time I want to call glade_xml_get_widget() the GladeXML *xml created by xml = glade_xml_new(filename.glade, NULL, NULL); is out of scope. If I call open the file again to get the widget it has no affect on the running window. I need to get the widget from the running window from some callback. Any ideas? If you have a widget produced by that tree, you can retrieve the tree again with glade_get_widget_tree() [0] and then use glade_xml_get_widget() on the return value. [0]http://library.gnome.org/devel/libglade/stable/GladeXML.html#glade-get-widget-tree -- No one can have a higher opinion of him than I have, and I think he's a dirty little beast. -- W. S. Gilbert Eduardo M KALINOWSKI [EMAIL PROTECTED] http://move.to/hpkb ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Finding a widget in a Glade interface
On Thu, 31 Jul 2008 11:07:34 + dhk [EMAIL PROTECTED] wrote: Jim George wrote: I wasn't a fan of keeping the GladeXml object around due to the resources it used. Even though it's not as efficient as storing pointer, I wish I could just traverse up and down the the object tree for my pointer. I guess I'll be storing the pointers that I need. That would mean that after calling glade_xml_new() I need to call glade_xml_get_widget() on each object I will need and then save that pointer . . . right? You don't need special API to traverse Gtk widgets, and GladeXml is less than needed: just use GTK_IS_CONTAINER() and gtk_container_get_children() or gtk_container_forall(). If you want to go from the leafs to the root, use gtk_widget_get_parent(). -- Nicola ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Finding a widget in a Glade interface
dhk wrote: I should have mentioned that by time I want to call glade_xml_get_widget() the GladeXML *xml created by xml = glade_xml_new(filename.glade, NULL, NULL); is out of scope. If I call open the file again to get the widget it has no affect on the running window. I need to get the widget from the running window from some callback. Any ideas? In the old days glade would assign data points to each widget that worked out to essentially astatic string. You could then take the widget that was passed to the callback, look for the parent until you got to the head of the widget tree, then start searching for the data point you were looking for. If I recall, glade used to provide a function to make this searching easy. I am pretty sure libglade still allows for something similar. Actually, looking at the docs, I'm pretty sure that if you traced your way up to the root node in the widget tree, and used the glade_get_widget_name() on all the children nodes, you should be able to find the widget by name (string). ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: dynamic memory for everything?
Martin (OPENGeoMap) escribió: Hi http://library.gnome.org/devel/glib/2.17/glib-Date-and-Time-Functions.html#GDate I have a doubt about how they are working all classes in the glib. Is it always uses dynamic memory for everything? GDate* g_date_new (void) { GDate *d = g_new0 (GDate, 1); /* happily, 0 is the invalid flag for everything. */ return d; } That is the kind of data which GData in principle could be used either as a variable. What advantages are obtained using dynamic memory in GData or other simple structs with only integers and not related with gobject system? regards. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list