Mercurial > pidgin
annotate finch/gntsound.c @ 19269:f14d539508ca
propagate from branch 'im.pidgin.pidgin' (head cb5420b4b28888af9a419d6ca29f524e552c9cf0)
to branch 'im.pidgin.soc.2007.certmgr' (head 97c2302635cebf1aef42b25b0c50a883ad091bde)
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Tue, 14 Aug 2007 05:58:53 +0000 |
parents | cdb0fbe5de7b |
children | ed80bace0934 |
rev | line source |
---|---|
19100 | 1 /** |
19170
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
2 * @file gntsound.c GNT Sound API |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
3 * @ingroup finch |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
4 * |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
5 * finch |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
6 * |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
8 * to list here. Please refer to the COPYRIGHT file distributed with this |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
9 * source distribution. |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
10 * |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
14 * (at your option) any later version. |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
15 * |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
19 * GNU General Public License for more details. |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
20 * |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
24 */ |
19100 | 25 #include "internal.h" |
26 #include "finch.h" | |
27 | |
28 #ifdef _WIN32 | |
29 #include <windows.h> | |
30 #include <mmsystem.h> | |
31 #endif | |
32 | |
33 #ifdef USE_GSTREAMER | |
34 #include <gst/gst.h> | |
35 #endif /* USE_GSTREAMER */ | |
36 | |
37 #include "debug.h" | |
38 #include "notify.h" | |
39 #include "prefs.h" | |
40 #include "sound.h" | |
41 #include "util.h" | |
42 | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
43 #include "gntbox.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
44 #include "gntwindow.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
45 #include "gntcombobox.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
46 #include "gntlabel.h" |
19100 | 47 #include "gntconv.h" |
48 #include "gntsound.h" | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
49 #include "gntwidget.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
50 #include "gntentry.h" |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
51 #include "gntcheckbox.h" |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
52 #include "gntline.h" |
19125
915ef65d68e3
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
19119
diff
changeset
|
53 #include "gntslider.h" |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
54 #include "gnttree.h" |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
55 #include "gntfilesel.h" |
19100 | 56 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
57 typedef struct { |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
58 PurpleSoundEventID id; |
19100 | 59 char *label; |
60 char *pref; | |
61 char *def; | |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
62 char *file; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
63 } FinchSoundEvent; |
19100 | 64 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
65 typedef struct { |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
66 GntWidget *method; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
67 GntWidget *command; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
68 GntWidget *conv_focus; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
69 GntWidget *while_status; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
70 GntWidget *volume; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
71 GntWidget *events; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
72 GntWidget *window; |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
73 GntWidget *selector; |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
74 |
19146 | 75 GntWidget *profiles; |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
76 GntWidget *new_profile; |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
77 gchar * original_profile; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
78 } SoundPrefDialog; |
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
79 |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
80 #define DEFAULT_PROFILE "default" |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
81 |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
82 static SoundPrefDialog *pref_dialog; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
83 |
19100 | 84 #define PLAY_SOUND_TIMEOUT 15000 |
85 | |
86 static guint mute_login_sounds_timeout = 0; | |
87 static gboolean mute_login_sounds = FALSE; | |
88 | |
89 #ifdef USE_GSTREAMER | |
90 static gboolean gst_init_failed; | |
91 #endif /* USE_GSTREAMER */ | |
92 | |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
93 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = { |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
94 {PURPLE_SOUND_BUDDY_ARRIVE, N_("Buddy logs in"), "login", "login.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
95 {PURPLE_SOUND_BUDDY_LEAVE, N_("Buddy logs out"), "logout", "logout.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
96 {PURPLE_SOUND_RECEIVE, N_("Message received"), "im_recv", "receive.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
97 {PURPLE_SOUND_FIRST_RECEIVE, N_("Message received begins conversation"), "first_im_recv", "receive.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
98 {PURPLE_SOUND_SEND, N_("Message sent"), "send_im", "send.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
99 {PURPLE_SOUND_CHAT_JOIN, N_("Person enters chat"), "join_chat", "login.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
100 {PURPLE_SOUND_CHAT_LEAVE, N_("Person leaves chat"), "left_chat", "logout.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
101 {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
102 {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
103 {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL}, |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
104 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your screen name in chat"), "nick_said", "alert.wav", NULL} |
19100 | 105 }; |
106 | |
19146 | 107 const char * |
108 finch_sound_get_active_profile() | |
109 { | |
110 return purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/actprofile"); | |
111 } | |
112 | |
113 /* This method creates a pref name based on the current active profile. | |
114 * So if "Home" is the current active profile the pref name | |
115 * [FINCH_PREFS_ROOT "/sound/profiles/Home/$NAME"] is created. | |
116 */ | |
117 static gchar * | |
118 make_pref(const char *name) | |
119 { | |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
120 static char pref_string[512]; |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
121 g_snprintf(pref_string, sizeof(pref_string), |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
122 FINCH_PREFS_ROOT "/sound/profiles/%s%s", finch_sound_get_active_profile(), name); |
19146 | 123 return pref_string; |
124 } | |
125 | |
126 | |
19100 | 127 static gboolean |
128 unmute_login_sounds_cb(gpointer data) | |
129 { | |
130 mute_login_sounds = FALSE; | |
131 mute_login_sounds_timeout = 0; | |
132 return FALSE; | |
133 } | |
134 | |
135 static gboolean | |
136 chat_nick_matches_name(PurpleConversation *conv, const char *aname) | |
137 { | |
138 PurpleConvChat *chat = NULL; | |
139 char *nick = NULL; | |
140 char *name = NULL; | |
141 gboolean ret = FALSE; | |
142 chat = purple_conversation_get_chat_data(conv); | |
143 | |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
144 if (chat == NULL) |
19100 | 145 return ret; |
146 | |
147 nick = g_strdup(purple_normalize(conv->account, chat->nick)); | |
148 name = g_strdup(purple_normalize(conv->account, aname)); | |
149 | |
150 if (g_utf8_collate(nick, name) == 0) | |
151 ret = TRUE; | |
152 | |
153 g_free(nick); | |
154 g_free(name); | |
155 | |
156 return ret; | |
157 } | |
158 | |
159 /* | |
160 * play a sound event for a conversation, honoring make_sound flag | |
161 * of conversation and checking for focus if conv_focus pref is set | |
162 */ | |
163 static void | |
164 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) | |
165 { | |
166 /* If we should not play the sound for some reason, then exit early */ | |
167 if (conv != NULL) | |
168 { | |
169 FinchConv *gntconv; | |
170 gboolean has_focus; | |
171 | |
172 gntconv = FINCH_CONV(conv); | |
173 | |
174 has_focus = purple_conversation_has_focus(conv); | |
175 | |
19146 | 176 if (has_focus && !purple_prefs_get_bool(make_pref("/conv_focus"))) |
19100 | 177 { |
178 return; | |
179 } | |
180 } | |
181 | |
182 purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); | |
183 } | |
184 | |
185 static void | |
186 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) | |
187 { | |
188 purple_sound_play_event(event, purple_buddy_get_account(buddy)); | |
189 } | |
190 | |
191 static void | |
192 im_msg_received_cb(PurpleAccount *account, char *sender, | |
193 char *message, PurpleConversation *conv, | |
194 PurpleMessageFlags flags, PurpleSoundEventID event) | |
195 { | |
196 if (flags & PURPLE_MESSAGE_DELAYED) | |
197 return; | |
198 | |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
199 if (conv == NULL) { |
19100 | 200 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
201 } else { |
19100 | 202 play_conv_event(conv, event); |
203 } | |
204 } | |
205 | |
206 static void | |
207 im_msg_sent_cb(PurpleAccount *account, const char *receiver, | |
208 const char *message, PurpleSoundEventID event) | |
209 { | |
210 PurpleConversation *conv = purple_find_conversation_with_account( | |
211 PURPLE_CONV_TYPE_ANY, receiver, account); | |
212 play_conv_event(conv, event); | |
213 } | |
214 | |
215 static void | |
216 chat_buddy_join_cb(PurpleConversation *conv, const char *name, | |
217 PurpleConvChatBuddyFlags flags, gboolean new_arrival, | |
218 PurpleSoundEventID event) | |
219 { | |
220 if (new_arrival && !chat_nick_matches_name(conv, name)) | |
221 play_conv_event(conv, event); | |
222 } | |
223 | |
224 static void | |
225 chat_buddy_left_cb(PurpleConversation *conv, const char *name, | |
226 const char *reason, PurpleSoundEventID event) | |
227 { | |
228 if (!chat_nick_matches_name(conv, name)) | |
229 play_conv_event(conv, event); | |
230 } | |
231 | |
232 static void | |
233 chat_msg_sent_cb(PurpleAccount *account, const char *message, | |
234 int id, PurpleSoundEventID event) | |
235 { | |
236 PurpleConnection *conn = purple_account_get_connection(account); | |
237 PurpleConversation *conv = NULL; | |
238 | |
239 if (conn!=NULL) | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
240 conv = purple_find_chat(conn, id); |
19100 | 241 |
242 play_conv_event(conv, event); | |
243 } | |
244 | |
245 static void | |
246 chat_msg_received_cb(PurpleAccount *account, char *sender, | |
247 char *message, PurpleConversation *conv, | |
248 PurpleMessageFlags flags, PurpleSoundEventID event) | |
249 { | |
250 PurpleConvChat *chat; | |
251 | |
252 if (flags & PURPLE_MESSAGE_DELAYED) | |
253 return; | |
254 | |
255 chat = purple_conversation_get_chat_data(conv); | |
256 g_return_if_fail(chat != NULL); | |
257 | |
258 if (purple_conv_chat_is_user_ignored(chat, sender)) | |
259 return; | |
260 | |
261 if (chat_nick_matches_name(conv, sender)) | |
262 return; | |
263 | |
264 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick)) | |
265 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK); | |
266 else | |
267 play_conv_event(conv, event); | |
268 } | |
269 | |
270 /* | |
271 * We mute sounds for the 10 seconds after you log in so that | |
272 * you don't get flooded with sounds when the blist shows all | |
273 * your buddies logging in. | |
274 */ | |
275 static void | |
276 account_signon_cb(PurpleConnection *gc, gpointer data) | |
277 { | |
278 if (mute_login_sounds_timeout != 0) | |
279 g_source_remove(mute_login_sounds_timeout); | |
280 mute_login_sounds = TRUE; | |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
281 mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL); |
19100 | 282 } |
283 | |
19177
19a4594e939c
Fix a memory leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19170
diff
changeset
|
284 static void * |
19100 | 285 finch_sound_get_handle() |
286 { | |
287 static int handle; | |
288 | |
289 return &handle; | |
290 } | |
291 | |
19146 | 292 |
293 /* This gets called when the active profile changes */ | |
294 static void | |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
295 initialize_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) |
19146 | 296 { |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
297 if (purple_prefs_exists(make_pref(""))) |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
298 return; |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
299 |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
300 purple_prefs_add_none(make_pref("")); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
301 purple_prefs_add_none(make_pref("/enabled")); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
302 purple_prefs_add_none(make_pref("/file")); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
303 purple_prefs_add_bool(make_pref("/enabled/login"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
304 purple_prefs_add_path(make_pref("/file/login"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
305 purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
306 purple_prefs_add_path(make_pref("/file/logout"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
307 purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
308 purple_prefs_add_path(make_pref("/file/im_recv"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
309 purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
310 purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
311 purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
312 purple_prefs_add_path(make_pref("/file/send_im"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
313 purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
314 purple_prefs_add_path(make_pref("/file/join_chat"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
315 purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
316 purple_prefs_add_path(make_pref("/file/left_chat"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
317 purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
318 purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
319 purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
320 purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
321 purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
322 purple_prefs_add_path(make_pref("/file/nick_said"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
323 purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
324 purple_prefs_add_path(make_pref("/file/pounce_default"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
325 purple_prefs_add_bool(make_pref("/conv_focus"), TRUE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
326 purple_prefs_add_bool(make_pref("/mute"), FALSE); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
327 purple_prefs_add_path(make_pref("/command"), ""); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
328 purple_prefs_add_string(make_pref("/method"), "automatic"); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
329 purple_prefs_add_int(make_pref("/volume"), 50); |
19146 | 330 } |
331 | |
19100 | 332 static void |
333 finch_sound_init(void) | |
334 { | |
335 void *gnt_sound_handle = finch_sound_get_handle(); | |
336 void *blist_handle = purple_blist_get_handle(); | |
337 void *conv_handle = purple_conversations_get_handle(); | |
338 #ifdef USE_GSTREAMER | |
339 GError *error = NULL; | |
340 #endif | |
341 | |
342 purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
343 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
344 NULL); | |
345 | |
346 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound"); | |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
347 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", DEFAULT_PROFILE); |
19146 | 348 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); |
19100 | 349 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
350 purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL); |
19146 | 351 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); |
352 | |
353 | |
19100 | 354 #ifdef USE_GSTREAMER |
355 purple_debug_info("sound", "Initializing sound output drivers.\n"); | |
356 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { | |
357 purple_notify_error(NULL, _("GStreamer Failure"), | |
358 _("GStreamer failed to initialize."), | |
359 error ? error->message : ""); | |
360 if (error) { | |
361 g_error_free(error); | |
362 error = NULL; | |
363 } | |
364 } | |
365 #endif /* USE_GSTREAMER */ | |
366 | |
367 purple_signal_connect(blist_handle, "buddy-signed-on", | |
368 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
369 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
370 purple_signal_connect(blist_handle, "buddy-signed-off", | |
371 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
372 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
373 purple_signal_connect(conv_handle, "received-im-msg", | |
374 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
375 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
376 purple_signal_connect(conv_handle, "sent-im-msg", | |
377 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
378 GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
379 purple_signal_connect(conv_handle, "chat-buddy-joined", | |
380 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb), | |
381 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); | |
382 purple_signal_connect(conv_handle, "chat-buddy-left", | |
383 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb), | |
384 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); | |
385 purple_signal_connect(conv_handle, "sent-chat-msg", | |
386 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
387 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
388 purple_signal_connect(conv_handle, "received-chat-msg", | |
389 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
390 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
391 } | |
392 | |
393 static void | |
394 finch_sound_uninit(void) | |
395 { | |
396 #ifdef USE_GSTREAMER | |
397 if (!gst_init_failed) | |
398 gst_deinit(); | |
399 #endif | |
400 | |
401 purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
402 } | |
403 | |
404 #ifdef USE_GSTREAMER | |
405 static gboolean | |
406 bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
407 { | |
408 GstElement *play = data; | |
409 GError *err = NULL; | |
410 | |
411 switch (GST_MESSAGE_TYPE (msg)) { | |
412 case GST_MESSAGE_EOS: | |
413 gst_element_set_state(play, GST_STATE_NULL); | |
414 gst_object_unref(GST_OBJECT(play)); | |
415 break; | |
416 case GST_MESSAGE_ERROR: | |
417 gst_message_parse_error(msg, &err, NULL); | |
19185
cdb0fbe5de7b
Print debug messages appropriately.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19184
diff
changeset
|
418 purple_debug_error("gstreamer", "%s\n", err->message); |
19100 | 419 g_error_free(err); |
420 break; | |
421 case GST_MESSAGE_WARNING: | |
422 gst_message_parse_warning(msg, &err, NULL); | |
19185
cdb0fbe5de7b
Print debug messages appropriately.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19184
diff
changeset
|
423 purple_debug_warning("gstreamer", "%s\n", err->message); |
19100 | 424 g_error_free(err); |
425 break; | |
426 default: | |
427 break; | |
428 } | |
429 return TRUE; | |
430 } | |
431 #endif | |
432 | |
433 static void | |
434 finch_sound_play_file(const char *filename) | |
435 { | |
436 const char *method; | |
437 #ifdef USE_GSTREAMER | |
438 float volume; | |
439 char *uri; | |
440 GstElement *sink = NULL; | |
441 GstElement *play = NULL; | |
442 GstBus *bus = NULL; | |
443 #endif | |
19146 | 444 if (purple_prefs_get_bool(make_pref("/mute"))) |
19100 | 445 return; |
446 | |
19146 | 447 method = purple_prefs_get_string(make_pref("/method")); |
19100 | 448 |
449 if (!strcmp(method, "none")) { | |
450 return; | |
451 } else if (!strcmp(method, "beep")) { | |
452 beep(); | |
453 return; | |
454 } | |
455 | |
456 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
457 purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
458 return; | |
459 } | |
460 | |
461 #ifndef _WIN32 | |
462 if (!strcmp(method, "custom")) { | |
463 const char *sound_cmd; | |
464 char *command; | |
465 char *esc_filename; | |
466 GError *error = NULL; | |
467 | |
19146 | 468 sound_cmd = purple_prefs_get_path(make_pref("/command")); |
19100 | 469 |
470 if (!sound_cmd || *sound_cmd == '\0') { | |
471 purple_debug_error("gntsound", | |
472 "'Command' sound method has been chosen, " | |
473 "but no command has been set."); | |
474 return; | |
475 } | |
476 | |
477 esc_filename = g_shell_quote(filename); | |
478 | |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
479 if (strstr(sound_cmd, "%s")) |
19100 | 480 command = purple_strreplace(sound_cmd, "%s", esc_filename); |
481 else | |
482 command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
483 | |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
484 if (!g_spawn_command_line_async(command, &error)) { |
19100 | 485 purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); |
486 g_error_free(error); | |
487 } | |
488 | |
489 g_free(esc_filename); | |
490 g_free(command); | |
491 return; | |
492 } | |
493 #ifdef USE_GSTREAMER | |
494 if (gst_init_failed) /* Perhaps do beep instead? */ | |
495 return; | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
496 volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)) / 50; |
19100 | 497 if (!strcmp(method, "automatic")) { |
498 if (purple_running_gnome()) { | |
499 sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
500 } | |
501 if (!sink) | |
502 sink = gst_element_factory_make("autoaudiosink", "sink"); | |
503 if (!sink) { | |
504 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
505 return; | |
506 } | |
507 } else if (!strcmp(method, "esd")) { | |
508 sink = gst_element_factory_make("esdsink", "sink"); | |
509 if (!sink) { | |
510 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
511 return; | |
512 } | |
513 } else if (!strcmp(method, "alsa")) { | |
514 sink = gst_element_factory_make("alsasink", "sink"); | |
515 if (!sink) { | |
516 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
517 return; | |
518 } | |
519 } else { | |
520 purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
521 return; | |
522 } | |
523 | |
524 play = gst_element_factory_make("playbin", "play"); | |
525 | |
526 if (play == NULL) { | |
527 return; | |
528 } | |
529 | |
530 uri = g_strdup_printf("file://%s", filename); | |
531 | |
532 g_object_set(G_OBJECT(play), "uri", uri, | |
533 "volume", volume, | |
534 "audio-sink", sink, NULL); | |
535 | |
536 bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
537 gst_bus_add_watch(bus, bus_call, play); | |
538 | |
539 gst_element_set_state(play, GST_STATE_PLAYING); | |
540 | |
541 gst_object_unref(bus); | |
542 g_free(uri); | |
543 | |
544 #else /* USE_GSTREAMER */ | |
545 beep(); | |
546 return; | |
547 #endif /* USE_GSTREAMER */ | |
548 #else /* _WIN32 */ | |
549 purple_debug_info("sound", "Playing %s\n", filename); | |
550 | |
551 if (G_WIN32_HAVE_WIDECHAR_API ()) { | |
552 wchar_t *wc_filename = g_utf8_to_utf16(filename, | |
553 -1, NULL, NULL, NULL); | |
554 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
555 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
556 g_free(wc_filename); | |
557 } else { | |
558 char *l_filename = g_locale_from_utf8(filename, | |
559 -1, NULL, NULL, NULL); | |
560 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
561 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
562 g_free(l_filename); | |
563 } | |
564 #endif /* _WIN32 */ | |
565 } | |
566 | |
567 static void | |
568 finch_sound_play_event(PurpleSoundEventID event) | |
569 { | |
570 char *enable_pref; | |
571 char *file_pref; | |
572 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
573 return; | |
574 | |
575 if (event >= PURPLE_NUM_SOUNDS) { | |
576 purple_debug_error("sound", "got request for unknown sound: %d\n", event); | |
577 return; | |
578 } | |
579 | |
19146 | 580 enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |
581 finch_sound_get_active_profile(), | |
19100 | 582 sounds[event].pref); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
583 file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(), sounds[event].pref); |
19100 | 584 |
585 /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
586 if (purple_prefs_get_bool(enable_pref)) { | |
587 char *filename = g_strdup(purple_prefs_get_path(file_pref)); | |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
588 if (!filename || !strlen(filename)) { |
19100 | 589 g_free(filename); |
19115 | 590 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
591 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
19100 | 592 } |
593 | |
594 purple_sound_play_file(filename, NULL); | |
595 g_free(filename); | |
596 } | |
597 | |
598 g_free(enable_pref); | |
599 g_free(file_pref); | |
600 } | |
601 | |
19146 | 602 GList * |
603 finch_sound_get_profiles() | |
604 { | |
19156
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
605 GList *list = NULL, *iter; |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
606 iter = purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles"); |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
607 while (iter) { |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
608 list = g_list_append(list, g_strdup(strrchr(iter->data, '/') + 1)); |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
609 g_free(iter->data); |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
610 iter = g_list_delete_link(iter, iter); |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
611 } |
f65c287e466e
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19154
diff
changeset
|
612 return list; |
19146 | 613 } |
614 | |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
615 /* This will also create it if it doesn't exist */ |
19146 | 616 void |
617 finch_sound_set_active_profile(const char *name) | |
618 { | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
619 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile", name); |
19146 | 620 } |
621 | |
19177
19a4594e939c
Fix a memory leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19170
diff
changeset
|
622 static gboolean |
19170
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
623 finch_sound_profile_exists(const char *name) |
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
624 { |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
625 gchar * tmp; |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
626 gboolean ret = purple_prefs_exists(tmp = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s", name)); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
627 g_free(tmp); |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
628 return ret; |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
629 } |
19146 | 630 |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
631 static void |
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
632 save_cb(GntWidget *button, gpointer win) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
633 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
634 GList * itr; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
635 |
19146 | 636 purple_prefs_set_string(make_pref("/method"), gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method))); |
637 purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command))); | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
638 purple_prefs_set_bool(make_pref("/conv_focus"), gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus))); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
639 purple_prefs_set_int("/purple/sound/while_status", GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status)))); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
640 purple_prefs_set_int(make_pref("/volume"), gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume))); |
19129 | 641 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
642 for (itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events)); itr; itr = itr->next) { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
643 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)]; |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
644 char * filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(), event->pref); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
645 char * boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", finch_sound_get_active_profile(), event->pref); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
646 purple_prefs_set_bool(boolpref, gnt_tree_get_choice(GNT_TREE(pref_dialog->events), itr->data)); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
647 purple_prefs_set_path(filepref, event->file ? event->file : ""); |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
648 g_free(filepref); |
19137 | 649 g_free(boolpref); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
650 } |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
651 gnt_widget_destroy(GNT_WIDGET(win)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
652 } |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
653 |
19130
d5a0b09470ee
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
19129
diff
changeset
|
654 static void |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
655 file_cb(GntFileSel *w, const char *path, const char *file, gpointer data) |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
656 { |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
657 FinchSoundEvent *event = data; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
658 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
659 g_free(event->file); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
660 event->file = g_strdup(path); |
19139
2d0925800d72
Made the display of files for sound events cleaner
Eric Polino <aluink@pidgin.im>
parents:
19137
diff
changeset
|
661 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
662 gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), 1, file); |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
663 gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), TRUE); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
664 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
665 gnt_widget_destroy(GNT_WIDGET(w)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
666 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
667 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
668 static void |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
669 test_cb(GntWidget *button, gpointer null) |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
670 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
671 PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
672 FinchSoundEvent * event = &sounds[id]; |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
673 char *enabled, *file, *tmpfile; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
674 gboolean temp_value; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
675 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
676 enabled = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
677 finch_sound_get_active_profile(), event->pref); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
678 file = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
679 finch_sound_get_active_profile(), event->pref); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
680 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
681 temp_value = purple_prefs_get_bool(enabled); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
682 tmpfile = g_strdup(purple_prefs_get_string(file)); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
683 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
684 purple_prefs_set_string(file, event->file); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
685 if (!temp_value) purple_prefs_set_bool(enabled, TRUE); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
686 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
687 purple_sound_play_event(id, NULL); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
688 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
689 if (!temp_value) purple_prefs_set_bool(enabled, FALSE); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
690 purple_prefs_set_string(file, tmpfile); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
691 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
692 g_free(enabled); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
693 g_free(file); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
694 g_free(tmpfile); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
695 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
696 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
697 static void |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
698 reset_cb(GntWidget *button, gpointer null) |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
699 { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
700 /* Don't dereference this pointer ! */ |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
701 gpointer key = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events)); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
702 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
703 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(key)]; |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
704 g_free(event->file); |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
705 event->file = NULL; |
19183
772670b9e9f8
Mark a string for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19182
diff
changeset
|
706 gnt_tree_change_text(GNT_TREE(pref_dialog->events), key, 1, _("(default)")); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
707 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
708 |
19146 | 709 |
710 static void | |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
711 choose_cb(GntWidget *button, gpointer null) |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
712 { |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
713 GntWidget *w = gnt_file_sel_new(); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
714 GntFileSel *sel = GNT_FILE_SEL(w); |
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
715 PurpleSoundEventID id = GPOINTER_TO_INT(gnt_tree_get_selection_data(GNT_TREE(pref_dialog->events))); |
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
716 FinchSoundEvent * event = &sounds[id]; |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
717 char *path = NULL; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
718 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
719 gnt_box_set_title(GNT_BOX(w), _("Select Sound File ...")); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
720 gnt_file_sel_set_current_location(sel, |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
721 (event && event->file) ? (path = g_path_get_dirname(event->file)) |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
722 : purple_home_dir()); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
723 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
724 g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate", G_CALLBACK(gnt_widget_destroy), sel); |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
725 g_signal_connect(G_OBJECT(sel), "file_selected", G_CALLBACK(file_cb), event); |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
726 g_signal_connect_swapped(G_OBJECT(sel), "destroy", G_CALLBACK(g_nullify_pointer), &pref_dialog->selector); |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
727 |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
728 /* If there's an already open file-selector, close that one. */ |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
729 if (pref_dialog->selector) |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
730 gnt_widget_destroy(pref_dialog->selector); |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
731 |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
732 pref_dialog->selector = w; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
733 |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
734 gnt_widget_show(w); |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
735 g_free(path); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
736 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
737 |
19128 | 738 static void |
739 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
|
740 { |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
741 GList * itr; |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
742 for (itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events)); itr; itr = itr->next) { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
743 PurpleSoundEventID id = GPOINTER_TO_INT(itr->data); |
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
744 FinchSoundEvent * e = &sounds[id]; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
745 g_free(e->file); |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
746 e->file = NULL; |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
747 } |
19143
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
748 if (pref_dialog->selector) |
3bec25803a00
Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19142
diff
changeset
|
749 gnt_widget_destroy(pref_dialog->selector); |
19128 | 750 g_free(pref_dialog); |
751 pref_dialog = NULL; | |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
752 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
753 |
19146 | 754 static void |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
755 load_pref_window(const char * profile) |
19146 | 756 { |
757 gint i; | |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
758 |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
759 finch_sound_set_active_profile(profile); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
760 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
761 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method), (gchar *)purple_prefs_get_string(make_pref("/method"))); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
762 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
763 gnt_entry_set_text(GNT_ENTRY(pref_dialog->command), purple_prefs_get_path(make_pref("/command"))); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
764 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
765 gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus), purple_prefs_get_bool(make_pref("/conv_focus"))); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
766 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
767 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status), GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status"))); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
768 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
769 gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume), CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
770 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
771 for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { |
19146 | 772 FinchSoundEvent * event = &sounds[i]; |
773 gchar *boolpref; | |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
774 gchar *filepref, *basename = NULL; |
19146 | 775 const char * profile = finch_sound_get_active_profile(); |
776 | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
777 filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", profile, event->pref); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
778 |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
779 g_free(event->file); |
19146 | 780 event->file = g_strdup(purple_prefs_get_path(filepref)); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
781 |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
782 g_free(filepref); |
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
783 if (event->label == NULL) { |
19146 | 784 continue; |
785 } | |
786 | |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
787 boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", profile, event->pref); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
788 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
789 gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 0, event->label); |
19184
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
790 gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), 1, |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
791 event->file[0] ? (basename = g_path_get_basename(event->file)) : _("(default)")); |
6902517cdfe6
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19183
diff
changeset
|
792 g_free(basename); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
793 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
794 gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(i), purple_prefs_get_bool(boolpref)); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
795 |
19146 | 796 g_free(boolpref); |
797 } | |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
798 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
799 gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), (gchar *)finch_sound_get_active_profile()); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
800 |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
801 gnt_widget_draw(pref_dialog->window); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
802 } |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
803 |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
804 static void |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
805 reload_pref_window(const char *profile) |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
806 { |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
807 if (!strcmp(profile, finch_sound_get_active_profile())) |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
808 return; |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
809 load_pref_window(profile); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
810 } |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
811 |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
812 static void |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
813 prof_del_cb(GntWidget *button, gpointer null) |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
814 { |
19167
42fc16a234ec
Deleting profile is now from the entry.
Eric Polino <aluink@pidgin.im>
parents:
19166
diff
changeset
|
815 const char * profile = gnt_entry_get_text(GNT_ENTRY(pref_dialog->new_profile)); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
816 gchar * pref; |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
817 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
818 if (!strcmp(profile, DEFAULT_PROFILE)) |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
819 return; |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
820 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
821 pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s", profile); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
822 purple_prefs_remove(pref); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
823 g_free(pref); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
824 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
825 if (!strcmp(pref_dialog->original_profile, profile)) { |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
826 g_free(pref_dialog->original_profile); |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
827 pref_dialog->original_profile = g_strdup(DEFAULT_PROFILE); |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
828 } |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
829 |
19170
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
830 if(!strcmp(profile, finch_sound_get_active_profile())) |
19166
7781dcecbd47
Reset to the default profile when the active profile is deleted.
Eric Polino <aluink@pidgin.im>
parents:
19165
diff
changeset
|
831 reload_pref_window(DEFAULT_PROFILE); |
7781dcecbd47
Reset to the default profile when the active profile is deleted.
Eric Polino <aluink@pidgin.im>
parents:
19165
diff
changeset
|
832 |
19170
315fd66bb08f
Whitespace fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19167
diff
changeset
|
833 gnt_tree_remove(GNT_TREE(pref_dialog->profiles), (gchar *) profile); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
834 } |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
835 |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
836 static void |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
837 prof_add_cb(GntButton *button, GntEntry * entry) |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
838 { |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
839 const char * profile = gnt_entry_get_text(entry); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
840 GntTreeRow * row; |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
841 if (!finch_sound_profile_exists(profile)) { |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
842 gpointer key = g_strdup(profile); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
843 row = gnt_tree_create_row(GNT_TREE(pref_dialog->profiles), profile); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
844 gnt_tree_add_row_after(GNT_TREE(pref_dialog->profiles), key, |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
845 row, |
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
846 NULL, NULL); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
847 gnt_entry_set_text(entry, ""); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
848 gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles), key); |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
849 finch_sound_set_active_profile(key); |
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
850 } else |
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
851 reload_pref_window(profile); |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
852 } |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
853 |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
854 static void |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
855 prof_load_cb(GntTree *tree, gpointer oldkey, gpointer newkey, gpointer null) |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
856 { |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
857 reload_pref_window(newkey); |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
858 } |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
859 |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
860 static void |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
861 cancel_cb(GntButton *button, gpointer win) |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
862 { |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
863 finch_sound_set_active_profile(pref_dialog->original_profile); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
864 gnt_widget_destroy(GNT_WIDGET(win)); |
19146 | 865 } |
866 | |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
867 void |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
868 finch_sounds_show_all(void) |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
869 { |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
870 GntWidget *box, *tmpbox, *splitbox, *cmbox, *slider; |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
871 GntWidget *entry; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
872 GntWidget *chkbox; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
873 GntWidget *button; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
874 GntWidget *label; |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
875 GntWidget *tree; |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
876 GntWidget *win; |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
877 |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
878 gint i; |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
879 GList *itr, *list; |
19127
f34e11e41122
Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents:
19126
diff
changeset
|
880 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
881 if (pref_dialog) { |
19128 | 882 gnt_window_present(pref_dialog->window); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
883 return; |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
884 } |
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
885 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
886 pref_dialog = g_new0(SoundPrefDialog, 1); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
887 |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
888 pref_dialog->original_profile = g_strdup(finch_sound_get_active_profile()); |
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
889 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
890 pref_dialog->window = win = gnt_window_box_new(FALSE, TRUE); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
891 gnt_box_set_pad(GNT_BOX(win), 0); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
892 gnt_box_set_toplevel(GNT_BOX(win), TRUE); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
893 gnt_box_set_title(GNT_BOX(win), _("Sound Preferences")); |
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
894 gnt_box_set_fill(GNT_BOX(win), TRUE); |
19165
d2a88d84fbac
This makes things look nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19164
diff
changeset
|
895 gnt_box_set_alignment(GNT_BOX(win), GNT_ALIGN_MID); |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
896 |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
897 /* Profiles */ |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
898 splitbox = gnt_hbox_new(FALSE); |
19162
e1678c435944
Reduce some of the paddings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19161
diff
changeset
|
899 gnt_box_set_pad(GNT_BOX(splitbox), 0); |
e1678c435944
Reduce some of the paddings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19161
diff
changeset
|
900 gnt_box_set_alignment(GNT_BOX(splitbox), GNT_ALIGN_TOP); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
901 |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
902 box = gnt_vbox_new(FALSE); |
19162
e1678c435944
Reduce some of the paddings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19161
diff
changeset
|
903 gnt_box_set_pad(GNT_BOX(box), 0); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
904 gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Profiles"), GNT_TEXT_FLAG_BOLD)); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
905 pref_dialog->profiles = tree = gnt_tree_new(); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
906 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
907 gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)g_ascii_strcasecmp); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
908 g_signal_connect(G_OBJECT(tree), "selection-changed", G_CALLBACK(prof_load_cb), NULL); |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
909 |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
910 itr = list = finch_sound_get_profiles(); |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
911 for (; itr; itr = itr->next) { |
19182 | 912 /* Do not free itr->data. It's the stored as a key for the tree, and will |
913 * be freed when the tree is destroyed. */ | |
914 gnt_tree_add_row_after(GNT_TREE(tree), itr->data, | |
915 gnt_tree_create_row(GNT_TREE(tree), itr->data), NULL, NULL); | |
19160
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
916 } |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
917 g_list_free(list); |
fbecc35c23bb
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
19159
diff
changeset
|
918 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
919 gnt_box_add_widget(GNT_BOX(box), tree); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
920 |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
921 pref_dialog->new_profile = entry = gnt_entry_new(""); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
922 gnt_box_add_widget(GNT_BOX(box), entry); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
923 |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
924 tmpbox = gnt_hbox_new(FALSE); |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
925 button = gnt_button_new("Add"); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
926 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_add_cb), entry); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
927 gnt_box_add_widget(GNT_BOX(tmpbox), button); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
928 button = gnt_button_new("Delete"); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
929 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(prof_del_cb), NULL); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
930 gnt_box_add_widget(GNT_BOX(tmpbox), button); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
931 gnt_box_add_widget(GNT_BOX(box), tmpbox); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
932 gnt_box_add_widget(GNT_BOX(splitbox), box); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
933 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
934 gnt_box_add_widget(GNT_BOX(splitbox), gnt_vline_new()); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
935 |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
936 /* Sound method */ |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
937 |
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
938 box = gnt_vbox_new(FALSE); |
19162
e1678c435944
Reduce some of the paddings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19161
diff
changeset
|
939 gnt_box_set_pad(GNT_BOX(box), 0); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
940 |
19128 | 941 pref_dialog->method = cmbox = gnt_combo_box_new(); |
19129 | 942 gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, NULL); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
943 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "automatic", _("Automatic")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
944 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "alsa", "ALSA"); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
945 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "esd", "ESD"); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
946 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "beep", _("Console Beep")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
947 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "custom", _("Command")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
948 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), "nosound", _("No Sound")); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
949 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
950 label = gnt_label_new_with_format(_("Sound Method"), GNT_TEXT_FLAG_BOLD); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
951 gnt_box_add_widget(GNT_BOX(box), label); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
952 tmpbox = gnt_hbox_new(TRUE); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
953 gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
954 gnt_box_set_pad(GNT_BOX(tmpbox), 0); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
955 gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Method: "))); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
956 gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
957 gnt_box_add_widget(GNT_BOX(box), tmpbox); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
958 |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
959 tmpbox = gnt_hbox_new(TRUE); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
960 gnt_box_set_pad(GNT_BOX(tmpbox), 0); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
961 gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
962 gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Sound Command\n(%s for filename)"))); |
19146 | 963 pref_dialog->command = entry = gnt_entry_new(""); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
964 gnt_box_add_widget(GNT_BOX(tmpbox), entry); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
965 gnt_box_add_widget(GNT_BOX(box), tmpbox); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
966 |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
967 gnt_box_add_widget(GNT_BOX(box), gnt_line_new(FALSE)); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
968 |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
969 /* Sound options */ |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
970 gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD)); |
19129 | 971 pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
972 gnt_box_add_widget(GNT_BOX(box), chkbox); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
973 |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
974 tmpbox = gnt_hbox_new(TRUE); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
975 gnt_box_set_pad(GNT_BOX(tmpbox), 0); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
976 gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
977 gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new("Enable Sounds:")); |
19128 | 978 pref_dialog->while_status = cmbox = gnt_combo_box_new(); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
979 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(3), _("Always")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
980 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(1), _("Only when available")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
981 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox), GINT_TO_POINTER(2), _("Only when not available")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
982 gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
983 gnt_box_add_widget(GNT_BOX(box), tmpbox); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
984 |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
985 tmpbox = gnt_hbox_new(TRUE); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
986 gnt_box_set_pad(GNT_BOX(tmpbox), 0); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
987 gnt_box_set_fill(GNT_BOX(tmpbox), FALSE); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
988 gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Volume(0-100):"))); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
989 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
990 pref_dialog->volume = slider = gnt_slider_new(FALSE, 100, 0); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
991 gnt_slider_set_step(GNT_SLIDER(slider), 5); |
19125
915ef65d68e3
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
19119
diff
changeset
|
992 label = gnt_label_new(""); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
993 gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(label)); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
994 gnt_box_set_pad(GNT_BOX(tmpbox), 1); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
995 gnt_box_add_widget(GNT_BOX(tmpbox), slider); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
996 gnt_box_add_widget(GNT_BOX(tmpbox), label); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
997 gnt_box_add_widget(GNT_BOX(box), tmpbox); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
998 gnt_box_add_widget(GNT_BOX(splitbox), box); |
19159
67fc276e5332
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
19158
diff
changeset
|
999 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1000 gnt_box_add_widget(GNT_BOX(win), splitbox); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
1001 |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
1002 gnt_box_add_widget(GNT_BOX(win), gnt_hline_new()); |
19118
cfe8f791d7c1
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
19117
diff
changeset
|
1003 |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
1004 /* Sound events */ |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1005 gnt_box_add_widget(GNT_BOX(win), gnt_label_new_with_format(_("Sound Events"), GNT_TEXT_FLAG_BOLD)); |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
1006 pref_dialog->events = tree = gnt_tree_new_with_columns(2); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1007 gnt_tree_set_column_titles(GNT_TREE(tree), _("Event"), _("File")); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1008 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
1009 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
1010 for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
1011 FinchSoundEvent * event = &sounds[i]; |
19146 | 1012 |
19163
1e4630ee4b2a
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19162
diff
changeset
|
1013 if (event->label == NULL) { |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
1014 continue; |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
1015 } |
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
1016 |
19134
0e4eeb6f6284
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
19132
diff
changeset
|
1017 gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i), |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1018 gnt_tree_create_row(GNT_TREE(tree), "", ""), |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
1019 NULL, NULL); |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
1020 } |
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
1021 |
19132
1b942e21ec1b
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
19131
diff
changeset
|
1022 gnt_tree_adjust_columns(GNT_TREE(tree)); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1023 gnt_box_add_widget(GNT_BOX(win), tree); |
19131
5da541d974a4
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
19130
diff
changeset
|
1024 |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
1025 box = gnt_hbox_new(FALSE); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
1026 button = gnt_button_new(_("Test")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1027 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(test_cb), NULL); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1028 gnt_box_add_widget(GNT_BOX(box), button); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
1029 button = gnt_button_new(_("Reset")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1030 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(reset_cb), NULL); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1031 gnt_box_add_widget(GNT_BOX(box), button); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
1032 button = gnt_button_new(_("Choose...")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1033 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(choose_cb), NULL); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1034 gnt_box_add_widget(GNT_BOX(box), button); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1035 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
|
1036 |
19146 | 1037 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
1038 | |
1039 /* Add new stuff before this */ | |
19141
fb880d1adb40
Fix a potential bug.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19139
diff
changeset
|
1040 box = gnt_hbox_new(FALSE); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1041 gnt_box_set_fill(GNT_BOX(box), TRUE); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
1042 button = gnt_button_new(_("Save")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1043 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_cb), win); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1044 gnt_box_add_widget(GNT_BOX(box), button); |
19142
5f2bcb110f00
Mark some strings for translation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19141
diff
changeset
|
1045 button = gnt_button_new(_("Cancel")); |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1046 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cancel_cb), win); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1047 gnt_box_add_widget(GNT_BOX(box), button); |
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1048 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
|
1049 |
19161
4521c558796e
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
19160
diff
changeset
|
1050 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
|
1051 |
19158
1d4ff2ba5a0b
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
19157
diff
changeset
|
1052 load_pref_window(finch_sound_get_active_profile()); |
19146 | 1053 |
19119
086cfcb71b01
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
19118
diff
changeset
|
1054 gnt_widget_show(win); |
19117
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
1055 } |
907c41608ada
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
19115
diff
changeset
|
1056 |
19100 | 1057 static PurpleSoundUiOps sound_ui_ops = |
1058 { | |
1059 finch_sound_init, | |
1060 finch_sound_uninit, | |
1061 finch_sound_play_file, | |
1062 finch_sound_play_event, | |
1063 NULL, | |
1064 NULL, | |
1065 NULL, | |
1066 NULL | |
1067 }; | |
1068 | |
1069 PurpleSoundUiOps * | |
1070 finch_sound_get_ui_ops(void) | |
1071 { | |
1072 return &sound_ui_ops; | |
1073 } | |
19154
01d574f529e0
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19149
diff
changeset
|
1074 |