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