annotate finch/gntsound.c @ 19130:d5a0b09470ee

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