Updated Spanish translation
[empathy-mirror.git] / libempathy-gtk / empathy-theme-manager.c
blob1233509ecc6f1753b43508a139ab559acc190110
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * Copyright (C) 2005-2007 Imendio AB
4 * Copyright (C) 2008 Collabora Ltd.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301 USA
21 * Authors: Xavier Claessens <xclaesse@gmail.com>
24 #include "config.h"
26 #include <string.h>
28 #include <glib/gi18n-lib.h>
29 #include <telepathy-glib/dbus.h>
30 #include <gtk/gtk.h>
32 #include <telepathy-glib/util.h>
34 #include <libempathy/empathy-gsettings.h>
35 #include <libempathy/empathy-utils.h>
37 #include "empathy-theme-manager.h"
38 #include "empathy-chat-view.h"
39 #include "empathy-chat-text-view.h"
40 #include "empathy-theme-boxes.h"
41 #include "empathy-theme-irc.h"
42 #include "empathy-theme-adium.h"
44 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
45 #include <libempathy/empathy-debug.h>
47 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeManager)
48 typedef struct {
49 GSettings *gsettings_chat;
50 gchar *name;
51 GtkSettings *settings;
52 GList *boxes_views;
53 guint emit_changed_idle;
54 gboolean in_constructor;
56 EmpathyAdiumData *adium_data;
57 gchar *adium_variant;
58 /* list of weakref to EmpathyThemeAdium objects */
59 GList *adium_views;
60 } EmpathyThemeManagerPriv;
62 enum {
63 THEME_CHANGED,
64 LAST_SIGNAL
67 static guint signals[LAST_SIGNAL] = { 0 };
69 static const gchar *themes[] = {
70 "classic", N_("Classic"),
71 "simple", N_("Simple"),
72 "clean", N_("Clean"),
73 "blue", N_("Blue"),
74 NULL
77 G_DEFINE_TYPE (EmpathyThemeManager, empathy_theme_manager, G_TYPE_OBJECT);
79 static gboolean
80 theme_manager_emit_changed_idle_cb (gpointer manager)
82 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
83 const gchar *adium_path = NULL;
85 if (priv->adium_data) {
86 adium_path = empathy_adium_data_get_path (priv->adium_data);
88 DEBUG ("Emit theme-changed with: name='%s' adium_path='%s' "
89 "adium_variant='%s'", priv->name, adium_path,
90 priv->adium_variant);
92 g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL);
93 priv->emit_changed_idle = 0;
95 return FALSE;
98 static void
99 theme_manager_emit_changed (EmpathyThemeManager *manager)
101 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
103 /* We emit the signal in idle callback to be sure we emit it only once
104 * in the case both the name and adium_path changed */
105 if (priv->emit_changed_idle == 0 && !priv->in_constructor) {
106 priv->emit_changed_idle = g_idle_add (
107 theme_manager_emit_changed_idle_cb, manager);
111 static void
112 theme_manager_view_weak_notify_cb (gpointer data,
113 GObject *where_the_object_was)
115 GList **list = data;
116 *list = g_list_remove (*list, where_the_object_was);
119 static void
120 clear_list_of_views (GList **views)
122 while (*views) {
123 g_object_weak_unref ((*views)->data,
124 theme_manager_view_weak_notify_cb,
125 views);
126 *views = g_list_delete_link (*views, *views);
130 static void
131 theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
133 g_snprintf (str_color, 10,
134 "#%02x%02x%02x",
135 gdk_color->red >> 8,
136 gdk_color->green >> 8,
137 gdk_color->blue >> 8);
140 static EmpathyThemeIrc *
141 theme_manager_create_irc_view (EmpathyThemeManager *manager)
143 EmpathyChatTextView *view;
144 EmpathyThemeIrc *theme;
146 theme = empathy_theme_irc_new ();
147 view = EMPATHY_CHAT_TEXT_VIEW (theme);
149 /* Define base tags */
150 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
151 "size", 2000,
152 NULL);
153 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
154 "foreground", "darkgrey",
155 "justification", GTK_JUSTIFY_CENTER,
156 NULL);
157 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
158 "foreground", "brown4",
159 "style", PANGO_STYLE_ITALIC,
160 NULL);
161 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
162 "foreground-set", FALSE,
163 NULL);
164 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
165 "foreground", "PeachPuff4",
166 "justification", GTK_JUSTIFY_LEFT,
167 NULL);
168 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
169 "foreground", "steelblue",
170 "underline", PANGO_UNDERLINE_SINGLE,
171 NULL);
172 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT,
173 "background", "yellow",
174 NULL);
176 /* Define IRC tags */
177 empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_SELF,
178 "foreground", "sea green",
179 NULL);
180 empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_OTHER,
181 "foreground", "skyblue4",
182 NULL);
183 empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT,
184 "foreground", "indian red",
185 "weight", PANGO_WEIGHT_BOLD,
186 NULL);
188 return theme;
191 static void on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, EmpathyThemeManager *self);
193 static EmpathyThemeBoxes *
194 theme_manager_create_boxes_view (EmpathyThemeManager *manager)
196 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
197 EmpathyThemeBoxes *theme;
199 theme = empathy_theme_boxes_new ();
200 priv->boxes_views = g_list_prepend (priv->boxes_views, theme);
201 g_object_weak_ref (G_OBJECT (theme),
202 theme_manager_view_weak_notify_cb,
203 &priv->boxes_views);
205 g_signal_connect (G_OBJECT (theme), "style-set",
206 G_CALLBACK (on_style_set_cb), manager);
208 return theme;
211 static void
212 theme_manager_update_boxes_tags (EmpathyThemeBoxes *theme,
213 const gchar *header_foreground,
214 const gchar *header_background,
215 const gchar *header_line_background,
216 const gchar *action_foreground,
217 const gchar *time_foreground,
218 const gchar *event_foreground,
219 const gchar *link_foreground,
220 const gchar *text_foreground,
221 const gchar *text_background,
222 const gchar *highlight_foreground)
225 EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme);
226 GtkTextTag *tag;
228 DEBUG ("Update view with new colors:\n"
229 "header_foreground = %s\n"
230 "header_background = %s\n"
231 "header_line_background = %s\n"
232 "action_foreground = %s\n"
233 "time_foreground = %s\n"
234 "event_foreground = %s\n"
235 "link_foreground = %s\n"
236 "text_foreground = %s\n"
237 "text_background = %s\n"
238 "highlight_foreground = %s\n",
239 header_foreground, header_background, header_line_background,
240 action_foreground, time_foreground, event_foreground,
241 link_foreground, text_foreground, text_background,
242 highlight_foreground);
245 /* FIXME: GtkTextTag don't support to set color properties to NULL.
246 * See bug #542523 */
248 #define TAG_SET(prop, prop_set, value) \
249 if (value != NULL) { \
250 g_object_set (tag, prop, value, NULL); \
251 } else { \
252 g_object_set (tag, prop_set, FALSE, NULL); \
255 /* Define base tags */
256 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT,
257 "weight", PANGO_WEIGHT_BOLD,
258 "pixels-above-lines", 4,
259 NULL);
260 TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
261 TAG_SET ("foreground", "foreground-set", highlight_foreground);
263 empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
264 "size", 3000,
265 "pixels-above-lines", 8,
266 NULL);
267 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
268 "justification", GTK_JUSTIFY_CENTER,
269 NULL);
270 TAG_SET ("foreground", "foreground-set", time_foreground);
271 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
272 "style", PANGO_STYLE_ITALIC,
273 "pixels-above-lines", 4,
274 NULL);
275 TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
276 TAG_SET ("foreground", "foreground-set", action_foreground);
277 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
278 "pixels-above-lines", 4,
279 NULL);
280 TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
281 TAG_SET ("foreground", "foreground-set", text_foreground);
282 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
283 "justification", GTK_JUSTIFY_LEFT,
284 NULL);
285 TAG_SET ("foreground", "foreground-set", event_foreground);
286 tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
287 "underline", PANGO_UNDERLINE_SINGLE,
288 NULL);
289 TAG_SET ("foreground", "foreground-set", link_foreground);
291 /* Define BOXES tags */
292 tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER,
293 "weight", PANGO_WEIGHT_BOLD,
294 NULL);
295 TAG_SET ("foreground", "foreground-set", header_foreground);
296 TAG_SET ("paragraph-background", "paragraph-background-set", header_background);
297 tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER_LINE,
298 "size", 1,
299 NULL);
300 TAG_SET ("paragraph-background", "paragraph-background-set", header_line_background);
302 #undef TAG_SET
305 static void
306 on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, EmpathyThemeManager *self)
308 EmpathyThemeManagerPriv *priv = GET_PRIV (self);
309 GtkStyle *style;
310 gchar color1[10];
311 gchar color2[10];
312 gchar color3[10];
313 gchar color4[10];
315 /* The simple theme depends on the current GTK+ theme so it has to be
316 * updated if the theme changes. */
317 if (tp_strdiff (priv->name, "simple"))
318 return;
320 style = gtk_widget_get_style (GTK_WIDGET (widget));
322 theme_manager_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color1);
323 theme_manager_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color2);
324 theme_manager_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color3);
325 theme_manager_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color4);
327 theme_manager_update_boxes_tags (EMPATHY_THEME_BOXES (widget),
328 color4, /* header_foreground */
329 color2, /* header_background */
330 color3, /* header_line_background */
331 color1, /* action_foreground */
332 "darkgrey", /* time_foreground */
333 "darkgrey", /* event_foreground */
334 color1, /* link_foreground */
335 NULL, /* text_foreground */
336 NULL, /* text_background */
337 NULL); /* highlight_foreground */
340 static void
341 theme_manager_update_boxes_theme (EmpathyThemeManager *manager,
342 EmpathyThemeBoxes *theme)
344 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
346 if (strcmp (priv->name, "simple") == 0) {
347 on_style_set_cb (GTK_WIDGET (theme), NULL, manager);
349 else if (strcmp (priv->name, "clean") == 0) {
350 theme_manager_update_boxes_tags (theme,
351 "black", /* header_foreground */
352 "#efefdf", /* header_background */
353 "#e3e3d3", /* header_line_background */
354 "brown4", /* action_foreground */
355 "darkgrey", /* time_foreground */
356 "darkgrey", /* event_foreground */
357 "#49789e", /* link_foreground */
358 NULL, /* text_foreground */
359 NULL, /* text_background */
360 NULL); /* highlight_foreground */
362 else if (strcmp (priv->name, "blue") == 0) {
363 theme_manager_update_boxes_tags (theme,
364 "black", /* header_foreground */
365 "#88a2b4", /* header_background */
366 "#7f96a4", /* header_line_background */
367 "brown4", /* action_foreground */
368 "darkgrey", /* time_foreground */
369 "#7f96a4", /* event_foreground */
370 "#49789e", /* link_foreground */
371 "black", /* text_foreground */
372 "#adbdc8", /* text_background */
373 "black"); /* highlight_foreground */
377 static EmpathyThemeAdium *
378 theme_manager_create_adium_view (EmpathyThemeManager *manager)
380 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
381 EmpathyThemeAdium *theme;
383 theme = empathy_theme_adium_new (priv->adium_data, priv->adium_variant);
384 priv->adium_views = g_list_prepend (priv->adium_views, theme);
385 g_object_weak_ref (G_OBJECT (theme),
386 theme_manager_view_weak_notify_cb,
387 &priv->adium_views);
389 return theme;
392 static void
393 theme_manager_notify_adium_path_cb (GSettings *gsettings_chat,
394 const gchar *key,
395 gpointer user_data)
397 EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data);
398 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
399 const gchar *current_path = NULL;
400 gchar *new_path;
402 new_path = g_settings_get_string (gsettings_chat, key);
404 if (priv->adium_data != NULL) {
405 current_path = empathy_adium_data_get_path (priv->adium_data);
408 /* If path did not really changed, ignore */
409 if (!tp_strdiff (current_path, new_path)) {
410 g_free (new_path);
411 return;
414 /* If path does not really contains an adium path, ignore */
415 if (!empathy_adium_path_is_valid (new_path)) {
416 DEBUG ("Invalid theme path set: %s", new_path);
417 g_free (new_path);
418 return;
421 /* Load new theme data, we can stop tracking existing views since we
422 * won't be able to change them live anymore */
423 clear_list_of_views (&priv->adium_views);
424 tp_clear_pointer (&priv->adium_data, empathy_adium_data_unref);
425 priv->adium_data = empathy_adium_data_new (new_path);
427 theme_manager_emit_changed (manager);
429 g_free (new_path);
432 static void
433 theme_manager_notify_adium_variant_cb (GSettings *gsettings_chat,
434 const gchar *key,
435 gpointer user_data)
437 EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data);
438 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
439 gchar *new_variant;
440 GList *l;
442 new_variant = g_settings_get_string (gsettings_chat, key);
443 if (!tp_strdiff (priv->adium_variant, new_variant)) {
444 g_free (new_variant);
445 return;
448 g_free (priv->adium_variant);
449 priv->adium_variant = new_variant;
451 for (l = priv->adium_views; l; l = l->next) {
452 empathy_theme_adium_set_variant (EMPATHY_THEME_ADIUM (l->data),
453 priv->adium_variant);
457 EmpathyChatView *
458 empathy_theme_manager_create_view (EmpathyThemeManager *manager)
460 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
461 EmpathyThemeBoxes *theme;
463 g_return_val_if_fail (EMPATHY_IS_THEME_MANAGER (manager), NULL);
465 DEBUG ("Using theme %s", priv->name);
467 if (strcmp (priv->name, "adium") == 0 && priv->adium_data != NULL) {
468 return EMPATHY_CHAT_VIEW (theme_manager_create_adium_view (manager));
471 if (strcmp (priv->name, "classic") == 0) {
472 return EMPATHY_CHAT_VIEW (theme_manager_create_irc_view (manager));
475 theme = theme_manager_create_boxes_view (manager);
476 theme_manager_update_boxes_theme (manager, theme);
478 return EMPATHY_CHAT_VIEW (theme);
481 static gboolean
482 theme_manager_ensure_theme_exists (const gchar *name)
484 gint i;
486 if (EMP_STR_EMPTY (name)) {
487 return FALSE;
490 if (strcmp ("adium", name) == 0) {
491 return TRUE;
494 for (i = 0; themes[i]; i += 2) {
495 if (strcmp (themes[i], name) == 0) {
496 return TRUE;
500 return FALSE;
503 typedef enum {
504 THEME_TYPE_IRC,
505 THEME_TYPE_BOXED,
506 THEME_TYPE_ADIUM,
507 } ThemeType;
509 static ThemeType
510 theme_type (const gchar *name)
512 if (!tp_strdiff (name, "classic")) {
513 return THEME_TYPE_IRC;
514 } else if (!tp_strdiff (name, "adium")) {
515 return THEME_TYPE_ADIUM;
516 } else {
517 return THEME_TYPE_BOXED;
521 static void
522 theme_manager_notify_name_cb (GSettings *gsettings_chat,
523 const gchar *key,
524 gpointer user_data)
526 EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data);
527 EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
528 gchar *name;
529 ThemeType old_type;
530 ThemeType new_type;
532 name = g_settings_get_string (gsettings_chat, key);
534 /* Fallback to classic theme if current setting does not exist */
535 if (!theme_manager_ensure_theme_exists (name)) {
536 g_free (name);
537 name = g_strdup ("classic");
540 /* If theme did not change, nothing to do */
541 if (!tp_strdiff (priv->name, name)) {
542 g_free (name);
543 return;
546 old_type = theme_type (priv->name);
547 g_free (priv->name);
548 priv->name = name;
549 new_type = theme_type (priv->name);
551 if (new_type == THEME_TYPE_BOXED) {
552 GList *l;
554 /* The theme changes to a boxed one, we can update boxed views */
555 for (l = priv->boxes_views; l; l = l->next) {
556 theme_manager_update_boxes_theme (manager,
557 EMPATHY_THEME_BOXES (l->data));
561 /* Do not emit theme-changed if theme type didn't change. If theme
562 * changed from a boxed to another boxed, all view are updated in place.
563 * If theme changed from an adium to another adium, the signal will be
564 * emited from theme_manager_notify_adium_path_cb ()
566 if (old_type != new_type) {
567 theme_manager_emit_changed (manager);
571 static void
572 theme_manager_finalize (GObject *object)
574 EmpathyThemeManagerPriv *priv = GET_PRIV (object);
576 g_object_unref (priv->gsettings_chat);
577 g_free (priv->name);
579 if (priv->emit_changed_idle != 0) {
580 g_source_remove (priv->emit_changed_idle);
583 clear_list_of_views (&priv->boxes_views);
585 clear_list_of_views (&priv->adium_views);
586 g_free (priv->adium_variant);
587 tp_clear_pointer (&priv->adium_data, empathy_adium_data_unref);
589 G_OBJECT_CLASS (empathy_theme_manager_parent_class)->finalize (object);
592 static void
593 empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
595 GObjectClass *object_class = G_OBJECT_CLASS (klass);
597 signals[THEME_CHANGED] =
598 g_signal_new ("theme-changed",
599 G_OBJECT_CLASS_TYPE (object_class),
600 G_SIGNAL_RUN_LAST,
602 NULL, NULL,
603 g_cclosure_marshal_generic,
604 G_TYPE_NONE,
607 g_type_class_add_private (object_class, sizeof (EmpathyThemeManagerPriv));
609 object_class->finalize = theme_manager_finalize;
612 static void
613 empathy_theme_manager_init (EmpathyThemeManager *manager)
615 EmpathyThemeManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
616 EMPATHY_TYPE_THEME_MANAGER, EmpathyThemeManagerPriv);
618 manager->priv = priv;
619 priv->in_constructor = TRUE;
621 priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
623 /* Take the theme name and track changes */
624 g_signal_connect (priv->gsettings_chat,
625 "changed::" EMPATHY_PREFS_CHAT_THEME,
626 G_CALLBACK (theme_manager_notify_name_cb),
627 manager);
628 theme_manager_notify_name_cb (priv->gsettings_chat,
629 EMPATHY_PREFS_CHAT_THEME,
630 manager);
632 /* Take the adium path/variant and track changes */
633 g_signal_connect (priv->gsettings_chat,
634 "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
635 G_CALLBACK (theme_manager_notify_adium_path_cb),
636 manager);
637 theme_manager_notify_adium_path_cb (priv->gsettings_chat,
638 EMPATHY_PREFS_CHAT_ADIUM_PATH,
639 manager);
641 g_signal_connect (priv->gsettings_chat,
642 "changed::" EMPATHY_PREFS_CHAT_THEME_VARIANT,
643 G_CALLBACK (theme_manager_notify_adium_variant_cb),
644 manager);
645 theme_manager_notify_adium_variant_cb (priv->gsettings_chat,
646 EMPATHY_PREFS_CHAT_THEME_VARIANT,
647 manager);
648 priv->in_constructor = FALSE;
651 EmpathyThemeManager *
652 empathy_theme_manager_dup_singleton (void)
654 static EmpathyThemeManager *manager = NULL;
656 if (manager == NULL) {
657 manager = g_object_new (EMPATHY_TYPE_THEME_MANAGER, NULL);
658 g_object_add_weak_pointer (G_OBJECT (manager), (gpointer *) &manager);
660 return manager;
663 return g_object_ref (manager);
666 const gchar **
667 empathy_theme_manager_get_themes (void)
669 return themes;
672 static void
673 find_themes (GList **list, const gchar *dirpath)
675 GDir *dir;
676 GError *error = NULL;
677 const gchar *name = NULL;
678 GHashTable *info = NULL;
680 dir = g_dir_open (dirpath, 0, &error);
681 if (dir != NULL) {
682 name = g_dir_read_name (dir);
683 while (name != NULL) {
684 gchar *path;
686 path = g_build_path (G_DIR_SEPARATOR_S, dirpath, name, NULL);
687 if (empathy_adium_path_is_valid (path)) {
688 info = empathy_adium_info_new (path);
689 if (info != NULL) {
690 *list = g_list_prepend (*list, info);
693 g_free (path);
694 name = g_dir_read_name (dir);
696 g_dir_close (dir);
697 } else {
698 DEBUG ("Error opening %s: %s\n", dirpath, error->message);
699 g_error_free (error);
703 GList *
704 empathy_theme_manager_get_adium_themes (void)
706 GList *themes_list = NULL;
707 gchar *userpath = NULL;
708 const gchar *const *paths = NULL;
709 gint i = 0;
711 userpath = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "adium/message-styles", NULL);
712 find_themes (&themes_list, userpath);
713 g_free (userpath);
715 paths = g_get_system_data_dirs ();
716 for (i = 0; paths[i] != NULL; i++) {
717 userpath = g_build_path (G_DIR_SEPARATOR_S, paths[i],
718 "adium/message-styles", NULL);
719 find_themes (&themes_list, userpath);
720 g_free (userpath);
723 return themes_list;