aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 19:24:03 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 19:28:35 +0800
commit9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d (patch)
tree19c2f3e21910935de040f9c84019681b816a2bab
parent9958d658c1c3eb7a4bd81a15a85d5d7658b4d85b (diff)
downloadgsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar.gz
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar.bz2
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar.lz
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar.xz
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.tar.zst
gsoc2013-empathy-9ea865f2b1e420d2a908cd0ac80e0c5d38a7ac4d.zip
List themes from EMPATHY_SRCDIR as well
-rw-r--r--libempathy-gtk/empathy-theme-manager.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index c18ca56be..4854a9632 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -287,7 +287,8 @@ empathy_theme_manager_dup_singleton (void)
}
static void
-find_themes (GList **list, const gchar *dirpath)
+find_themes (GHashTable *hash,
+ const gchar *dirpath)
{
GDir *dir;
GError *error = NULL;
@@ -309,7 +310,11 @@ find_themes (GList **list, const gchar *dirpath)
info = empathy_adium_info_new (path);
if (info != NULL)
- *list = g_list_prepend (*list, info);
+ {
+ g_hash_table_insert (hash,
+ empathy_theme_manager_dup_theme_name_from_path (path),
+ info);
+ }
}
g_free (path);
@@ -328,26 +333,54 @@ find_themes (GList **list, const gchar *dirpath)
GList *
empathy_theme_manager_get_adium_themes (void)
{
- GList *themes_list = NULL;
- gchar *userpath = NULL;
+ /* Theme name -> GHashTable info */
+ GHashTable *hash;
+ GList *result;
+ gchar *path = NULL;
const gchar *const *paths = NULL;
gint i = 0;
+ const gchar *dir;
- userpath = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
- "adium/message-styles", NULL);
- find_themes (&themes_list, userpath);
- g_free (userpath);
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ /* Start from the more general locations (the system) to the more specific
+ * ones ($HOME, EMPATHY_SRCDIR) so the more specific themes will override
+ * the more general ones.*/
+ /* System */
paths = g_get_system_data_dirs ();
for (i = 0; paths[i] != NULL; i++)
{
- userpath = g_build_path (G_DIR_SEPARATOR_S, paths[i],
+ path = g_build_path (G_DIR_SEPARATOR_S, paths[i],
"adium/message-styles", NULL);
- find_themes (&themes_list, userpath);
- g_free (userpath);
+
+ find_themes (hash, path);
+ g_free (path);
}
- return themes_list;
+ /* Home */
+ path = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ "adium/message-styles", NULL);
+
+ find_themes (hash, path);
+ g_free (path);
+
+ /* EMPATHY_SRCDIR */
+ dir = g_getenv ("EMPATHY_SRCDIR");
+ if (dir != NULL)
+ {
+ path = g_build_path (G_DIR_SEPARATOR_S, dir, "data/themes/", NULL);
+
+ find_themes (hash, path);
+ g_free (path);
+ }
+
+ /* Pass ownership of the info hash table to the list */
+ result = g_list_copy (g_hash_table_get_values (hash));
+
+ g_hash_table_unref (hash);
+
+ return result;
}
gchar *