diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2012-06-29 12:12:14 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-07-02 16:03:23 +0800 |
commit | 518d54667e1934f0e339e3368d77cfc953a34314 (patch) | |
tree | 8001c79bc000224ee8020b29837cf776ef06fe4c /libempathy-gtk/empathy-theme-manager.c | |
parent | f433b0821c24fc7382bd289f2246b7b1e2039106 (diff) | |
download | gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar.gz gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar.bz2 gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar.lz gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar.xz gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.tar.zst gsoc2013-empathy-518d54667e1934f0e339e3368d77cfc953a34314.zip |
theme-manager: make it possible to look up theme by name
Diffstat (limited to 'libempathy-gtk/empathy-theme-manager.c')
-rw-r--r-- | libempathy-gtk/empathy-theme-manager.c | 67 |
1 files changed, 65 insertions, 2 deletions
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; +} |