Re: How to create unique widget when reusing widget id's from a GladeXML object.



Tristan Van Berkom wrote:
If you are using one glade file for the tab contents and parsing it again
for each tab, then you get widgets in your runtime interface that have
the same name, thats not an issue for gtk+ - but, as you named them
yourself, its up to you to identify them some other way.

Im not sure I understood properly what you wrote, but if I did, I would
expect you to be using a list of structs or objects representing the
data and widgets in that tab.

Cheers,
                   -Tristan

On Mon, Aug 11, 2008 at 7:15 PM, dhk <dhkuhl optonline net> wrote:
dhk wrote:
I'm adding tabs to a notebook by getting the tab (a vbox) out of a
GladeXML object.  The tab widget returned from glade_xml_build_widget() can
be added to the notebook and everything works fine.

The problem is when more tabs are added.  It doesn't seem like the widget
id's on each tab are exclusive to that tab.  The last tab added behaves the
best, but if a previous tab is clicked data entered and events on that tab
appear on the last tab.  This appears to be because the widget id's are the
same in each tab because each tab was build from the same widget in the
GladeXML file.  What happens is when there are two tabs, the data placed in
a field on tab one shows up in the field on both tabs.  I thought the scope
of the widget added to one tab would be out of scope for all other tabs.

How can a unique widget be created by using the same widget from a
GladeXML object multiple times?

Thanks,
dave
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Does this have to do with referencing?  It looks like the same resources are
being used by the new widgets.  Any ideas?

Thanks,
dave


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


Are you saying that I have to get each object out of the widget and store their reference and data somewhere? That sounds like it could get messy. I thought just by adding a widget to a container, in this case a notebook container, would keep track of that widget as long a I could keep track of the page it's on.

What's happening is I add the same widget from the Glade xml, it's a vbox which is a tab page to a notebook, multiple times. Now I have a notebook of n pages. Each page is a form. The data and events on one page affect other pages which it shouldn't. Each page has a unique name so when I search that vbox widget for the page with focus I would expect to get the widgets of the form on that page, but I don't. So in a way I am keeping track of the widget by the unique name of the tab. Is this ok?

Thanks,
dave



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]