diff options
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-manager.c | 67 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-manager.h | 1 |
3 files changed, 69 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index 485d361f6..f1aad6eac 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -1710,6 +1710,9 @@ empathy_adium_path_is_valid (const gchar *path) gboolean ret; gchar *file; + if (path[0] != '/') + return FALSE; + /* The theme is not valid if there is no Info.plist */ file = g_build_filename (path, "Contents", "Info.plist", NULL); diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index bb0b3f784..81b15d5ca 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -165,8 +165,12 @@ theme_manager_notify_adium_path_cb (GSettings *gsettings_chat, } /* If path does not really contains an adium path, ignore */ - if (!empathy_adium_path_is_valid (new_path)) { - DEBUG ("Invalid theme path set: %s", new_path); + if (empathy_adium_path_is_valid (new_path)) { + /* pass */ + } else if (empathy_theme_manager_find_theme (new_path) != NULL) { + new_path = empathy_theme_manager_find_theme (new_path); + } else { + g_warning ("Do not understand theme: %s", new_path); goto finally; } @@ -406,3 +410,62 @@ empathy_theme_manager_get_adium_themes (void) return themes_list; } + +gchar * +empathy_theme_manager_find_theme (const gchar *name) +{ + gchar *path; + const gchar * const *paths; + gint i; + + /* look in EMPATHY_SRCDIR */ + path = g_strjoin (NULL, + g_getenv ("EMPATHY_SRCDIR"), + "/data/themes/", + name, + ".AdiumMessageStyle", + NULL); + + DEBUG ("Trying '%s'", path); + + if (empathy_adium_path_is_valid (path)) + return path; + + g_free (path); + + /* look in user dir */ + path = g_strjoin (NULL, + g_get_user_data_dir (), + "/adium/message-styles/", + name, + ".AdiumMessageStyle", + NULL); + + DEBUG ("Trying '%s'", path); + + if (empathy_adium_path_is_valid (path)) + return path; + + g_free (path); + + /* look in system dirs */ + paths = g_get_system_data_dirs (); + + for (i = 0; paths[i] != NULL; i++) { + path = g_strjoin (NULL, + paths[i], + "/adium/message-styles/", + name, + ".AdiumMessageStyle", + NULL); + + DEBUG ("Trying '%s'", path); + + if (empathy_adium_path_is_valid (path)) + return path; + + g_free (path); + } + + return NULL; +} diff --git a/libempathy-gtk/empathy-theme-manager.h b/libempathy-gtk/empathy-theme-manager.h index c60dc0cd9..4d5194570 100644 --- a/libempathy-gtk/empathy-theme-manager.h +++ b/libempathy-gtk/empathy-theme-manager.h @@ -53,6 +53,7 @@ EmpathyThemeManager * empathy_theme_manager_dup_singleton (void); const gchar ** empathy_theme_manager_get_themes (void); GList * empathy_theme_manager_get_adium_themes (void); EmpathyChatView * empathy_theme_manager_create_view (EmpathyThemeManager *manager); +gchar * empathy_theme_manager_find_theme (const gchar *name); G_END_DECLS |