pidgin/gtksound.c

branch
cpw.attention_ui
changeset 26047
a7c475364465
parent 25932
8c579d02a976
parent 25888
d0fdd378a635
child 26795
e09a6fd69ee7
equal deleted inserted replaced
25949:afdac7a0f6a4 26047:a7c475364465
38 38
39 #include "debug.h" 39 #include "debug.h"
40 #include "notify.h" 40 #include "notify.h"
41 #include "prefs.h" 41 #include "prefs.h"
42 #include "sound.h" 42 #include "sound.h"
43 #include "sound-theme.h"
44 #include "theme-manager.h"
43 #include "util.h" 45 #include "util.h"
44 46
45 #include "gtkconv.h" 47 #include "gtkconv.h"
46 #include "gtksound.h" 48 #include "gtksound.h"
47 49
308 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv", ""); 310 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv", "");
309 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE); 311 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE);
310 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", ""); 312 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", "");
311 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); 313 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE);
312 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", ""); 314 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", "");
315 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", "");
313 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE); 316 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE);
314 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", ""); 317 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", "");
315 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE); 318 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE);
316 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", ""); 319 purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", "");
317 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE); 320 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE);
581 static void 584 static void
582 pidgin_sound_play_event(PurpleSoundEventID event) 585 pidgin_sound_play_event(PurpleSoundEventID event)
583 { 586 {
584 char *enable_pref; 587 char *enable_pref;
585 char *file_pref; 588 char *file_pref;
589 const char *theme_name;
590 PurpleSoundTheme *theme;
586 591
587 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) 592 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
588 return; 593 return;
589 594
590 if (event >= PURPLE_NUM_SOUNDS) { 595 if (event >= PURPLE_NUM_SOUNDS) {
597 file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref); 602 file_pref = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[event].pref);
598 603
599 /* check NULL for sounds that don't have an option, ie buddy pounce */ 604 /* check NULL for sounds that don't have an option, ie buddy pounce */
600 if (purple_prefs_get_bool(enable_pref)) { 605 if (purple_prefs_get_bool(enable_pref)) {
601 char *filename = g_strdup(purple_prefs_get_path(file_pref)); 606 char *filename = g_strdup(purple_prefs_get_path(file_pref));
602 if(!filename || !strlen(filename)) { 607 theme_name = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/theme");
608
609 if (theme_name && *theme_name && (!filename || !*filename)) {
610 /* Use theme */
603 g_free(filename); 611 g_free(filename);
612
613 theme = PURPLE_SOUND_THEME(purple_theme_manager_find_theme(theme_name, "sound"));
614 filename = purple_sound_theme_get_file_full(theme, sounds[event].pref);
615
616 if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)){ /* Use Default sound in this case */
617 purple_debug_error("sound", "The file: (%s) %s\n from theme: %s, was not found or wasn't readable\n",
618 sounds[event].pref, filename, theme_name);
619 g_free(filename);
620 }
621 }
622
623 if (!filename || !strlen(filename)) { /* Use Default sounds */
624 g_free(filename);
625
604 /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */ 626 /* XXX Consider creating a constant for "sounds/purple" to be shared with Finch */
605 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); 627 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
606 } 628 }
607 629
608 purple_sound_play_file(filename, NULL); 630 purple_sound_play_file(filename, NULL);
631
609 g_free(filename); 632 g_free(filename);
610 } 633 }
611 634
612 g_free(enable_pref); 635 g_free(enable_pref);
613 g_free(file_pref); 636 g_free(file_pref);
637 }
638
639 gboolean
640 pidgin_sound_is_customized(void)
641 {
642 gint i;
643 gchar *path, *file;
644
645 for (i = 0; i < PURPLE_NUM_SOUNDS; i++) {
646 path = g_strdup_printf(PIDGIN_PREFS_ROOT "/sound/file/%s", sounds[i].pref);
647 file = g_strdup(purple_prefs_get_path(path));
648 g_free(path);
649
650 if (file && file[0] != '\0'){
651 g_free(file);
652 return TRUE;
653 }
654
655 g_free(file);
656 }
657
658 return FALSE;
659
614 } 660 }
615 661
616 static PurpleSoundUiOps sound_ui_ops = 662 static PurpleSoundUiOps sound_ui_ops =
617 { 663 {
618 pidgin_sound_init, 664 pidgin_sound_init,

mercurial