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