finch/gntsound.c

Thu, 05 Jul 2007 02:34:30 +0000

author
Eric Polino <aluink@pidgin.im>
date
Thu, 05 Jul 2007 02:34:30 +0000
branch
soc.2007.finchfeat
changeset 18440
9d1e67686dfb
parent 18439
5b6c9a328910
child 18616
ce2f681adadf
permissions
-rw-r--r--

Some more work to the sound prefs

Added: Events, still can't reset

18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
1 /**
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
2 * @file gntsound.c GNT Sound API
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
3 * @ingroup finch
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
4 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
5 * finch
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
6 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
7 * Finch is the legal property of its developers, whose names are too numerous
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
9 * source distribution.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
10 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
15 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
20 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
24 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
25 #include "internal.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
26 #include "finch.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
27
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
28 #ifdef _WIN32
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
29 #include <windows.h>
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
30 #include <mmsystem.h>
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
31 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
32
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
33 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
34 #include <gst/gst.h>
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
35 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
36
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
37 #include "debug.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
38 #include "notify.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
39 #include "prefs.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
40 #include "sound.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
41 #include "util.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
42
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
43 #include "gntbox.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
44 #include "gntwindow.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
45 #include "gntcombobox.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
46 #include "gntlabel.h"
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
47 #include "gntconv.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
48 #include "gntsound.h"
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
49 #include "gntwidget.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
50 #include "gntentry.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
51 #include "gntcheckbox.h"
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
52 #include "gntline.h"
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
53 #include "gntslider.h"
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
54 #include "gnttree.h"
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
55 #include "gntfilesel.h"
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
56
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
57 typedef struct {
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
58 char *label;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
59 char *pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
60 char *def;
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
61 PurpleSoundEventID id;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
62 } FinchSoundEvent;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
63
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
64 typedef struct {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
65 FinchSoundEvent *event;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
66 char *file;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
67 } FinchSoundPrefEvent;
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
68
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
69 typedef struct {
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
70 GntWidget *method;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
71 GntWidget *command;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
72 GntWidget *conv_focus;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
73 GntWidget *while_status;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
74 GntWidget *volume;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
75 GntWidget *events;
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
76 GntWidget *window;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
77 } SoundPrefDialog;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
78
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
79 SoundPrefDialog *pref_dialog;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
80
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
81 #define PLAY_SOUND_TIMEOUT 15000
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
82
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
83 static guint mute_login_sounds_timeout = 0;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
84 static gboolean mute_login_sounds = FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
85
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
86 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
87 static gboolean gst_init_failed;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
88 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
89
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
90 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
91 {N_("Buddy logs in"), "login", "login.wav",PURPLE_SOUND_BUDDY_ARRIVE},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
92 {N_("Buddy logs out"), "logout", "logout.wav",PURPLE_SOUND_BUDDY_LEAVE},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
93 {N_("Message received"), "im_recv", "receive.wav",PURPLE_SOUND_RECEIVE},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
94 {N_("Message received begins conversation"), "first_im_recv", "receive.wav",PURPLE_SOUND_FIRST_RECEIVE},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
95 {N_("Message sent"), "send_im", "send.wav",PURPLE_SOUND_SEND},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
96 {N_("Person enters chat"), "join_chat", "login.wav",PURPLE_SOUND_CHAT_JOIN},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
97 {N_("Person leaves chat"), "left_chat", "logout.wav",PURPLE_SOUND_CHAT_LEAVE},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
98 {N_("You talk in chat"), "send_chat_msg", "send.wav",PURPLE_SOUND_CHAT_YOU_SAY},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
99 {N_("Others talk in chat"), "chat_msg_recv", "receive.wav",PURPLE_SOUND_CHAT_SAY},
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
100 /* this isn't a terminator, it's the buddy pounce default sound event ;-) */
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
101 {NULL, "pounce_default", "alert.wav",PURPLE_SOUND_POUNCE_DEFAULT},
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
102 {N_("Someone says your screen name in chat"), "nick_said", "alert.wav",PURPLE_SOUND_CHAT_NICK}
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
103 };
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
104
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
105 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
106 unmute_login_sounds_cb(gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
107 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
108 mute_login_sounds = FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
109 mute_login_sounds_timeout = 0;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
110 return FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
111 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
112
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
113 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
114 chat_nick_matches_name(PurpleConversation *conv, const char *aname)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
115 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
116 PurpleConvChat *chat = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
117 char *nick = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
118 char *name = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
119 gboolean ret = FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
120 chat = purple_conversation_get_chat_data(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
121
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
122 if (chat==NULL)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
123 return ret;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
124
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
125 nick = g_strdup(purple_normalize(conv->account, chat->nick));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
126 name = g_strdup(purple_normalize(conv->account, aname));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
127
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
128 if (g_utf8_collate(nick, name) == 0)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
129 ret = TRUE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
130
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
131 g_free(nick);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
132 g_free(name);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
133
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
134 return ret;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
135 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
136
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
137 /*
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
138 * play a sound event for a conversation, honoring make_sound flag
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
139 * of conversation and checking for focus if conv_focus pref is set
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
140 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
141 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
142 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
143 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
144 /* If we should not play the sound for some reason, then exit early */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
145 if (conv != NULL)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
146 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
147 FinchConv *gntconv;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
148 gboolean has_focus;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
149
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
150 gntconv = FINCH_CONV(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
151
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
152 has_focus = purple_conversation_has_focus(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
153
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
154 if (has_focus && !purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus"))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
155 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
156 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
157 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
158 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
159
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
160 purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
161 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
162
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
163 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
164 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
165 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
166 purple_sound_play_event(event, purple_buddy_get_account(buddy));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
167 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
168
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
169 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
170 im_msg_received_cb(PurpleAccount *account, char *sender,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
171 char *message, PurpleConversation *conv,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
172 PurpleMessageFlags flags, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
173 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
174 if (flags & PURPLE_MESSAGE_DELAYED)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
175 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
176
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
177 if (conv==NULL){
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
178 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
179 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
180 else{
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
181 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
182 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
183 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
184
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
185 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
186 im_msg_sent_cb(PurpleAccount *account, const char *receiver,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
187 const char *message, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
188 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
189 PurpleConversation *conv = purple_find_conversation_with_account(
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
190 PURPLE_CONV_TYPE_ANY, receiver, account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
191 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
192 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
193
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
194 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
195 chat_buddy_join_cb(PurpleConversation *conv, const char *name,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
196 PurpleConvChatBuddyFlags flags, gboolean new_arrival,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
197 PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
198 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
199 if (new_arrival && !chat_nick_matches_name(conv, name))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
200 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
201 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
202
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
203 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
204 chat_buddy_left_cb(PurpleConversation *conv, const char *name,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
205 const char *reason, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
206 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
207 if (!chat_nick_matches_name(conv, name))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
208 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
209 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
210
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
211 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
212 chat_msg_sent_cb(PurpleAccount *account, const char *message,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
213 int id, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
214 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
215 PurpleConnection *conn = purple_account_get_connection(account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
216 PurpleConversation *conv = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
217
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
218 if (conn!=NULL)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
219 conv = purple_find_chat(conn,id);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
220
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
221 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
222 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
223
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
224 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
225 chat_msg_received_cb(PurpleAccount *account, char *sender,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
226 char *message, PurpleConversation *conv,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
227 PurpleMessageFlags flags, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
228 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
229 PurpleConvChat *chat;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
230
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
231 if (flags & PURPLE_MESSAGE_DELAYED)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
232 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
233
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
234 chat = purple_conversation_get_chat_data(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
235 g_return_if_fail(chat != NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
236
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
237 if (purple_conv_chat_is_user_ignored(chat, sender))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
238 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
239
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
240 if (chat_nick_matches_name(conv, sender))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
241 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
242
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
243 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
244 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
245 else
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
246 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
247 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
248
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
249 /*
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
250 * We mute sounds for the 10 seconds after you log in so that
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
251 * you don't get flooded with sounds when the blist shows all
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
252 * your buddies logging in.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
253 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
254 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
255 account_signon_cb(PurpleConnection *gc, gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
256 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
257 if (mute_login_sounds_timeout != 0)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
258 g_source_remove(mute_login_sounds_timeout);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
259 mute_login_sounds = TRUE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
260 mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
261 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
262
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
263 const char *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
264 finch_sound_get_event_option(PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
265 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
266 if(event >= PURPLE_NUM_SOUNDS)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
267 return 0;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
268
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
269 return sounds[event].pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
270 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
271
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
272 const char *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
273 finch_sound_get_event_label(PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
274 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
275 if(event >= PURPLE_NUM_SOUNDS)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
276 return NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
277
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
278 return sounds[event].label;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
279 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
280
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
281 void *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
282 finch_sound_get_handle()
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
283 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
284 static int handle;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
285
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
286 return &handle;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
287 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
288
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
289 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
290 finch_sound_init(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
291 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
292 void *gnt_sound_handle = finch_sound_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
293 void *blist_handle = purple_blist_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
294 void *conv_handle = purple_conversations_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
295 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
296 GError *error = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
297 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
298
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
299 purple_signal_connect(purple_connections_get_handle(), "signed-on",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
300 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
301 NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
302
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
303 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
304 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/enabled");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
305 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/file");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
306 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/login", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
307 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/login", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
308 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/logout", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
309 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/logout", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
310 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/im_recv", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
311 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/im_recv", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
312 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
313 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/first_im_recv", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
314 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_im", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
315 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_im", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
316 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/join_chat", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
317 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/join_chat", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
318 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/left_chat", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
319 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/left_chat", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
320 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
321 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_chat_msg", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
322 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
323 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/chat_msg_recv", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
324 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/nick_said", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
325 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/nick_said", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
326 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/pounce_default", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
327 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/pounce_default", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
328 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/conv_focus", TRUE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
329 purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/mute", FALSE);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
330 purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/command", "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
331 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/method", "automatic");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
332 purple_prefs_add_int(FINCH_PREFS_ROOT "/sound/volume", 50);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
333
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
334 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
335 purple_debug_info("sound", "Initializing sound output drivers.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
336 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
337 purple_notify_error(NULL, _("GStreamer Failure"),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
338 _("GStreamer failed to initialize."),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
339 error ? error->message : "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
340 if (error) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
341 g_error_free(error);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
342 error = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
343 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
344 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
345 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
346
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
347 purple_signal_connect(blist_handle, "buddy-signed-on",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
348 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
349 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
350 purple_signal_connect(blist_handle, "buddy-signed-off",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
351 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
352 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
353 purple_signal_connect(conv_handle, "received-im-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
354 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
355 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
356 purple_signal_connect(conv_handle, "sent-im-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
357 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
358 GINT_TO_POINTER(PURPLE_SOUND_SEND));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
359 purple_signal_connect(conv_handle, "chat-buddy-joined",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
360 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
361 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
362 purple_signal_connect(conv_handle, "chat-buddy-left",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
363 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
364 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
365 purple_signal_connect(conv_handle, "sent-chat-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
366 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
367 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
368 purple_signal_connect(conv_handle, "received-chat-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
369 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
370 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
371 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
372
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
373 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
374 finch_sound_uninit(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
375 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
376 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
377 if (!gst_init_failed)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
378 gst_deinit();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
379 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
380
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
381 purple_signals_disconnect_by_handle(finch_sound_get_handle());
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
382 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
383
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
384 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
385 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
386 bus_call (GstBus *bus, GstMessage *msg, gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
387 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
388 GstElement *play = data;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
389 GError *err = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
390
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
391 switch (GST_MESSAGE_TYPE (msg)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
392 case GST_MESSAGE_EOS:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
393 gst_element_set_state(play, GST_STATE_NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
394 gst_object_unref(GST_OBJECT(play));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
395 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
396 case GST_MESSAGE_ERROR:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
397 gst_message_parse_error(msg, &err, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
398 purple_debug_error("gstreamer", err->message);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
399 g_error_free(err);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
400 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
401 case GST_MESSAGE_WARNING:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
402 gst_message_parse_warning(msg, &err, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
403 purple_debug_warning("gstreamer", err->message);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
404 g_error_free(err);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
405 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
406 default:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
407 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
408 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
409 return TRUE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
410 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
411 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
412
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
413 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
414 finch_sound_play_file(const char *filename)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
415 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
416 const char *method;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
417 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
418 float volume;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
419 char *uri;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
420 GstElement *sink = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
421 GstElement *play = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
422 GstBus *bus = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
423 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
424 if (purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/mute"))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
425 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
426
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
427 method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
428
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
429 if (!strcmp(method, "none")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
430 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
431 } else if (!strcmp(method, "beep")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
432 beep();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
433 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
434 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
435
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
436 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
437 purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
438 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
439 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
440
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
441 #ifndef _WIN32
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
442 if (!strcmp(method, "custom")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
443 const char *sound_cmd;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
444 char *command;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
445 char *esc_filename;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
446 GError *error = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
447
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
448 sound_cmd = purple_prefs_get_path(FINCH_PREFS_ROOT "/sound/command");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
449
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
450 if (!sound_cmd || *sound_cmd == '\0') {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
451 purple_debug_error("gntsound",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
452 "'Command' sound method has been chosen, "
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
453 "but no command has been set.");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
454 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
455 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
456
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
457 esc_filename = g_shell_quote(filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
458
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
459 if(strstr(sound_cmd, "%s"))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
460 command = purple_strreplace(sound_cmd, "%s", esc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
461 else
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
462 command = g_strdup_printf("%s %s", sound_cmd, esc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
463
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
464 if(!g_spawn_command_line_async(command, &error)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
465 purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
466 g_error_free(error);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
467 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
468
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
469 g_free(esc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
470 g_free(command);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
471 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
472 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
473 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
474 if (gst_init_failed) /* Perhaps do beep instead? */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
475 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
476 volume = (float)(CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100)) / 50;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
477 if (!strcmp(method, "automatic")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
478 if (purple_running_gnome()) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
479 sink = gst_element_factory_make("gconfaudiosink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
480 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
481 if (!sink)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
482 sink = gst_element_factory_make("autoaudiosink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
483 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
484 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
485 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
486 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
487 } else if (!strcmp(method, "esd")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
488 sink = gst_element_factory_make("esdsink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
489 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
490 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
491 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
492 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
493 } else if (!strcmp(method, "alsa")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
494 sink = gst_element_factory_make("alsasink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
495 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
496 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
497 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
498 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
499 } else {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
500 purple_debug_error("sound", "Unknown sound method '%s'\n", method);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
501 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
502 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
503
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
504 play = gst_element_factory_make("playbin", "play");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
505
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
506 if (play == NULL) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
507 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
508 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
509
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
510 uri = g_strdup_printf("file://%s", filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
511
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
512 g_object_set(G_OBJECT(play), "uri", uri,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
513 "volume", volume,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
514 "audio-sink", sink, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
515
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
516 bus = gst_pipeline_get_bus(GST_PIPELINE(play));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
517 gst_bus_add_watch(bus, bus_call, play);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
518
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
519 gst_element_set_state(play, GST_STATE_PLAYING);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
520
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
521 gst_object_unref(bus);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
522 g_free(uri);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
523
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
524 #else /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
525 beep();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
526 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
527 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
528 #else /* _WIN32 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
529 purple_debug_info("sound", "Playing %s\n", filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
530
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
531 if (G_WIN32_HAVE_WIDECHAR_API ()) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
532 wchar_t *wc_filename = g_utf8_to_utf16(filename,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
533 -1, NULL, NULL, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
534 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
535 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
536 g_free(wc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
537 } else {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
538 char *l_filename = g_locale_from_utf8(filename,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
539 -1, NULL, NULL, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
540 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
541 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
542 g_free(l_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
543 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
544 #endif /* _WIN32 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
545 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
546
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
547 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
548 finch_sound_play_event(PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
549 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
550 char *enable_pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
551 char *file_pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
552 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
553 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
554
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
555 if (event >= PURPLE_NUM_SOUNDS) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
556 purple_debug_error("sound", "got request for unknown sound: %d\n", event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
557 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
558 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
559
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
560 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
561 sounds[event].pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
562 file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/file/%s", sounds[event].pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
563
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
564 /* check NULL for sounds that don't have an option, ie buddy pounce */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
565 if (purple_prefs_get_bool(enable_pref)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
566 char *filename = g_strdup(purple_prefs_get_path(file_pref));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
567 if(!filename || !strlen(filename)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
568 g_free(filename);
18292
Eric Polino <aluink@pidgin.im>
parents: 18155
diff changeset
569 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */
Eric Polino <aluink@pidgin.im>
parents: 18155
diff changeset
570 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
571 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
572
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
573 purple_sound_play_file(filename, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
574 g_free(filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
575 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
576
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
577 g_free(enable_pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
578 g_free(file_pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
579 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
580
18438
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
581 static void
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
582 save_cb(GntWidget *button, gpointer win)
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
583 {
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
584 gint i;
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
585
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
586 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/method", gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method)));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
587 purple_prefs_set_path(FINCH_PREFS_ROOT "/sound/command", gnt_entry_get_text(GNT_ENTRY(pref_dialog->command)));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
588 purple_prefs_set_bool(FINCH_PREFS_ROOT "/sound/conv_focus",gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus)));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
589 purple_prefs_set_int("/purple/sound/while_status",GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status))));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
590 purple_prefs_set_int(FINCH_PREFS_ROOT "/sound/volume",gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
591
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
592 for(i = 0;i < PURPLE_NUM_SOUNDS;i++){
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
593 GList * itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
594 for(;itr;itr = itr->next){
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
595 FinchSoundPrefEvent * event = itr->data;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
596 char * pref = g_strdup_printf("%s/sound/file/%s",FINCH_PREFS_ROOT,event->event->pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
597 if(event->file)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
598 purple_prefs_set_path(pref,event->file);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
599 g_free(pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
600 }
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
601 }
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
602 gnt_widget_destroy(GNT_WIDGET(win));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
603 }
18438
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
604 static void
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
605 file_cb(GntWidget *w, gpointer data)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
606 {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
607 GntFileSel *sel = GNT_FILE_SEL(data);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
608 const char * file = gnt_file_sel_get_selected_file(sel);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
609 FinchSoundPrefEvent * event = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
610
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
611 if(event->file)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
612 g_free(event->file);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
613 event->file = g_strdup(file);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
614
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
615 gnt_widget_destroy(GNT_WIDGET(data));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
616 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
617
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
618 static void
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
619 test_cb(GntWidget *button, gpointer null)
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
620 {
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
621 FinchSoundPrefEvent * event = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
622 char *pref;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
623 gboolean temp_value;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
624
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
625 pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s",
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
626 event->event->pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
627
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
628 temp_value = purple_prefs_get_bool(pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
629
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
630 if (!temp_value) purple_prefs_set_bool(pref, TRUE);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
631
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
632 purple_sound_play_event(event->event->id, NULL);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
633
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
634 if (!temp_value) purple_prefs_set_bool(pref, FALSE);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
635
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
636 g_free(pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
637 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
638
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
639 static void
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
640 reset_cb(GntWidget *button,gpointer null)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
641 {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
642
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
643 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
644
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
645 static void
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
646 choose_cb(GntWidget *button, gpointer null)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
647 {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
648 GntWidget *w = gnt_file_sel_new();
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
649
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
650 GntFileSel *sel = GNT_FILE_SEL(w);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
651 gnt_file_sel_set_current_location(sel,purple_home_dir());
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
652
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
653 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
654 g_signal_connect(G_OBJECT(sel->select),"activate",G_CALLBACK(file_cb),sel);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
655
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
656 gnt_widget_show(w);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
657 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
658
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
659 static void
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
660 release_pref_dialog(GntBindable *data, gpointer null)
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
661 {
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
662 GList * itr;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
663 for(itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events));itr;itr = itr->next){
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
664 FinchSoundPrefEvent * e = (FinchSoundPrefEvent *)itr->data;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
665 g_free(e->file);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
666 }
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
667 g_free(pref_dialog);
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
668 pref_dialog = NULL;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
669 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
670
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
671 void
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
672 finch_sounds_show_all(void)
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
673 {
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
674 GntWidget *box;
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
675 GntWidget *cmbox;
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
676 GntWidget *slider;
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
677 GntWidget *entry;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
678 GntWidget *chkbox;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
679 GntWidget *button;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
680 GntWidget *label;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
681 GntWidget *tree;
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
682 GntWidget *win;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
683
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
684 gchar *buf;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
685 gint i;
18434
48c2aa1fc3a9 Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents: 18433
diff changeset
686
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
687 if(pref_dialog){
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
688 gnt_window_present(pref_dialog->window);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
689 return;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
690 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
691
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
692
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
693 pref_dialog = g_new0(SoundPrefDialog,1);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
694
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
695 pref_dialog->window = win = gnt_window_box_new(FALSE,TRUE);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
696 gnt_box_set_pad(GNT_BOX(win),0);
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
697 gnt_box_set_fill(GNT_BOX(win),FALSE);
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
698 gnt_box_set_toplevel(GNT_BOX(win), TRUE);
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
699 gnt_box_set_title(GNT_BOX(win),_("Sound Preferences"));
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
700 gnt_box_set_fill(GNT_BOX(win),TRUE);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
701 gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_LEFT);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
702
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
703 pref_dialog->method = cmbox = gnt_combo_box_new();
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
704 gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, NULL);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
705 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
706 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA");
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
707 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD");
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
708 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
709 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
710 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound"));
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
711 buf = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"));
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
712 gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),buf);
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
713 g_free(buf);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
714
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
715 label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
716 gnt_box_add_widget(GNT_BOX(win),label);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
717 box = gnt_hbox_new(TRUE);
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
718 gnt_box_set_fill(GNT_BOX(box),FALSE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
719 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
720 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Method: ")));
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
721 gnt_box_add_widget(GNT_BOX(box),cmbox);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
722 gnt_box_add_widget(GNT_BOX(win),box);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
723
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
724 box = gnt_hbox_new(TRUE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
725 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
726 gnt_box_set_fill(GNT_BOX(box),FALSE);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
727 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)")));
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
728 pref_dialog->command = entry = gnt_entry_new(purple_prefs_get_path(FINCH_PREFS_ROOT "/sound/command"));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
729 gnt_box_add_widget(GNT_BOX(box),entry);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
730 gnt_box_add_widget(GNT_BOX(win),box);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
731
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
732 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
733
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
734 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD));
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
735 pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus"));
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
736 gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus"));
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
737 gnt_box_add_widget(GNT_BOX(win),chkbox);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
738
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
739 box = gnt_hbox_new(TRUE);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
740 gnt_box_set_pad(GNT_BOX(box),0);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
741 gnt_box_set_fill(GNT_BOX(box),FALSE);
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
742 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:"));
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
743 pref_dialog->while_status = cmbox = gnt_combo_box_new();
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
744 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(3),_("Always"));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
745 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(1),_("Only when available"));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
746 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(2),_("Only when not available"));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
747 gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status")));
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
748 gnt_box_add_widget(GNT_BOX(box),cmbox);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
749 gnt_box_add_widget(GNT_BOX(win),box);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
750
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
751 box = gnt_hbox_new(TRUE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
752 gnt_box_set_pad(GNT_BOX(box),0);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
753 gnt_box_set_fill(GNT_BOX(box),FALSE);
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
754 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Volume(0-100):")));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
755
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
756 pref_dialog->volume = slider = gnt_slider_new(FALSE,100,0);
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
757 gnt_slider_set_step(GNT_SLIDER(slider),5);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
758 label = gnt_label_new("");
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
759 gnt_slider_reflect_label(GNT_SLIDER(slider),GNT_LABEL(label));
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
760 gnt_slider_set_value(GNT_SLIDER(slider),CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100));
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
761 gnt_box_set_pad(GNT_BOX(box),1);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
762 gnt_box_add_widget(GNT_BOX(box),slider);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
763 gnt_box_add_widget(GNT_BOX(box),label);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
764 gnt_box_add_widget(GNT_BOX(win),box);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
765
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
766 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
767
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
768 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Events"),GNT_TEXT_FLAG_BOLD));
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
769
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
770 pref_dialog->events = tree = gnt_tree_new_with_columns(2);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
771 gnt_tree_set_hash_fns(GNT_TREE(tree),NULL,NULL,g_free);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
772 gnt_tree_set_column_titles(GNT_TREE(tree),_("Event"),_("File"));
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
773 gnt_tree_set_show_title(GNT_TREE(tree),TRUE);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
774
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
775 for(i = 0;i < PURPLE_NUM_SOUNDS;i++){
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
776 FinchSoundPrefEvent * event = g_new0(FinchSoundPrefEvent,1);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
777 gchar *boolpref;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
778 gchar *filepref;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
779
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
780 event->event = &sounds[i];
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
781 boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s", event->event->pref);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
782
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
783 filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/file/%s", event->event->pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
784 event->file = g_strdup(purple_prefs_get_path(filepref));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
785 if(event->event->label == NULL){
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
786 continue;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
787 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
788
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
789 gnt_tree_add_choice(GNT_TREE(tree), event,
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
790 gnt_tree_create_row(GNT_TREE(tree),event->event->label,event->file[0] ? g_path_get_basename(event->file) : ""),
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
791 NULL, NULL);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
792 gnt_tree_set_choice(GNT_TREE(tree),event,purple_prefs_get_bool(boolpref));
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
793 g_free(boolpref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
794 g_free(filepref);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
795 }
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
796
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
797 gnt_tree_adjust_columns(GNT_TREE(tree));
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
798 gnt_box_add_widget(GNT_BOX(win),tree);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
799
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
800 box = gnt_hbox_new(TRUE);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
801 button = gnt_button_new("Test");
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
802 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(test_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
803 gnt_box_add_widget(GNT_BOX(box),button);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
804 button = gnt_button_new("Reset");
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
805 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(reset_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
806 gnt_box_add_widget(GNT_BOX(box),button);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
807 button = gnt_button_new("Choose...");
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
808 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(choose_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
809 gnt_box_add_widget(GNT_BOX(box),button);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
810 gnt_box_add_widget(GNT_BOX(win),box);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
811
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
812 box = gnt_hbox_new(TRUE);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
813 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
814 gnt_box_set_fill(GNT_BOX(box),TRUE);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
815 button = gnt_button_new("Save");
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
816 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),win);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
817 gnt_box_add_widget(GNT_BOX(box),button);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
818 button = gnt_button_new("Cancel");
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
819 g_signal_connect_swapped(G_OBJECT(button),"activate",G_CALLBACK(gnt_widget_destroy),win);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
820 gnt_box_add_widget(GNT_BOX(box),button);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
821 gnt_box_add_widget(GNT_BOX(win),box);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
822
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
823
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
824 g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_dialog),NULL);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
825
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
826 gnt_widget_show(win);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
827
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
828 }
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
829
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
830 static PurpleSoundUiOps sound_ui_ops =
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
831 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
832 finch_sound_init,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
833 finch_sound_uninit,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
834 finch_sound_play_file,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
835 finch_sound_play_event,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
836 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
837 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
838 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
839 NULL
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
840 };
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
841
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
842 PurpleSoundUiOps *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
843 finch_sound_get_ui_ops(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
844 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
845 return &sound_ui_ops;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
846 }

mercurial