pidgin: 26f493ec: Set the default variant when loading the...

qulogic at pidgin.im qulogic at pidgin.im
Mon Sep 19 17:20:52 EDT 2011


----------------------------------------------------------------------
Revision: 26f493ec6f5a41774c9d3d20d8251910f7cd5b58
Parent:   31df27f65588d92e0f184551e28e05466c14742c
Author:   qulogic at pidgin.im
Date:     09/19/11 17:03:21
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/26f493ec6f5a41774c9d3d20d8251910f7cd5b58

Changelog: 

Set the default variant when loading the theme. The priorities
are value-from-prefs > default-from-theme > first-name-read.

Changes against parent 31df27f65588d92e0f184551e28e05466c14742c

  patched  pidgin/gtkconv-theme-loader.c

-------------- next part --------------
============================================================
--- pidgin/gtkconv-theme-loader.c	cb2e7af50ab5b4c2502795216dab026f8876bd46
+++ pidgin/gtkconv-theme-loader.c	512d94f4c3d24d716f550412d2ea4ab7516f6898
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 
+#include "pidgin.h"
 #include "gtkconv-theme-loader.h"
 #include "gtkconv-theme.h"
 
@@ -185,9 +186,32 @@ pidgin_conv_loader_build(const gchar *di
 	g_free(variant_dir);
 
 	if (variants) {
+		char *prefname;
+		const char *default_variant = NULL;
 		const char *file;
-		char *name;
 
+		/* Try user-set variant */
+		prefname = g_strdup_printf(PIDGIN_PREFS_ROOT "/conversations/themes/%s/variant",
+		                           CFBundleIdentifier);
+		default_variant = purple_prefs_get_string(prefname);
+		g_free(prefname);
+
+		if (default_variant && *default_variant) {
+			pidgin_conversation_theme_set_variant(theme, default_variant);
+
+		} else {
+			/* Try theme default */
+			val = g_hash_table_lookup(info, "DefaultVariant");
+			if (val && G_VALUE_HOLDS_STRING(val)) {
+				default_variant = g_value_get_string(val);
+				if (default_variant && *default_variant)
+					pidgin_conversation_theme_set_variant(theme, default_variant);
+				else
+					default_variant = NULL;
+			} else
+				default_variant = NULL;
+		}
+
 		while ((file = g_dir_read_name(variants)) != NULL) {
 			const char *end = g_strrstr(file, ".css");
 			char *name;
@@ -197,6 +221,12 @@ pidgin_conv_loader_build(const gchar *di
 
 			name = g_strndup(file, end - file);
 			pidgin_conversation_theme_add_variant(theme, name);
+
+			/* Set variant with first found */
+			if (!default_variant) {
+				pidgin_conversation_theme_set_variant(theme, name);
+				default_variant = name;
+			}
 		}
 
 		g_dir_close(variants);


More information about the Commits mailing list