From 9da5a48b5c7d8c47418b56776839ff7687ecd7f0 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 18 Jul 2008 19:45:53 +0200 Subject: Quick check if the theme path is OK. --- libempathy-gtk/empathy-theme-adium.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'libempathy-gtk/empathy-theme-adium.c') diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index a878715b6..84a023956 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -20,7 +20,9 @@ */ #include "config.h" + #include +#include #include @@ -61,7 +63,8 @@ G_DEFINE_TYPE_WITH_CODE (EmpathyThemeAdium, empathy_theme_adium, theme_adium_iface_init)); static void -theme_adium_load (EmpathyThemeAdium *theme) +theme_adium_load (EmpathyThemeAdium *theme, + const gchar *path) { EmpathyThemeAdiumPriv *priv = GET_PRIV (theme); gchar *basedir; @@ -73,8 +76,7 @@ theme_adium_load (EmpathyThemeAdium *theme) gchar *content; gchar *css_path; - /* FIXME: Find a better way to get the theme dir */ - basedir = g_build_filename (g_get_home_dir (), "Contents", "Resources", NULL); + basedir = g_build_filename (path, "Contents", "Resources", NULL); /* Load html files */ file = g_build_filename (basedir, "Template.html", NULL); @@ -558,6 +560,7 @@ empathy_theme_adium_init (EmpathyThemeAdium *theme) { EmpathyThemeAdiumPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme, EMPATHY_TYPE_THEME_ADIUM, EmpathyThemeAdiumPriv); + gchar *path = NULL; theme->priv = priv; @@ -570,8 +573,10 @@ empathy_theme_adium_init (EmpathyThemeAdium *theme) G_CALLBACK (theme_adium_navigation_requested_cb), NULL); - - theme_adium_load (theme); + empathy_conf_get_string (empathy_conf_get (), + EMPATHY_PREFS_CHAT_ADIUM_PATH, + &path); + theme_adium_load (theme, path); } EmpathyThemeAdium * @@ -583,6 +588,18 @@ empathy_theme_adium_new (void) gboolean empathy_theme_adium_is_valid (const gchar *path) { - return TRUE; + gboolean ret; + gchar *file; + + /* We ship a default Template.html as fallback if there is any problem + * with the one inside the theme. The only other required file is + * Content.html for incoming messages (outgoing fallback to use + * incoming). */ + file = g_build_filename (path, "Contents", "Resources", "Incoming", + "Content.html", NULL); + ret = g_file_test (file, G_FILE_TEST_EXISTS); + g_free (file); + + return ret; } -- cgit v1.2.3