Mercurial > pidgin.yaz
annotate finch/gntsound.c @ 19146:5ff1231993af
Added sound profiles
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Tue, 10 Jul 2007 16:10:06 +0000 |
parents | 3bec25803a00 |
children | 5a6f174bf6dd |
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; |
19146 | 74 GntWidget *profiles; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
75 } SoundPrefDialog; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
76 |
19128 | 77 SoundPrefDialog *pref_dialog; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
78 |
19100 | 79 #define PLAY_SOUND_TIMEOUT 15000 |
80 | |
81 static guint mute_login_sounds_timeout = 0; | |
82 static gboolean mute_login_sounds = FALSE; | |
19146 | 83 static gchar * pref_string = NULL; |
19100 | 84 |
85 #ifdef USE_GSTREAMER | |
86 static gboolean gst_init_failed; | |
87 #endif /* USE_GSTREAMER */ | |
88 | |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
89 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = { |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
90 {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
|
91 {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
|
92 {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
|
93 {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
|
94 {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
|
95 {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
|
96 {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
|
97 {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
|
98 {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
|
99 {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
|
100 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your screen name in chat"), "nick_said", "alert.wav",NULL} |
19100 | 101 }; |
102 | |
19146 | 103 const char * |
104 finch_sound_get_active_profile() | |
105 { | |
106 return purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/actprofile"); | |
107 } | |
108 | |
109 /* This method creates a pref name based on the current active profile. | |
110 * So if "Home" is the current active profile the pref name | |
111 * [FINCH_PREFS_ROOT "/sound/profiles/Home/$NAME"] is created. | |
112 */ | |
113 static gchar * | |
114 make_pref(const char *name) | |
115 { | |
116 g_free(pref_string); | |
117 pref_string = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s%s",finch_sound_get_active_profile(),name); | |
118 return pref_string; | |
119 } | |
120 | |
121 | |
19100 | 122 static gboolean |
123 unmute_login_sounds_cb(gpointer data) | |
124 { | |
125 mute_login_sounds = FALSE; | |
126 mute_login_sounds_timeout = 0; | |
127 return FALSE; | |
128 } | |
129 | |
130 static gboolean | |
131 chat_nick_matches_name(PurpleConversation *conv, const char *aname) | |
132 { | |
133 PurpleConvChat *chat = NULL; | |
134 char *nick = NULL; | |
135 char *name = NULL; | |
136 gboolean ret = FALSE; | |
137 chat = purple_conversation_get_chat_data(conv); | |
138 | |
139 if (chat==NULL) | |
140 return ret; | |
141 | |
142 nick = g_strdup(purple_normalize(conv->account, chat->nick)); | |
143 name = g_strdup(purple_normalize(conv->account, aname)); | |
144 | |
145 if (g_utf8_collate(nick, name) == 0) | |
146 ret = TRUE; | |
147 | |
148 g_free(nick); | |
149 g_free(name); | |
150 | |
151 return ret; | |
152 } | |
153 | |
154 /* | |
155 * play a sound event for a conversation, honoring make_sound flag | |
156 * of conversation and checking for focus if conv_focus pref is set | |
157 */ | |
158 static void | |
159 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) | |
160 { | |
161 /* If we should not play the sound for some reason, then exit early */ | |
162 if (conv != NULL) | |
163 { | |
164 FinchConv *gntconv; | |
165 gboolean has_focus; | |
166 | |
167 gntconv = FINCH_CONV(conv); | |
168 | |
169 has_focus = purple_conversation_has_focus(conv); | |
170 | |
19146 | 171 if (has_focus && !purple_prefs_get_bool(make_pref("/conv_focus"))) |
19100 | 172 { |
173 return; | |
174 } | |
175 } | |
176 | |
177 purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); | |
178 } | |
179 | |
180 static void | |
181 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) | |
182 { | |
183 purple_sound_play_event(event, purple_buddy_get_account(buddy)); | |
184 } | |
185 | |
186 static void | |
187 im_msg_received_cb(PurpleAccount *account, char *sender, | |
188 char *message, PurpleConversation *conv, | |
189 PurpleMessageFlags flags, PurpleSoundEventID event) | |
190 { | |
191 if (flags & PURPLE_MESSAGE_DELAYED) | |
192 return; | |
193 | |
194 if (conv==NULL){ | |
195 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); | |
196 } | |
197 else{ | |
198 play_conv_event(conv, event); | |
199 } | |
200 } | |
201 | |
202 static void | |
203 im_msg_sent_cb(PurpleAccount *account, const char *receiver, | |
204 const char *message, PurpleSoundEventID event) | |
205 { | |
206 PurpleConversation *conv = purple_find_conversation_with_account( | |
207 PURPLE_CONV_TYPE_ANY, receiver, account); | |
208 play_conv_event(conv, event); | |
209 } | |
210 | |
211 static void | |
212 chat_buddy_join_cb(PurpleConversation *conv, const char *name, | |
213 PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
214 PurpleSoundEventID event) | |
215 { | |
216 if (new_arrival && !chat_nick_matches_name(conv, name)) | |
217 play_conv_event(conv, event); | |
218 } | |
219 | |
220 static void | |
221 chat_buddy_left_cb(PurpleConversation *conv, const char *name, | |
222 const char *reason, PurpleSoundEventID event) | |
223 { | |
224 if (!chat_nick_matches_name(conv, name)) | |
225 play_conv_event(conv, event); | |
226 } | |
227 | |
228 static void | |
229 chat_msg_sent_cb(PurpleAccount *account, const char *message, | |
230 int id, PurpleSoundEventID event) | |
231 { | |
232 PurpleConnection *conn = purple_account_get_connection(account); | |
233 PurpleConversation *conv = NULL; | |
234 | |
235 if (conn!=NULL) | |
236 conv = purple_find_chat(conn,id); | |
237 | |
238 play_conv_event(conv, event); | |
239 } | |
240 | |
241 static void | |
242 chat_msg_received_cb(PurpleAccount *account, char *sender, | |
243 char *message, PurpleConversation *conv, | |
244 PurpleMessageFlags flags, PurpleSoundEventID event) | |
245 { | |
246 PurpleConvChat *chat; | |
247 | |
248 if (flags & PURPLE_MESSAGE_DELAYED) | |
249 return; | |
250 | |
251 chat = purple_conversation_get_chat_data(conv); | |
252 g_return_if_fail(chat != NULL); | |
253 | |
254 if (purple_conv_chat_is_user_ignored(chat, sender)) | |
255 return; | |
256 | |
257 if (chat_nick_matches_name(conv, sender)) | |
258 return; | |
259 | |
260 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) | |
261 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
262 else | |
263 play_conv_event(conv, event); | |
264 } | |
265 | |
266 /* | |
267 * We mute sounds for the 10 seconds after you log in so that | |
268 * you don't get flooded with sounds when the blist shows all | |
269 * your buddies logging in. | |
270 */ | |
271 static void | |
272 account_signon_cb(PurpleConnection *gc, gpointer data) | |
273 { | |
274 if (mute_login_sounds_timeout != 0) | |
275 g_source_remove(mute_login_sounds_timeout); | |
276 mute_login_sounds = TRUE; | |
277 mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); | |
278 } | |
279 | |
280 const char * | |
281 finch_sound_get_event_option(PurpleSoundEventID event) | |
282 { | |
283 if(event >= PURPLE_NUM_SOUNDS) | |
284 return 0; | |
285 | |
286 return sounds[event].pref; | |
287 } | |
288 | |
289 const char * | |
290 finch_sound_get_event_label(PurpleSoundEventID event) | |
291 { | |
292 if(event >= PURPLE_NUM_SOUNDS) | |
293 return NULL; | |
294 | |
295 return sounds[event].label; | |
296 } | |
297 | |
298 void * | |
299 finch_sound_get_handle() | |
300 { | |
301 static int handle; | |
302 | |
303 return &handle; | |
304 } | |
305 | |
19146 | 306 |
307 /* This gets called when the active profile changes */ | |
308 static void | |
309 load_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) | |
310 { | |
311 if(!purple_prefs_exists(make_pref(""))){ | |
312 purple_prefs_add_none(make_pref("")); | |
313 purple_prefs_add_none(make_pref("/enabled")); | |
314 purple_prefs_add_none(make_pref("/file")); | |
315 purple_prefs_add_bool(make_pref("/enabled/login"), TRUE); | |
316 purple_prefs_add_path(make_pref("/file/login"), ""); | |
317 purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE); | |
318 purple_prefs_add_path(make_pref("/file/logout"), ""); | |
319 purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE); | |
320 purple_prefs_add_path(make_pref("/file/im_recv"), ""); | |
321 purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); | |
322 purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); | |
323 purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE); | |
324 purple_prefs_add_path(make_pref("/file/send_im"), ""); | |
325 purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); | |
326 purple_prefs_add_path(make_pref("/file/join_chat"), ""); | |
327 purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); | |
328 purple_prefs_add_path(make_pref("/file/left_chat"), ""); | |
329 purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); | |
330 purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); | |
331 purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); | |
332 purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); | |
333 purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); | |
334 purple_prefs_add_path(make_pref("/file/nick_said"), ""); | |
335 purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE); | |
336 purple_prefs_add_path(make_pref("/file/pounce_default"), ""); | |
337 purple_prefs_add_bool(make_pref("/conv_focus"), TRUE); | |
338 purple_prefs_add_bool(make_pref("/mute"), FALSE); | |
339 purple_prefs_add_path(make_pref("/command"), ""); | |
340 purple_prefs_add_string(make_pref("/method"), "automatic"); | |
341 purple_prefs_add_int(make_pref("/volume"), 50); | |
342 } | |
343 } | |
344 | |
19100 | 345 static void |
346 finch_sound_init(void) | |
347 { | |
348 void *gnt_sound_handle = finch_sound_get_handle(); | |
349 void *blist_handle = purple_blist_get_handle(); | |
350 void *conv_handle = purple_conversations_get_handle(); | |
351 #ifdef USE_GSTREAMER | |
352 GError *error = NULL; | |
353 #endif | |
354 | |
355 purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
356 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
357 NULL); | |
358 | |
359 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); | |
19146 | 360 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", "default"); |
361 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); | |
19100 | 362 |
19146 | 363 purple_prefs_connect_callback(gnt_sound_handle,FINCH_PREFS_ROOT "/sound/actprofile",load_profile,NULL); |
364 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); | |
365 | |
366 | |
19100 | 367 #ifdef USE_GSTREAMER |
368 purple_debug_info("sound", "Initializing sound output drivers.\n"); | |
369 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { | |
370 purple_notify_error(NULL, _("GStreamer Failure"), | |
371 _("GStreamer failed to initialize."), | |
372 error ? error->message : ""); | |
373 if (error) { | |
374 g_error_free(error); | |
375 error = NULL; | |
376 } | |
377 } | |
378 #endif /* USE_GSTREAMER */ | |
379 | |
380 purple_signal_connect(blist_handle, "buddy-signed-on", | |
381 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
382 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
383 purple_signal_connect(blist_handle, "buddy-signed-off", | |
384 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
385 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
386 purple_signal_connect(conv_handle, "received-im-msg", | |
387 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
388 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
389 purple_signal_connect(conv_handle, "sent-im-msg", | |
390 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
391 GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
392 purple_signal_connect(conv_handle, "chat-buddy-joined", | |
393 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
394 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
395 purple_signal_connect(conv_handle, "chat-buddy-left", | |
396 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
397 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
398 purple_signal_connect(conv_handle, "sent-chat-msg", | |
399 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
400 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
401 purple_signal_connect(conv_handle, "received-chat-msg", | |
402 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
403 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
404 } | |
405 | |
406 static void | |
407 finch_sound_uninit(void) | |
408 { | |
409 #ifdef USE_GSTREAMER | |
410 if (!gst_init_failed) | |
411 gst_deinit(); | |
412 #endif | |
413 | |
414 purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
415 } | |
416 | |
417 #ifdef USE_GSTREAMER | |
418 static gboolean | |
419 bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
420 { | |
421 GstElement *play = data; | |
422 GError *err = NULL; | |
423 | |
424 switch (GST_MESSAGE_TYPE (msg)) { | |
425 case GST_MESSAGE_EOS: | |
426 gst_element_set_state(play, GST_STATE_NULL); | |
427 gst_object_unref(GST_OBJECT(play)); | |
428 break; | |
429 case GST_MESSAGE_ERROR: | |
430 gst_message_parse_error(msg, &err, NULL); | |
431 purple_debug_error("gstreamer", err->message); | |
432 g_error_free(err); | |
433 break; | |
434 case GST_MESSAGE_WARNING: | |
435 gst_message_parse_warning(msg, &err, NULL); | |
436 purple_debug_warning("gstreamer", err->message); | |
437 g_error_free(err); | |
438 break; | |
439 default: | |
440 break; | |
441 } | |
442 return TRUE; | |
443 } | |
444 #endif | |
445 | |
446 static void | |
447 finch_sound_play_file(const char *filename) | |
448 { | |
449 const char *method; | |
450 #ifdef USE_GSTREAMER | |
451 float volume; | |
452 char *uri; | |
453 GstElement *sink = NULL; | |
454 GstElement *play = NULL; | |
455 GstBus *bus = NULL; | |
456 #endif | |
19146 | 457 if (purple_prefs_get_bool(make_pref("/mute"))) |
19100 | 458 return; |
459 | |
19146 | 460 method = purple_prefs_get_string(make_pref("/method")); |
19100 | 461 |
462 if (!strcmp(method, "none")) { | |
463 return; | |
464 } else if (!strcmp(method, "beep")) { | |
465 beep(); | |
466 return; | |
467 } | |
468 | |
469 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
470 purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
471 return; | |
472 } | |
473 | |
474 #ifndef _WIN32 | |
475 if (!strcmp(method, "custom")) { | |
476 const char *sound_cmd; | |
477 char *command; | |
478 char *esc_filename; | |
479 GError *error = NULL; | |
480 | |
19146 | 481 sound_cmd = purple_prefs_get_path(make_pref("/command")); |
19100 | 482 |
483 if (!sound_cmd || *sound_cmd == '\0') { | |
484 purple_debug_error("gntsound", | |
485 "'Command' sound method has been chosen, " | |
486 "but no command has been set."); | |
487 return; | |
488 } | |
489 | |
490 esc_filename = g_shell_quote(filename); | |
491 | |
492 if(strstr(sound_cmd, "%s")) | |
493 command = purple_strreplace(sound_cmd, "%s", esc_filename); | |
494 else | |
495 command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
496 | |
497 if(!g_spawn_command_line_async(command, &error)) { | |
498 purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); | |
499 g_error_free(error); | |
500 } | |
501 | |
502 g_free(esc_filename); | |
503 g_free(command); | |
504 return; | |
505 } | |
506 #ifdef USE_GSTREAMER | |
507 if (gst_init_failed) /* Perhaps do beep instead? */ | |
508 return; | |
19146 | 509 volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100)) / 50; |
19100 | 510 if (!strcmp(method, "automatic")) { |
511 if (purple_running_gnome()) { | |
512 sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
513 } | |
514 if (!sink) | |
515 sink = gst_element_factory_make("autoaudiosink", "sink"); | |
516 if (!sink) { | |
517 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
518 return; | |
519 } | |
520 } else if (!strcmp(method, "esd")) { | |
521 sink = gst_element_factory_make("esdsink", "sink"); | |
522 if (!sink) { | |
523 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
524 return; | |
525 } | |
526 } else if (!strcmp(method, "alsa")) { | |
527 sink = gst_element_factory_make("alsasink", "sink"); | |
528 if (!sink) { | |
529 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
530 return; | |
531 } | |
532 } else { | |
533 purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
534 return; | |
535 } | |
536 | |
537 play = gst_element_factory_make("playbin", "play"); | |
538 | |
539 if (play == NULL) { | |
540 return; | |
541 } | |
542 | |
543 uri = g_strdup_printf("file://%s", filename); | |
544 | |
545 g_object_set(G_OBJECT(play), "uri", uri, | |
546 "volume", volume, | |
547 "audio-sink", sink, NULL); | |
548 | |
549 bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
550 gst_bus_add_watch(bus, bus_call, play); | |
551 | |
552 gst_element_set_state(play, GST_STATE_PLAYING); | |
553 | |
554 gst_object_unref(bus); | |
555 g_free(uri); | |
556 | |
557 #else /* USE_GSTREAMER */ | |
558 beep(); | |
559 return; | |
560 #endif /* USE_GSTREAMER */ | |
561 #else /* _WIN32 */ | |
562 purple_debug_info("sound", "Playing %s\n", filename); | |
563 | |
564 if (G_WIN32_HAVE_WIDECHAR_API ()) { | |
565 wchar_t *wc_filename = g_utf8_to_utf16(filename, | |
566 -1, NULL, NULL, NULL); | |
567 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
568 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
569 g_free(wc_filename); | |
570 } else { | |
571 char *l_filename = g_locale_from_utf8(filename, | |
572 -1, NULL, NULL, NULL); | |
573 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
574 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
575 g_free(l_filename); | |
576 } | |
577 #endif /* _WIN32 */ | |
578 } | |
579 | |
580 static void | |
581 finch_sound_play_event(PurpleSoundEventID event) | |
582 { | |
583 char *enable_pref; | |
584 char *file_pref; | |
585 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
586 return; | |
587 | |
588 if (event >= PURPLE_NUM_SOUNDS) { | |
589 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
590 return; | |
591 } | |
592 | |
19146 | 593 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |
594 finch_sound_get_active_profile(), | |
19100 | 595 sounds[event].pref); |
19146 | 596 file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(),sounds[event].pref); |
19100 | 597 |
598 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
599 if (purple_prefs_get_bool(enable_pref)) { | |
600 char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
601 if(!filename || !strlen(filename)) { | |
602 g_free(filename); | |
19115 | 603 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
604 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
19100 | 605 } |
606 | |
607 purple_sound_play_file(filename, NULL); | |
608 g_free(filename); | |
609 } | |
610 | |
611 g_free(enable_pref); | |
612 g_free(file_pref); | |
613 } | |
614 | |
19146 | 615 GList * |
616 finch_sound_get_profiles() | |
617 { | |
618 return purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles"); | |
619 } | |
620 | |
621 static gboolean | |
622 profile_exists(const char *name) | |
623 { | |
624 GList *itr = NULL; | |
625 for(itr = finch_sound_get_profiles();itr;itr = itr->next){ | |
626 if(!strcmp(itr->data,name)) | |
627 return TRUE; | |
628 } | |
629 return FALSE; | |
630 } | |
631 | |
632 void | |
633 finch_sound_set_active_profile(const char *name) | |
634 { | |
635 if(profile_exists(name)){ | |
636 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name); | |
637 } | |
638 } | |
639 | |
640 | |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
641 static void |
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
642 save_cb(GntWidget *button, gpointer win) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
643 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
644 GList * itr; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
645 |
19146 | 646 purple_prefs_set_string(make_pref("/method"), gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method))); |
647 purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command))); | |
648 purple_prefs_set_bool(make_pref("/conv_focus"),gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus))); | |
19129 | 649 purple_prefs_set_int("/purple/sound/while_status",GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status)))); |
19146 | 650 purple_prefs_set_int(make_pref("/volume"),gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume))); |
19129 | 651 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
652 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
|
653 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)]; |
19146 | 654 char * filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",finch_sound_get_active_profile(),event->pref); |
655 char * boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",finch_sound_get_active_profile(),event->pref); | |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
656 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
|
657 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
|
658 g_free(filepref); |
19137 | 659 g_free(boolpref); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
660 } |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
661 gnt_widget_destroy(GNT_WIDGET(win)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
662 } |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
663 |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
664 static void |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
665 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
|
666 { |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
667 FinchSoundEvent *event = data; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
668 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
669 g_free(event->file); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
670 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
|
671 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
672 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
|
673 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
674 gnt_widget_destroy(GNT_WIDGET(w)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
675 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
676 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
677 static void |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
678 test_cb(GntWidget *button, gpointer null) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
679 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
680 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
|
681 FinchSoundEvent * event = &sounds[id]; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
682 char *pref; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
683 gboolean temp_value; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
684 |
19146 | 685 pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",finch_sound_get_active_profile(), |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
686 event->pref); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
687 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
688 temp_value = purple_prefs_get_bool(pref); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
689 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
690 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
|
691 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
692 purple_sound_play_event(id, NULL); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
693 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
694 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
|
695 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
696 g_free(pref); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
697 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
698 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
699 static void |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
700 reset_cb(GntWidget *button,gpointer null) |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
701 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
702 /* Don't dereference this pointer ! */ |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
703 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
|
704 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
705 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
|
706 g_free(event->file); |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
707 event->file = NULL; |
19139
2d0925800d72
Made the display of files for sound events cleaner
Eric Polino <aluink@pidgin.im>
parents:
19137
diff
changeset
|
708 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
|
709 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
710 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
711 static void |
19146 | 712 pref_load_cb(GntWidget *button, gpointer null) |
713 { | |
714 | |
715 const gchar * value = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->profiles)); | |
716 | |
717 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",value); | |
718 | |
719 } | |
720 | |
721 static void | |
722 pref_save_cb(GntWidget *button, gpointer null) | |
723 { | |
724 | |
725 } | |
726 | |
727 static void | |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
728 choose_cb(GntWidget *button, gpointer null) |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
729 { |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
730 GntWidget *w = gnt_file_sel_new(); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
731 GntFileSel *sel = GNT_FILE_SEL(w); |
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
732 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
|
733 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
|
734 char *path = NULL; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
735 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
736 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
|
737 (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
|
738 : purple_home_dir()); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
739 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
740 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
|
741 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
|
742 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
|
743 |
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
|
744 /* 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
|
745 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
|
746 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
|
747 |
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
|
748 pref_dialog->selector = w; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
749 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
750 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
|
751 g_free(path); |
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 |
19128 | 754 static void |
755 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
|
756 { |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
757 GList * itr; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
758 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
|
759 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
|
760 FinchSoundEvent * e = &sounds[id]; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
761 g_free(e->file); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
762 } |
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
|
763 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
|
764 gnt_widget_destroy(pref_dialog->selector); |
19128 | 765 g_free(pref_dialog); |
766 pref_dialog = NULL; | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
767 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
768 |
19146 | 769 static void |
770 reload_pref_window(GntComboBox *box, gpointer oldkey, gpointer newkey, gpointer null) | |
771 { | |
772 gint i; | |
773 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",(gchar *)newkey); | |
774 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method),(gchar *)purple_prefs_get_string(make_pref("/method"))); | |
775 gnt_entry_set_text(GNT_ENTRY(pref_dialog->command),purple_prefs_get_path(make_pref("/command"))); | |
776 gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus),purple_prefs_get_bool(make_pref("/conv_focus"))); | |
777 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status),GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status"))); | |
778 gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume),CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100)); | |
779 for(i = 0;i < PURPLE_NUM_SOUNDS;i++){ | |
780 FinchSoundEvent * event = &sounds[i]; | |
781 gchar *boolpref; | |
782 gchar *filepref; | |
783 const char * profile = finch_sound_get_active_profile(); | |
784 | |
785 boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",profile,event->pref); | |
786 | |
787 filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",profile,event->pref); | |
788 event->file = g_strdup(purple_prefs_get_path(filepref)); | |
789 if(event->label == NULL){ | |
790 continue; | |
791 } | |
792 | |
793 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),0,event->label); | |
794 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),1,event->file[0] ? g_path_get_basename(event->file) : "(default)"); | |
795 gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref)); | |
796 g_free(boolpref); | |
797 g_free(filepref); | |
798 } | |
799 } | |
800 | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
801 void |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
802 finch_sounds_show_all(void) |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
803 { |
19146 | 804 GntWidget *box; GntWidget *cmbox; GntWidget *slider; |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
805 GntWidget *entry; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
806 GntWidget *chkbox; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
807 GntWidget *button; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
808 GntWidget *label; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
809 GntWidget *tree; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
810 GntWidget *win; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
811 |
19146 | 812 GList *itr,*list; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
813 gint i; |
19127
f34e11e41122
Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents:
19126
diff
changeset
|
814 |
19128 | 815 if(pref_dialog){ |
816 gnt_window_present(pref_dialog->window); | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
817 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
818 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
819 |
19128 | 820 pref_dialog = g_new0(SoundPrefDialog,1); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
821 |
19128 | 822 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
|
823 gnt_box_set_pad(GNT_BOX(win),0); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
824 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
|
825 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
|
826 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
|
827 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
|
828 |
19128 | 829 pref_dialog->method = cmbox = gnt_combo_box_new(); |
19129 | 830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound")); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
837 |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
838 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
|
839 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
|
840 box = gnt_hbox_new(TRUE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
841 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
|
842 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
843 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
|
844 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
|
845 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
|
846 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
847 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
848 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
849 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
|
850 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)"))); |
19146 | 851 pref_dialog->command = entry = gnt_entry_new(""); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
852 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
|
853 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
|
854 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
855 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
|
856 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
857 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); |
19129 | 858 pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus")); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
859 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
|
860 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
861 box = gnt_hbox_new(TRUE); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
862 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
|
863 gnt_box_set_fill(GNT_BOX(box),FALSE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
864 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:")); |
19128 | 865 pref_dialog->while_status = cmbox = gnt_combo_box_new(); |
19129 | 866 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(3),_("Always")); |
867 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(1),_("Only when available")); | |
868 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(2),_("Only when not available")); | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
869 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
|
870 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
|
871 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
872 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
873 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
|
874 gnt_box_set_fill(GNT_BOX(box),FALSE); |
19129 | 875 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
|
876 |
19128 | 877 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
|
878 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
|
879 label = gnt_label_new(""); |
915ef65d68e3
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
19119
diff
changeset
|
880 gnt_slider_reflect_label(GNT_SLIDER(slider),GNT_LABEL(label)); |
915ef65d68e3
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
19119
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 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
|
885 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
886 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
|
887 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
888 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
|
889 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
|
890 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
|
891 gnt_tree_set_show_title(GNT_TREE(tree),TRUE); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
892 |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
893 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
|
894 FinchSoundEvent * event = &sounds[i]; |
19146 | 895 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
896 if(event->label == NULL){ |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
897 continue; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
898 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
899 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
900 gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i), |
19146 | 901 gnt_tree_create_row(GNT_TREE(tree),"",""), |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
902 NULL, NULL); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
903 } |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
904 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
905 gnt_tree_adjust_columns(GNT_TREE(tree)); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
906 gnt_box_add_widget(GNT_BOX(win),tree); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
907 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
908 box = gnt_hbox_new(FALSE); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
909 button = gnt_button_new(_("Test")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
910 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
|
911 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
|
912 button = gnt_button_new(_("Reset")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
913 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
|
914 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
|
915 button = gnt_button_new(_("Choose...")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
916 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
|
917 gnt_box_add_widget(GNT_BOX(box),button); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
918 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
|
919 |
19146 | 920 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
921 | |
922 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD)); | |
923 box = gnt_hbox_new(FALSE); | |
924 pref_dialog->profiles = cmbox = gnt_combo_box_new(); | |
925 list = itr = finch_sound_get_profiles(); | |
926 for(;itr;itr = itr->next){ | |
927 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),itr->data,itr->data); | |
928 } | |
929 g_signal_connect(G_OBJECT(cmbox),"selection-changed",G_CALLBACK(reload_pref_window),NULL); | |
930 g_list_free(list); | |
931 gnt_box_add_widget(GNT_BOX(box),cmbox); | |
932 button = gnt_button_new("Load"); | |
933 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(pref_load_cb),NULL); | |
934 gnt_box_add_widget(GNT_BOX(box),button); | |
935 button = gnt_button_new("Save"); | |
936 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(pref_save_cb),NULL); | |
937 gnt_box_add_widget(GNT_BOX(box),button); | |
938 gnt_box_add_widget(GNT_BOX(win),box); | |
939 | |
940 | |
941 /* Add new stuff before this */ | |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
942 box = gnt_hbox_new(FALSE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
943 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
944 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
|
945 button = gnt_button_new(_("Save")); |
19129 | 946 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
|
947 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
|
948 button = gnt_button_new(_("Cancel")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
949 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
|
950 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
|
951 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
|
952 |
19128 | 953 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
|
954 |
19146 | 955 reload_pref_window(NULL,NULL,(gchar *)finch_sound_get_active_profile(),NULL); |
956 | |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
957 gnt_widget_show(win); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
958 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
959 } |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
960 |
19100 | 961 static PurpleSoundUiOps sound_ui_ops = |
962 { | |
963 finch_sound_init, | |
964 finch_sound_uninit, | |
965 finch_sound_play_file, | |
966 finch_sound_play_event, | |
967 NULL, | |
968 NULL, | |
969 NULL, | |
970 NULL | |
971 }; | |
972 | |
973 PurpleSoundUiOps * | |
974 finch_sound_get_ui_ops(void) | |
975 { | |
976 return &sound_ui_ops; | |
977 } |