aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-theme-adium.c22
-rw-r--r--libempathy-gtk/empathy-theme-manager.c61
-rw-r--r--libempathy-gtk/empathy-theme-manager.h1
3 files changed, 77 insertions, 7 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index aab1f6f3d..0464a6193 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -820,6 +820,15 @@ empathy_adium_path_is_valid (const gchar *path)
gboolean ret;
gchar *file;
+ /* The theme is not valid if there is no Info.plist */
+ file = g_build_filename (path, "Contents", "Info.plist",
+ NULL);
+ ret = g_file_test (file, G_FILE_TEST_EXISTS);
+ g_free (file);
+
+ if (ret == FALSE)
+ return ret;
+
/* 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
@@ -845,10 +854,15 @@ empathy_adium_info_new (const gchar *path)
value = empathy_plist_parse_from_file (file);
g_free (file);
- if (value) {
- info = g_value_dup_boxed (value);
- tp_g_value_slice_free (value);
- }
+ if (value == NULL)
+ return NULL;
+
+ info = g_value_dup_boxed (value);
+ tp_g_value_slice_free (value);
+
+ /* Insert the theme's path into the hash table,
+ * keys have to be dupped */
+ tp_asv_set_string (info, g_strdup ("path"), path);
return info;
}
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index ba3d48e68..7a6d57ba5 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -26,6 +26,7 @@
#include <string.h>
#include <glib/gi18n-lib.h>
+#include <telepathy-glib/dbus.h>
#include <gtk/gtk.h>
#include <telepathy-glib/util.h>
@@ -67,9 +68,6 @@ static const gchar *themes[] = {
"simple", N_("Simple"),
"clean", N_("Clean"),
"blue", N_("Blue"),
-#ifdef HAVE_WEBKIT
- "adium", N_("Adium"),
-#endif
NULL
};
@@ -378,6 +376,10 @@ theme_manager_ensure_theme_exists (const gchar *name)
return FALSE;
}
+ if (strcmp ("adium", name) == 0) {
+ return TRUE;
+ }
+
for (i = 0; themes[i]; i += 2) {
if (strcmp (themes[i], name) == 0) {
return TRUE;
@@ -534,3 +536,56 @@ empathy_theme_manager_get_themes (void)
return themes;
}
+static void
+find_themes (GList **list, const gchar *dirpath)
+{
+ GDir *dir;
+ GError *error = NULL;
+ const gchar *name = NULL;
+ GHashTable *info = NULL;
+
+ dir = g_dir_open (dirpath, 0, &error);
+ if (dir != NULL) {
+ name = g_dir_read_name (dir);
+ while (name != NULL) {
+ gchar *path;
+
+ path = g_build_path (G_DIR_SEPARATOR_S, dirpath, name, NULL);
+ if (empathy_adium_path_is_valid (path)) {
+ info = empathy_adium_info_new (path);
+ if (info != NULL) {
+ *list = g_list_prepend (*list, info);
+ }
+ }
+ g_free (path);
+ name = g_dir_read_name (dir);
+ }
+ g_dir_close (dir);
+ } else {
+ DEBUG ("Error opening %s: %s\n", dirpath, error->message);
+ g_error_free (error);
+ }
+}
+
+GList *
+empathy_theme_manager_get_adium_themes (void)
+{
+ GList *themes = NULL;
+ gchar *userpath = NULL;
+ const gchar *const *paths = NULL;
+ gint i = 0;
+
+ userpath = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "adium/message-styles", NULL);
+ find_themes (&themes, userpath);
+ g_free (userpath);
+
+ paths = g_get_system_data_dirs ();
+ for (i = 0; paths[i] != NULL; i++) {
+ userpath = g_build_path (G_DIR_SEPARATOR_S, paths[i],
+ "adium/message-styles", NULL);
+ find_themes (&themes, userpath);
+ g_free (userpath);
+ }
+
+ return themes;
+}
diff --git a/libempathy-gtk/empathy-theme-manager.h b/libempathy-gtk/empathy-theme-manager.h
index 99c96d784..a459b43cb 100644
--- a/libempathy-gtk/empathy-theme-manager.h
+++ b/libempathy-gtk/empathy-theme-manager.h
@@ -51,6 +51,7 @@ struct _EmpathyThemeManagerClass {
GType empathy_theme_manager_get_type (void) G_GNUC_CONST;
EmpathyThemeManager * empathy_theme_manager_get (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);
G_END_DECLS