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