On Tue, Mar 18, 2008 at 3:35 PM, Aubanel MONNIER <aubanel@...400...> wrote:
Ok, I'v been fiddling with that and I'm quite stuck with some limitations of the prefs API. I need a way to get each children without knowing it's id (I did that with reprs ans XML::Nodes but that break encapsulation, should I add a function in the prefs API that returns a GSList of strings for the ids of the children to be queried later by the pref API ?)
Yes, we didn't need this before, but now that we need it, I think the best approach is to extend the prefs API. This had to happen sooner or later, you are just the first to hit the wall :)
I need a way to create a child preference. I have difficulies in making that work too, I tried something like: Node *parent=the_parent; Node new_child=parent->document()->createElement("group"); but that does not seem to work. Any hint ?
Did you attach the new_child to the_parent?
About breaking encapsulation, I'm not sure of what I must do, because the xml/nodes.h interface is already included in toolbox.cpp and it requires to add non-frequently used elsewhere functions into prefs and introduces additional memory considerations (should I free or should I go ? ) on the GSList.
I don't think prefs pose the risk of becoming a resource hog, at least not in the foreseeable future.
Another different topic, I need a way to be notified that a setting has been changed from the toolbox. I such a signal existing somewhere ?
When I needed it, I just added a listener to the repr of the pref setting, and was notified whenever that setting is changed by no matter who. E.g. look into the tool style indicator (at the right end of control bars of object-creating tools).