aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 18:58:56 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 19:00:56 +0800
commit9b222761cc9995a09f37b7537a12e4955b586323 (patch)
treedb1925d6d43a85bcb9bb49c1626a0237c46525a2 /src
parent5e112661cca767870225936428515a82b2f6f82c (diff)
downloadgsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar.gz
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar.bz2
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar.lz
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar.xz
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.tar.zst
gsoc2013-empathy-9b222761cc9995a09f37b7537a12e4955b586323.zip
Store the theme name in the 'theme' gsettings key
The 'adium-path' key is now deprecated as we lookup the theme path from its name.
Diffstat (limited to 'src')
-rw-r--r--src/empathy-preferences.c46
-rw-r--r--src/empathy-sanity-cleaning.c47
2 files changed, 59 insertions, 34 deletions
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index c410affd1..df5e39187 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -115,7 +115,7 @@ enum {
enum {
COL_THEME_VISIBLE_NAME,
- COL_THEME_ADIUM_PATH,
+ COL_THEME_ADIUM_NAME,
COL_THEME_ADIUM_INFO,
COL_THEME_COUNT
};
@@ -834,24 +834,24 @@ preferences_theme_changed_cb (GtkComboBox *combo,
if (gtk_combo_box_get_active_iter (combo, &iter)) {
GtkTreeModel *model;
- gchar *path;
+ gchar *name;
GHashTable *info;
gboolean variant;
model = gtk_combo_box_get_model (combo);
gtk_tree_model_get (model, &iter,
- COL_THEME_ADIUM_PATH, &path,
+ COL_THEME_ADIUM_NAME, &name,
COL_THEME_ADIUM_INFO, &info,
-1);
g_settings_set_string (priv->gsettings_chat,
- EMPATHY_PREFS_CHAT_ADIUM_PATH,
- path);
+ EMPATHY_PREFS_CHAT_THEME,
+ name);
variant = preferences_theme_variants_fill (preferences, info);
gtk_widget_set_visible (priv->hbox_chat_theme_variant, variant);
- g_free (path);
+ g_free (name);
tp_clear_pointer (&info, g_hash_table_unref);
}
}
@@ -864,31 +864,31 @@ preferences_theme_notify_cb (GSettings *gsettings,
EmpathyPreferences *preferences = user_data;
EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
GtkComboBox *combo;
- gchar *conf_path;
+ gchar *theme;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean found = FALSE;
gboolean ok;
- conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
+ theme = g_settings_get_string (gsettings, key);
combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
model = gtk_combo_box_get_model (combo);
for (ok = gtk_tree_model_get_iter_first (model, &iter);
ok && !found;
ok = gtk_tree_model_iter_next (model, &iter)) {
- gchar *path;
+ gchar *name;
gtk_tree_model_get (model, &iter,
- COL_THEME_ADIUM_PATH, &path,
+ COL_THEME_ADIUM_NAME, &name,
-1);
- if (!tp_strdiff (path, conf_path)) {
+ if (!tp_strdiff (name, theme)) {
found = TRUE;
gtk_combo_box_set_active_iter (combo, &iter);
}
- g_free (path);
+ g_free (name);
}
/* Fallback to the first one. */
@@ -898,7 +898,7 @@ preferences_theme_notify_cb (GSettings *gsettings,
}
}
- g_free (conf_path);
+ g_free (theme);
}
static void
@@ -928,21 +928,23 @@ preferences_themes_setup (EmpathyPreferences *preferences)
adium_themes = empathy_theme_manager_get_adium_themes ();
while (adium_themes != NULL) {
GHashTable *info;
- const gchar *name;
- const gchar *path;
+ const gchar *visible_name;
+ gchar *name;
info = adium_themes->data;
- name = tp_asv_get_string (info, "CFBundleName");
- path = tp_asv_get_string (info, "path");
+ visible_name = tp_asv_get_string (info, "CFBundleName");
+ name = empathy_theme_manager_dup_theme_name_from_path (
+ tp_asv_get_string (info, "path"));
- if (name != NULL && path != NULL) {
+ if (visible_name != NULL && name != NULL) {
gtk_list_store_insert_with_values (store, NULL, -1,
- COL_THEME_VISIBLE_NAME, name,
- COL_THEME_ADIUM_PATH, path,
+ COL_THEME_VISIBLE_NAME, visible_name,
+ COL_THEME_ADIUM_NAME, name,
COL_THEME_ADIUM_INFO, info,
-1);
}
g_hash_table_unref (info);
+ g_free (name);
adium_themes = g_list_delete_link (adium_themes, adium_themes);
}
@@ -961,11 +963,11 @@ preferences_themes_setup (EmpathyPreferences *preferences)
/* Select the theme from the GSetting key and track changes */
preferences_theme_notify_cb (priv->gsettings_chat,
- EMPATHY_PREFS_CHAT_ADIUM_PATH,
+ EMPATHY_PREFS_CHAT_THEME,
preferences);
g_signal_connect (priv->gsettings_chat,
- "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
+ "changed::" EMPATHY_PREFS_CHAT_THEME,
G_CALLBACK (preferences_theme_notify_cb),
preferences);
}
diff --git a/src/empathy-sanity-cleaning.c b/src/empathy-sanity-cleaning.c
index b14f4f527..8bc61b4cf 100644
--- a/src/empathy-sanity-cleaning.c
+++ b/src/empathy-sanity-cleaning.c
@@ -144,8 +144,8 @@ static void
upgrade_chat_theme_settings (void)
{
GSettings *gsettings_chat;
- gchar *theme;
- const char *adium_theme, *variant = "";
+ gchar *theme, *new_theme = NULL;
+ const char *variant = "";
gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
@@ -153,33 +153,56 @@ upgrade_chat_theme_settings (void)
EMPATHY_PREFS_CHAT_THEME);
if (!tp_strdiff (theme, "adium")) {
- goto finally;
+ gchar *path, *fullname;
+
+ path = g_settings_get_string (gsettings_chat,
+ EMPATHY_PREFS_CHAT_ADIUM_PATH);
+
+ fullname = g_path_get_basename (path);
+ if (g_str_has_suffix (fullname, ".AdiumMessageStyle"))
+ {
+ gchar **tmp;
+
+ tmp = g_strsplit (fullname, ".AdiumMessageStyle", 0);
+ new_theme = g_strdup (tmp[0]);
+
+ g_strfreev (tmp);
+ }
+ else
+ {
+ /* Use the Classic theme as fallback */
+ new_theme = g_strdup ("Classic");
+ }
+
+ g_free (path);
+ g_free (fullname);
} else if (!tp_strdiff (theme, "gnome")) {
- adium_theme = "PlanetGNOME";
+ new_theme = g_strdup ("PlanetGNOME");
} else if (!tp_strdiff (theme, "simple")) {
- adium_theme = "Boxes";
+ new_theme = g_strdup ("Boxes");
variant = "Simple";
} else if (!tp_strdiff (theme, "clean")) {
- adium_theme = "Boxes";
+ new_theme = g_strdup ("Boxes");
variant = "Clean";
} else if (!tp_strdiff (theme, "blue")) {
- adium_theme = "Boxes";
+ new_theme = g_strdup ("Boxes");
variant = "Blue";
} else {
- adium_theme = "Classic";
+ /* Assume that's an Adium theme name. The theme manager will fallback to
+ * 'Classic' if it can't find it. */
+ goto finally;
}
- DEBUG ("Migrating to '%s' variant '%s'", adium_theme, variant);
+ DEBUG ("Migrating to '%s' variant '%s'", new_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);
+ EMPATHY_PREFS_CHAT_THEME, new_theme);
g_settings_set_string (gsettings_chat,
EMPATHY_PREFS_CHAT_THEME_VARIANT, variant);
finally:
g_free (theme);
+ g_free (new_theme);
g_object_unref (gsettings_chat);
}