Author: kelnos
Date: 2008-07-27 01:06:54 +0000 (Sun, 27 Jul 2008)
New Revision: 27376

Modified:
   xfconf/trunk/common/xfconf-dbus.xml
   xfconf/trunk/docs/reference/tmpl/xfconf-backend.sgml
   xfconf/trunk/docs/reference/tmpl/xfconf-channel.sgml
   xfconf/trunk/docs/reference/tmpl/xfconf-unused.sgml
   xfconf/trunk/docs/reference/xfconf-sections.txt
   xfconf/trunk/xfconf-query/main.c
   xfconf/trunk/xfconf/xfconf-channel.c
   xfconf/trunk/xfconf/xfconf-channel.h
   xfconf/trunk/xfconf/xfconf.symbols
   xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
   xfconf/trunk/xfconfd/xfconf-backend.c
   xfconf/trunk/xfconfd/xfconf-backend.h
   xfconf/trunk/xfconfd/xfconf-daemon.c
Log:
make RemoveProperty and GetAllProperties interfaces easier to use

all removing multiple properties at once based on a subtree of the property
tree.  ditto for getting multiple properties at once

Modified: xfconf/trunk/common/xfconf-dbus.xml
===================================================================
--- xfconf/trunk/common/xfconf-dbus.xml 2008-07-26 12:27:03 UTC (rev 27375)
+++ xfconf/trunk/common/xfconf-dbus.xml 2008-07-27 01:06:54 UTC (rev 27376)
@@ -38,12 +38,16 @@
         </method>
         
         <!--
-             Array{String,Variant} org.xfce.Xfconf.GetAllProperties(String 
channel)
+             Array{String,Variant} org.xfce.Xfconf.GetAllProperties(String 
channel,
+                                                                    String 
property_base)
              
              @channel: A channel/application/namespace name.
+             @property_base: The root of poperties to return.
              
              Gets all the properties and values that exist in
-             @channel.
+             @channel that are rooted at @property_base.  Passing
+             "/" or the empty string as @property_base will return
+             all properties in the channel.
              
              Returns: An array of properties and values; the
                       properties are strings, and the values are 
@@ -51,6 +55,7 @@
         -->
         <method name="GetAllProperties">
             <arg direction="in" name="channel" type="s"/>
+            <arg direction="in" name="property_base" type="s"/>
             <arg direction="out" name="properties" type="a{sv}"/>
         </method>
         
@@ -73,30 +78,26 @@
         
         <!--
              void org.xfce.Xfconf.RemoveProperty(String channel,
-                                                 String property)
+                                                 String property,
+                                                 Boolean recursive)
              
              @channel: A channel/application/namespace name.
              @property: A property name.
+             @recursive: Whether the operation removes sub-properties.
              
-             Removes @property and its value from @channel.
+             Removes @property and its value from @channel.  If
+             @recursive is true, all sub-properties of the
+             specified property will be removed as well.  If the
+             special "/" property is specified for @property, and
+             @recursive is true, the entire channel will be removed.
         -->
         <method name="RemoveProperty">
             <arg direction="in" name="channel" type="s"/>
             <arg direction="in" name="property" type="s"/>
+            <arg direction="in" name="recursive" type="b"/>
         </method>
         
         <!--
-             void org.xfce.Xfconf.RemoveChannel(String channel)
-             
-             @channel: A channel/application/namespace name.
-             
-             Removes a channel and all properties in it.
-        -->
-        <method name="RemoveChannel">
-            <arg direction="in" name="channel" type="s"/>
-        </method>
-        
-        <!--
              void org.xfce.Xfconf.PropertyChanged(String channel,
                                                   String property.
                                                   Variant value)

Modified: xfconf/trunk/docs/reference/tmpl/xfconf-backend.sgml
===================================================================
--- xfconf/trunk/docs/reference/tmpl/xfconf-backend.sgml        2008-07-26 
12:27:03 UTC (rev 27375)
+++ xfconf/trunk/docs/reference/tmpl/xfconf-backend.sgml        2008-07-27 
01:06:54 UTC (rev 27376)
@@ -32,7 +32,6 @@
 @get_all: See xfconf_backend_get_all().
 @exists: See xfconf_backend_exists().
 @remove: See xfconf_backend_remove().
[EMAIL PROTECTED]: See xfconf_backend_remove_channel().
 @flush: See xfconf_backend_flush().
 @register_property_changed_func: See 
xfconf_backend_register_property_changed_func().
 @_xb_reserved0: Reserved for future expansion.
@@ -89,6 +88,7 @@
 
 @backend: 
 @channel: 
[EMAIL PROTECTED]: 
 @properties: 
 @error: 
 @Returns: 
@@ -115,21 +115,11 @@
 @backend: 
 @channel: 
 @property: 
[EMAIL PROTECTED]: 
 @error: 
 @Returns: 
 
 
-<!-- ##### FUNCTION xfconf_backend_remove_channel ##### -->
-<para>
-
-</para>
-
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
-
-
 <!-- ##### FUNCTION xfconf_backend_flush ##### -->
 <para>
 

Modified: xfconf/trunk/docs/reference/tmpl/xfconf-channel.sgml
===================================================================
--- xfconf/trunk/docs/reference/tmpl/xfconf-channel.sgml        2008-07-26 
12:27:03 UTC (rev 27375)
+++ xfconf/trunk/docs/reference/tmpl/xfconf-channel.sgml        2008-07-27 
01:06:54 UTC (rev 27376)
@@ -68,12 +68,22 @@
 @property: 
 
 
-<!-- ##### FUNCTION xfconf_channel_get_all ##### -->
+<!-- ##### FUNCTION xfconf_channel_remove_properties ##### -->
 <para>
 
 </para>
 
 @channel: 
[EMAIL PROTECTED]: 
+
+
+<!-- ##### FUNCTION xfconf_channel_get_properties ##### -->
+<para>
+
+</para>
+
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
 @Returns: 
 
 

Modified: xfconf/trunk/docs/reference/tmpl/xfconf-unused.sgml
===================================================================
--- xfconf/trunk/docs/reference/tmpl/xfconf-unused.sgml 2008-07-26 12:27:03 UTC 
(rev 27375)
+++ xfconf/trunk/docs/reference/tmpl/xfconf-unused.sgml 2008-07-27 01:06:54 UTC 
(rev 27376)
@@ -66,6 +66,16 @@
 
 @Returns: 
 
+<!-- ##### FUNCTION xfconf_backend_remove_channel ##### -->
+<para>
+
+</para>
+
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
+
 <!-- ##### FUNCTION xfconf_channel_begin_transaction ##### -->
 <para>
 
@@ -89,6 +99,14 @@
 @channel: 
 @Returns: 
 
+<!-- ##### FUNCTION xfconf_channel_get_all ##### -->
+<para>
+
+</para>
+
[EMAIL PROTECTED]: 
[EMAIL PROTECTED]: 
+
 <!-- ##### FUNCTION xfconf_channel_get_int64 ##### -->
 <para>
 

Modified: xfconf/trunk/docs/reference/xfconf-sections.txt
===================================================================
--- xfconf/trunk/docs/reference/xfconf-sections.txt     2008-07-26 12:27:03 UTC 
(rev 27375)
+++ xfconf/trunk/docs/reference/xfconf-sections.txt     2008-07-27 01:06:54 UTC 
(rev 27376)
@@ -4,7 +4,8 @@
 xfconf_channel_new
 xfconf_channel_has_property
 xfconf_channel_remove_property
-xfconf_channel_get_all
+xfconf_channel_remove_properties
+xfconf_channel_get_properties
 xfconf_channel_get_string
 xfconf_channel_get_string_list
 xfconf_channel_get_int

Modified: xfconf/trunk/xfconf/xfconf-channel.c
===================================================================
--- xfconf/trunk/xfconf/xfconf-channel.c        2008-07-26 12:27:03 UTC (rev 
27375)
+++ xfconf/trunk/xfconf/xfconf-channel.c        2008-07-27 01:06:54 UTC (rev 
27376)
@@ -412,33 +412,65 @@
     ERROR_DEFINE;
 
     if(!xfconf_client_remove_property(proxy, channel->channel_name, property,
-                                      ERROR))
+                                      FALSE, ERROR))
     {
         ERROR_CHECK;
     }
 }
 
 /**
- * xfconf_channel_get_all:
+ * xfconf_channel_remove_properties:
  * @channel: An #XfconfChannel.
+ * @property_base: The base property name of properties to remove.
  *
- * Retrieves all properties from @channel and stores them in a #GHashTable
- * in which the keys correspond to the string (gchar *) properties, and
- * the values correspond to variant (GValue *) values.  The keys and values
- * are owned by the hash table and should be copied if needed.
+ * Removes @property_base from @channel, and removes all
+ * sub-properties of @property_base as well.  To remove the
+ * entire channel, specify "/" or %NULL for @property_base.
+ **/
+void
+xfconf_channel_remove_properties(XfconfChannel *channel,
+                                 const gchar *property_base)
+{
+    DBusGProxy *proxy = _xfconf_get_dbus_g_proxy();
+    ERROR_DEFINE;
+
+    if(!xfconf_client_remove_property(proxy, channel->channel_name,
+                                      property_base ? property_base : "/",
+                                      TRUE, ERROR))
+    {
+        ERROR_CHECK;
+    }
+}
+
+/**
+ * xfconf_channel_get_properties:
+ * @channel: An #XfconfChannel.
+ * @property_base: The base property name of properties to retrieve.
  *
+ * Retrieves multiple properties from @channel and stores
+ * them in a #GHashTable in which the keys correspond to
+ * the string (gchar *) property names, and the values
+ * correspond to variant (GValue *) values.  The keys and
+ * values are owned by the hash table and should be copied
+ * if needed.  The value of the property specified by
+ * @property_base (if it exists) and all sub-properties are
+ * retrieved.  To retrieve all properties in the channel,
+ * specify "/" or %NULL for @property_base.
+ *
  * Returns: A newly-allocated #GHashTable, which should be freed with
  *          g_hash_table_destroy() when no longer needed.
  **/
 GHashTable *
-xfconf_channel_get_all(XfconfChannel *channel)
+xfconf_channel_get_properties(XfconfChannel *channel,
+                              const gchar *property_base)
 {
     DBusGProxy *proxy = _xfconf_get_dbus_g_proxy();
     GHashTable *properties = NULL;
     ERROR_DEFINE;
 
     if(!xfconf_client_get_all_properties(proxy, channel->channel_name,
-       &properties, ERROR))
+                                         property_base ? property_base : "/",
+                                         &properties, ERROR))
     {
         ERROR_CHECK;
         return NULL;

Modified: xfconf/trunk/xfconf/xfconf-channel.h
===================================================================
--- xfconf/trunk/xfconf/xfconf-channel.h        2008-07-26 12:27:03 UTC (rev 
27375)
+++ xfconf/trunk/xfconf/xfconf-channel.h        2008-07-27 01:06:54 UTC (rev 
27376)
@@ -46,8 +46,11 @@
 
 void xfconf_channel_remove_property(XfconfChannel *channel,
                                     const gchar *property);
+void xfconf_channel_remove_properties(XfconfChannel *channel,
+                                      const gchar *property_base);
 
-GHashTable *xfconf_channel_get_all(XfconfChannel *channel);
+GHashTable *xfconf_channel_get_properties(XfconfChannel *channel,
+                                          const gchar *property_base);
 
 /* basic types */
 

Modified: xfconf/trunk/xfconf/xfconf.symbols
===================================================================
--- xfconf/trunk/xfconf/xfconf.symbols  2008-07-26 12:27:03 UTC (rev 27375)
+++ xfconf/trunk/xfconf/xfconf.symbols  2008-07-27 01:06:54 UTC (rev 27376)
@@ -59,7 +59,8 @@
 xfconf_channel_new
 xfconf_channel_has_property
 xfconf_channel_remove_property
-xfconf_channel_get_all
+xfconf_channel_remove_properties
+xfconf_channel_get_properties
 xfconf_channel_get_string
 xfconf_channel_set_string
 xfconf_channel_get_int

Modified: xfconf/trunk/xfconf-query/main.c
===================================================================
--- xfconf/trunk/xfconf-query/main.c    2008-07-26 12:27:03 UTC (rev 27375)
+++ xfconf/trunk/xfconf-query/main.c    2008-07-27 01:06:54 UTC (rev 27376)
@@ -371,7 +371,7 @@
 
     if (list)
     {
-        GHashTable *channel_contents = xfconf_channel_get_all(channel);
+        GHashTable *channel_contents = xfconf_channel_get_properties(channel, 
NULL);
         if (channel_contents)
         {
             gint size = 0;

Modified: xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c
===================================================================
--- xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c        2008-07-26 
12:27:03 UTC (rev 27375)
+++ xfconf/trunk/xfconfd/xfconf-backend-perchannel-xml.c        2008-07-27 
01:06:54 UTC (rev 27376)
@@ -145,6 +145,7 @@
                                                   GError **error);
 static gboolean xfconf_backend_perchannel_xml_get_all(XfconfBackend *backend,
                                                       const gchar *channel,
+                                                      const gchar 
*property_base,
                                                       GHashTable *properties,
                                                       GError **error);
 static gboolean xfconf_backend_perchannel_xml_exists(XfconfBackend *backend,
@@ -155,10 +156,8 @@
 static gboolean xfconf_backend_perchannel_xml_remove(XfconfBackend *backend,
                                                      const gchar *channel,
                                                      const gchar *property,
+                                                     gboolean recursive,
                                                      GError **error);
-static gboolean xfconf_backend_perchannel_xml_remove_channel(XfconfBackend 
*backend,
-                                                             const gchar 
*channel,
-                                                             GError **error);
 static gboolean xfconf_backend_perchannel_xml_flush(XfconfBackend *backend,
                                                     GError **error);
 static void 
xfconf_backend_perchannel_xml_register_property_changed_func(XfconfBackend 
*backend,
@@ -183,6 +182,8 @@
                                            gboolean locked);
 static XfconfProperty *xfconf_proptree_lookup(GNode *proptree,
                                               const gchar *name);
+static GNode *xfconf_proptree_lookup_node(GNode *proptree,
+                                          const gchar *name);
 static gboolean xfconf_proptree_remove(GNode *proptree,
                                        const gchar *name);
 static void xfconf_proptree_destroy(GNode *proptree);
@@ -241,7 +242,6 @@
     iface->get_all = xfconf_backend_perchannel_xml_get_all;
     iface->exists = xfconf_backend_perchannel_xml_exists;
     iface->remove = xfconf_backend_perchannel_xml_remove;
-    iface->remove_channel = xfconf_backend_perchannel_xml_remove_channel;
     iface->flush = xfconf_backend_perchannel_xml_flush;
     iface->register_property_changed_func = 
xfconf_backend_perchannel_xml_register_property_changed_func;
 }
@@ -409,6 +409,7 @@
 static gboolean
 xfconf_backend_perchannel_xml_get_all(XfconfBackend *backend,
                                       const gchar *channel,
+                                      const gchar *property_base,
                                       GHashTable *properties,
                                       GError **error)
 {
@@ -423,14 +424,26 @@
             return FALSE;
     }
 
-    for(cur = g_node_first_child(props_tree);
-        cur;
-        cur = g_node_next_sibling(cur))
-    {
+    if(property_base[0] && property_base[1]) {
+        /* it's not "" or "/" */
+        cur = xfconf_proptree_lookup_node(props_tree, property_base);
+        if(!cur) {
+            if(error) {
+                g_set_error(error, XFCONF_ERROR, 
XFCONF_ERROR_PROPERTY_NOT_FOUND,
+                             _("Property \"%s\" does not exist on channel 
\"%s\""),
+                             property_base, channel);
+            }
+            return FALSE;
+        }
+
+        g_strlcpy(cur_path, property_base, sizeof(cur_path));
+    } else {
+        cur = props_tree;
         cur_path[0] = 0;
-        xfconf_proptree_node_to_hash_table(cur, properties, cur_path);
     }
 
+    xfconf_proptree_node_to_hash_table(cur, properties, cur_path);
+
     return TRUE;
 }
 
@@ -471,40 +484,6 @@
     return TRUE;
 }
 
-static gboolean
-xfconf_backend_perchannel_xml_remove(XfconfBackend *backend,
-                                     const gchar *channel,
-                                     const gchar *property,
-                                     GError **error)
-{
-    XfconfBackendPerchannelXml *xbpx = XFCONF_BACKEND_PERCHANNEL_XML(backend);
-    GNode *properties = g_tree_lookup(xbpx->channels, channel);
-
-    if(!properties) {
-        properties = xfconf_backend_perchannel_xml_load_channel(xbpx, channel,
-                                                                error);
-        if(!properties)
-            return FALSE;
-    }
-
-    if(!xfconf_proptree_remove(properties, property)) {
-        if(error) {
-            g_set_error(error, XFCONF_ERROR,
-                        XFCONF_ERROR_PROPERTY_NOT_FOUND,
-                        _("Property \"%s\" does not exist on channel \"%s\""),
-                        property, channel);
-        }
-        return FALSE;
-    }
-
-    if(xbpx->prop_changed_func)
-        xbpx->prop_changed_func(backend, channel, property, 
xbpx->prop_changed_data);
-
-    xfconf_backend_perchannel_xml_schedule_save(xbpx, channel);
-
-    return TRUE;
-}
-
 typedef struct
 {
     XfconfBackend *backend;
@@ -526,9 +505,10 @@
 }
 
 static gboolean
-xfconf_backend_perchannel_xml_remove_channel(XfconfBackend *backend,
-                                             const gchar *channel,
-                                             GError **error)
+do_remove_channel(XfconfBackend *backend,
+                  const gchar *channel,
+                  GNode *properties,
+                  GError **error)
 {
     XfconfBackendPerchannelXml *xbpx = XFCONF_BACKEND_PERCHANNEL_XML(backend);
     gchar *filename;
@@ -545,14 +525,8 @@
     }
 
     if(xbpx->prop_changed_func) {
-        GNode *properties = g_tree_lookup(xbpx->channels, channel);
         PropChangeData pdata;
 
-        if(!properties) {
-            properties = xfconf_backend_perchannel_xml_load_channel(xbpx,
-                                                                    channel,
-                                                                    NULL);
-        }
         pdata.backend = backend;
         pdata.channel = channel;
         g_node_children_foreach(properties, G_TRAVERSE_ALL,
@@ -577,6 +551,77 @@
 }
 
 static gboolean
+xfconf_backend_perchannel_xml_remove(XfconfBackend *backend,
+                                     const gchar *channel,
+                                     const gchar *property,
+                                     gboolean recursive,
+                                     GError **error)
+{
+    XfconfBackendPerchannelXml *xbpx = XFCONF_BACKEND_PERCHANNEL_XML(backend);
+    GNode *properties = g_tree_lookup(xbpx->channels, channel);
+
+    if(!properties) {
+        properties = xfconf_backend_perchannel_xml_load_channel(xbpx, channel,
+                                                                error);
+        if(!properties)
+            return FALSE;
+    }
+
+    if(!recursive) {
+        if(!xfconf_proptree_remove(properties, property)) {
+            if(error) {
+                g_set_error(error, XFCONF_ERROR,
+                            XFCONF_ERROR_PROPERTY_NOT_FOUND,
+                            _("Property \"%s\" does not exist on channel 
\"%s\""),
+                            property, channel);
+            }
+            return FALSE;
+        }
+
+        if(xbpx->prop_changed_func)
+            xbpx->prop_changed_func(backend, channel, property, 
xbpx->prop_changed_data);
+    } else {
+        GNode *top;
+        XfconfProperty *prop;
+        
+        if(property[0] && property[1]) {
+            PropChangeData pdata;
+
+            /* it's not "" or "/" */
+            top = xfconf_proptree_lookup_node(properties, property);
+            if(!top) {
+                if(error) {
+                    g_set_error(error, XFCONF_ERROR,
+                                XFCONF_ERROR_PROPERTY_NOT_FOUND,
+                                _("Property \"%s\" does not exist on channel 
\"%s\""),
+                                property, channel);
+                }
+                return FALSE;
+            }
+
+            g_node_unlink(top);
+            prop = top->data;
+            if(G_VALUE_TYPE(&prop->value) && xbpx->prop_changed_func)
+                xbpx->prop_changed_func(backend, channel, property, 
xbpx->prop_changed_data);
+
+            pdata.backend = backend;
+            pdata.channel = channel;
+            g_node_children_foreach(top, G_TRAVERSE_ALL,
+                                    nodes_do_propchange_remove, &pdata);
+
+            xfconf_proptree_destroy(top);
+        } else {
+            /* remove the entire channel */
+            return do_remove_channel(backend, channel, properties, error);
+        }
+    }
+
+    xfconf_backend_perchannel_xml_schedule_save(xbpx, channel);
+
+    return TRUE;
+}
+
+static gboolean
 xfconf_backend_perchannel_xml_flush(XfconfBackend *backend,
                                     GError **error)
 {

Modified: xfconf/trunk/xfconfd/xfconf-backend.c
===================================================================
--- xfconf/trunk/xfconfd/xfconf-backend.c       2008-07-26 12:27:03 UTC (rev 
27375)
+++ xfconf/trunk/xfconfd/xfconf-backend.c       2008-07-27 01:06:54 UTC (rev 
27376)
@@ -264,13 +264,18 @@
  * xfconf_backend_get_all:
  * @backend: The #XfconfBackend.
  * @channel: A channel name.
+ * @property_base: The base of properties to return.
  * @properties: A #GHashTable.
  * @error: An error return.
  *
- * Gets all properties and values on @channel and stores them in
+ * Gets multiple properties and values on @channel and stores them in
  * @properties, which is already initialized to hold #gchar* keys and
- * #GValue<!-- -->* values.
+ * #GValue<!-- -->* values.  The @property_base parameter can be
+ * used to limit the retrieval to a sub-tree of the property tree.
  *
+ * A value of the empty string ("") or forward slash ("/") for
+ * @property_base indicates the entire channel.
+ *
  * Return value: The backend should return %TRUE if the operation
  *               was successful, or %FALSE otherwise.  On %FALSE,
  *               @error should be set to a description of the failure.
@@ -278,18 +283,25 @@
 gboolean
 xfconf_backend_get_all(XfconfBackend *backend,
                        const gchar *channel,
+                       const gchar *property_base,
                        GHashTable *properties,
                        GError **error)
 {
     XfconfBackendInterface *iface = XFCONF_BACKEND_GET_INTERFACE(backend);
     
     xfconf_backend_return_val_if_fail(iface && iface->get_all && channel
-                                      && *channel && properties
+                                      && *channel && property_base
+                                      && properties
                                       && (!error || !*error), FALSE);
     if(!xfconf_channel_is_valid(channel, error))
         return FALSE;
+    if(*property_base && !(property_base[0] == '/' && !property_base[1])
+       && !xfconf_property_is_valid(property_base, error))
+    {
+        return FALSE;
+    }
 
-    return iface->get_all(backend, channel, properties, error);
+    return iface->get_all(backend, channel, property_base, properties, error);
 }
 
 /**
@@ -333,9 +345,13 @@
  * @backend: The #XfconfBackend.
  * @channel: A channel name.
  * @property: A property name.
+ * @recursive: Whether or not the remove is recursive.
  * @error: An error return.
  *
  * Removes the property identified by @property from @channel.
+ * If @recursive is %TRUE, all sub-properties of @property will be
+ * removed as well.  If the empty string ("") or a forward slash ("/")
+ * is specified for @property, the entire channel will be removed.
  *
  * Return value: The backend should return %TRUE if the operation
  *               was successful, or %FALSE otherwise.  On %FALSE,
@@ -345,6 +361,7 @@
 xfconf_backend_remove(XfconfBackend *backend,
                       const gchar *channel,
                       const gchar *property,
+                      gboolean recursive,
                       GError **error)
 {
     XfconfBackendInterface *iface = XFCONF_BACKEND_GET_INTERFACE(backend);
@@ -354,38 +371,21 @@
                                       && (!error || !*error), FALSE);
     if(!xfconf_channel_is_valid(channel, error))
         return FALSE;
-    if(!xfconf_property_is_valid(property, error))
-        return FALSE;
-    
-    return iface->remove(backend, channel, property, error);
-}
 
-/**
- * xfconf_backend_remove_channel:
- * @backend: An #XfconfBackend.
- * @channel: A channel name.
- * @error: An error return.
- *
- * Removes @channel (and al its properties) from the confguration store.
- *
- * Return value: The backend should return %TRUE if the operation
- *               was successful, or %FALSE otherwise.  On %FALSE,
- *               @error should be set to a description of the failure.
- **/ 
-gboolean
-xfconf_backend_remove_channel(XfconfBackend *backend,
-                              const gchar *channel,
-                              GError **error)
-{
-    XfconfBackendInterface *iface = XFCONF_BACKEND_GET_INTERFACE(backend);
-    
-    xfconf_backend_return_val_if_fail(iface && iface->remove_channel && channel
-                                      && *channel
-                                      && (!error || !*error), FALSE);
-    if(!xfconf_channel_is_valid(channel, error))
+    if(!recursive && (!*property || (property[0] == '/' && !property[1]))) {
+        if(error) {
+            g_set_error(error, XFCONF_ERROR, XFCONF_ERROR_INVALID_PROPERTY,
+                        _("The property name can only be empty or \"/\" if a 
recursive remove was specified."));
+        }
         return FALSE;
+    }
+    if(*property && !(property[0] == '/' && !property[1])
+       && !xfconf_property_is_valid(property, error))
+    {
+        return FALSE;
+    }
 
-    return iface->remove_channel(backend, channel, error);
+    return iface->remove(backend, channel, property, recursive, error);
 }
 
 /**

Modified: xfconf/trunk/xfconfd/xfconf-backend.h
===================================================================
--- xfconf/trunk/xfconfd/xfconf-backend.h       2008-07-26 12:27:03 UTC (rev 
27375)
+++ xfconf/trunk/xfconfd/xfconf-backend.h       2008-07-27 01:06:54 UTC (rev 
27376)
@@ -78,6 +78,7 @@
     
     gboolean (*get_all)(XfconfBackend *backend,
                         const gchar *channel,
+                        const gchar *property_base,
                         GHashTable *properties,
                         GError **error);
     
@@ -90,12 +91,9 @@
     gboolean (*remove)(XfconfBackend *backend,
                        const gchar *channel,
                        const gchar *property,
+                       gboolean recursive,
                        GError **error);
     
-    gboolean (*remove_channel)(XfconfBackend *backend,
-                               const gchar *channel,
-                               GError **error);
-    
     gboolean (*flush)(XfconfBackend *backend,
                       GError **error);
 
@@ -129,6 +127,7 @@
 
 gboolean xfconf_backend_get_all(XfconfBackend *backend,
                                 const gchar *channel,
+                                const gchar *property_base,
                                 GHashTable *properties,
                                 GError **error);
 
@@ -141,12 +140,9 @@
 gboolean xfconf_backend_remove(XfconfBackend *backend,
                                const gchar *channel,
                                const gchar *property,
+                               gboolean recursive,
                                GError **error);
 
-gboolean xfconf_backend_remove_channel(XfconfBackend *backend,
-                                       const gchar *channel,
-                                       GError **error);
-    
 gboolean xfconf_backend_flush(XfconfBackend *backend,
                               GError **error);
 

Modified: xfconf/trunk/xfconfd/xfconf-daemon.c
===================================================================
--- xfconf/trunk/xfconfd/xfconf-daemon.c        2008-07-26 12:27:03 UTC (rev 
27375)
+++ xfconf/trunk/xfconfd/xfconf-daemon.c        2008-07-27 01:06:54 UTC (rev 
27376)
@@ -43,6 +43,7 @@
                                     GError **error);
 static gboolean xfconf_get_all_properties(XfconfDaemon *xfconfd,
                                           const gchar *channel,
+                                          const gchar *property_base,
                                           GHashTable **properties,
                                           GError **error);
 static gboolean xfconf_property_exists(XfconfDaemon *xfconfd,
@@ -53,10 +54,8 @@
 static gboolean xfconf_remove_property(XfconfDaemon *xfconfd,
                                        const gchar *channel,
                                        const gchar *property,
+                                       gboolean recursive,
                                        GError **error);
-static gboolean xfconf_remove_channel(XfconfDaemon *xfconfd,
-                                      const gchar *channel,
-                                      GError **error);
 static gboolean xfconf_gui_show_list(XfconfDaemon *xfconfd,
                                      const gchar *display,
                                      GError **error);
@@ -249,6 +248,7 @@
 static gboolean
 xfconf_get_all_properties(XfconfDaemon *xfconfd,
                           const gchar *channel,
+                          const gchar *property_base,
                           GHashTable **properties,
                           GError **error)
 {
@@ -263,9 +263,11 @@
     
     /* get all properties from all backends.  if they all fail, return FALSE */
     for(l = xfconfd->backends; l; l = l->next) {
-        if(xfconf_backend_get_all(l->data, channel, *properties, error))
+        if(xfconf_backend_get_all(l->data, channel, property_base,
+                                  *properties, error))
+        {
             ret = TRUE;
-        else if(l->next && error && *error) {
+        } else if(l->next && error && *error) {
             g_error_free(*error);
             *error = NULL;
         }
@@ -276,9 +278,6 @@
         *properties = NULL;
     }
     
-    /* FIXME: presumably, |*properties| leaks.  how do we fix this?  perhaps
-     * using the org.freedesktop.DBus.GLib.Async annotation? */
-    
     return ret;
 }
 
@@ -316,6 +315,7 @@
 xfconf_remove_property(XfconfDaemon *xfconfd,
                        const gchar *channel,
                        const gchar *property,
+                       gboolean recursive,
                        GError **error)
 {
     gboolean ret = FALSE;
@@ -326,7 +326,7 @@
      * later */
     
     for(l = xfconfd->backends; l; l = l->next) {
-        if(xfconf_backend_remove(l->data, channel, property, error))
+        if(xfconf_backend_remove(l->data, channel, property, recursive, error))
             ret = TRUE;
         else if(l->next && error && *error) {
             g_error_free(*error);
@@ -338,30 +338,6 @@
 }
 
 static gboolean
-xfconf_remove_channel(XfconfDaemon *xfconfd,
-                      const gchar *channel,
-                      GError **error)
-{
-    gboolean ret = FALSE;
-    GList *l;
-    
-    /* while technically all backends but the first should be opened read-only,
-     * we need to remove from all backends so the channel doesn't reappear
-     * later */
-    
-    for(l = xfconfd->backends; l; l = l->next) {
-        if(xfconf_backend_remove_channel(l->data, channel, error))
-            ret = TRUE;
-        else if(l->next && error && *error) {
-            g_error_free(*error);
-            *error = NULL;
-        }
-    }
-    
-    return ret;
-}
-
-static gboolean
 xfconf_gui_show_list(XfconfDaemon *xfconfd,
                      const gchar *display,
                      GError **error)

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to