From 9b222761cc9995a09f37b7537a12e4955b586323 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 2 Jul 2012 12:58:56 +0200 Subject: 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. --- libempathy-gtk/empathy-theme-manager.c | 47 +++++++++++++++------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index 1f6611663..c18ca56be 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, -- cgit v1.2.3