aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2012-06-29 12:12:14 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 16:03:23 +0800
commit518d54667e1934f0e339e3368d77cfc953a34314 (patch)
tree8001c79bc000224ee8020b29837cf776ef06fe4c
parentf433b0821c24fc7382bd289f2246b7b1e2039106 (diff)
downloadgsoc2013-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
-rw-r--r--libempathy-gtk/empathy-theme-adium.c3
-rw-r--r--libempathy-gtk/empathy-theme-manager.c67
-rw-r--r--libempathy-gtk/empathy-theme-manager.h1
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