From 2bdbb3de1b5fda8f230ad144e8248472321920f1 Mon Sep 17 00:00:00 2001 From: Danielle Madeley Date: Fri, 22 Jun 2012 17:53:02 +1000 Subject: 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 file changed, 47 insertions(+) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index ff53c9594..bb0b3f784 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -261,6 +261,51 @@ empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass) object_class->finalize = theme_manager_finalize; } +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) { @@ -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, -- cgit v1.2.3