Mercurial > pidgin
annotate finch/gntsound.c @ 19153:58743fae0db2
merge of '8e1c0ef9ebb6ce5efc6fad6c18ad02f6f83f220e'
and 'db793e506dda38bd8d837986f60cfcbe027860e4'
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Wed, 11 Jul 2007 20:03:24 +0000 |
parents | 700fe77a79b3 |
children | 3266c971527e |
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 void * | |
281 finch_sound_get_handle() | |
282 { | |
283 static int handle; | |
284 | |
285 return &handle; | |
286 } | |
287 | |
19146 | 288 |
289 /* This gets called when the active profile changes */ | |
290 static void | |
291 load_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) | |
292 { | |
293 if(!purple_prefs_exists(make_pref(""))){ | |
294 purple_prefs_add_none(make_pref("")); | |
295 purple_prefs_add_none(make_pref("/enabled")); | |
296 purple_prefs_add_none(make_pref("/file")); | |
297 purple_prefs_add_bool(make_pref("/enabled/login"), TRUE); | |
298 purple_prefs_add_path(make_pref("/file/login"), ""); | |
299 purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE); | |
300 purple_prefs_add_path(make_pref("/file/logout"), ""); | |
301 purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE); | |
302 purple_prefs_add_path(make_pref("/file/im_recv"), ""); | |
303 purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); | |
304 purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); | |
305 purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE); | |
306 purple_prefs_add_path(make_pref("/file/send_im"), ""); | |
307 purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); | |
308 purple_prefs_add_path(make_pref("/file/join_chat"), ""); | |
309 purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); | |
310 purple_prefs_add_path(make_pref("/file/left_chat"), ""); | |
311 purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); | |
312 purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); | |
313 purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); | |
314 purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); | |
315 purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); | |
316 purple_prefs_add_path(make_pref("/file/nick_said"), ""); | |
317 purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE); | |
318 purple_prefs_add_path(make_pref("/file/pounce_default"), ""); | |
319 purple_prefs_add_bool(make_pref("/conv_focus"), TRUE); | |
320 purple_prefs_add_bool(make_pref("/mute"), FALSE); | |
321 purple_prefs_add_path(make_pref("/command"), ""); | |
322 purple_prefs_add_string(make_pref("/method"), "automatic"); | |
323 purple_prefs_add_int(make_pref("/volume"), 50); | |
324 } | |
325 } | |
326 | |
19100 | 327 static void |
328 finch_sound_init(void) | |
329 { | |
330 void *gnt_sound_handle = finch_sound_get_handle(); | |
331 void *blist_handle = purple_blist_get_handle(); | |
332 void *conv_handle = purple_conversations_get_handle(); | |
333 #ifdef USE_GSTREAMER | |
334 GError *error = NULL; | |
335 #endif | |
336 | |
337 purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
338 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
339 NULL); | |
340 | |
341 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); | |
19146 | 342 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", "default"); |
343 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); | |
19100 | 344 |
19146 | 345 purple_prefs_connect_callback(gnt_sound_handle,FINCH_PREFS_ROOT "/sound/actprofile",load_profile,NULL); |
346 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); | |
347 | |
348 | |
19100 | 349 #ifdef USE_GSTREAMER |
350 purple_debug_info("sound", "Initializing sound output drivers.\n"); | |
351 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { | |
352 purple_notify_error(NULL, _("GStreamer Failure"), | |
353 _("GStreamer failed to initialize."), | |
354 error ? error->message : ""); | |
355 if (error) { | |
356 g_error_free(error); | |
357 error = NULL; | |
358 } | |
359 } | |
360 #endif /* USE_GSTREAMER */ | |
361 | |
362 purple_signal_connect(blist_handle, "buddy-signed-on", | |
363 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
364 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
365 purple_signal_connect(blist_handle, "buddy-signed-off", | |
366 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
367 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
368 purple_signal_connect(conv_handle, "received-im-msg", | |
369 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
370 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
371 purple_signal_connect(conv_handle, "sent-im-msg", | |
372 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
373 GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
374 purple_signal_connect(conv_handle, "chat-buddy-joined", | |
375 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
376 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
377 purple_signal_connect(conv_handle, "chat-buddy-left", | |
378 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
379 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
380 purple_signal_connect(conv_handle, "sent-chat-msg", | |
381 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
382 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
383 purple_signal_connect(conv_handle, "received-chat-msg", | |
384 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
385 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
386 } | |
387 | |
388 static void | |
389 finch_sound_uninit(void) | |
390 { | |
391 #ifdef USE_GSTREAMER | |
392 if (!gst_init_failed) | |
393 gst_deinit(); | |
394 #endif | |
395 | |
396 purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
397 } | |
398 | |
399 #ifdef USE_GSTREAMER | |
400 static gboolean | |
401 bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
402 { | |
403 GstElement *play = data; | |
404 GError *err = NULL; | |
405 | |
406 switch (GST_MESSAGE_TYPE (msg)) { | |
407 case GST_MESSAGE_EOS: | |
408 gst_element_set_state(play, GST_STATE_NULL); | |
409 gst_object_unref(GST_OBJECT(play)); | |
410 break; | |
411 case GST_MESSAGE_ERROR: | |
412 gst_message_parse_error(msg, &err, NULL); | |
413 purple_debug_error("gstreamer", err->message); | |
414 g_error_free(err); | |
415 break; | |
416 case GST_MESSAGE_WARNING: | |
417 gst_message_parse_warning(msg, &err, NULL); | |
418 purple_debug_warning("gstreamer", err->message); | |
419 g_error_free(err); | |
420 break; | |
421 default: | |
422 break; | |
423 } | |
424 return TRUE; | |
425 } | |
426 #endif | |
427 | |
428 static void | |
429 finch_sound_play_file(const char *filename) | |
430 { | |
431 const char *method; | |
432 #ifdef USE_GSTREAMER | |
433 float volume; | |
434 char *uri; | |
435 GstElement *sink = NULL; | |
436 GstElement *play = NULL; | |
437 GstBus *bus = NULL; | |
438 #endif | |
19146 | 439 if (purple_prefs_get_bool(make_pref("/mute"))) |
19100 | 440 return; |
441 | |
19146 | 442 method = purple_prefs_get_string(make_pref("/method")); |
19100 | 443 |
444 if (!strcmp(method, "none")) { | |
445 return; | |
446 } else if (!strcmp(method, "beep")) { | |
447 beep(); | |
448 return; | |
449 } | |
450 | |
451 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
452 purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
453 return; | |
454 } | |
455 | |
456 #ifndef _WIN32 | |
457 if (!strcmp(method, "custom")) { | |
458 const char *sound_cmd; | |
459 char *command; | |
460 char *esc_filename; | |
461 GError *error = NULL; | |
462 | |
19146 | 463 sound_cmd = purple_prefs_get_path(make_pref("/command")); |
19100 | 464 |
465 if (!sound_cmd || *sound_cmd == '\0') { | |
466 purple_debug_error("gntsound", | |
467 "'Command' sound method has been chosen, " | |
468 "but no command has been set."); | |
469 return; | |
470 } | |
471 | |
472 esc_filename = g_shell_quote(filename); | |
473 | |
474 if(strstr(sound_cmd, "%s")) | |
475 command = purple_strreplace(sound_cmd, "%s", esc_filename); | |
476 else | |
477 command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
478 | |
479 if(!g_spawn_command_line_async(command, &error)) { | |
480 purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); | |
481 g_error_free(error); | |
482 } | |
483 | |
484 g_free(esc_filename); | |
485 g_free(command); | |
486 return; | |
487 } | |
488 #ifdef USE_GSTREAMER | |
489 if (gst_init_failed) /* Perhaps do beep instead? */ | |
490 return; | |
19146 | 491 volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100)) / 50; |
19100 | 492 if (!strcmp(method, "automatic")) { |
493 if (purple_running_gnome()) { | |
494 sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
495 } | |
496 if (!sink) | |
497 sink = gst_element_factory_make("autoaudiosink", "sink"); | |
498 if (!sink) { | |
499 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
500 return; | |
501 } | |
502 } else if (!strcmp(method, "esd")) { | |
503 sink = gst_element_factory_make("esdsink", "sink"); | |
504 if (!sink) { | |
505 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
506 return; | |
507 } | |
508 } else if (!strcmp(method, "alsa")) { | |
509 sink = gst_element_factory_make("alsasink", "sink"); | |
510 if (!sink) { | |
511 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
512 return; | |
513 } | |
514 } else { | |
515 purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
516 return; | |
517 } | |
518 | |
519 play = gst_element_factory_make("playbin", "play"); | |
520 | |
521 if (play == NULL) { | |
522 return; | |
523 } | |
524 | |
525 uri = g_strdup_printf("file://%s", filename); | |
526 | |
527 g_object_set(G_OBJECT(play), "uri", uri, | |
528 "volume", volume, | |
529 "audio-sink", sink, NULL); | |
530 | |
531 bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
532 gst_bus_add_watch(bus, bus_call, play); | |
533 | |
534 gst_element_set_state(play, GST_STATE_PLAYING); | |
535 | |
536 gst_object_unref(bus); | |
537 g_free(uri); | |
538 | |
539 #else /* USE_GSTREAMER */ | |
540 beep(); | |
541 return; | |
542 #endif /* USE_GSTREAMER */ | |
543 #else /* _WIN32 */ | |
544 purple_debug_info("sound", "Playing %s\n", filename); | |
545 | |
546 if (G_WIN32_HAVE_WIDECHAR_API ()) { | |
547 wchar_t *wc_filename = g_utf8_to_utf16(filename, | |
548 -1, NULL, NULL, NULL); | |
549 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
550 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
551 g_free(wc_filename); | |
552 } else { | |
553 char *l_filename = g_locale_from_utf8(filename, | |
554 -1, NULL, NULL, NULL); | |
555 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
556 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
557 g_free(l_filename); | |
558 } | |
559 #endif /* _WIN32 */ | |
560 } | |
561 | |
562 static void | |
563 finch_sound_play_event(PurpleSoundEventID event) | |
564 { | |
565 char *enable_pref; | |
566 char *file_pref; | |
567 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
568 return; | |
569 | |
570 if (event >= PURPLE_NUM_SOUNDS) { | |
571 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
572 return; | |
573 } | |
574 | |
19146 | 575 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |
576 finch_sound_get_active_profile(), | |
19100 | 577 sounds[event].pref); |
19146 | 578 file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(),sounds[event].pref); |
19100 | 579 |
580 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
581 if (purple_prefs_get_bool(enable_pref)) { | |
582 char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
583 if(!filename || !strlen(filename)) { | |
584 g_free(filename); | |
19115 | 585 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
586 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
19100 | 587 } |
588 | |
589 purple_sound_play_file(filename, NULL); | |
590 g_free(filename); | |
591 } | |
592 | |
593 g_free(enable_pref); | |
594 g_free(file_pref); | |
595 } | |
596 | |
19146 | 597 GList * |
598 finch_sound_get_profiles() | |
599 { | |
600 return purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles"); | |
601 } | |
602 | |
603 static gboolean | |
604 profile_exists(const char *name) | |
605 { | |
606 GList *itr = NULL; | |
607 for(itr = finch_sound_get_profiles();itr;itr = itr->next){ | |
608 if(!strcmp(itr->data,name)) | |
609 return TRUE; | |
610 } | |
611 return FALSE; | |
612 } | |
613 | |
614 void | |
615 finch_sound_set_active_profile(const char *name) | |
616 { | |
617 if(profile_exists(name)){ | |
618 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name); | |
619 } | |
620 } | |
621 | |
622 | |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
623 static void |
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
624 save_cb(GntWidget *button, gpointer win) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
625 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
626 GList * itr; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
627 |
19146 | 628 purple_prefs_set_string(make_pref("/method"), gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method))); |
629 purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command))); | |
630 purple_prefs_set_bool(make_pref("/conv_focus"),gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus))); | |
19129 | 631 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 | 632 purple_prefs_set_int(make_pref("/volume"),gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume))); |
19129 | 633 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
634 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
|
635 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)]; |
19146 | 636 char * filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",finch_sound_get_active_profile(),event->pref); |
637 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
|
638 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
|
639 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
|
640 g_free(filepref); |
19137 | 641 g_free(boolpref); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
642 } |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
643 gnt_widget_destroy(GNT_WIDGET(win)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
644 } |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
645 |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
646 static void |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
647 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
|
648 { |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
649 FinchSoundEvent *event = data; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
650 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
651 g_free(event->file); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
652 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
|
653 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
654 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
|
655 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
656 gnt_widget_destroy(GNT_WIDGET(w)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
657 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
658 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
659 static void |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
660 test_cb(GntWidget *button, gpointer null) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
661 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
662 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
|
663 FinchSoundEvent * event = &sounds[id]; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
664 char *pref; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
665 gboolean temp_value; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
666 |
19146 | 667 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
|
668 event->pref); |
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 temp_value = purple_prefs_get_bool(pref); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
671 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
672 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
|
673 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
674 purple_sound_play_event(id, NULL); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
675 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
676 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
|
677 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
678 g_free(pref); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
679 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
680 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
681 static void |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
682 reset_cb(GntWidget *button,gpointer null) |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
683 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
684 /* Don't dereference this pointer ! */ |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
685 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
|
686 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
687 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
|
688 g_free(event->file); |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
689 event->file = NULL; |
19139
2d0925800d72
Made the display of files for sound events cleaner
Eric Polino <aluink@pidgin.im>
parents:
19137
diff
changeset
|
690 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
|
691 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
692 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
693 static void |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
694 pref_load_cb(GntWidget *button, gpointer null) |
19146 | 695 { |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
696 |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
697 const gchar * value = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->profiles)); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
698 |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
699 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",value); |
19146 | 700 |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
701 } |
19146 | 702 |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
703 static void |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
704 pref_save_cb(GntWidget *button, gpointer null) |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
705 { |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
706 |
19146 | 707 } |
708 | |
709 static void | |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
710 choose_cb(GntWidget *button, gpointer null) |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
711 { |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
712 GntWidget *w = gnt_file_sel_new(); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
713 GntFileSel *sel = GNT_FILE_SEL(w); |
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
714 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
|
715 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
|
716 char *path = NULL; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
717 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
718 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
|
719 (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
|
720 : purple_home_dir()); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
721 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
722 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
|
723 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
|
724 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
|
725 |
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
|
726 /* 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
|
727 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
|
728 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
|
729 |
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
|
730 pref_dialog->selector = w; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
731 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
732 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
|
733 g_free(path); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
734 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
735 |
19128 | 736 static void |
737 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
|
738 { |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
739 GList * itr; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
740 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
|
741 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
|
742 FinchSoundEvent * e = &sounds[id]; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
743 g_free(e->file); |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
744 } |
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
|
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); |
19128 | 747 g_free(pref_dialog); |
748 pref_dialog = NULL; | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
749 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
750 |
19146 | 751 static void |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
752 reload_pref_window(GntComboBox *box, gpointer oldkey, gpointer newkey, gpointer null) |
19146 | 753 { |
754 gint i; | |
755 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",(gchar *)newkey); | |
756 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method),(gchar *)purple_prefs_get_string(make_pref("/method"))); | |
757 gnt_entry_set_text(GNT_ENTRY(pref_dialog->command),purple_prefs_get_path(make_pref("/command"))); | |
758 gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus),purple_prefs_get_bool(make_pref("/conv_focus"))); | |
759 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status),GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status"))); | |
760 gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume),CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100)); | |
761 for(i = 0;i < PURPLE_NUM_SOUNDS;i++){ | |
762 FinchSoundEvent * event = &sounds[i]; | |
763 gchar *boolpref; | |
764 gchar *filepref; | |
765 const char * profile = finch_sound_get_active_profile(); | |
766 | |
767 boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",profile,event->pref); | |
768 | |
769 filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",profile,event->pref); | |
770 event->file = g_strdup(purple_prefs_get_path(filepref)); | |
771 if(event->label == NULL){ | |
772 continue; | |
773 } | |
774 | |
775 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),0,event->label); | |
776 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),1,event->file[0] ? g_path_get_basename(event->file) : "(default)"); | |
777 gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref)); | |
778 g_free(boolpref); | |
779 g_free(filepref); | |
780 } | |
781 } | |
782 | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
783 void |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
784 finch_sounds_show_all(void) |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
785 { |
19146 | 786 GntWidget *box; GntWidget *cmbox; GntWidget *slider; |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
787 GntWidget *entry; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
788 GntWidget *chkbox; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
789 GntWidget *button; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
790 GntWidget *label; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
791 GntWidget *tree; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
792 GntWidget *win; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
793 |
19146 | 794 GList *itr,*list; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
795 gint i; |
19127
f34e11e41122
Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents:
19126
diff
changeset
|
796 |
19128 | 797 if(pref_dialog){ |
798 gnt_window_present(pref_dialog->window); | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
799 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
800 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
801 |
19128 | 802 pref_dialog = g_new0(SoundPrefDialog,1); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
803 |
19128 | 804 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
|
805 gnt_box_set_pad(GNT_BOX(win),0); |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
806 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
|
807 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
|
808 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
|
809 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
|
810 |
19128 | 811 pref_dialog->method = cmbox = gnt_combo_box_new(); |
19129 | 812 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
|
813 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
|
814 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
|
815 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
|
816 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
|
817 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
|
818 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
|
819 |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
820 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
|
821 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
|
822 box = gnt_hbox_new(TRUE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
823 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
|
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_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
|
826 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
|
827 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
|
828 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
829 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
830 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
831 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
|
832 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)"))); |
19146 | 833 pref_dialog->command = entry = gnt_entry_new(""); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
834 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
|
835 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
|
836 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
837 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
|
838 |
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),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); |
19129 | 840 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
|
841 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
|
842 |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
843 box = gnt_hbox_new(TRUE); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
844 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
|
845 gnt_box_set_fill(GNT_BOX(box),FALSE); |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
846 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:")); |
19128 | 847 pref_dialog->while_status = cmbox = gnt_combo_box_new(); |
19129 | 848 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(3),_("Always")); |
849 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(1),_("Only when available")); | |
850 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
|
851 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
|
852 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
|
853 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
854 box = gnt_hbox_new(TRUE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
855 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
|
856 gnt_box_set_fill(GNT_BOX(box),FALSE); |
19129 | 857 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
|
858 |
19128 | 859 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
|
860 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
|
861 label = gnt_label_new(""); |
915ef65d68e3
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
19119
diff
changeset
|
862 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
868 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
|
869 |
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),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
|
871 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
|
872 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
|
873 gnt_tree_set_show_title(GNT_TREE(tree),TRUE); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
874 |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
875 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
|
876 FinchSoundEvent * event = &sounds[i]; |
19146 | 877 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
878 if(event->label == NULL){ |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
879 continue; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
880 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
881 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
882 gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i), |
19146 | 883 gnt_tree_create_row(GNT_TREE(tree),"",""), |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
884 NULL, NULL); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
885 } |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
886 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
887 gnt_tree_adjust_columns(GNT_TREE(tree)); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
888 gnt_box_add_widget(GNT_BOX(win),tree); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
889 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
890 box = gnt_hbox_new(FALSE); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
891 button = gnt_button_new(_("Test")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
892 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
|
893 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
|
894 button = gnt_button_new(_("Reset")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
895 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
|
896 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
|
897 button = gnt_button_new(_("Choose...")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
898 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
|
899 gnt_box_add_widget(GNT_BOX(box),button); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
900 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
|
901 |
19146 | 902 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
903 | |
904 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD)); | |
905 box = gnt_hbox_new(FALSE); | |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
906 pref_dialog->profiles = cmbox = gnt_combo_box_new(); |
19146 | 907 list = itr = finch_sound_get_profiles(); |
908 for(;itr;itr = itr->next){ | |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
909 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),itr->data,itr->data); |
19146 | 910 } |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
911 g_signal_connect(G_OBJECT(cmbox),"selection-changed",G_CALLBACK(reload_pref_window),NULL); |
19146 | 912 g_list_free(list); |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
913 gnt_box_add_widget(GNT_BOX(box),cmbox); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
914 button = gnt_button_new("Load"); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
915 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(pref_load_cb),NULL); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
916 gnt_box_add_widget(GNT_BOX(box),button); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
917 button = gnt_button_new("Save"); |
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
918 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(pref_save_cb),NULL); |
19146 | 919 gnt_box_add_widget(GNT_BOX(box),button); |
920 gnt_box_add_widget(GNT_BOX(win),box); | |
921 | |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
922 |
19146 | 923 /* Add new stuff before this */ |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
924 box = gnt_hbox_new(FALSE); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
925 gnt_box_set_pad(GNT_BOX(box),0); |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
926 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
|
927 button = gnt_button_new(_("Save")); |
19129 | 928 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
|
929 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
|
930 button = gnt_button_new(_("Cancel")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
931 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
|
932 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
|
933 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
|
934 |
19128 | 935 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
|
936 |
19151
700fe77a79b3
disapproval of revision '28530bc53fbe271f49ca1baa55938a067f20aed8'
Eric Polino <aluink@pidgin.im>
parents:
19150
diff
changeset
|
937 reload_pref_window(NULL,NULL,(gchar *)finch_sound_get_active_profile(),NULL); |
19146 | 938 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
939 gnt_widget_show(win); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
940 |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
941 } |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
942 |
19100 | 943 static PurpleSoundUiOps sound_ui_ops = |
944 { | |
945 finch_sound_init, | |
946 finch_sound_uninit, | |
947 finch_sound_play_file, | |
948 finch_sound_play_event, | |
949 NULL, | |
950 NULL, | |
951 NULL, | |
952 NULL | |
953 }; | |
954 | |
955 PurpleSoundUiOps * | |
956 finch_sound_get_ui_ops(void) | |
957 { | |
958 return &sound_ui_ops; | |
959 } |