Mercurial > pidgin
comparison finch/gntsound.c @ 19141:fb880d1adb40
Fix a potential bug.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 07 Jul 2007 01:11:45 +0000 |
parents | 2d0925800d72 |
children | 5f2bcb110f00 |
comparison
equal
deleted
inserted
replaced
19140:7a5025b8698c | 19141:fb880d1adb40 |
---|---|
53 #include "gntslider.h" | 53 #include "gntslider.h" |
54 #include "gnttree.h" | 54 #include "gnttree.h" |
55 #include "gntfilesel.h" | 55 #include "gntfilesel.h" |
56 | 56 |
57 typedef struct { | 57 typedef struct { |
58 PurpleSoundEventID id; | |
58 char *label; | 59 char *label; |
59 char *pref; | 60 char *pref; |
60 char *def; | 61 char *def; |
61 char *file; | 62 char *file; |
62 } FinchSoundEvent; | 63 } FinchSoundEvent; |
81 #ifdef USE_GSTREAMER | 82 #ifdef USE_GSTREAMER |
82 static gboolean gst_init_failed; | 83 static gboolean gst_init_failed; |
83 #endif /* USE_GSTREAMER */ | 84 #endif /* USE_GSTREAMER */ |
84 | 85 |
85 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = { | 86 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = { |
86 {N_("Buddy logs in"), "login", "login.wav",NULL}, | 87 {PURPLE_SOUND_BUDDY_ARRIVE, N_("Buddy logs in"), "login", "login.wav",NULL}, |
87 {N_("Buddy logs out"), "logout", "logout.wav",NULL}, | 88 {PURPLE_SOUND_BUDDY_LEAVE, N_("Buddy logs out"), "logout", "logout.wav",NULL}, |
88 {N_("Message received"), "im_recv", "receive.wav",NULL}, | 89 {PURPLE_SOUND_RECEIVE, N_("Message received"), "im_recv", "receive.wav",NULL}, |
89 {N_("Message received begins conversation"), "first_im_recv", "receive.wav",NULL}, | 90 {PURPLE_SOUND_FIRST_RECEIVE,N_("Message received begins conversation"), "first_im_recv", "receive.wav",NULL}, |
90 {N_("Message sent"), "send_im", "send.wav",NULL}, | 91 {PURPLE_SOUND_SEND, N_("Message sent"), "send_im", "send.wav",NULL}, |
91 {N_("Person enters chat"), "join_chat", "login.wav",NULL}, | 92 {PURPLE_SOUND_CHAT_JOIN, N_("Person enters chat"), "join_chat", "login.wav",NULL}, |
92 {N_("Person leaves chat"), "left_chat", "logout.wav",NULL}, | 93 {PURPLE_SOUND_CHAT_LEAVE, N_("Person leaves chat"), "left_chat", "logout.wav",NULL}, |
93 {N_("You talk in chat"), "send_chat_msg", "send.wav",NULL}, | 94 {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav",NULL}, |
94 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav",NULL}, | 95 {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav",NULL}, |
95 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | 96 {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav",NULL}, |
96 {NULL, "pounce_default", "alert.wav",NULL}, | 97 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your screen name in chat"), "nick_said", "alert.wav",NULL} |
97 {N_("Someone says your screen name in chat"), "nick_said", "alert.wav",NULL} | |
98 }; | 98 }; |
99 | 99 |
100 static gboolean | 100 static gboolean |
101 unmute_login_sounds_cb(gpointer data) | 101 unmute_login_sounds_cb(gpointer data) |
102 { | 102 { |
593 g_free(filepref); | 593 g_free(filepref); |
594 g_free(boolpref); | 594 g_free(boolpref); |
595 } | 595 } |
596 gnt_widget_destroy(GNT_WIDGET(win)); | 596 gnt_widget_destroy(GNT_WIDGET(win)); |
597 } | 597 } |
598 static void | 598 |
599 file_cb(GntWidget *w, gpointer data) | 599 static void |
600 { | 600 file_cb(GntFileSel *w, const char *path, const char *file, gpointer data) |
601 GntFileSel *sel = GNT_FILE_SEL(data); | 601 { |
602 const char * file = gnt_file_sel_get_selected_file(sel); | 602 FinchSoundEvent *event = data; |
603 gpointer key = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)); | |
604 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(key)]; | |
605 | 603 |
606 g_free(event->file); | 604 g_free(event->file); |
607 event->file = g_strdup(file); | 605 event->file = g_strdup(path); |
608 | 606 |
609 gnt_tree_change_text(GNT_TREE(pref_dialog->events),key,1,g_path_get_basename(file)); | 607 gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), 1, file); |
610 | 608 |
611 gnt_widget_destroy(GNT_WIDGET(data)); | 609 gnt_widget_destroy(GNT_WIDGET(w)); |
612 } | 610 } |
613 | 611 |
614 static void | 612 static void |
615 test_cb(GntWidget *button, gpointer null) | 613 test_cb(GntWidget *button, gpointer null) |
616 { | 614 { |
647 | 645 |
648 static void | 646 static void |
649 choose_cb(GntWidget *button, gpointer null) | 647 choose_cb(GntWidget *button, gpointer null) |
650 { | 648 { |
651 GntWidget *w = gnt_file_sel_new(); | 649 GntWidget *w = gnt_file_sel_new(); |
652 | |
653 GntFileSel *sel = GNT_FILE_SEL(w); | 650 GntFileSel *sel = GNT_FILE_SEL(w); |
654 gnt_file_sel_set_current_location(sel,purple_home_dir()); | 651 PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); |
652 FinchSoundEvent * event = &sounds[id]; | |
653 | |
654 gnt_file_sel_set_current_location(sel, | |
655 (event && event->file) ? g_path_get_dirname(event->file) : purple_home_dir()); | |
655 | 656 |
656 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel); | 657 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel); |
657 g_signal_connect(G_OBJECT(sel->select),"activate",G_CALLBACK(file_cb),sel); | 658 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_cb), event); |
658 | 659 |
659 gnt_widget_show(w); | 660 gnt_widget_show(w); |
660 } | 661 } |
661 | 662 |
662 static void | 663 static void |
793 } | 794 } |
794 | 795 |
795 gnt_tree_adjust_columns(GNT_TREE(tree)); | 796 gnt_tree_adjust_columns(GNT_TREE(tree)); |
796 gnt_box_add_widget(GNT_BOX(win),tree); | 797 gnt_box_add_widget(GNT_BOX(win),tree); |
797 | 798 |
798 box = gnt_hbox_new(TRUE); | 799 box = gnt_hbox_new(FALSE); |
799 button = gnt_button_new("Test"); | 800 button = gnt_button_new("Test"); |
800 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(test_cb),NULL); | 801 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(test_cb),NULL); |
801 gnt_box_add_widget(GNT_BOX(box),button); | 802 gnt_box_add_widget(GNT_BOX(box),button); |
802 button = gnt_button_new("Reset"); | 803 button = gnt_button_new("Reset"); |
803 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(reset_cb),NULL); | 804 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(reset_cb),NULL); |
805 button = gnt_button_new("Choose..."); | 806 button = gnt_button_new("Choose..."); |
806 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(choose_cb),NULL); | 807 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(choose_cb),NULL); |
807 gnt_box_add_widget(GNT_BOX(box),button); | 808 gnt_box_add_widget(GNT_BOX(box),button); |
808 gnt_box_add_widget(GNT_BOX(win),box); | 809 gnt_box_add_widget(GNT_BOX(win),box); |
809 | 810 |
810 box = gnt_hbox_new(TRUE); | 811 box = gnt_hbox_new(FALSE); |
811 gnt_box_set_pad(GNT_BOX(box),0); | 812 gnt_box_set_pad(GNT_BOX(box),0); |
812 gnt_box_set_fill(GNT_BOX(box),TRUE); | 813 gnt_box_set_fill(GNT_BOX(box),TRUE); |
813 button = gnt_button_new("Save"); | 814 button = gnt_button_new("Save"); |
814 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),win); | 815 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),win); |
815 gnt_box_add_widget(GNT_BOX(box),button); | 816 gnt_box_add_widget(GNT_BOX(box),button); |