[empathy] theme-manager: automatically migrate from legacy themes to Adium themes



commit 2bdbb3de1b5fda8f230ad144e8248472321920f1
Author: Danielle Madeley <danielle madeley collabora co uk>
Date:   Fri Jun 22 17:53:02 2012 +1000

    theme-manager: automatically migrate from legacy themes to Adium themes
    
    Because Adium themes are saved by path (urgh), adding a legacy theme
    called 'gnome' which can be used to set the default theme.

 libempathy-gtk/empathy-theme-manager.c |   47 ++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index ff53c95..bb0b3f7 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -262,6 +262,51 @@ 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 = "";
+	char *path;
+
+	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";
+	}
+
+	path = g_strjoin (NULL, DATADIR, "/adium/message-styles/",
+		adium_theme, ".AdiumMessageStyle",
+		NULL);
+
+	DEBUG ("Migrating to '%s' variant '%s'", path, 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, path);
+	g_settings_set_string (priv->gsettings_chat,
+		EMPATHY_PREFS_CHAT_THEME_VARIANT, variant);
+
+	g_free (path);
+
+finally:
+	g_free (theme);
+}
+
+static void
 empathy_theme_manager_init (EmpathyThemeManager *manager)
 {
 	EmpathyThemeManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
@@ -272,6 +317,8 @@ 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,



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