pidgin: 275f30eb: Load the list of variants when building ...
qulogic at pidgin.im
qulogic at pidgin.im
Mon Sep 19 17:20:53 EDT 2011
----------------------------------------------------------------------
Revision: 275f30ebdaaf463eb11a67f1d276f181e5834c22
Parent: fd0a394b4cb3ea30a43cc1b9375fc70246e68318
Author: qulogic at pidgin.im
Date: 09/19/11 14:48:00
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/275f30ebdaaf463eb11a67f1d276f181e5834c22
Changelog:
Load the list of variants when building the theme.
Changes against parent fd0a394b4cb3ea30a43cc1b9375fc70246e68318
patched pidgin/gtkconv-theme-loader.c
patched pidgin/gtkconv-theme.c
patched pidgin/gtkconv-theme.h
patched pidgin/gtkprefs.c
-------------- next part --------------
============================================================
--- pidgin/gtkprefs.c d68bce4cd6e63fefcd8afe898fb709701442afd0
+++ pidgin/gtkprefs.c 894c545dfc5f16a4219a22ffd53e5e10637f28d7
@@ -496,7 +496,7 @@ prefs_themes_sort(PurpleTheme *theme)
g_object_unref(G_OBJECT(pixbuf));
} else if (PIDGIN_IS_CONV_THEME(theme)) {
- GList *variants;
+ const GList *variants;
/* No image available? */
@@ -509,14 +509,12 @@ prefs_themes_sort(PurpleTheme *theme)
*/
for (variants = pidgin_conversation_theme_get_variants(PIDGIN_CONV_THEME(theme));
variants;
- variants = g_list_delete_link(variants, variants)) {
+ variants = g_list_next(variants)) {
markup = get_theme_markup(name, FALSE, NULL, variants->data);
gtk_list_store_append(prefs_conv_themes, &iter);
gtk_list_store_set(prefs_conv_themes, &iter, 1, markup, 2, name, -1);
-
- g_free(variants->data);
}
}
}
============================================================
--- pidgin/gtkconv-theme-loader.c e4c5562affd867fca8e4b810f4d94121ed3d3772
+++ pidgin/gtkconv-theme-loader.c ac0fa5cfe578ed02d9f374712874aa453f1a6261
@@ -109,6 +109,8 @@ pidgin_conv_loader_build(const gchar *di
int MessageViewVersion;
const char *CFBundleName;
const char *CFBundleIdentifier;
+ GDir *variants;
+ char *variant_dir;
g_return_val_if_fail(dir != NULL, NULL);
@@ -168,6 +170,29 @@ pidgin_conv_loader_build(const gchar *di
"directory", dir,
"info", info, NULL);
+ /* Read list of variants */
+ variant_dir = g_build_filename(dir, "Contents", "Resources", "Variants", NULL);
+ variants = g_dir_open(variant_dir, 0, NULL);
+ g_free(variant_dir);
+
+ if (variants) {
+ const char *file;
+ char *name;
+
+ while ((file = g_dir_read_name(variants)) != NULL) {
+ const char *end = g_strrstr(file, ".css");
+ char *name;
+
+ if ((end == NULL) || (*(end + 4) != '\0'))
+ continue;
+
+ name = g_strndup(file, end - file);
+ pidgin_conversation_theme_add_variant(theme, name);
+ }
+
+ g_dir_close(variants);
+ }
+
return PURPLE_THEME(theme);
}
============================================================
--- pidgin/gtkconv-theme.c f07ca7d174d9a4707f109a0def07c6d811a8b758
+++ pidgin/gtkconv-theme.c a718d1194ca8c0cbad1295c94bc825d97b6aaae0
@@ -47,6 +47,7 @@ typedef struct {
typedef struct {
/* current config options */
char *variant; /* allowed to be NULL if there are no variants */
+ GList *variants;
/* Info.plist keys/values */
GHashTable *info;
@@ -552,51 +553,50 @@ void
}
void
-pidgin_conversation_theme_save_state(const PidginConvTheme *theme)
+pidgin_conversation_theme_add_variant(PidginConvTheme *theme, const char *variant)
{
PidginConvThemePrivate *priv;
- const GValue *val;
- char *prefname;
- char *variant;
-
priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
- val = get_key(priv, "CFBundleIdentifier", FALSE);
- prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversation/themes/%s", g_value_get_string(val));
- variant = g_strdup_printf("%s/variant", prefname);
+ priv->variants = g_list_prepend(priv->variants, g_strdup(variant));
+}
- purple_debug_info("webkit", "saving state with variant %s\n", priv->variant);
- purple_prefs_add_none(prefname);
- purple_prefs_add_string(variant, "");
- purple_prefs_set_string(variant, priv->variant);
+const char *
+pidgin_conversation_theme_get_variant(PidginConvTheme *theme)
+{
+ PidginConvThemePrivate *priv;
+ priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
- g_free(prefname);
- g_free(variant);
+ return g_strdup(priv->variant);
}
-static void
-pidgin_conversation_theme_load_state(PidginConvTheme *theme)
+void
+pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant)
{
PidginConvThemePrivate *priv;
const GValue *val;
char *prefname;
- const char* value;
- gboolean changed;
-
priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
- val = get_key(priv, "CFBundleIdentifier", FALSE);
- prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversation/themes/%s/variant", g_value_get_string(val));
-
- value = purple_prefs_get_string(prefname);
- changed = !priv->variant || !g_str_equal(priv->variant, value);
-
g_free(priv->variant);
- priv->variant = g_strdup(value);
+ priv->variant = g_strdup(variant);
+ val = get_key(priv, "CFBundleIdentifier", FALSE);
+ prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversation/themes/%s/variant",
+ g_value_get_string(val));
+ purple_prefs_set_string(prefname, variant);
g_free(prefname);
}
+const GList *
+pidgin_conversation_theme_get_variants(PidginConvTheme *theme)
+{
+ PidginConvThemePrivate *priv;
+ priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
+
+ return priv->variants;
+}
+
PidginConvTheme *
pidgin_conversation_theme_copy(const PidginConvTheme *theme)
{
@@ -622,66 +622,7 @@ pidgin_conversation_theme_copy(const Pid
return ret;
}
-void
-pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant)
-{
- PidginConvThemePrivate *priv;
-
- priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
-
- /* I'm not going to test whether this variant is valid! */
- g_free(priv->variant);
- priv->variant = g_strdup(variant);
-
- /* todo, the style has "changed". Ideally, I would like to use signals at this point. */
-}
-
char *
-pidgin_conversation_theme_get_variant(PidginConvTheme *theme)
-{
- PidginConvThemePrivate *priv;
- priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
-
- return g_strdup(priv->variant);
-}
-
-/**
- * Get a list of variants supported by the style.
- */
-GList *
-pidgin_conversation_theme_get_variants(PidginConvTheme *theme)
-{
- PidginConvThemePrivate *priv;
- GList *ret = NULL;
- GDir *variants;
- const char *css_file;
- char *css;
- char *variant_dir;
-
- priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
-
- variant_dir = g_build_filename(purple_theme_get_dir(PURPLE_THEME(theme)), "Contents", "Resources", "Variants", NULL);
-
- variants = g_dir_open(variant_dir, 0, NULL);
- if (!variants)
- return NULL;
-
- while ((css_file = g_dir_read_name(variants)) != NULL) {
- if (!g_str_has_suffix(css_file, ".css"))
- continue;
-
- css = g_strndup(css_file, strlen(css_file) - 4);
- ret = g_list_append(ret, css);
- }
-
- g_dir_close(variants);
- g_free(variant_dir);
-
- ret = g_list_sort(ret, (GCompareFunc)g_strcmp0);
- return ret;
-}
-
-char *
pidgin_conversation_theme_get_css(PidginConvTheme *theme)
{
PidginConvThemePrivate *priv;
============================================================
--- pidgin/gtkconv-theme.h f26e1079460ab031aaf7d4d5a68a0c44cd2a267a
+++ pidgin/gtkconv-theme.h 651dd2931040c2d569dfc35475443249f54e7a8b
@@ -72,13 +72,14 @@ void pidgin_conversation_theme_set_info(
const GHashTable *pidgin_conversation_theme_get_info(const PidginConvTheme *theme);
void pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info);
+void pidgin_conversation_theme_add_variant(PidginConvTheme *theme, const char *variant);
+const char *pidgin_conversation_theme_get_variant(PidginConvTheme *theme);
+void pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant);
+const GList *pidgin_conversation_theme_get_variants(PidginConvTheme *theme);
+
PidginConvTheme *pidgin_conversation_theme_load(const char *styledir);
PidginConvTheme *pidgin_conversation_theme_copy(const PidginConvTheme *theme);
void pidgin_conversation_theme_save_state(const PidginConvTheme *theme);
-void pidgin_conversation_theme_read_info_plist(PidginConvTheme *theme, const char *variant);
-char *pidgin_conversation_theme_get_variant(PidginConvTheme *theme);
-GList *pidgin_conversation_theme_get_variants(PidginConvTheme *theme);
-void pidgin_conversation_theme_set_variant(PidginConvTheme *theme, const char *variant);
char *pidgin_conversation_theme_get_css(PidginConvTheme *theme);
More information about the Commits
mailing list