annotate finch/gntsound.c @ 25813:828640306e31

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