[gnome-panel/wip/3.0-freeze-break] panel: Add panel_gsettings_remove_all_from_strv() API



commit e7beb787e10b193695c69b3e0199bd5c458a3bde
Author: Vincent Untz <vuntz gnome org>
Date:   Fri Mar 25 18:21:03 2011 +0100

    panel: Add panel_gsettings_remove_all_from_strv() API

 gnome-panel/libpanel-util/panel-gsettings.c |   27 +++++++++++++++++++++++++++
 gnome-panel/libpanel-util/panel-gsettings.h |    4 ++++
 2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/gnome-panel/libpanel-util/panel-gsettings.c b/gnome-panel/libpanel-util/panel-gsettings.c
index 8d1368f..8f0ac9d 100644
--- a/gnome-panel/libpanel-util/panel-gsettings.c
+++ b/gnome-panel/libpanel-util/panel-gsettings.c
@@ -121,3 +121,30 @@ panel_gsettings_append_strv (GSettings   *settings,
 
         return retval;
 }
+
+gboolean
+panel_gsettings_remove_all_from_strv (GSettings   *settings,
+                                      const gchar *key,
+                                      const gchar *value)
+{
+        GArray    *array;
+        gchar    **old;
+        gint       i;
+        gboolean   retval;
+
+        old = g_settings_get_strv (settings, key);
+        array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+
+        for (i = 0; old[i] != NULL; i++) {
+                if (g_strcmp0 (old[i], value) != 0)
+                        array = g_array_append_val (array, old[i]);
+        }
+
+        retval = g_settings_set_strv (settings, key,
+                                      (const gchar **) array->data);
+
+        g_strfreev (old);
+        g_array_free (array, TRUE);
+
+        return retval;
+}
diff --git a/gnome-panel/libpanel-util/panel-gsettings.h b/gnome-panel/libpanel-util/panel-gsettings.h
index c9630b4..852ca72 100644
--- a/gnome-panel/libpanel-util/panel-gsettings.h
+++ b/gnome-panel/libpanel-util/panel-gsettings.h
@@ -36,6 +36,10 @@ gboolean panel_gsettings_append_strv      (GSettings   *settings,
                                            const gchar *key,
                                            const gchar *value);
 
+gboolean panel_gsettings_remove_all_from_strv (GSettings   *settings,
+                                               const gchar *key,
+                                               const gchar *value);
+
 G_END_DECLS
 
 #endif /* __PANEL_GSETTINGS_H__ */



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