Fri, 29 Jun 2007 21:12:03 +0000
Changed the volume changer to a GntSlider.
| 18155 | 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 | ||
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
43 | #include "gntbox.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
44 | #include "gntwindow.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
45 | #include "gntcombobox.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
46 | #include "gntlabel.h" |
| 18155 | 47 | #include "gntconv.h" |
| 48 | #include "gntsound.h" | |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
49 | #include "gntwidget.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
50 | #include "gntentry.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
51 | #include "gntcheckbox.h" |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
52 | #include "gntline.h" |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
53 | #include "gntslider.h" |
| 18155 | 54 | |
| 55 | struct finch_sound_event { | |
| 56 | char *label; | |
| 57 | char *pref; | |
| 58 | char *def; | |
| 59 | }; | |
| 60 | ||
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
61 | typedef struct { |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
62 | GntWidget *method; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
63 | GntWidget *command; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
64 | GntWidget *conv_focus; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
65 | GntWidget *while_status; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
66 | GntWidget *volume; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
67 | GntWidget *window; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
68 | } SoundPrefDialog; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
69 | |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
70 | static struct { |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
71 | gchar *method; |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
72 | gchar *command; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
73 | gboolean conv_focus; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
74 | gint while_status; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
75 | gint volume; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
76 | GntTree *events; |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
77 | SoundPrefDialog *dialog; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
78 | } sound_pref_data; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
79 | |
| 18155 | 80 | #define PLAY_SOUND_TIMEOUT 15000 |
| 81 | ||
| 82 | static guint mute_login_sounds_timeout = 0; | |
| 83 | static gboolean mute_login_sounds = FALSE; | |
| 84 | ||
| 85 | #ifdef USE_GSTREAMER | |
| 86 | static gboolean gst_init_failed; | |
| 87 | #endif /* USE_GSTREAMER */ | |
| 88 | ||
| 89 | static struct finch_sound_event sounds[PURPLE_NUM_SOUNDS] = { | |
| 90 | {N_("Buddy logs in"), "login", "login.wav"}, | |
| 91 | {N_("Buddy logs out"), "logout", "logout.wav"}, | |
| 92 | {N_("Message received"), "im_recv", "receive.wav"}, | |
| 93 | {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, | |
| 94 | {N_("Message sent"), "send_im", "send.wav"}, | |
| 95 | {N_("Person enters chat"), "join_chat", "login.wav"}, | |
| 96 | {N_("Person leaves chat"), "left_chat", "logout.wav"}, | |
| 97 | {N_("You talk in chat"), "send_chat_msg", "send.wav"}, | |
| 98 | {N_("Others talk in chat"), "chat_msg_recv", "receive.wav"}, | |
| 99 | /* this isn't a terminator, it's the buddy pounce default sound event ;-) */ | |
| 100 | {NULL, "pounce_default", "alert.wav"}, | |
| 101 | {N_("Someone says your screen name in chat"), "nick_said", "alert.wav"} | |
| 102 | }; | |
| 103 | ||
| 104 | static gboolean | |
| 105 | unmute_login_sounds_cb(gpointer data) | |
| 106 | { | |
| 107 | mute_login_sounds = FALSE; | |
| 108 | mute_login_sounds_timeout = 0; | |
| 109 | return FALSE; | |
| 110 | } | |
| 111 | ||
| 112 | static gboolean | |
| 113 | chat_nick_matches_name(PurpleConversation *conv, const char *aname) | |
| 114 | { | |
| 115 | PurpleConvChat *chat = NULL; | |
| 116 | char *nick = NULL; | |
| 117 | char *name = NULL; | |
| 118 | gboolean ret = FALSE; | |
| 119 | chat = purple_conversation_get_chat_data(conv); | |
| 120 | ||
| 121 | if (chat==NULL) | |
| 122 | return ret; | |
| 123 | ||
| 124 | nick = g_strdup(purple_normalize(conv->account, chat->nick)); | |
| 125 | name = g_strdup(purple_normalize(conv->account, aname)); | |
| 126 | ||
| 127 | if (g_utf8_collate(nick, name) == 0) | |
| 128 | ret = TRUE; | |
| 129 | ||
| 130 | g_free(nick); | |
| 131 | g_free(name); | |
| 132 | ||
| 133 | return ret; | |
| 134 | } | |
| 135 | ||
| 136 | /* | |
| 137 | * play a sound event for a conversation, honoring make_sound flag | |
| 138 | * of conversation and checking for focus if conv_focus pref is set | |
| 139 | */ | |
| 140 | static void | |
| 141 | play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) | |
| 142 | { | |
| 143 | /* If we should not play the sound for some reason, then exit early */ | |
| 144 | if (conv != NULL) | |
| 145 | { | |
| 146 | FinchConv *gntconv; | |
| 147 | gboolean has_focus; | |
| 148 | ||
| 149 | gntconv = FINCH_CONV(conv); | |
| 150 | ||
| 151 | has_focus = purple_conversation_has_focus(conv); | |
| 152 | ||
| 153 | if (has_focus && !purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus")) | |
| 154 | { | |
| 155 | return; | |
| 156 | } | |
| 157 | } | |
| 158 | ||
| 159 | purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); | |
| 160 | } | |
| 161 | ||
| 162 | static void | |
| 163 | buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) | |
| 164 | { | |
| 165 | purple_sound_play_event(event, purple_buddy_get_account(buddy)); | |
| 166 | } | |
| 167 | ||
| 168 | static void | |
| 169 | im_msg_received_cb(PurpleAccount *account, char *sender, | |
| 170 | char *message, PurpleConversation *conv, | |
| 171 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
| 172 | { | |
| 173 | if (flags & PURPLE_MESSAGE_DELAYED) | |
| 174 | return; | |
| 175 | ||
| 176 | if (conv==NULL){ | |
| 177 | purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); | |
| 178 | } | |
| 179 | else{ | |
| 180 | play_conv_event(conv, event); | |
| 181 | } | |
| 182 | } | |
| 183 | ||
| 184 | static void | |
| 185 | im_msg_sent_cb(PurpleAccount *account, const char *receiver, | |
| 186 | const char *message, PurpleSoundEventID event) | |
| 187 | { | |
| 188 | PurpleConversation *conv = purple_find_conversation_with_account( | |
| 189 | PURPLE_CONV_TYPE_ANY, receiver, account); | |
| 190 | play_conv_event(conv, event); | |
| 191 | } | |
| 192 | ||
| 193 | static void | |
| 194 | chat_buddy_join_cb(PurpleConversation *conv, const char *name, | |
| 195 | PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
| 196 | PurpleSoundEventID event) | |
| 197 | { | |
| 198 | if (new_arrival && !chat_nick_matches_name(conv, name)) | |
| 199 | play_conv_event(conv, event); | |
| 200 | } | |
| 201 | ||
| 202 | static void | |
| 203 | chat_buddy_left_cb(PurpleConversation *conv, const char *name, | |
| 204 | const char *reason, PurpleSoundEventID event) | |
| 205 | { | |
| 206 | if (!chat_nick_matches_name(conv, name)) | |
| 207 | play_conv_event(conv, event); | |
| 208 | } | |
| 209 | ||
| 210 | static void | |
| 211 | chat_msg_sent_cb(PurpleAccount *account, const char *message, | |
| 212 | int id, PurpleSoundEventID event) | |
| 213 | { | |
| 214 | PurpleConnection *conn = purple_account_get_connection(account); | |
| 215 | PurpleConversation *conv = NULL; | |
| 216 | ||
| 217 | if (conn!=NULL) | |
| 218 | conv = purple_find_chat(conn,id); | |
| 219 | ||
| 220 | play_conv_event(conv, event); | |
| 221 | } | |
| 222 | ||
| 223 | static void | |
| 224 | chat_msg_received_cb(PurpleAccount *account, char *sender, | |
| 225 | char *message, PurpleConversation *conv, | |
| 226 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
| 227 | { | |
| 228 | PurpleConvChat *chat; | |
| 229 | ||
| 230 | if (flags & PURPLE_MESSAGE_DELAYED) | |
| 231 | return; | |
| 232 | ||
| 233 | chat = purple_conversation_get_chat_data(conv); | |
| 234 | g_return_if_fail(chat != NULL); | |
| 235 | ||
| 236 | if (purple_conv_chat_is_user_ignored(chat, sender)) | |
| 237 | return; | |
| 238 | ||
| 239 | if (chat_nick_matches_name(conv, sender)) | |
| 240 | return; | |
| 241 | ||
| 242 | if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) | |
| 243 | play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
| 244 | else | |
| 245 | play_conv_event(conv, event); | |
| 246 | } | |
| 247 | ||
| 248 | /* | |
| 249 | * We mute sounds for the 10 seconds after you log in so that | |
| 250 | * you don't get flooded with sounds when the blist shows all | |
| 251 | * your buddies logging in. | |
| 252 | */ | |
| 253 | static void | |
| 254 | account_signon_cb(PurpleConnection *gc, gpointer data) | |
| 255 | { | |
| 256 | if (mute_login_sounds_timeout != 0) | |
| 257 | g_source_remove(mute_login_sounds_timeout); | |
| 258 | mute_login_sounds = TRUE; | |
| 259 | mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); | |
| 260 | } | |
| 261 | ||
| 262 | const char * | |
| 263 | finch_sound_get_event_option(PurpleSoundEventID event) | |
| 264 | { | |
| 265 | if(event >= PURPLE_NUM_SOUNDS) | |
| 266 | return 0; | |
| 267 | ||
| 268 | return sounds[event].pref; | |
| 269 | } | |
| 270 | ||
| 271 | const char * | |
| 272 | finch_sound_get_event_label(PurpleSoundEventID event) | |
| 273 | { | |
| 274 | if(event >= PURPLE_NUM_SOUNDS) | |
| 275 | return NULL; | |
| 276 | ||
| 277 | return sounds[event].label; | |
| 278 | } | |
| 279 | ||
| 280 | void * | |
| 281 | finch_sound_get_handle() | |
| 282 | { | |
| 283 | static int handle; | |
| 284 | ||
| 285 | return &handle; | |
| 286 | } | |
| 287 | ||
| 288 | static void | |
| 289 | finch_sound_init(void) | |
| 290 | { | |
| 291 | void *gnt_sound_handle = finch_sound_get_handle(); | |
| 292 | void *blist_handle = purple_blist_get_handle(); | |
| 293 | void *conv_handle = purple_conversations_get_handle(); | |
| 294 | #ifdef USE_GSTREAMER | |
| 295 | GError *error = NULL; | |
| 296 | #endif | |
| 297 | ||
| 298 | purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
| 299 | gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
| 300 | NULL); | |
| 301 | ||
| 302 | purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); | |
| 303 | purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/enabled"); | |
| 304 | purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/file"); | |
| 305 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/login", TRUE); | |
| 306 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/login", ""); | |
| 307 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/logout", TRUE); | |
| 308 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/logout", ""); | |
| 309 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/im_recv", TRUE); | |
| 310 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/im_recv", ""); | |
| 311 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE); | |
| 312 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/first_im_recv", ""); | |
| 313 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_im", TRUE); | |
| 314 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_im", ""); | |
| 315 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/join_chat", FALSE); | |
| 316 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/join_chat", ""); | |
| 317 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/left_chat", FALSE); | |
| 318 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/left_chat", ""); | |
| 319 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE); | |
| 320 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/send_chat_msg", ""); | |
| 321 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE); | |
| 322 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/chat_msg_recv", ""); | |
| 323 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/nick_said", FALSE); | |
| 324 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/nick_said", ""); | |
| 325 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/enabled/pounce_default", TRUE); | |
| 326 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/file/pounce_default", ""); | |
| 327 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/conv_focus", TRUE); | |
| 328 | purple_prefs_add_bool(FINCH_PREFS_ROOT "/sound/mute", FALSE); | |
| 329 | purple_prefs_add_path(FINCH_PREFS_ROOT "/sound/command", ""); | |
| 330 | purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/method", "automatic"); | |
| 331 | purple_prefs_add_int(FINCH_PREFS_ROOT "/sound/volume", 50); | |
| 332 | ||
| 333 | #ifdef USE_GSTREAMER | |
| 334 | purple_debug_info("sound", "Initializing sound output drivers.\n"); | |
| 335 | if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { | |
| 336 | purple_notify_error(NULL, _("GStreamer Failure"), | |
| 337 | _("GStreamer failed to initialize."), | |
| 338 | error ? error->message : ""); | |
| 339 | if (error) { | |
| 340 | g_error_free(error); | |
| 341 | error = NULL; | |
| 342 | } | |
| 343 | } | |
| 344 | #endif /* USE_GSTREAMER */ | |
| 345 | ||
| 346 | purple_signal_connect(blist_handle, "buddy-signed-on", | |
| 347 | gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 348 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
| 349 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 350 | gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 351 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
| 352 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 353 | gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
| 354 | GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
| 355 | purple_signal_connect(conv_handle, "sent-im-msg", | |
| 356 | gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
| 357 | GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
| 358 | purple_signal_connect(conv_handle, "chat-buddy-joined", | |
| 359 | gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
| 360 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
| 361 | purple_signal_connect(conv_handle, "chat-buddy-left", | |
| 362 | gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
| 363 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
| 364 | purple_signal_connect(conv_handle, "sent-chat-msg", | |
| 365 | gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
| 366 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
| 367 | purple_signal_connect(conv_handle, "received-chat-msg", | |
| 368 | gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
| 369 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
| 370 | } | |
| 371 | ||
| 372 | static void | |
| 373 | finch_sound_uninit(void) | |
| 374 | { | |
| 375 | #ifdef USE_GSTREAMER | |
| 376 | if (!gst_init_failed) | |
| 377 | gst_deinit(); | |
| 378 | #endif | |
| 379 | ||
| 380 | purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
| 381 | } | |
| 382 | ||
| 383 | #ifdef USE_GSTREAMER | |
| 384 | static gboolean | |
| 385 | bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
| 386 | { | |
| 387 | GstElement *play = data; | |
| 388 | GError *err = NULL; | |
| 389 | ||
| 390 | switch (GST_MESSAGE_TYPE (msg)) { | |
| 391 | case GST_MESSAGE_EOS: | |
| 392 | gst_element_set_state(play, GST_STATE_NULL); | |
| 393 | gst_object_unref(GST_OBJECT(play)); | |
| 394 | break; | |
| 395 | case GST_MESSAGE_ERROR: | |
| 396 | gst_message_parse_error(msg, &err, NULL); | |
| 397 | purple_debug_error("gstreamer", err->message); | |
| 398 | g_error_free(err); | |
| 399 | break; | |
| 400 | case GST_MESSAGE_WARNING: | |
| 401 | gst_message_parse_warning(msg, &err, NULL); | |
| 402 | purple_debug_warning("gstreamer", err->message); | |
| 403 | g_error_free(err); | |
| 404 | break; | |
| 405 | default: | |
| 406 | break; | |
| 407 | } | |
| 408 | return TRUE; | |
| 409 | } | |
| 410 | #endif | |
| 411 | ||
| 412 | static void | |
| 413 | finch_sound_play_file(const char *filename) | |
| 414 | { | |
| 415 | const char *method; | |
| 416 | #ifdef USE_GSTREAMER | |
| 417 | float volume; | |
| 418 | char *uri; | |
| 419 | GstElement *sink = NULL; | |
| 420 | GstElement *play = NULL; | |
| 421 | GstBus *bus = NULL; | |
| 422 | #endif | |
| 423 | if (purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/mute")) | |
| 424 | return; | |
| 425 | ||
| 426 | method = purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method"); | |
| 427 | ||
| 428 | if (!strcmp(method, "none")) { | |
| 429 | return; | |
| 430 | } else if (!strcmp(method, "beep")) { | |
| 431 | beep(); | |
| 432 | return; | |
| 433 | } | |
| 434 | ||
| 435 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
| 436 | purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
| 437 | return; | |
| 438 | } | |
| 439 | ||
| 440 | #ifndef _WIN32 | |
| 441 | if (!strcmp(method, "custom")) { | |
| 442 | const char *sound_cmd; | |
| 443 | char *command; | |
| 444 | char *esc_filename; | |
| 445 | GError *error = NULL; | |
| 446 | ||
| 447 | sound_cmd = purple_prefs_get_path(FINCH_PREFS_ROOT "/sound/command"); | |
| 448 | ||
| 449 | if (!sound_cmd || *sound_cmd == '\0') { | |
| 450 | purple_debug_error("gntsound", | |
| 451 | "'Command' sound method has been chosen, " | |
| 452 | "but no command has been set."); | |
| 453 | return; | |
| 454 | } | |
| 455 | ||
| 456 | esc_filename = g_shell_quote(filename); | |
| 457 | ||
| 458 | if(strstr(sound_cmd, "%s")) | |
| 459 | command = purple_strreplace(sound_cmd, "%s", esc_filename); | |
| 460 | else | |
| 461 | command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
| 462 | ||
| 463 | if(!g_spawn_command_line_async(command, &error)) { | |
| 464 | purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); | |
| 465 | g_error_free(error); | |
| 466 | } | |
| 467 | ||
| 468 | g_free(esc_filename); | |
| 469 | g_free(command); | |
| 470 | return; | |
| 471 | } | |
| 472 | #ifdef USE_GSTREAMER | |
| 473 | if (gst_init_failed) /* Perhaps do beep instead? */ | |
| 474 | return; | |
| 475 | volume = (float)(CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100)) / 50; | |
| 476 | if (!strcmp(method, "automatic")) { | |
| 477 | if (purple_running_gnome()) { | |
| 478 | sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
| 479 | } | |
| 480 | if (!sink) | |
| 481 | sink = gst_element_factory_make("autoaudiosink", "sink"); | |
| 482 | if (!sink) { | |
| 483 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 484 | return; | |
| 485 | } | |
| 486 | } else if (!strcmp(method, "esd")) { | |
| 487 | sink = gst_element_factory_make("esdsink", "sink"); | |
| 488 | if (!sink) { | |
| 489 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 490 | return; | |
| 491 | } | |
| 492 | } else if (!strcmp(method, "alsa")) { | |
| 493 | sink = gst_element_factory_make("alsasink", "sink"); | |
| 494 | if (!sink) { | |
| 495 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 496 | return; | |
| 497 | } | |
| 498 | } else { | |
| 499 | purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
| 500 | return; | |
| 501 | } | |
| 502 | ||
| 503 | play = gst_element_factory_make("playbin", "play"); | |
| 504 | ||
| 505 | if (play == NULL) { | |
| 506 | return; | |
| 507 | } | |
| 508 | ||
| 509 | uri = g_strdup_printf("file://%s", filename); | |
| 510 | ||
| 511 | g_object_set(G_OBJECT(play), "uri", uri, | |
| 512 | "volume", volume, | |
| 513 | "audio-sink", sink, NULL); | |
| 514 | ||
| 515 | bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
| 516 | gst_bus_add_watch(bus, bus_call, play); | |
| 517 | ||
| 518 | gst_element_set_state(play, GST_STATE_PLAYING); | |
| 519 | ||
| 520 | gst_object_unref(bus); | |
| 521 | g_free(uri); | |
| 522 | ||
| 523 | #else /* USE_GSTREAMER */ | |
| 524 | beep(); | |
| 525 | return; | |
| 526 | #endif /* USE_GSTREAMER */ | |
| 527 | #else /* _WIN32 */ | |
| 528 | purple_debug_info("sound", "Playing %s\n", filename); | |
| 529 | ||
| 530 | if (G_WIN32_HAVE_WIDECHAR_API ()) { | |
| 531 | wchar_t *wc_filename = g_utf8_to_utf16(filename, | |
| 532 | -1, NULL, NULL, NULL); | |
| 533 | if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
| 534 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
| 535 | g_free(wc_filename); | |
| 536 | } else { | |
| 537 | char *l_filename = g_locale_from_utf8(filename, | |
| 538 | -1, NULL, NULL, NULL); | |
| 539 | if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
| 540 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
| 541 | g_free(l_filename); | |
| 542 | } | |
| 543 | #endif /* _WIN32 */ | |
| 544 | } | |
| 545 | ||
| 546 | static void | |
| 547 | finch_sound_play_event(PurpleSoundEventID event) | |
| 548 | { | |
| 549 | char *enable_pref; | |
| 550 | char *file_pref; | |
| 551 | if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
| 552 | return; | |
| 553 | ||
| 554 | if (event >= PURPLE_NUM_SOUNDS) { | |
| 555 | purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
| 556 | return; | |
| 557 | } | |
| 558 | ||
| 559 | enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/enabled/%s", | |
| 560 | sounds[event].pref); | |
| 561 | file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/file/%s", sounds[event].pref); | |
| 562 | ||
| 563 | /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
| 564 | if (purple_prefs_get_bool(enable_pref)) { | |
| 565 | char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
| 566 | if(!filename || !strlen(filename)) { | |
| 567 | g_free(filename); | |
| 18292 | 568 | /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
| 569 | filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
| 18155 | 570 | } |
| 571 | ||
| 572 | purple_sound_play_file(filename, NULL); | |
| 573 | g_free(filename); | |
| 574 | } | |
| 575 | ||
| 576 | g_free(enable_pref); | |
| 577 | g_free(file_pref); | |
| 578 | } | |
| 579 | ||
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
580 | static void init_pref_data() |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
581 | { |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
582 | GntTree *events = NULL; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
583 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
584 | if(sound_pref_data.method){ |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
585 | return; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
586 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
587 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
588 | /* TODO Setup the events tree */ |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
589 | |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
590 | sound_pref_data.method = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/method")); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
591 | sound_pref_data.command = g_strdup(purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/command")); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
592 | sound_pref_data.conv_focus = purple_prefs_get_bool(FINCH_PREFS_ROOT "/sound/conv_focus"); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
593 | sound_pref_data.while_status = purple_prefs_get_int(FINCH_PREFS_ROOT "/purple/sound/while_status"); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
594 | sound_pref_data.volume = CLAMP(purple_prefs_get_int(FINCH_PREFS_ROOT "/sound/volume"),0,100); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
595 | sound_pref_data.events = events; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
596 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
597 | return; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
598 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
599 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
600 | static gboolean |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
601 | save_cb(GntBindable *data, gpointer *win) |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
602 | { |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
603 | gnt_widget_destroy(GNT_WIDGET(win)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
604 | return TRUE; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
605 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
606 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
607 | static gboolean |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
608 | cancel_cb(GntBindable *data, gpointer win) |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
609 | { |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
610 | gnt_widget_destroy(GNT_WIDGET(win)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
611 | return TRUE; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
612 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
613 | |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
614 | static void |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
615 | release_pref_window(GntBindable *data, gpointer null) |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
616 | { |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
617 | g_free(sound_pref_data.dialog); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
618 | sound_pref_data.dialog = NULL; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
619 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
620 | |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
621 | void |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
622 | finch_sounds_show_all(void) |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
623 | { |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
624 | GntWidget *box; |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
625 | GntWidget *cmbox; |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
626 | GntWidget *slider; |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
627 | GntWidget *entry; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
628 | GntWidget *chkbox; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
629 | GntWidget *button; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
630 | GntWidget *label; |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
631 | GntWidget *win; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
632 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
633 | if(sound_pref_data.dialog){ |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
634 | gnt_window_present(sound_pref_data.dialog->window); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
635 | return; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
636 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
637 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
638 | init_pref_data(); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
639 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
640 | sound_pref_data.dialog = g_new0(SoundPrefDialog,1); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
641 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
642 | sound_pref_data.dialog->window = win = gnt_window_box_new(FALSE,TRUE); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
643 | gnt_box_set_pad(GNT_BOX(win),0); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
644 | gnt_box_set_fill(GNT_BOX(win),FALSE); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
645 | gnt_box_set_toplevel(GNT_BOX(win), TRUE); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
646 | gnt_box_set_title(GNT_BOX(win),_("Sound Preferences")); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
647 | gnt_box_set_fill(GNT_BOX(win),TRUE); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
648 | gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_MID); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
649 | |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
650 | sound_pref_data.dialog->method = cmbox = gnt_combo_box_new(); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
651 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic")); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
652 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA"); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
653 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD"); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
654 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep")); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
655 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command")); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
656 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound")); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
657 | gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),sound_pref_data.method); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
658 | |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
659 | label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
660 | gnt_box_add_widget(GNT_BOX(win),label); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
661 | box = gnt_hbox_new(TRUE); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
662 | gnt_box_set_fill(GNT_BOX(box),FALSE); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
663 | gnt_box_set_pad(GNT_BOX(box),0); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
664 | gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Method: "))); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
665 | gnt_box_add_widget(GNT_BOX(box),cmbox); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
666 | gnt_box_add_widget(GNT_BOX(win),box); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
667 | |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
668 | box = gnt_hbox_new(TRUE); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
669 | gnt_box_set_pad(GNT_BOX(box),0); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
670 | gnt_box_set_fill(GNT_BOX(box),FALSE); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
671 | gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)"))); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
672 | sound_pref_data.dialog->command = entry = gnt_entry_new(sound_pref_data.command); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
673 | gnt_box_add_widget(GNT_BOX(box),entry); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
674 | gnt_box_add_widget(GNT_BOX(win),box); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
675 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
676 | gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
677 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
678 | gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
679 | sound_pref_data.dialog->conv_focus = chkbox = gnt_check_box_new("Sounds when conversation has focus"); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
680 | gnt_check_box_set_checked(GNT_CHECK_BOX(chkbox),sound_pref_data.conv_focus); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
681 | gnt_box_add_widget(GNT_BOX(win),chkbox); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
682 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
683 | box = gnt_hbox_new(TRUE); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
684 | gnt_box_set_pad(GNT_BOX(box),0); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
685 | gnt_box_set_fill(GNT_BOX(box),FALSE); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
686 | gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:")); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
687 | sound_pref_data.dialog->while_status = cmbox = gnt_combo_box_new(); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
688 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"always","Always"); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
689 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"available","Only when available"); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
690 | gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"away","Only when not available"); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
691 | switch(sound_pref_data.while_status){ |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
692 | case 1:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"available");break; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
693 | case 2:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"away");break; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
694 | default:gnt_combo_box_set_selected(GNT_COMBO_BOX(cmbox),"always");break; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
695 | } |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
696 | gnt_box_add_widget(GNT_BOX(box),cmbox); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
697 | gnt_box_add_widget(GNT_BOX(win),box); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
698 | |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
699 | box = gnt_hbox_new(TRUE); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
700 | gnt_box_set_pad(GNT_BOX(box),0); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
701 | gnt_box_set_fill(GNT_BOX(box),FALSE); |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
702 | gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Volume(0-100):")); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
703 | |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
704 | sound_pref_data.dialog->volume = slider = gnt_slider_new(FALSE,100,0); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
705 | gnt_slider_set_step(GNT_SLIDER(slider),5); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
706 | label = gnt_label_new(""); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
707 | gnt_slider_reflect_label(GNT_SLIDER(slider),GNT_LABEL(label)); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
708 | gnt_slider_set_value(GNT_SLIDER(slider),sound_pref_data.volume); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
709 | gnt_box_set_pad(GNT_BOX(box),1); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
710 | gnt_box_add_widget(GNT_BOX(box),slider); |
|
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
711 | gnt_box_add_widget(GNT_BOX(box),label); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
712 | gnt_box_add_widget(GNT_BOX(win),box); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
713 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
714 | gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
715 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
716 | gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Events"),GNT_TEXT_FLAG_BOLD)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
717 | /* Put events tree here */ |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
718 | |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
719 | box = gnt_hbox_new(TRUE); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
720 | gnt_box_set_pad(GNT_BOX(box),0); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
721 | gnt_box_set_fill(GNT_BOX(box),TRUE); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
722 | button = gnt_button_new("Save"); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
723 | g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),NULL); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
724 | gnt_box_add_widget(GNT_BOX(box),button); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
725 | button = gnt_button_new("Cancel"); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
726 | g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(cancel_cb),NULL); |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
727 | gnt_box_add_widget(GNT_BOX(box),button); |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
728 | gnt_box_add_widget(GNT_BOX(win),box); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
729 | |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
730 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
731 | g_signal_connect(G_OBJECT(win),"destroy",G_CALLBACK(release_pref_window),NULL); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
732 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
733 | gnt_widget_show(win); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
734 | |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
735 | } |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
736 | |
| 18155 | 737 | static PurpleSoundUiOps sound_ui_ops = |
| 738 | { | |
| 739 | finch_sound_init, | |
| 740 | finch_sound_uninit, | |
| 741 | finch_sound_play_file, | |
| 742 | finch_sound_play_event, | |
| 743 | NULL, | |
| 744 | NULL, | |
| 745 | NULL, | |
| 746 | NULL | |
| 747 | }; | |
| 748 | ||
| 749 | PurpleSoundUiOps * | |
| 750 | finch_sound_get_ui_ops(void) | |
| 751 | { | |
| 752 | return &sound_ui_ops; | |
| 753 | } |