changeset 25122:9525fb966efb

theme loader cleanup, and remove a few warnings
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Tue, 26 Aug 2008 08:28:25 +0000
parents b37ccfd1697b
children 1a4417138a8f
files libpurple/sound-loader.c libpurple/theme-manager.c libpurple/xmlnode.c pidgin/gtkblist-loader.c pidgin/gtkblist-theme.c pidgin/gtkblist-theme.h pidgin/gtkicon-loader.c pidgin/gtkicon-theme.c pidgin/gtkicon-theme.h pidgin/gtkprefs.c pidgin/gtksound.c pidgin/pidginstock.c
diffstat 12 files changed, 97 insertions(+), 189 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/sound-loader.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/libpurple/sound-loader.c	Tue Aug 26 08:28:25 2008 +0000
@@ -26,9 +26,6 @@
 #include "util.h"
 #include "xmlnode.h"
 
-/******************************************************************************
- * Globals
- *****************************************************************************/
 /*****************************************************************************
  * Sound Theme Builder                                                      
  *****************************************************************************/
@@ -36,24 +33,18 @@
 static PurpleTheme *
 purple_sound_loader_build(const gchar *dir)
 {
-	xmlnode *root_node, *sub_node;
-	gchar *filename, *filename_full, *data;
-	GDir *gdir;
+	xmlnode *root_node = NULL, *sub_node;
+	gchar *filename_full, *data;
 	PurpleSoundTheme *theme = NULL;
 
 	/* Find the theme file */
-	gdir = g_dir_open(dir, 0, NULL);
-	g_return_val_if_fail(gdir != NULL, NULL);
+	g_return_val_if_fail(dir != NULL, NULL);
+	filename_full = g_build_filename(dir, "theme.xml", NULL);
 
-	while ((filename = g_strdup(g_dir_read_name(gdir))) != NULL && ! g_str_has_suffix(filename, ".xml"))
-		g_free(filename);
-	
-	g_return_val_if_fail(filename != NULL, NULL);
-	
-	/* Build the xml tree */
-	filename_full = g_build_filename(dir, filename, NULL);
+	if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
+		root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader");
 
-	root_node = xmlnode_from_file(dir, filename, "sound themes", "sound-loader");
+	g_free(filename_full);
 	g_return_val_if_fail(root_node != NULL, NULL);
 
 	/* Parse the tree */	
@@ -68,20 +59,18 @@
 				    "image", xmlnode_get_attrib(root_node, "image"),
 				    "directory", dir,
 				    "description", data, NULL);
-	
-		xmlnode_free(sub_node);
 
-		while ((sub_node = xmlnode_get_child(root_node, "event")) != NULL){
+		sub_node = xmlnode_get_child(root_node, "event");
+
+		while (sub_node) {
 			purple_sound_theme_set_file(theme,
 						    xmlnode_get_attrib(sub_node, "name"),
 						    xmlnode_get_attrib(sub_node, "file"));
-			xmlnode_free(sub_node);
+			sub_node = xmlnode_get_next_twin(sub_node);
 		}
 	}
 
 	xmlnode_free(root_node);	
-	g_dir_close(gdir);
-	g_free(filename_full);
 	g_free(data);
 	return PURPLE_THEME(theme);
 }
@@ -91,7 +80,7 @@
  *****************************************************************************/
 
 static void
-purple_sound_theme_loader_class_init (PurpleSoundThemeLoaderClass *klass)
+purple_sound_theme_loader_class_init(PurpleSoundThemeLoaderClass *klass)
 {
 	PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
 
@@ -100,7 +89,7 @@
 
 
 GType 
-purple_sound_theme_loader_get_type (void)
+purple_sound_theme_loader_get_type(void)
 {
   static GType type = 0;
   if (type == 0) {
@@ -116,7 +105,7 @@
       NULL,    /* instance_init */
       NULL,   /* value table */
     };
-    type = g_type_register_static (PURPLE_TYPE_THEME_LOADER,
+    type = g_type_register_static(PURPLE_TYPE_THEME_LOADER,
                                    "PurpleSoundThemeLoader",
                                    &info, 0);
   }
--- a/libpurple/theme-manager.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/libpurple/theme-manager.c	Tue Aug 26 08:28:25 2008 +0000
@@ -36,7 +36,7 @@
  ****************************************************************************/
 
 GType 
-purple_theme_manager_get_type (void)
+purple_theme_manager_get_type(void)
 {
   static GType type = 0;
   if (type == 0) {
@@ -52,7 +52,7 @@
       NULL,    /* instance_init */
       NULL,   /* Value Table */
     };
-    type = g_type_register_static (G_TYPE_OBJECT,
+    type = g_type_register_static(G_TYPE_OBJECT,
                                    "PurpleThemeManager",
                                    &info, 0);
   }
@@ -94,7 +94,7 @@
                 		      PTFunc user_data)
 {
 	if (PURPLE_IS_THEME(value))
-		(* user_data) (value);
+		(* user_data)(value);
 }
 
 static void
@@ -106,19 +106,19 @@
 	GDir *dir;
 	PurpleThemeLoader *loader;
 
-	rdir =  g_dir_open(root, 0, NULL);
+	rdir = g_dir_open(root, 0, NULL);
 
 	g_return_if_fail(rdir);
 
 	/* Parses directory by root/name/purple/type */
-	while ((name = g_strdup(g_dir_read_name (rdir)))){
+	while ((name = g_strdup(g_dir_read_name(rdir)))){
 		
 		purple_dir = g_build_filename(root, name, "purple", NULL);
 		dir =  g_dir_open(purple_dir, 0, NULL);	
 	
 		if (dir) {
-			while ((type = g_strdup(g_dir_read_name (dir)))) {
-				if ((loader = g_hash_table_lookup (theme_table, type))){
+			while ((type = g_strdup(g_dir_read_name(dir)))) {
+				if ((loader = g_hash_table_lookup(theme_table, type))){
 
 					theme_dir = g_build_filename(purple_dir, type, NULL);
 					purple_theme_manager_add_theme(purple_theme_loader_build(loader, theme_dir));
@@ -143,9 +143,9 @@
  *****************************************************************************/
 
 void
-purple_theme_manager_init (void)
+purple_theme_manager_init(void)
 {
-	theme_table = g_hash_table_new_full (g_str_hash,
+	theme_table = g_hash_table_new_full(g_str_hash,
                	                             g_str_equal,
                	                             g_free,
                	                             g_object_unref);
@@ -154,8 +154,8 @@
 void 
 purple_theme_manager_refresh()
 {
-	g_hash_table_foreach_remove (theme_table,
-                	             (GHRFunc) purple_theme_manager_is_theme,
+	g_hash_table_foreach_remove(theme_table,
+                	            (GHRFunc) purple_theme_manager_is_theme,
                 	             NULL);	
 	
 	/* TODO: add correct directories to parse */
@@ -164,7 +164,7 @@
 }
 
 void 
-purple_theme_manager_uninit ()
+purple_theme_manager_uninit()
 {
 	g_hash_table_destroy(theme_table);
 }
@@ -181,7 +181,7 @@
 	g_return_if_fail(type);
 
 	/* if something is already there do nothing */
-	if (! g_hash_table_lookup (theme_table, type)) 
+	if (! g_hash_table_lookup(theme_table, type)) 
 		g_hash_table_insert(theme_table, type, loader);
 }
 
@@ -195,13 +195,13 @@
 	type = purple_theme_loader_get_type_string(loader);
 	g_return_if_fail(type);
 
-	if (g_hash_table_lookup (theme_table, type) == loader){
+	if (g_hash_table_lookup(theme_table, type) == loader){
 
-		g_hash_table_remove (theme_table, type);
+		g_hash_table_remove(theme_table, type);
 
-		g_hash_table_foreach_remove (theme_table,
-                	                     (GHRFunc) purple_theme_manager_is_theme_type,
-                	                     type);		
+		g_hash_table_foreach_remove(theme_table,
+                	                    (GHRFunc)purple_theme_manager_is_theme_type,
+                	                    (gpointer)type);		
 	}/* only free if given registered loader */
 }
 
--- a/libpurple/xmlnode.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/libpurple/xmlnode.c	Tue Aug 26 08:28:25 2008 +0000
@@ -729,7 +729,7 @@
 }
 
 xmlnode *
-xmlnode_from_file(const char *dir, const char *filename, const char *description, const char *process)
+xmlnode_from_file(const char *dir,const char *filename, const char *description, const char *process)
 {
 	gchar *filename_full;
 	GError *error = NULL;
--- a/pidgin/gtkblist-loader.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkblist-loader.c	Tue Aug 26 08:28:25 2008 +0000
@@ -39,34 +39,28 @@
 static PurpleTheme *
 pidgin_blist_loader_build(const gchar *dir)
 {
-	xmlnode *root_node, *sub_node, *sub_sub_node;
-	gchar *filename, *filename_full, *data;
-	const gchar *icon_theme = NULL, *temp;
+	xmlnode *root_node = NULL, *sub_node, *sub_sub_node;
+	gchar *filename_full, *data;
+	const gchar *temp;
 	gboolean sucess = TRUE;
 	GdkColor *bgcolor, *expanded_bgcolor, *collapsed_bgcolor, *contact_color;
 	GdkColor color;
 	FontColorPair *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *status;
 	PidginBlistLayout *layout;
-	GDir *gdir;
 	PidginBlistTheme *theme;
 
 	/* Find the theme file */
-	gdir = g_dir_open(dir, 0, NULL);
-	g_return_val_if_fail(gdir != NULL, NULL);
+	g_return_val_if_fail(dir != NULL, NULL);
+	filename_full = g_build_filename(dir, "theme.xml", NULL);
+
+	if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
+		root_node = xmlnode_from_file(dir, "theme.xml", "buddy list themes", "blist-loader");
 
-	while ((filename = g_strdup(g_dir_read_name(gdir))) != NULL && ! g_str_has_suffix(filename, ".xml"))
-		g_free(filename);
-	
-	if (filename == NULL){
-		g_dir_close(gdir);
-		return NULL;
-	}
-	
-	/* Build the xml tree */
-	filename_full = g_build_filename(dir, filename, NULL);
+	g_free(filename_full);
+	g_return_val_if_fail(root_node != NULL, NULL);
 
-	root_node = xmlnode_from_file(dir, filename, "blist themes", "blist-loader");
-	g_return_val_if_fail(root_node != NULL, NULL);
+	sub_node = xmlnode_get_child(root_node, "description");
+	data = xmlnode_get_data(sub_node);
 
 	/* init all structs and colors */
 	bgcolor = g_new0(GdkColor, 1);
@@ -87,16 +81,8 @@
 	message = g_new0(FontColorPair, 1); 
 	status = g_new0(FontColorPair, 1);
 
-	/* Parse the tree */	
-	sub_node = xmlnode_get_child(root_node, "description");
-	data = xmlnode_get_data(sub_node);
-
-	/* <icon_theme> */
-	if ((sucess = (sub_node = xmlnode_get_child(root_node, "icon_theme")) != NULL))
-		icon_theme = xmlnode_get_attrib(sub_node, "name");
-
 	/* <blist> */
-	if ((sucess = sucess && (sub_node = xmlnode_get_child(root_node, "blist")) != NULL)) {
+	if ((sucess = (sub_node = xmlnode_get_child(root_node, "blist")) != NULL)) {
 		if ((temp = xmlnode_get_attrib(sub_node, "color")) != NULL && gdk_color_parse(temp, bgcolor))
 			gdk_colormap_alloc_color(gdk_colormap_get_system(), bgcolor, FALSE, TRUE);
 		else {
@@ -221,7 +207,6 @@
 			    "image", xmlnode_get_attrib(root_node, "image"),
 			    "directory", dir,
 			    "description", data,
-			    "icon-theme", icon_theme,
 			    "background-color", bgcolor,
 			    "layout", layout,
 			    "expanded-color", expanded_bgcolor,
@@ -237,17 +222,15 @@
 			    "message", message,
 			    "status", status, NULL);
 
-	/* malformed xml file */
+	xmlnode_free(root_node);	
+	g_free(data);
+
+	/* malformed xml file - also frees all partial data*/
 	if (!sucess) {
 		g_object_unref(theme);
 		theme = NULL;
 	}
 
-	xmlnode_free(sub_node);
-	xmlnode_free(root_node);	
-	g_dir_close(gdir);
-	g_free(filename_full);
-	g_free(data);
 	return PURPLE_THEME(theme);
 }
 
@@ -256,7 +239,7 @@
  *****************************************************************************/
 
 static void
-pidgin_blist_theme_loader_class_init (PidginBlistThemeLoaderClass *klass)
+pidgin_blist_theme_loader_class_init(PidginBlistThemeLoaderClass *klass)
 {
 	PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
 
@@ -265,7 +248,7 @@
 
 
 GType 
-pidgin_blist_theme_loader_get_type (void)
+pidgin_blist_theme_loader_get_type(void)
 {
   static GType type = 0;
   if (type == 0) {
@@ -281,7 +264,7 @@
       NULL,    /* instance_init */
       NULL,   /* value table */
     };
-    type = g_type_register_static (PURPLE_TYPE_THEME_LOADER,
+    type = g_type_register_static(PURPLE_TYPE_THEME_LOADER,
                                    "PidginBlistThemeLoader",
                                    &info, 0);
   }
--- a/pidgin/gtkblist-theme.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkblist-theme.c	Tue Aug 26 08:28:25 2008 +0000
@@ -30,11 +30,9 @@
  * Structs
  *****************************************************************************/
 typedef struct {
-	gchar *icon_theme;
-
 	/* Buddy list */
+	gdouble opacity;
 	GdkColor *bgcolor;
-	gdouble opacity;
 	PidginBlistLayout *layout;
 	
 	/* groups */
@@ -70,7 +68,6 @@
  *****************************************************************************/
 enum {
 	PROP_ZERO = 0,
-	PROP_ICON_THEME,
 	PROP_BACKGROUND_COLOR,
 	PROP_OPACITY,
 	PROP_LAYOUT,
@@ -122,9 +119,6 @@
 	PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
 
 	switch(param_id) {
-		case PROP_ICON_THEME:
-			g_value_set_string(value, pidgin_blist_theme_get_icon_theme(theme));
-			break;
 		case PROP_BACKGROUND_COLOR:
 			g_value_set_pointer(value, pidgin_blist_theme_get_background_color(theme));
 			break;
@@ -177,15 +171,12 @@
 }
 
 static void
-pidgin_blist_theme_set_property(GObject *obj, guint param_id, GValue *value,
+pidgin_blist_theme_set_property(GObject *obj, guint param_id, const GValue *value,
 						 GParamSpec *psec)
 {
 	PidginBlistTheme *theme = PIDGIN_BLIST_THEME(obj);
 
 	switch(param_id) {
-		case PROP_ICON_THEME:
-			pidgin_blist_theme_set_icon_theme(theme, g_value_get_string(value));
-			break;
 		case PROP_BACKGROUND_COLOR:
 			pidgin_blist_theme_set_background_color(theme, g_value_get_pointer(value));
 			break;
@@ -244,7 +235,6 @@
 	priv = PIDGIN_BLIST_THEME_GET_PRIVATE(obj);
 
 	/* Buddy List */
-	g_free(priv->icon_theme);
 	g_free(priv->layout);
 	
 	/* Group */
@@ -276,13 +266,6 @@
 	obj_class->set_property = pidgin_blist_theme_set_property;
 	obj_class->finalize = pidgin_blist_theme_finalize;
 
-	/* Icon Theme */
-	pspec = g_param_spec_string("icon-theme", "Icon Theme",
-				    "The icon theme to go with this buddy list theme",
-				    NULL,
-				    G_PARAM_READWRITE);
-	g_object_class_install_property(obj_class, PROP_ICON_THEME, pspec);
-
 	/* Buddy List */
 	pspec = g_param_spec_pointer("background-color", "Background Color",
 				    "The background color for the buddy list",
@@ -388,18 +371,6 @@
  *****************************************************************************/
 
 /* get methods */
-gchar *
-pidgin_blist_theme_get_icon_theme(PidginBlistTheme *theme)
-{
-	PidginBlistThemePrivate *priv;
-
-	g_return_val_if_fail(PIDGIN_IS_BLIST_THEME(theme), NULL);
-
-	priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
-
-	return priv->icon_theme;
-}
-
 GdkColor *
 pidgin_blist_theme_get_background_color(PidginBlistTheme *theme)
 {
@@ -582,19 +553,6 @@
 
 /* Set Methods */
 void
-pidgin_blist_theme_set_icon_theme(PidginBlistTheme *theme, const gchar *icon_theme)
-{
-	PidginBlistThemePrivate *priv;
-
-	g_return_if_fail(PIDGIN_IS_BLIST_THEME(theme));
-
-	priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme));
-
-	g_free(priv->icon_theme);
-	priv->icon_theme = g_strdup(icon_theme);
-}
-
-void
 pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, GdkColor *color)
 {
 	PidginBlistThemePrivate *priv;
--- a/pidgin/gtkblist-theme.h	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkblist-theme.h	Tue Aug 26 08:28:25 2008 +0000
@@ -35,7 +35,7 @@
 /**
  * extends PurpleTheme (theme.h)
  * A pidgin buddy list theme.
- * This is an object for Purple to represent a sound theme.
+ * This is an object for Purple to represent a buddy list theme.
  *
  * PidginBlistTheme is a PurpleTheme Object.
  */
@@ -99,12 +99,6 @@
 GType pidgin_blist_theme_get_type(void);
 
 /* get methods */
-/**
- * Returns the icon theme to be used with the buddy list theme
- *
- * @returns 	the icon theme
- */
-gchar *pidgin_blist_theme_get_icon_theme(PidginBlistTheme *theme);
 
 /**
  * Returns the background color of the buddy list
@@ -215,13 +209,6 @@
 /* Set Methods */
 
 /**
- * Sets the icon theme to be used for this buddy list theme
- *
- * @param icon_theme	the new icon theme name
- */
-void pidgin_blist_theme_set_icon_theme(PidginBlistTheme *theme, const gchar *icon_theme);
-
-/**
  * Sets the background color to be used for this buddy list theme
  *
  * @param color		the new background color
--- a/pidgin/gtkicon-loader.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkicon-loader.c	Tue Aug 26 08:28:25 2008 +0000
@@ -26,35 +26,25 @@
 
 #include "xmlnode.h"
 
-
-/******************************************************************************
- * Globals
- *****************************************************************************/
 /*****************************************************************************
- * Sound Theme Builder                                                      
+ * Icon Theme Builder                                                      
  *****************************************************************************/
 
 static PurpleTheme *
 pidgin_icon_loader_build(const gchar *dir)
 {
-	xmlnode *root_node, *sub_node;
-	gchar *filename, *filename_full, *data;
-	GDir *gdir;
+	xmlnode *root_node = NULL, *sub_node;
+	gchar *filename_full, *data;
 	PidginIconTheme *theme = NULL;
 
 	/* Find the theme file */
-	gdir = g_dir_open(dir, 0, NULL);
-	g_return_val_if_fail(gdir != NULL, NULL);
+	g_return_val_if_fail(dir != NULL, NULL);
+	filename_full = g_build_filename(dir, "theme.xml", NULL);
 
-	while ((filename = g_strdup(g_dir_read_name(gdir))) != NULL && ! g_str_has_suffix(filename, ".xml"))
-		g_free(filename);
-	
-	g_return_val_if_fail(filename != NULL, NULL);
-	
-	/* Build the xml tree */
-	filename_full = g_build_filename(dir, filename, NULL);
+	if (g_file_test(filename_full, G_FILE_TEST_IS_REGULAR))
+		root_node = xmlnode_from_file(dir, "theme.xml", "sound themes", "sound-loader");
 
-	root_node = xmlnode_from_file(dir, filename, "status icon themes", "icon-loader");
+	g_free(filename_full);
 	g_return_val_if_fail(root_node != NULL, NULL);
 
 	/* Parse the tree */	
@@ -70,19 +60,17 @@
 				    "directory", dir,
 				    "description", data, NULL);
 	
-		xmlnode_free(sub_node);
-	
-		while ((sub_node = xmlnode_get_child(root_node, "icon")) != NULL){
-			pidgin_icon_theme_set_file(theme,
+		sub_node = xmlnode_get_child(root_node, "icon");
+
+		while (sub_node){
+			pidgin_icon_theme_set_icon(theme,
 						   xmlnode_get_attrib(sub_node, "id"),
 						   xmlnode_get_attrib(sub_node, "file"));
-			xmlnode_free(sub_node);
+			sub_node = xmlnode_get_next_twin(sub_node);
 		}
 	}
 
 	xmlnode_free(root_node);	
-	g_dir_close(gdir);
-	g_free(filename_full);
 	g_free(data);
 	return PURPLE_THEME(theme);
 }
--- a/pidgin/gtkicon-theme.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkicon-theme.c	Tue Aug 26 08:28:25 2008 +0000
@@ -45,9 +45,6 @@
 static GObjectClass *parent_class = NULL;
 
 /******************************************************************************
- * Enums
- *****************************************************************************/
-/******************************************************************************
  * GObject Stuff                                                              
  *****************************************************************************/
 
@@ -61,14 +58,14 @@
 
 	priv = PIDGIN_ICON_THEME_GET_PRIVATE(instance);
 
-	priv->icon_files = g_hash_table_new_full (g_str_hash,
+	priv->icon_files = g_hash_table_new_full(g_str_hash,
 						   g_str_equal,
 						   g_free,
 						   g_free);
 }
 
 static void 
-pidgin_icon_theme_finalize (GObject *obj)
+pidgin_icon_theme_finalize(GObject *obj)
 {
 	PidginIconThemePrivate *priv;
 
@@ -76,21 +73,21 @@
 	
 	g_hash_table_destroy(priv->icon_files);
 
-	parent_class->finalize (obj);
+	parent_class->finalize(obj);
 }
 
 static void
-pidgin_icon_theme_class_init (PidginIconThemeClass *klass)
+pidgin_icon_theme_class_init(PidginIconThemeClass *klass)
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
-	parent_class = g_type_class_peek_parent (klass);
+	parent_class = g_type_class_peek_parent(klass);
 
         obj_class->finalize = pidgin_icon_theme_finalize;
 }
 
 GType 
-pidgin_icon_theme_get_type (void)
+pidgin_icon_theme_get_type(void)
 {
   static GType type = 0;
   if (type == 0) {
@@ -106,7 +103,7 @@
       pidgin_icon_theme_init,    /* instance_init */
       NULL,   /* value table */
     };
-    type = g_type_register_static (PURPLE_TYPE_THEME,
+    type = g_type_register_static(PURPLE_TYPE_THEME,
                                    "PidginIconTheme",
                                    &info, G_TYPE_FLAG_ABSTRACT);
   }
@@ -119,7 +116,7 @@
  *****************************************************************************/
 
 const gchar *
-pidgin_icon_theme_get_file(PidginIconTheme *theme,
+pidgin_icon_theme_get_icon(PidginIconTheme *theme,
 			    const gchar *id)
 {
 	PidginIconThemePrivate *priv;
@@ -132,7 +129,7 @@
 }
 
 void 
-pidgin_icon_theme_set_file(PidginIconTheme *theme,
+pidgin_icon_theme_set_icon(PidginIconTheme *theme,
 			    const gchar *id, 
 			    const gchar *filename)
 {
@@ -141,7 +138,8 @@
 	
 	priv = PIDGIN_ICON_THEME_GET_PRIVATE(theme);
 
-	if (filename != NULL)g_hash_table_replace(priv->icon_files,
+	if (filename != NULL)
+		g_hash_table_replace(priv->icon_files,
                  	             g_strdup(id),
                         	     g_strdup(filename));
 	else g_hash_table_remove(priv->icon_files, id);
--- a/pidgin/gtkicon-theme.h	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkicon-theme.h	Tue Aug 26 08:28:25 2008 +0000
@@ -70,21 +70,21 @@
 GType pidgin_icon_theme_get_type(void);
 
 /**
- * Returns a copy of the filename for the icon event
+ * Returns a copy of the filename for the icon event or NULL if it is not set
  *
  * @param event		the pidgin icon event to look up
  *
  * @returns the filename of the icon event
  */
-const gchar *pidgin_icon_theme_get_file(PidginIconTheme *theme,
-				   const gchar *event);
+const gchar *pidgin_icon_theme_get_icon(PidginIconTheme *theme,
+				  	const gchar *event);
 /**
- * Sets the filename for a given icon id
+ * Sets the filename for a given icon id, setting the icon to NULL will remove the icon from the theme
  *
  * @param icon_id		a string representing what the icon is to be used for
  * @param filename		the name of the file to be used for the given id
  */
-void pidgin_icon_theme_set_file(PidginIconTheme *theme,
+void pidgin_icon_theme_set_icon(PidginIconTheme *theme,
 				const gchar *icon_id, 
 			    	const gchar *filename);
 
--- a/pidgin/gtkprefs.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtkprefs.c	Tue Aug 26 08:28:25 2008 +0000
@@ -693,6 +693,7 @@
 	GtkCellRenderer *cell_rend;
 	GtkTreeIter iter;
 	gchar *theme = NULL;
+	gboolean unset = TRUE;
 
 	g_return_val_if_fail(store != NULL && current_theme != NULL, NULL);
 
@@ -714,13 +715,18 @@
 		do {
 			gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 2, &theme, -1);
 
-			if (g_str_equal(current_theme, theme))
+			if (g_str_equal(current_theme, theme)) {
 				gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_box), &iter);
-			
+				unset = FALSE;
+			}
+
 			g_free(theme);
 		} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
 	}
 
+	if (unset)
+		gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), 0);
+
 	return combo_box;
 }
 
--- a/pidgin/gtksound.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/gtksound.c	Tue Aug 26 08:28:25 2008 +0000
@@ -560,7 +560,7 @@
 {
 	char *enable_pref;
 	char *file_pref;
-	char *theme_name;
+	const char *theme_name;
 	PurpleSoundTheme *theme;
 
 	if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
@@ -607,7 +607,6 @@
 		g_free(filename);
 	}
 
-
 	g_free(enable_pref);
 	g_free(file_pref);
 }
--- a/pidgin/pidginstock.c	Sun Aug 10 03:27:12 2008 +0000
+++ b/pidgin/pidginstock.c	Tue Aug 26 08:28:25 2008 +0000
@@ -269,7 +269,7 @@
 	gchar *file_full = NULL;
 
 	if (theme != NULL) {
-		file = pidgin_icon_theme_get_file(PIDGIN_ICON_THEME(theme), sized_icon.name);
+		file = pidgin_icon_theme_get_icon(PIDGIN_ICON_THEME(theme), sized_icon.name);
 		dir = purple_theme_get_dir(PURPLE_THEME(theme));
 
 		if (rtl)
@@ -505,11 +505,11 @@
 	gtk_widget_destroy(win);
 	g_object_unref(G_OBJECT(icon_factory));
 
-	/* Pre-load Status icon theme*/
+	/* Pre-load Status icon theme - this avoids a bug with displaying the correct icon in the tray */
 	if (purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/status/theme") && 
 	   (path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir"))) {
 		
-		PidginStatusIconTheme *theme = purple_theme_loader_build(PURPLE_THEME_LOADER(loader), path);
+		PidginStatusIconTheme *theme = PIDGIN_STATUS_ICON_THEME(purple_theme_loader_build(PURPLE_THEME_LOADER(loader), path));
 		pidgin_stock_load_status_icon_theme(theme);
 		g_object_unref(G_OBJECT(theme));