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