soc.2009.webkitmessageview: ffe06962: theme detection.
tdrhq at soc.pidgin.im
tdrhq at soc.pidgin.im
Tue Aug 25 12:06:54 EDT 2009
-----------------------------------------------------------------
Revision: ffe0696220cc252e516fa817a0e4f3f8c03414e0
Ancestor: c6bfeb3a6ef95acc8ca5174f4c6021feff051f64
Author: tdrhq at soc.pidgin.im
Date: 2009-08-10T08:40:12
Branch: im.pidgin.soc.2009.webkitmessageview
URL: http://d.pidgin.im/viewmtn/revision/info/ffe0696220cc252e516fa817a0e4f3f8c03414e0
Modified files:
pidgin/plugins/adiumthemes/webkit.c
ChangeLog:
theme detection.
-------------- next part --------------
============================================================
--- pidgin/plugins/adiumthemes/webkit.c 704a71203d07259a7cff64b26aeeefb21f31ac9f
+++ pidgin/plugins/adiumthemes/webkit.c e5e0a1d89f377f0c65c812d47c3bf86d721419e4
@@ -38,6 +38,7 @@
/* Purple headers */
#include <conversation.h>
+#include <debug.h>
#include <notify.h>
#include <util.h>
#include <version.h>
@@ -608,7 +609,7 @@ static GList*
* that they are in the directories for themes.
*/
static GList*
-get_theme_directory_list ()
+get_style_directory_list ()
{
char *user_dir, *user_style_dir, *global_style_dir;
GList *list1, *list2;
@@ -634,7 +635,37 @@ get_theme_directory_list ()
return g_list_concat (list1, list2);
}
+/**
+ * use heuristics or previous user options to figure out what
+ * theme to use as default in this Pidgin instance.
+ */
+static void
+style_set_default ()
+{
+ GList* styles = get_style_directory_list (), *iter;
+ const char *stylepath = purple_prefs_get_string ("/plugins/gtk/adiumthemes/stylepath");
+ g_assert (cur_style_dir == NULL);
+ if (stylepath)
+ styles = g_list_prepend (styles, g_strdup (stylepath));
+
+ /* pick any one that works. Note that we have first preference
+ * for the one in the userdir */
+ for (iter = styles; iter; iter = g_list_next (iter)) {
+ PidginMessageStyle *style = pidgin_message_style_load (iter->data);
+ if (style) {
+ cur_style_dir = (char*) g_strdup (iter->data);
+ pidgin_message_style_unref (style);
+ break;
+ }
+ purple_debug_info ("webkit", "Style %s is invalid\n", (char*) iter->data);
+ }
+
+ for (iter = styles; iter; iter = g_list_next (iter))
+ g_free (iter->data);
+ g_list_free (styles);
+}
+
/**
* Get each of the files corresponding to each variant.
*/
@@ -701,29 +732,9 @@ plugin_load(PurplePlugin *plugin)
static gboolean
plugin_load(PurplePlugin *plugin)
{
- PidginMessageStyle *_style; /* temp */
+ style_set_default ();
+ if (!cur_style_dir) return FALSE; /* couldn't find a style */
- if (g_path_is_absolute (purple_user_dir()))
- cur_style_dir = g_build_filename(purple_user_dir(), "style", NULL);
- else {
-
-
-
- char* cur = g_get_current_dir ();
- cur_style_dir = g_build_filename (cur, purple_user_dir(), "style", NULL);
- g_free (cur);
- }
-
-
- _style = pidgin_message_style_load (cur_style_dir);
- if (!_style) {
- g_free (cur_style_dir);
- cur_style_dir = NULL;
- return FALSE;
- }
-
- pidgin_message_style_unref (_style);
-
purple_signal_connect (pidgin_conversations_get_handle (),
"displaying-im-msg",
webkit_plugin_get_handle (),
More information about the Commits
mailing list