Mercurial > pidgin.yaz
diff pidgin/gtksound.c @ 25409:bc8d1607f9b8
propagate from branch 'im.pidgin.pidgin' (head 566d2e86bfd45c806aba1b32d6f85a9a409ff9ea)
to branch 'im.pidgin.pidgin.next.minor' (head ffd76856f93610f7cd6178e943d0b61e4220b549)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 26 Jan 2009 02:39:55 +0000 |
parents | 32ad012ef6ac |
children | c0e3b62f8098 |
line wrap: on
line diff
--- a/pidgin/gtksound.c Mon Jan 26 02:39:50 2009 +0000 +++ b/pidgin/gtksound.c Mon Jan 26 02:39:55 2009 +0000 @@ -40,6 +40,8 @@ #include "notify.h" #include "prefs.h" #include "sound.h" +#include "sound-theme.h" +#include "theme-manager.h" #include "util.h" #include "gtkconv.h" @@ -294,6 +296,7 @@ purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); + purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", ""); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE); purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", ""); @@ -557,6 +560,8 @@ { char *enable_pref; char *file_pref; + const char *theme_name; + PurpleSoundTheme *theme; if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) return; @@ -570,16 +575,35 @@ sounds[event].pref); file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref); + + /* check NULL for sounds that don't have an option, ie buddy pounce */ if (purple_prefs_get_bool(enable_pref)) { char *filename = g_strdup(purple_prefs_get_path(file_pref)); - if(!filename || !strlen(filename)) { + theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme"); + + if (theme_name && strlen(theme_name) && (!filename || !strlen(filename))){ /* Use theme */ g_free(filename); + + theme = PURPLE_SOUND_THEME(purple_theme_manager_find_theme(theme_name, "sound")); + filename = purple_sound_theme_get_file_full(theme, sounds[event].pref); + + if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)){ /* Use Default sound in this case */ + purple_debug_error("sound", "The file: (%s) %s\n from theme: %s, was not found or wasn't readable\n", + sounds[event].pref, filename, theme_name); + g_free(filename); + } + } + + if (!filename || !strlen(filename)) { /* Use Default sounds */ + g_free(filename); + /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); } purple_sound_play_file(filename, NULL); + g_free(filename); } @@ -587,6 +611,29 @@ g_free(file_pref); } +gboolean +pidgin_sound_is_customized(void) +{ + gint i; + gchar *path, *file; + + for (i=0; i < PURPLE_NUM_SOUNDS; i++){ + path = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[i].pref); + file = g_strdup(purple_prefs_get_path(path)); + g_free(path); + + if (file && strlen(file)){ + g_free(file); + return TRUE; + } + + g_free(file); + } + + return FALSE; + +} + static PurpleSoundUiOps sound_ui_ops = { pidgin_sound_init,