[frogr] Minor cleanup in FrogrConfig and FrogrAccount



commit 28597440d78ecb7244c718bfb1474ab966080837
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Thu Apr 5 15:57:20 2012 +0200

    Minor cleanup in FrogrConfig and FrogrAccount

 src/frogr-account.c |   13 ++++---------
 src/frogr-account.h |    3 +++
 src/frogr-config.c  |    5 +----
 src/frogr-config.h  |    3 +++
 4 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/frogr-account.c b/src/frogr-account.c
index 247f6fe..da3b0b5 100644
--- a/src/frogr-account.c
+++ b/src/frogr-account.c
@@ -22,9 +22,6 @@
 
 #include "frogr-account.h"
 
-/* Increase this when changing the xml schema for storing accounts */
-#define ACCOUNTS_FORMAT_VERSION "2"
-
 #define FROGR_ACCOUNT_GET_PRIVATE(object)               \
   (G_TYPE_INSTANCE_GET_PRIVATE ((object),               \
                                 FROGR_TYPE_ACCOUNT,     \
@@ -273,7 +270,7 @@ frogr_account_class_init (FrogrAccountClass *klass)
                                "version",
                                "Version of the format used to store"
                                "the details for an account",
-                               ACCOUNTS_FORMAT_VERSION,
+                               ACCOUNTS_CURRENT_VERSION,
                                G_PARAM_READWRITE);
   g_object_class_install_property (obj_class, PROP_VERSION, pspec);
 
@@ -336,17 +333,14 @@ frogr_account_init (FrogrAccount *self)
 FrogrAccount *
 frogr_account_new (void)
 {
-  return FROGR_ACCOUNT (g_object_new (FROGR_TYPE_ACCOUNT, NULL));
+  return frogr_account_new_full (NULL, NULL);
 }
 
 FrogrAccount *
 frogr_account_new_with_token (const gchar *token)
 {
   g_return_val_if_fail (token, NULL);
-
-  return FROGR_ACCOUNT (g_object_new (FROGR_TYPE_ACCOUNT,
-                                      "token", token,
-                                      NULL));
+  return frogr_account_new_full (token, NULL);
 }
 
 FrogrAccount*
@@ -355,6 +349,7 @@ frogr_account_new_full (const gchar *token, const gchar *token_secret)
   return FROGR_ACCOUNT (g_object_new (FROGR_TYPE_ACCOUNT,
                                       "token", token,
                                       "token-secret", token_secret,
+                                      "version", ACCOUNTS_CURRENT_VERSION,
                                       NULL));
 }
 
diff --git a/src/frogr-account.h b/src/frogr-account.h
index 35b2014..ed341d5 100644
--- a/src/frogr-account.h
+++ b/src/frogr-account.h
@@ -35,6 +35,9 @@ G_BEGIN_DECLS
 #define FROGR_ACCOUNT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST(klass,  FROGR_TYPE_ACCOUNT, FrogrAccountClass))
 #define FROGR_ACCOUNT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS(obj,  FROGR_TYPE_ACCOUNT, FrogrAccountClass))
 
+/* Increase this when changing the xml schema for storing accounts */
+#define ACCOUNTS_CURRENT_VERSION "2"
+
 typedef struct _FrogrAccount      FrogrAccount;
 typedef struct _FrogrAccountClass FrogrAccountClass;
 
diff --git a/src/frogr-config.c b/src/frogr-config.c
index 4503a2c..614bbdf 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -34,9 +34,6 @@
 #define ACCOUNTS_FILENAME "accounts.xml"
 #define SETTINGS_FILENAME "settings.xml"
 
-/* Increase this when changing the xml schema for storing settings */
-#define SETTINGS_FORMAT_VERSION "1"
-
 #define FROGR_CONFIG_GET_PRIVATE(object)                \
   (G_TYPE_INSTANCE_GET_PRIVATE ((object),               \
                                 FROGR_TYPE_CONFIG,      \
@@ -679,7 +676,7 @@ _save_settings (FrogrConfig *self)
   xmlDocSetRootElement (xml, root);
 
   /* Settings versioning */
-  xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) SETTINGS_FORMAT_VERSION);
+  xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) SETTINGS_CURRENT_VERSION);
 
   /* Default visibility */
   node = xmlNewNode (NULL, (const xmlChar*) "default-visibility");
diff --git a/src/frogr-config.h b/src/frogr-config.h
index 38806cb..d5f91e0 100644
--- a/src/frogr-config.h
+++ b/src/frogr-config.h
@@ -40,6 +40,9 @@ G_BEGIN_DECLS
 #define FROGR_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST(klass,  FROGR_TYPE_CONFIG, FrogrConfigClass))
 #define FROGR_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS(obj,  FROGR_TYPE_CONFIG, FrogrConfigClass))
 
+/* Increase this when changing the xml schema for storing settings */
+#define SETTINGS_CURRENT_VERSION "1"
+
 typedef struct _FrogrConfig        FrogrConfig;
 typedef struct _FrogrConfigClass   FrogrConfigClass;
 



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