[gnome-online-accounts/gnome-3-6] Rename goa_util_set_keyfile_boolean as goa_utils_keyfile_set_boolean



commit 91327fa235c8c2da3010539aee3ef77645fc15d4
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Nov 13 15:36:10 2012 +0100

    Rename goa_util_set_keyfile_boolean as goa_utils_keyfile_set_boolean
    
    ... and move it to goautils.[ch] from goaprovider.c so that it can be
    used from other places.
    
    Fixes: https://bugzilla.gnome.org/687962

 src/goabackend/goaprovider.c |   53 +----------------------------------------
 src/goabackend/goautils.c    |   50 +++++++++++++++++++++++++++++++++++++++
 src/goabackend/goautils.h    |    2 +
 3 files changed, 54 insertions(+), 51 deletions(-)
---
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 53ff0f5..306f7c9 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -37,6 +37,7 @@
 #endif
 
 #include "goaeditablelabel.h"
+#include "goautils.h"
 
 /**
  * SECTION:goaprovider
@@ -863,56 +864,6 @@ goa_util_lookup_keyfile_boolean (GoaObject    *object,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static void
-goa_util_set_keyfile_boolean (GoaAccount *account, const gchar *key, gboolean value)
-{
-  GError *error;
-  GKeyFile *key_file;
-  gchar *contents;
-  gchar *group;
-  gchar *path;
-  gsize length;
-
-  contents = NULL;
-
-  path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
-  group = g_strdup_printf ("Account %s", goa_account_get_id (account));
-
-  key_file = g_key_file_new ();
-  error = NULL;
-  if (!g_key_file_load_from_file (key_file,
-                                  path,
-                                  G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
-                                  &error))
-    {
-      goa_warning ("Error loading keyfile %s: %s (%s, %d)",
-                   path,
-                   error->message,
-                   g_quark_to_string (error->domain),
-                   error->code);
-      g_error_free (error);
-      goto out;
-    }
-
-  g_key_file_set_boolean (key_file, group, key, value);
-  contents = g_key_file_to_data (key_file, &length, NULL);
-
-  error = NULL;
-  if (!g_file_set_contents (path, contents, length, &error))
-    {
-      g_prefix_error (&error, "Error writing key-value-file %s: ", path);
-      goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
-      g_error_free (error);
-      goto out;
-    }
-
- out:
-  g_free (contents);
-  g_key_file_free (key_file);
-  g_free (group);
-  g_free (path);
-}
-
 void
 goa_util_account_notify_property_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
 {
@@ -928,7 +879,7 @@ goa_util_account_notify_property_cb (GObject *object, GParamSpec *pspec, gpointe
   name = g_param_spec_get_name (pspec);
 
   g_object_get (account, name, &value, NULL);
-  goa_util_set_keyfile_boolean (account, key, !value);
+  goa_utils_keyfile_set_boolean (account, key, !value);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 50c337c..199081c 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -344,6 +344,56 @@ goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key)
 }
 
 void
+goa_utils_keyfile_set_boolean (GoaAccount *account, const gchar *key, gboolean value)
+{
+  GError *error;
+  GKeyFile *key_file;
+  gchar *contents;
+  gchar *group;
+  gchar *path;
+  gsize length;
+
+  contents = NULL;
+
+  path = g_strdup_printf ("%s/goa-1.0/accounts.conf", g_get_user_config_dir ());
+  group = g_strdup_printf ("Account %s", goa_account_get_id (account));
+
+  key_file = g_key_file_new ();
+  error = NULL;
+  if (!g_key_file_load_from_file (key_file,
+                                  path,
+                                  G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
+                                  &error))
+    {
+      goa_warning ("Error loading keyfile %s: %s (%s, %d)",
+                   path,
+                   error->message,
+                   g_quark_to_string (error->domain),
+                   error->code);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_key_file_set_boolean (key_file, group, key, value);
+  contents = g_key_file_to_data (key_file, &length, NULL);
+
+  error = NULL;
+  if (!g_file_set_contents (path, contents, length, &error))
+    {
+      g_prefix_error (&error, "Error writing key-value-file %s: ", path);
+      goa_warning ("%s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+      goto out;
+    }
+
+ out:
+  g_free (contents);
+  g_key_file_free (key_file);
+  g_free (group);
+  g_free (path);
+}
+
+void
 goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value)
 {
   GError *error;
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 70d2fee..f38828f 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -67,6 +67,8 @@ gboolean         goa_utils_store_credentials_for_object_sync (GoaProvider    *pr
 
 void             goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key);
 
+void             goa_utils_keyfile_set_boolean (GoaAccount *account, const gchar *key, gboolean value);
+
 void             goa_utils_keyfile_set_string (GoaAccount *account, const gchar *key, const gchar *value);
 
 G_END_DECLS



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