! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Remove property including all children
Status:
RESOLVED: FIXED
Product:
Xfconf
Component:
Libxfconf

Comments

Description Nick Schermer editbugs 2008-07-25 08:49:11 CEST
It would be nice to have a function to remove a property including all the children. This way you can remove a group of properties.

It's not that hard to implement if you use xfconf_channel_get_all internally and remove all properties that start with the property name, but that's probably not optimal (but is guess nobody cares).
Comment 1 Brian J. Tarricone (not reading bugmail) 2008-07-25 16:12:44 CEST
I'd rather not complicate the dbus interface with a new method (it already has more than I'd like).  If you really forsee the need to remove a subset of properties that often, maybe you should just use separate channels?  Unless you'd like to describe your use-case a bit more...
Comment 2 Nick Schermer editbugs 2008-07-25 17:33:46 CEST
Well, I'm curretly writing the display settings code, which works with schemes. All the schemes are saved like this:

<property name="Default" type="empty">
  <property name="Layout" type="string" value="Screens"/>
  <property name="Primary" type="empty">
    <property name="Rotation" type="int" value="0"/>
    <property name="Resolution" type="string" value="1680x1050"/>
    <property name="RefreshRate" type="double" value="50.000000"/>
  </property>
</property>

Currently, when a scheme is removed (and most likely also saved when the layout changes), i have to grab the hash table and remove all the properties that start with /Default. I think more people would like to do things like this, so the hash table way of removing could be added to libxfconf. This way you don't need to change the dbus infterface, but provide a common way to remove a property with all its children.

In this case, multiple channels makes it too complicated IMHO.
Comment 3 Brian J. Tarricone (not reading bugmail) 2008-07-25 18:56:06 CEST
Ah ok, yeah, multiple channels are probably not a good idea here.

Out of curiosity: are you more concerned here with convenience from the app developer's point of view, or with performance (many round-trips for each prop remove)?

I guess we could have xfconf_channel_remove_all() that takes a "base" param so you'd pass it "/Default" as base to remove /Default and everything under it.  Using the hash table method (or just a simple list) of props to remove doesn't really save the app dev any work since they still have to iterate over the hash table to find the props they want to kill.

Actually, this concept could be extended to _get_all() -- _get_all() could have a base param as well, so only a subset of props could be returned in the hash table.  I guess this doesn't really save any CPU/memory, since the dbus interface would have to be modified to really take advantage of this.  But I guess changing the dbus interface isn't a big deal, esp if the libxfconf API changes as well.  In that case I might as well just change the dbus interface as well -- it's not like there's another independent implementation of the lib or daemon...

So... Stephan, what do you think?  I'd like to make a dbus interface change:

Array{String,Variant} org.xfce.Xfconf.GetAllProperties(String channel,
                                                       String property_base)

void org.xfce.Xfconf.RemoveProperty(String channel,
                                    String property,
                                    Boolean recursive)

And a libxfconf API change/add:

GHashTable *xfconf_channel_get_all(XfconfChannel *channel,
                                   const gchar *base);

void xfconf_channel_remove_all(XfconfChannel *channel,
                               const gchar *base);

If you pass NULL or "/" as base, you get all properties.  A better name for _remove_all() would be welcome if anyone has a good idea.

I've also never liked the RemoveChannel() dbus method -- could we maybe remove this entirely, and then a RemoveProperty("FooChanel", "/", TRUE) would just remove the entire channel?  I don't think I've even put xfconf_channel_remove() in the libxfconf API yet, so this wouldn't be a big deal.

What do you think?
Comment 4 Nick Schermer editbugs 2008-07-25 21:55:09 CEST
(In reply to comment #3)
> Ah ok, yeah, multiple channels are probably not a good idea here.
> 
> Out of curiosity: are you more concerned here with convenience from the app
> developer's point of view, or with performance (many round-trips for each prop
> remove)?

Normally I do care about performance (altough faster is always better ^_^), but this time is move a convenience thing. Assuming you're not using this kind of remove a lot and storing 10e9 properties in 1 channel.

I think the api/dbus changes you suggested look good, makes sence. You've got my vote.
Comment 5 Brian J. Tarricone (not reading bugmail) 2008-07-27 01:07:31 CEST
Ok, this stuff's done.

Bug #4245

Reported by:
Nick Schermer
Reported on: 2008-07-25
Last modified on: 2015-02-16

People

Assignee:
Brian J. Tarricone (not reading bugmail)
CC List:
0 users

Version

Version:
GIT Master

Attachments

Additional information