changeset 23464:9ffbfbcf307d

Fixed purple sound loader class init function (bug on startup) and added shell sound theme selector
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Sat, 21 Jun 2008 05:55:58 +0000
parents 51bdbab30704
children d60c3d1c6966
files libpurple/core.c libpurple/sound-loader.c libpurple/sound-loader.h libpurple/theme-loader.c libpurple/theme-manager.c pidgin/gtkprefs.c
diffstat 6 files changed, 46 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/core.c	Tue Jun 17 03:26:00 2008 +0000
+++ b/libpurple/core.c	Sat Jun 21 05:55:58 2008 +0000
@@ -45,10 +45,12 @@
 #include "signals.h"
 #include "smiley.h"
 #include "sound.h"
+#include "sound-loader.h"
 #include "sslconn.h"
 #include "status.h"
 #include "stun.h"
 #include "util.h"
+#include "theme-manager.h"
 
 #ifdef HAVE_DBUS
 #  ifndef DBUS_API_SUBJECT_TO_CHANGE
@@ -147,6 +149,7 @@
 	/* Accounts use status, buddy icons and connection signals, so
 	 * initialize these before accounts
 	 */
+	purple_theme_manager_init(g_object_new(PURPLE_TYPE_SOUND_THEME_LOADER, NULL), NULL);
 	purple_status_init();
 	purple_buddy_icons_init();
 	purple_connections_init();
@@ -169,7 +172,7 @@
 	purple_xfers_init();
 	purple_idle_init();
 	purple_smileys_init();
-
+		
 	/*
 	 * Call this early on to try to auto-detect our IP address and
 	 * hopefully save some time later.
@@ -178,6 +181,7 @@
 
 	if (ops != NULL && ops->ui_init != NULL)
 		ops->ui_init();
+	
 
 	return TRUE;
 }
@@ -213,6 +217,7 @@
 	purple_status_uninit();
 	purple_prefs_uninit();
 	purple_sound_uninit();
+	purple_theme_manager_uninit();
 	purple_xfers_uninit();
 	purple_proxy_uninit();
 	purple_dnsquery_uninit();
--- a/libpurple/sound-loader.c	Tue Jun 17 03:26:00 2008 +0000
+++ b/libpurple/sound-loader.c	Sat Jun 21 05:55:58 2008 +0000
@@ -22,6 +22,7 @@
  */
 
 #include "sound-loader.h"
+#include "sound-theme.h"
 #include "util.h"
 #include "xmlnode.h"
 
@@ -102,9 +103,9 @@
 static void
 purple_sound_theme_loader_class_init (PurpleSoundThemeLoaderClass *klass)
 {
-	parent_class = g_type_class_peek_parent (klass);
-	
-	parent_class->purple_theme_loader_build = purple_sound_loader_build;
+	PurpleThemeLoaderClass *loader_klass = PURPLE_THEME_LOADER_CLASS(klass);
+
+	loader_klass->purple_theme_loader_build = purple_sound_loader_build;
 }
 
 
--- a/libpurple/sound-loader.h	Tue Jun 17 03:26:00 2008 +0000
+++ b/libpurple/sound-loader.h	Sat Jun 21 05:55:58 2008 +0000
@@ -29,7 +29,6 @@
 #include <glib.h>
 #include <glib-object.h>
 #include "theme-loader.h"
-#include "sound-theme.h"
 
 /**
  * A purple sound theme loader. extends PurpleThemeLoader (theme-loader.h)
@@ -40,9 +39,9 @@
 typedef struct _PurpleSoundThemeLoader        PurpleSoundThemeLoader;
 typedef struct _PurpleSoundThemeLoaderClass   PurpleSoundThemeLoaderClass;
 
-#define PURPLE_TYPE_SOUND_THEME_LOADER		  	  (purple_sound_theme_loader_get_type ())
-#define PURPLE_SOUND_THEME_LOADER(obj)	 		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_TYPE_SOUND_THEME_LOADER, PurpleSoundThemeLoader))
-#define PURPLE_SOUND_THEME_LOADER_CLASS(klass)	  	  (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_TYPE_SOUND_THEME_LOADER, PurpleSoundThemeLoaderClass))
+#define PURPLE_TYPE_SOUND_THEME_LOADER			  (purple_sound_theme_loader_get_type ())
+#define PURPLE_SOUND_THEME_LOADER(obj)			  (G_TYPE_CHECK_INSTANCE_CAST ((obj), PURPLE_TYPE_SOUND_THEME_LOADER, PurpleSoundThemeLoader))
+#define PURPLE_SOUND_THEME_LOADER_CLASS(klass)		  (G_TYPE_CHECK_CLASS_CAST ((klass), PURPLE_TYPE_SOUND_THEME_LOADER, PurpleSoundThemeLoaderClass))
 #define PURPLE_IS_SOUND_THEME_LOADER(obj)	  	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PURPLE_TYPE_SOUND_THEME_LOADER))
 #define PURPLE_IS_SOUND_THEME_LOADER_CLASS(klass) 	  (G_TYPE_CHECK_CLASS_TYPE ((klass), PURPLE_TYPE_SOUND_THEME_LOADER))
 #define PURPLE_SOUND_THEME_LOADER_GET_CLASS(obj)  	  (G_TYPE_INSTANCE_GET_CLASS ((obj), PURPLE_TYPE_SOUND_THEME_LOADER, PurpleSoundThemeLoaderClass))
--- a/libpurple/theme-loader.c	Tue Jun 17 03:26:00 2008 +0000
+++ b/libpurple/theme-loader.c	Sat Jun 21 05:55:58 2008 +0000
@@ -90,7 +90,7 @@
 {
 	PurpleThemeLoader *loader = PURPLE_THEME_LOADER(obj);	
 	PurpleThemeLoaderPrivate *priv = PURPLE_THEME_LOADER_GET_PRIVATE(loader);
-	
+
 	g_free(priv->type);
 
 	parent_class->finalize (obj);
@@ -101,13 +101,13 @@
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 	GParamSpec *pspec;
-
+	
 	parent_class = g_type_class_peek_parent (klass);
 
 	obj_class->get_property = purple_theme_loader_get_property;
 	obj_class->set_property = purple_theme_loader_set_property;
 	obj_class->finalize = purple_theme_loader_finalize;
-	
+
 	/* TYPE STRING (read only) */
 	pspec = g_param_spec_string(PROP_TYPE_S, "Type",
 				    "The string represtenting the type of the theme",
--- a/libpurple/theme-manager.c	Tue Jun 17 03:26:00 2008 +0000
+++ b/libpurple/theme-manager.c	Sat Jun 21 05:55:58 2008 +0000
@@ -28,7 +28,7 @@
  * Globals
  *****************************************************************************/
 
-static GHashTable *theme_table;
+static GHashTable *theme_table = NULL;
 
 /*****************************************************************************
  * GObject Stuff                                                     
@@ -147,7 +147,7 @@
 	va_list args;
 	PurpleThemeLoader *loader;
 
-	g_return_if_fail(theme_table != NULL);
+	/*g_return_if_fail(theme_table != NULL);*/
 
 	theme_table = g_hash_table_new_full (g_str_hash,
                	                             g_str_equal,
@@ -160,7 +160,7 @@
 	va_end(args);
 
 	/* TODO: add themes properly */
-	purple_theme_manager_build_dir(NULL);
+	purple_theme_manager_build_dir("/usr/share/themes");
 }
 
 void 
@@ -171,7 +171,7 @@
                 	             NULL);	
 	
 	/* TODO: this also needs to be fixed the same as new */
-	purple_theme_manager_build_dir(NULL);
+	purple_theme_manager_build_dir("/usr/share/themes");
 
 }
 
@@ -189,14 +189,12 @@
 
 	g_return_if_fail(PURPLE_IS_THEME_LOADER(loader));
 
-	type = purple_theme_loader_get_type_string(loader);
+	type = g_strdup(purple_theme_loader_get_type_string(loader));
 	g_return_if_fail(type);
 
 	/* if something is already there do nothing */
 	if (! g_hash_table_lookup (theme_table, type)) 
 		g_hash_table_insert(theme_table, type, loader);
-	
-	g_free(type);
 }
 
 void
--- a/pidgin/gtkprefs.c	Tue Jun 17 03:26:00 2008 +0000
+++ b/pidgin/gtkprefs.c	Sat Jun 21 05:55:58 2008 +0000
@@ -69,6 +69,8 @@
 static int notebook_page = 0;
 static GtkTreeRowReference *previous_smiley_row = NULL;
 
+static GtkListStore *sound_themes;
+
 /*
  * PROTOTYPES
  */
@@ -1832,7 +1834,7 @@
 sound_page(void)
 {
 	GtkWidget *ret;
-	GtkWidget *vbox, *sw, *button;
+	GtkWidget *vbox, *sw, *button, *combo_box;
 	GtkSizeGroup *sg;
 	GtkTreeIter iter;
 	GtkWidget *event_view;
@@ -1845,6 +1847,8 @@
 	int j;
 	const char *file;
 	char *pref;
+	GtkCellRenderer *cell_rend;
+	GdkPixbuf *pixbuf;
 #ifndef _WIN32
 	GtkWidget *dd;
 	GtkWidget *entry;
@@ -1922,7 +1926,6 @@
 	purple_prefs_connect_callback(prefs, PIDGIN_PREFS_ROOT "/sound/method",
 								sound_changed2_cb, vbox);
 #endif
-
 	vbox = pidgin_make_frame(ret, _("Sound Events"));
 
 	/* The following is an ugly hack to make the frame expand so the
@@ -1934,6 +1937,26 @@
 	gtk_box_set_child_packing(GTK_BOX(vbox->parent->parent->parent),
 			vbox->parent->parent, TRUE, TRUE, 0, GTK_PACK_START);
 
+	/* SOUND THEMES */
+	sound_themes = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+
+	combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (sound_themes));
+	gtk_box_pack_start (GTK_BOX (vbox), combo_box, FALSE, FALSE, 0);
+
+	cell_rend = gtk_cell_renderer_pixbuf_new ();
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell_rend, FALSE);
+	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell_rend, "pixbuf", 0, NULL);
+	
+	cell_rend = gtk_cell_renderer_text_new ();
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell_rend, FALSE);
+	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell_rend, "text", 1, NULL);
+	
+	pixbuf = gdk_pixbuf_new_from_file (NULL, NULL);
+	gtk_list_store_append (sound_themes, &iter);
+	gtk_list_store_set (sound_themes, &iter, 0, pixbuf, 1, _("(Default)"), -1);
+	gdk_pixbuf_unref (pixbuf);
+
+	/* SOUND SELECTION */
 	sw = gtk_scrolled_window_new(NULL,NULL);
 	gtk_widget_set_size_request(sw, -1, 100);
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);