diff options
-rw-r--r-- | data/org.gnome.Empathy.gschema.xml | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-manager.c | 47 | ||||
-rw-r--r-- | src/empathy-preferences.c | 46 | ||||
-rw-r--r-- | src/empathy-sanity-cleaning.c | 47 |
4 files changed, 80 insertions, 62 deletions
diff --git a/data/org.gnome.Empathy.gschema.xml b/data/org.gnome.Empathy.gschema.xml index 9b653ccc..393e9332 100644 --- a/data/org.gnome.Empathy.gschema.xml +++ b/data/org.gnome.Empathy.gschema.xml @@ -183,7 +183,7 @@ present them to the user immediately.</description> <key name="adium-path" type="s"> <default>''</default> <summary>Path of the Adium theme to use</summary> - <description>Path of the Adium theme to use if the theme used for chat is Adium.</description> + <description>Path of the Adium theme to use if the theme used for chat is Adium. Deprecated.</description> </key> <key name="enable-webkit-developer-tools" type="b"> <default>false</default> diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index 1f661166..c18ca56b 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -132,48 +132,41 @@ theme_manager_create_adium_view (EmpathyThemeManager *self) } static void -theme_manager_notify_adium_path_cb (GSettings *gsettings_chat, +theme_manager_notify_theme_cb (GSettings *gsettings_chat, const gchar *key, gpointer user_data) { EmpathyThemeManager *self = EMPATHY_THEME_MANAGER (user_data); - const gchar *current_path = NULL; - gchar *new_path; + gchar *theme, *path; - new_path = g_settings_get_string (gsettings_chat, key); + theme = g_settings_get_string (gsettings_chat, key); - if (self->priv->adium_data != NULL) - current_path = empathy_adium_data_get_path (self->priv->adium_data); - - /* If path did not really changed, ignore */ - if (!tp_strdiff (current_path, new_path)) - goto finally; - - /* If path does not really contains an adium path, ignore */ - if (empathy_adium_path_is_valid (new_path)) - { - /* pass */ - } - else if (empathy_theme_manager_find_theme (new_path) != NULL) + if (empathy_theme_manager_find_theme (theme) != NULL) { - new_path = empathy_theme_manager_find_theme (new_path); + path = empathy_theme_manager_find_theme (theme); + g_free (theme); } else { - g_warning ("Do not understand theme: %s", new_path); - goto finally; + g_warning ("Can't find theme: %s; fallback to 'Classic'", + theme); + + g_free (theme); + + path = empathy_theme_manager_find_theme ("Classic"); + if (path == NULL) + g_critical ("Can't find 'Classic theme"); } /* Load new theme data, we can stop tracking existing views since we * won't be able to change them live anymore */ clear_list_of_views (&self->priv->adium_views); tp_clear_pointer (&self->priv->adium_data, empathy_adium_data_unref); - self->priv->adium_data = empathy_adium_data_new (new_path); + self->priv->adium_data = empathy_adium_data_new (path); theme_manager_emit_changed (self); -finally: - g_free (new_path); + g_free (path); } static void @@ -261,11 +254,11 @@ empathy_theme_manager_init (EmpathyThemeManager *self) /* Take the adium path/variant and track changes */ g_signal_connect (self->priv->gsettings_chat, - "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH, - G_CALLBACK (theme_manager_notify_adium_path_cb), self); + "changed::" EMPATHY_PREFS_CHAT_THEME, + G_CALLBACK (theme_manager_notify_theme_cb), self); - theme_manager_notify_adium_path_cb (self->priv->gsettings_chat, - EMPATHY_PREFS_CHAT_ADIUM_PATH, self); + theme_manager_notify_theme_cb (self->priv->gsettings_chat, + EMPATHY_PREFS_CHAT_THEME, self); g_signal_connect (self->priv->gsettings_chat, "changed::" EMPATHY_PREFS_CHAT_THEME_VARIANT, diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c index c410affd..df5e3918 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 b14f4f52..8bc61b4c 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); } |