Mercurial > pidgin.yaz
diff pidgin/gtkconv-theme.c @ 32827:4a34689eeb33 default tip
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 19 Nov 2011 14:42:54 +0900 |
parents | 910475e626be |
children |
line wrap: on
line diff
--- a/pidgin/gtkconv-theme.c Mon Sep 26 14:57:21 2011 +0900 +++ b/pidgin/gtkconv-theme.c Sat Nov 19 14:42:54 2011 +0900 @@ -83,7 +83,9 @@ *****************************************************************************/ static GObjectClass *parent_class = NULL; +#if GLIB_CHECK_VERSION(2,26,0) static GParamSpec *properties[PROP_LAST]; +#endif /****************************************************************************** * Helper Functions @@ -109,6 +111,23 @@ return val; } +/* The template path can either come from the theme, or can + * be stock Template.html that comes with Pidgin */ +static char * +get_template_path(const char *dir) +{ + char *file; + + file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); + + if (!g_file_test(file, G_FILE_TEST_EXISTS)) { + g_free(file); + file = g_build_filename(DATADIR, "pidgin", "theme", "conversation", "Template.html", NULL); + } + + return file; +} + static const char * get_template_html(PidginConvThemePrivate *priv, const char *dir) { @@ -117,14 +136,7 @@ if (priv->template_html) return priv->template_html; - /* The template path can either come from the theme, or can - * be stock Template.html that comes with the plugin */ - file = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); - - if (!g_file_test(file, G_FILE_TEST_EXISTS)) { - g_free(file); - file = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL); - } + file = get_template_path(dir); if (!g_file_get_contents(file, &priv->template_html, NULL, NULL)) { purple_debug_error("webkit", "Could not locate a Template.html (%s)\n", file); @@ -369,6 +381,7 @@ if (!g_file_get_contents(file, &priv->outgoing_next_context_html, NULL, NULL)) { priv->outgoing_next_context_html = g_strdup(get_outgoing_context_html(priv, dir)); } + g_free(file); return priv->outgoing_next_context_html; } @@ -507,15 +520,18 @@ G_TYPE_HASH_TABLE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); g_object_class_install_property(obj_class, PROP_INFO, pspec); +#if GLIB_CHECK_VERSION(2,26,0) properties[PROP_INFO] = pspec; +#endif /* VARIANT */ pspec = g_param_spec_string("variant", "Variant", "The current variant for this theme", - NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + NULL, G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_VARIANT, pspec); +#if GLIB_CHECK_VERSION(2,26,0) properties[PROP_VARIANT] = pspec; - +#endif } GType @@ -680,7 +696,11 @@ pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant) { _set_variant(theme, variant); +#if GLIB_CHECK_VERSION(2,26,0) g_object_notify_by_pspec(G_OBJECT(theme), properties[PROP_VARIANT]); +#else + g_object_notify(G_OBJECT(theme), "variant"); +#endif } const GList * @@ -699,19 +719,12 @@ pidgin_conversation_theme_get_template_path(PidginConvTheme *theme) { const char *dir; - char *filename; g_return_val_if_fail(theme != NULL, NULL); dir = purple_theme_get_dir(PURPLE_THEME(theme)); - filename = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL); - if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { - g_free(filename); - filename = g_build_filename(DATADIR, "pidgin", "webkit", "Template.html", NULL); - } - - return filename; + return get_template_path(dir); } char *