[empathy] move theme migration code to sanity-cleaning.c



commit 2daf6b4066dbde6fdcaa3aee6d85d67f3353bfac
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jul 2 10:32:01 2012 +0200

    move theme migration code to sanity-cleaning.c
    
    That's where this kind of code is meant to be.

 libempathy-gtk/empathy-theme-manager.c |   40 ---------------------------
 src/empathy-sanity-cleaning.c          |   46 +++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 41 deletions(-)
---
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index 13d98af..7d0ebfa 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -266,44 +266,6 @@ empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
 }
 
 static void
-theme_manager_migrate_from_legacy_theme (EmpathyThemeManager *self)
-{
-	EmpathyThemeManagerPriv *priv = self->priv;
-	char *theme = g_settings_get_string (priv->gsettings_chat,
-			EMPATHY_PREFS_CHAT_THEME);
-	const char *adium_theme, *variant = "";
-
-	if (!tp_strdiff (theme, "adium")) {
-		goto finally;
-	} else if (!tp_strdiff (theme, "gnome")) {
-		adium_theme = "PlanetGNOME";
-	} else if (!tp_strdiff (theme, "simple")) {
-		adium_theme = "Boxes";
-		variant = "Simple";
-	} else if (!tp_strdiff (theme, "clean")) {
-		adium_theme = "Boxes";
-		variant = "Clean";
-	} else if (!tp_strdiff (theme, "blue")) {
-		adium_theme = "Boxes";
-		variant = "Blue";
-	} else {
-		adium_theme = "Classic";
-	}
-
-	DEBUG ("Migrating to '%s' variant '%s'", adium_theme, variant);
-
-	g_settings_set_string (priv->gsettings_chat,
-		EMPATHY_PREFS_CHAT_THEME, "adium");
-	g_settings_set_string (priv->gsettings_chat,
-		EMPATHY_PREFS_CHAT_ADIUM_PATH, adium_theme);
-	g_settings_set_string (priv->gsettings_chat,
-		EMPATHY_PREFS_CHAT_THEME_VARIANT, variant);
-
-finally:
-	g_free (theme);
-}
-
-static void
 empathy_theme_manager_init (EmpathyThemeManager *manager)
 {
 	EmpathyThemeManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
@@ -314,8 +276,6 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
 
 	priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
 
-	theme_manager_migrate_from_legacy_theme (manager);
-
 	/* Take the adium path/variant and track changes */
 	g_signal_connect (priv->gsettings_chat,
 			  "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c
index 70e5de2..b14f4f5 100644
--- a/src/empathy-sanity-cleaning.c
+++ b/src/empathy-sanity-cleaning.c
@@ -38,7 +38,7 @@
  * If the number stored in gsettings is lower than it, all the tasks will
  * be executed.
  */
-#define SANITY_CLEANING_NUMBER 2
+#define SANITY_CLEANING_NUMBER 3
 
 static void
 account_update_parameters_cb (GObject *source,
@@ -141,12 +141,56 @@ set_facebook_account_fallback_server (TpAccountManager *am)
 }
 
 static void
+upgrade_chat_theme_settings (void)
+{
+  GSettings *gsettings_chat;
+  gchar *theme;
+  const char *adium_theme, *variant = "";
+
+  gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+
+  theme = g_settings_get_string (gsettings_chat,
+      EMPATHY_PREFS_CHAT_THEME);
+
+  if (!tp_strdiff (theme, "adium")) {
+    goto finally;
+  } else if (!tp_strdiff (theme, "gnome")) {
+    adium_theme = "PlanetGNOME";
+  } else if (!tp_strdiff (theme, "simple")) {
+    adium_theme = "Boxes";
+    variant = "Simple";
+  } else if (!tp_strdiff (theme, "clean")) {
+    adium_theme = "Boxes";
+    variant = "Clean";
+  } else if (!tp_strdiff (theme, "blue")) {
+    adium_theme = "Boxes";
+    variant = "Blue";
+  } else {
+    adium_theme = "Classic";
+  }
+
+  DEBUG ("Migrating to '%s' variant '%s'", adium_theme, variant);
+
+  g_settings_set_string (gsettings_chat,
+    EMPATHY_PREFS_CHAT_THEME, "adium");
+  g_settings_set_string (gsettings_chat,
+    EMPATHY_PREFS_CHAT_ADIUM_PATH, adium_theme);
+  g_settings_set_string (gsettings_chat,
+    EMPATHY_PREFS_CHAT_THEME_VARIANT, variant);
+
+finally:
+  g_free (theme);
+  g_object_unref (gsettings_chat);
+}
+
+static void
 run_sanity_cleaning_tasks (TpAccountManager *am)
 {
   DEBUG ("Starting sanity cleaning tasks");
 
   fix_xmpp_account_priority (am);
   set_facebook_account_fallback_server (am);
+  upgrade_chat_theme_settings ();
 }
 
 static void



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