! 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 !
Unbind all properties on an object
Status:
RESOLVED: FIXED
Product:
Xfconf
Component:
Libxfconf

Comments

Description Nick Schermer editbugs 2008-07-28 10:08:09 CEST
The property binding code works great, but it would be useful to
unbind all properties on an object. Let me explain the use case:

With property binding together with Schemes/devices you have 
to remember the previous name when unbinding.

Example for the mouse settings:

1) Bind a property to for a device:

   g_snprintf (property, sizeof (property), "/%s/Acceleration", device_name);
   xfconf_g_property_bind (channel, property, G_TYPE_DOUBLE, adjustment, "value");
   gchar *current_device_name = device_name;

2) User selects another device in the list:

   g_snprintf (property, sizeof (property), "/%s/Acceleration", *current_device_name);
   xfconf_g_property_unbind (channel, property, adjustment, "value");
   
   g_snprintf (property, sizeof (property), "/%s/Acceleration", device_name);
   xfconf_g_property_bind (channel, property, G_TYPE_DOUBLE, adjustment, "value");
   g_free (current_device_name);
   current_device_name = device_name;

As you can see you need to remember the previous device name to unbind, 
while I only want to unbind all the binding on the object.

It would be nice to unbind all properties on an object using a single command:

void xfconf_g_property_unbind_all (XfconfChannel *channel, GObject *object);

This way you can easily change bindings when the user selects another device:
xfconf_g_property_unbind_all (channel, adjustment);
g_snprintf (property, sizeof (property), "/%s/Acceleration", device_name);
xfconf_g_property_bind (channel, property, G_TYPE_DOUBLE, adjustment, "value");
Comment 1 Brian J. Tarricone (not reading bugmail) 2008-07-28 18:08:08 CEST
Yeah, good idea.  Do you care about the XfconfChannel?  I mean, does it make as much sense just to take a GObject and unbind all props on that object regardless of what channel it's bound to?
Comment 2 Nick Schermer editbugs 2008-07-28 18:35:32 CEST
Not really, but you've attached the binding data to the channel, so I though...
Comment 3 Nick Schermer editbugs 2008-07-28 21:37:30 CEST
Created attachment 1750 
v1

Patch to implement xfconf_g_property_unbind_all(GObject *object).

Changes:
* New function xfconf_g_property_unbind_all.
* Bindings list is now set to the object, not the channel.
* Changed an append to prepend, here it can't hurt.

Normal binding seems to work fine, haven't tried unbinding since we don't use it anywhere atm. Will write some code to test it tomorrow if you want to change it this way.
Comment 4 Brian J. Tarricone (not reading bugmail) 2008-07-28 21:41:34 CEST
Looks good, go ahead.  Please regen the docs and check in any needed .sgml changes as well.  If you're not set up with gtk-doc and it's a pain, don't worry about it.
Comment 5 Nick Schermer editbugs 2008-07-29 06:24:01 CEST
Ok, will commit it tonight the patch after I've tested the unbindings.

I'll attach a patch here (after the commit) with a test for (un)bindings, so you can take a look at it.
Comment 6 Nick Schermer editbugs 2008-07-29 06:25:17 CEST
Err. good morning, try 2:
Ok, will commit the patch tonight after I've tested the unbindings.
Comment 7 Nick Schermer editbugs 2008-07-29 19:27:30 CEST
Tested the code and committed in revision 27399. Will post a patch to test the bindings in another bug.

Bug #4252

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

People

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

Version

Version:
4.5.91 (4.6beta1)

Attachments

v1 (3.98 KB, patch)
2008-07-28 21:37 CEST , Nick Schermer
no flags

Additional information