Tue, 04 Feb 2014 16:30:55 +0530
Remove @file from .c files
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19933
diff
changeset
|
1 | /* finch |
|
18717
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
2 | * |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
3 | * 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
|
4 | * 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
|
5 | * source distribution. |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
6 | * |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
7 | * 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
|
8 | * 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
|
9 | * the Free Software Foundation; either version 2 of the License, or |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
10 | * (at your option) any later version. |
|
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 distributed in the hope that it will be useful, |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
15 | * GNU General Public License for more details. |
|
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 | * 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
|
18 | * 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
|
19 | * 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
|
20 | */ |
| 18155 | 21 | #include "finch.h" |
|
27829
94b279f7c38c
Don't include an internal header in the public finch headers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23087
diff
changeset
|
22 | #include <internal.h> |
| 18155 | 23 | |
| 24 | #ifdef _WIN32 | |
| 25 | #include <windows.h> | |
| 26 | #include <mmsystem.h> | |
| 27 | #endif | |
| 28 | ||
| 29 | #ifdef USE_GSTREAMER | |
| 30 | #include <gst/gst.h> | |
| 31 | #endif /* USE_GSTREAMER */ | |
| 32 | ||
| 33 | #include "debug.h" | |
| 34 | #include "notify.h" | |
| 35 | #include "prefs.h" | |
| 36 | #include "sound.h" | |
| 37 | #include "util.h" | |
| 38 | ||
|
19612
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
39 | #include "gntconv.h" |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
40 | |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
41 | #include "gntbox.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
42 | #include "gntwindow.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
43 | #include "gntcombobox.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
44 | #include "gntlabel.h" |
| 18155 | 45 | #include "gntconv.h" |
| 46 | #include "gntsound.h" | |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
47 | #include "gntwidget.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
48 | #include "gntentry.h" |
|
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
49 | #include "gntcheckbox.h" |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
50 | #include "gntline.h" |
|
18432
8fd3963b9ce0
Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents:
18296
diff
changeset
|
51 | #include "gntslider.h" |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
52 | #include "gnttree.h" |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
53 | #include "gntfilesel.h" |
| 18155 | 54 | |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
55 | typedef struct { |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
56 | PurpleSoundEventID id; |
| 18155 | 57 | char *label; |
| 58 | char *pref; | |
| 59 | char *def; | |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
60 | char *file; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
61 | } FinchSoundEvent; |
| 18155 | 62 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
63 | typedef struct { |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
64 | GntWidget *method; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
65 | GntWidget *command; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
66 | GntWidget *conv_focus; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
67 | GntWidget *while_status; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
68 | GntWidget *volume; |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
69 | GntWidget *events; |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
70 | 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
|
71 | 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
|
72 | |
| 18683 | 73 | GntWidget *profiles; |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
74 | 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
|
75 | gchar * original_profile; |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
76 | } SoundPrefDialog; |
|
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
77 | |
|
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
|
78 | #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
|
79 | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
80 | static SoundPrefDialog *pref_dialog; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
81 | |
| 18155 | 82 | #define PLAY_SOUND_TIMEOUT 15000 |
| 83 | ||
| 84 | static guint mute_login_sounds_timeout = 0; | |
| 85 | static gboolean mute_login_sounds = FALSE; | |
| 86 | ||
| 87 | #ifdef USE_GSTREAMER | |
| 88 | static gboolean gst_init_failed; | |
| 89 | #endif /* USE_GSTREAMER */ | |
| 90 | ||
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
91 | 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
|
92 | {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
|
93 | {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
|
94 | {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
|
95 | {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
|
96 | {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
|
97 | {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
|
98 | {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
|
99 | {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
|
100 | {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
|
101 | {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav", NULL}, |
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
102 | {PURPLE_SOUND_CHAT_NICK, N_("Someone says your username in chat"), "nick_said", "alert.wav", NULL}, |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
103 | {PURPLE_SOUND_GOT_ATTENTION, N_("Attention received"), "got_attention", "alert.wav", NULL} |
| 18155 | 104 | }; |
| 105 | ||
| 18683 | 106 | const char * |
| 107 | finch_sound_get_active_profile() | |
| 108 | { | |
| 109 | return purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/actprofile"); | |
| 110 | } | |
| 111 | ||
| 112 | /* This method creates a pref name based on the current active profile. | |
| 113 | * So if "Home" is the current active profile the pref name | |
| 114 | * [FINCH_PREFS_ROOT "/sound/profiles/Home/$NAME"] is created. | |
| 115 | */ | |
| 116 | static gchar * | |
| 117 | make_pref(const char *name) | |
| 118 | { | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
119 | static char pref_string[512]; |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
120 | g_snprintf(pref_string, sizeof(pref_string), |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
121 | FINCH_PREFS_ROOT "/sound/profiles/%s%s", finch_sound_get_active_profile(), name); |
| 18683 | 122 | return pref_string; |
| 123 | } | |
| 124 | ||
| 125 | ||
| 18155 | 126 | static gboolean |
| 127 | unmute_login_sounds_cb(gpointer data) | |
| 128 | { | |
| 129 | mute_login_sounds = FALSE; | |
| 130 | mute_login_sounds_timeout = 0; | |
| 131 | return FALSE; | |
| 132 | } | |
| 133 | ||
| 134 | static gboolean | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
135 | chat_nick_matches_name(PurpleChatConversation *chat, const char *aname) |
| 18155 | 136 | { |
| 137 | char *nick = NULL; | |
| 138 | char *name = NULL; | |
| 139 | gboolean ret = FALSE; | |
|
22337
9868137b6724
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
140 | PurpleAccount *account; |
|
9868137b6724
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
141 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
142 | if (chat == NULL) |
| 18155 | 143 | return ret; |
| 144 | ||
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
145 | account = purple_conversation_get_account(PURPLE_CONVERSATION(chat)); |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33509
diff
changeset
|
146 | nick = g_strdup(purple_normalize(account, purple_chat_conversation_get_nick(chat))); |
|
22337
9868137b6724
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
147 | name = g_strdup(purple_normalize(account, aname)); |
| 18155 | 148 | |
| 149 | if (g_utf8_collate(nick, name) == 0) | |
| 150 | ret = TRUE; | |
| 151 | ||
| 152 | g_free(nick); | |
| 153 | g_free(name); | |
| 154 | ||
| 155 | return ret; | |
| 156 | } | |
| 157 | ||
| 158 | /* | |
| 159 | * play a sound event for a conversation, honoring make_sound flag | |
| 160 | * of conversation and checking for focus if conv_focus pref is set | |
| 161 | */ | |
| 162 | static void | |
| 163 | play_conv_event(PurpleConversation *conv, PurpleSoundEventID event) | |
| 164 | { | |
| 165 | /* If we should not play the sound for some reason, then exit early */ | |
| 166 | if (conv != NULL) | |
| 167 | { | |
| 168 | FinchConv *gntconv; | |
| 169 | gboolean has_focus; | |
| 170 | ||
| 171 | gntconv = FINCH_CONV(conv); | |
| 172 | ||
| 173 | has_focus = purple_conversation_has_focus(conv); | |
| 174 | ||
|
19612
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
175 | 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
|
176 | (has_focus && !purple_prefs_get_bool(make_pref("/conv_focus")))) |
| 18155 | 177 | { |
| 178 | return; | |
| 179 | } | |
| 180 | } | |
| 181 | ||
| 182 | purple_sound_play_event(event, conv ? purple_conversation_get_account(conv) : NULL); | |
| 183 | } | |
| 184 | ||
| 185 | static void | |
| 186 | buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event) | |
| 187 | { | |
| 188 | purple_sound_play_event(event, purple_buddy_get_account(buddy)); | |
| 189 | } | |
| 190 | ||
| 191 | static void | |
| 192 | im_msg_received_cb(PurpleAccount *account, char *sender, | |
| 193 | char *message, PurpleConversation *conv, | |
| 194 | PurpleMessageFlags flags, PurpleSoundEventID event) | |
| 195 | { | |
| 196 | if (flags & PURPLE_MESSAGE_DELAYED) | |
| 197 | return; | |
| 198 | ||
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
199 | if (conv == NULL) { |
| 18155 | 200 | 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
|
201 | } else { |
| 18155 | 202 | play_conv_event(conv, event); |
| 203 | } | |
| 204 | } | |
| 205 | ||
| 206 | static void | |
| 207 | im_msg_sent_cb(PurpleAccount *account, const char *receiver, | |
| 208 | const char *message, PurpleSoundEventID event) | |
| 209 | { | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
210 | PurpleIMConversation *im = purple_conversations_find_im_with_account( |
|
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
211 | receiver, account); |
|
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
212 | play_conv_event(PURPLE_CONVERSATION(im), event); |
| 18155 | 213 | } |
| 214 | ||
| 215 | static void | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
216 | chat_user_join_cb(PurpleChatConversation *chat, const char *name, |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
217 | PurpleChatUserFlags flags, gboolean new_arrival, |
| 18155 | 218 | PurpleSoundEventID event) |
| 219 | { | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
220 | if (new_arrival && !chat_nick_matches_name(chat, name)) |
|
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
221 | play_conv_event(PURPLE_CONVERSATION(chat), event); |
| 18155 | 222 | } |
| 223 | ||
| 224 | static void | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
225 | chat_user_left_cb(PurpleChatConversation *chat, const char *name, |
| 18155 | 226 | const char *reason, PurpleSoundEventID event) |
| 227 | { | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
228 | if (!chat_nick_matches_name(chat, name)) |
|
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
229 | play_conv_event(PURPLE_CONVERSATION(chat), event); |
| 18155 | 230 | } |
| 231 | ||
| 232 | static void | |
| 233 | chat_msg_sent_cb(PurpleAccount *account, const char *message, | |
| 234 | int id, PurpleSoundEventID event) | |
| 235 | { | |
| 236 | PurpleConnection *conn = purple_account_get_connection(account); | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
237 | PurpleChatConversation *chat = NULL; |
| 18155 | 238 | |
| 239 | if (conn!=NULL) | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
240 | chat = purple_conversations_find_chat(conn, id); |
| 18155 | 241 | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
242 | play_conv_event(PURPLE_CONVERSATION(chat), event); |
| 18155 | 243 | } |
| 244 | ||
| 245 | static void | |
| 246 | chat_msg_received_cb(PurpleAccount *account, char *sender, | |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
247 | char *message, PurpleChatConversation *chat, |
| 18155 | 248 | PurpleMessageFlags flags, PurpleSoundEventID event) |
| 249 | { | |
| 250 | if (flags & PURPLE_MESSAGE_DELAYED) | |
| 251 | return; | |
| 252 | ||
| 253 | g_return_if_fail(chat != NULL); | |
| 254 | ||
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
255 | if (purple_chat_conversation_is_ignored_user(chat, sender)) |
| 18155 | 256 | return; |
| 257 | ||
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
258 | if (chat_nick_matches_name(chat, sender)) |
| 18155 | 259 | return; |
| 260 | ||
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
33509
diff
changeset
|
261 | if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, purple_chat_conversation_get_nick(chat))) |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
262 | play_conv_event(PURPLE_CONVERSATION(chat), PURPLE_SOUND_CHAT_NICK); |
| 18155 | 263 | else |
|
34657
b10d6297ffd5
Refactored finch to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
264 | play_conv_event(PURPLE_CONVERSATION(chat), event); |
| 18155 | 265 | } |
| 266 | ||
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
267 | static void |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
268 | got_attention_cb(PurpleAccount *account, const char *who, |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
269 | PurpleConversation *conv, guint type, PurpleSoundEventID event) |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
270 | { |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
271 | play_conv_event(conv, event); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
272 | } |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
273 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
274 | |
| 18155 | 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 | { |
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
302 | FinchSoundEvent *event; |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
303 | if (purple_prefs_exists(make_pref(""))) |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
304 | return; |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
305 | |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
306 | purple_prefs_add_none(make_pref("")); |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
307 | purple_prefs_add_none(make_pref("/enabled")); |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
308 | purple_prefs_add_none(make_pref("/file")); |
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
309 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
310 | for (event = sounds; event - sounds < PURPLE_NUM_SOUNDS; event++) { |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
311 | char pref[512]; |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
312 | g_snprintf(pref, sizeof(pref), "/enabled/%s", event->pref); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
313 | purple_prefs_add_bool(make_pref(pref), FALSE); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
314 | g_snprintf(pref, sizeof(pref), "/file/%s", event->pref); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
315 | purple_prefs_add_path(make_pref(pref), ""); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
316 | } |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
317 | |
|
19410
85956504e631
Don't enable the sounds by default.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19403
diff
changeset
|
318 | 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
|
319 | 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
|
320 | purple_prefs_add_path(make_pref("/command"), ""); |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
321 | 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
|
322 | purple_prefs_add_int(make_pref("/volume"), 50); |
| 18683 | 323 | } |
| 324 | ||
| 18155 | 325 | static void |
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
326 | update_profiles(void) |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
327 | { |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
328 | GList *list = finch_sound_get_profiles(); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
329 | for (; list; list = g_list_delete_link(list, list)) { |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
330 | char pname[512]; |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
331 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
332 | /* got_attention was added in libpurple 2.7.0 */ |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
333 | g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
334 | (char *)list->data, "/enabled/got_attention"); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
335 | purple_prefs_add_bool(pname, FALSE); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
336 | g_snprintf(pname, sizeof(pname), FINCH_PREFS_ROOT "/sound/profiles/%s%s", |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
337 | (char *)list->data, "/file/got_attention"); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
338 | purple_prefs_add_path(pname, ""); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
339 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
340 | g_free(list->data); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
341 | } |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
342 | } |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
343 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
344 | static void |
| 18155 | 345 | finch_sound_init(void) |
| 346 | { | |
| 347 | void *gnt_sound_handle = finch_sound_get_handle(); | |
| 348 | void *blist_handle = purple_blist_get_handle(); | |
| 349 | void *conv_handle = purple_conversations_get_handle(); | |
| 350 | #ifdef USE_GSTREAMER | |
| 351 | GError *error = NULL; | |
| 352 | #endif | |
| 353 | ||
| 354 | purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
| 355 | gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb), | |
| 356 | NULL); | |
| 357 | ||
| 358 | 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
|
359 | purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", DEFAULT_PROFILE); |
| 18683 | 360 | purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles"); |
| 18155 | 361 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
362 | purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL); |
| 18683 | 363 | purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile"); |
| 364 | ||
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
365 | |
| 18155 | 366 | #ifdef USE_GSTREAMER |
| 367 | 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
|
368 | #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
|
369 | (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
|
370 | (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
|
371 | 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
|
372 | #endif |
| 18155 | 373 | if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) { |
| 374 | purple_notify_error(NULL, _("GStreamer Failure"), | |
| 375 | _("GStreamer failed to initialize."), | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33509
diff
changeset
|
376 | error ? error->message : "", NULL); |
| 18155 | 377 | if (error) { |
| 378 | g_error_free(error); | |
| 379 | error = NULL; | |
| 380 | } | |
| 381 | } | |
| 382 | #endif /* USE_GSTREAMER */ | |
| 383 | ||
| 384 | purple_signal_connect(blist_handle, "buddy-signed-on", | |
| 385 | gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 386 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE)); | |
| 387 | purple_signal_connect(blist_handle, "buddy-signed-off", | |
| 388 | gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb), | |
| 389 | GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE)); | |
| 390 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 391 | gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb), | |
| 392 | GINT_TO_POINTER(PURPLE_SOUND_RECEIVE)); | |
| 393 | purple_signal_connect(conv_handle, "sent-im-msg", | |
| 394 | gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb), | |
| 395 | GINT_TO_POINTER(PURPLE_SOUND_SEND)); | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
396 | purple_signal_connect(conv_handle, "chat-user-joined", |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
397 | gnt_sound_handle, PURPLE_CALLBACK(chat_user_join_cb), |
| 18155 | 398 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN)); |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
399 | purple_signal_connect(conv_handle, "chat-user-left", |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34657
diff
changeset
|
400 | gnt_sound_handle, PURPLE_CALLBACK(chat_user_left_cb), |
| 18155 | 401 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE)); |
| 402 | purple_signal_connect(conv_handle, "sent-chat-msg", | |
| 403 | gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb), | |
| 404 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY)); | |
| 405 | purple_signal_connect(conv_handle, "received-chat-msg", | |
| 406 | gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb), | |
| 407 | GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY)); | |
|
30502
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
408 | purple_signal_connect(conv_handle, "got-attention", |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
409 | gnt_sound_handle, PURPLE_CALLBACK(got_attention_cb), |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
410 | GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION)); |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
411 | |
|
1f2c325ec6d5
Add sound-support for got-attention event.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30501
diff
changeset
|
412 | update_profiles(); |
| 18155 | 413 | } |
| 414 | ||
| 415 | static void | |
| 416 | finch_sound_uninit(void) | |
| 417 | { | |
| 418 | #ifdef USE_GSTREAMER | |
| 419 | if (!gst_init_failed) | |
| 420 | gst_deinit(); | |
| 421 | #endif | |
| 422 | ||
| 423 | purple_signals_disconnect_by_handle(finch_sound_get_handle()); | |
| 424 | } | |
| 425 | ||
| 426 | #ifdef USE_GSTREAMER | |
| 427 | static gboolean | |
| 428 | bus_call (GstBus *bus, GstMessage *msg, gpointer data) | |
| 429 | { | |
| 430 | GstElement *play = data; | |
| 431 | GError *err = NULL; | |
| 432 | ||
| 433 | switch (GST_MESSAGE_TYPE (msg)) { | |
| 434 | case GST_MESSAGE_ERROR: | |
| 435 | gst_message_parse_error(msg, &err, NULL); | |
|
19323
576433b2c438
Print debug messages appropriately.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19322
diff
changeset
|
436 | purple_debug_error("gstreamer", "%s\n", err->message); |
| 18155 | 437 | 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
|
438 | /* 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
|
439 | 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
|
440 | 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
|
441 | gst_object_unref(GST_OBJECT(play)); |
| 18155 | 442 | break; |
| 443 | case GST_MESSAGE_WARNING: | |
| 444 | gst_message_parse_warning(msg, &err, NULL); | |
|
19323
576433b2c438
Print debug messages appropriately.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19322
diff
changeset
|
445 | purple_debug_warning("gstreamer", "%s\n", err->message); |
| 18155 | 446 | g_error_free(err); |
| 447 | break; | |
| 448 | default: | |
| 449 | break; | |
| 450 | } | |
| 451 | return TRUE; | |
| 452 | } | |
| 453 | #endif | |
| 454 | ||
| 455 | static void | |
| 456 | finch_sound_play_file(const char *filename) | |
| 457 | { | |
| 458 | const char *method; | |
| 459 | #ifdef USE_GSTREAMER | |
| 460 | float volume; | |
| 461 | char *uri; | |
| 462 | GstElement *sink = NULL; | |
| 463 | GstElement *play = NULL; | |
| 464 | GstBus *bus = NULL; | |
| 465 | #endif | |
| 18683 | 466 | if (purple_prefs_get_bool(make_pref("/mute"))) |
| 18155 | 467 | return; |
| 468 | ||
| 18683 | 469 | method = purple_prefs_get_string(make_pref("/method")); |
| 18155 | 470 | |
|
19403
e391da646b62
leak fix, and fix nosound
Richard Nelson <wabz@pidgin.im>
parents:
19323
diff
changeset
|
471 | if (!strcmp(method, "nosound")) { |
| 18155 | 472 | return; |
| 473 | } else if (!strcmp(method, "beep")) { | |
| 474 | beep(); | |
| 475 | return; | |
| 476 | } | |
| 477 | ||
| 478 | if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
| 479 | purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); | |
| 480 | return; | |
| 481 | } | |
| 482 | ||
| 483 | #ifndef _WIN32 | |
| 484 | if (!strcmp(method, "custom")) { | |
| 485 | const char *sound_cmd; | |
| 486 | char *command; | |
| 487 | char *esc_filename; | |
| 488 | GError *error = NULL; | |
| 489 | ||
| 18683 | 490 | sound_cmd = purple_prefs_get_path(make_pref("/command")); |
| 18155 | 491 | |
| 492 | if (!sound_cmd || *sound_cmd == '\0') { | |
| 493 | purple_debug_error("gntsound", | |
| 494 | "'Command' sound method has been chosen, " | |
| 495 | "but no command has been set."); | |
| 496 | return; | |
| 497 | } | |
| 498 | ||
| 499 | esc_filename = g_shell_quote(filename); | |
| 500 | ||
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
501 | if (strstr(sound_cmd, "%s")) |
| 18155 | 502 | command = purple_strreplace(sound_cmd, "%s", esc_filename); |
| 503 | else | |
| 504 | command = g_strdup_printf("%s %s", sound_cmd, esc_filename); | |
| 505 | ||
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
506 | if (!g_spawn_command_line_async(command, &error)) { |
| 18155 | 507 | purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); |
| 508 | g_error_free(error); | |
| 509 | } | |
| 510 | ||
| 511 | g_free(esc_filename); | |
| 512 | g_free(command); | |
| 513 | return; | |
| 514 | } | |
| 515 | #ifdef USE_GSTREAMER | |
| 516 | if (gst_init_failed) /* Perhaps do beep instead? */ | |
| 517 | return; | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
518 | volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)) / 50; |
| 18155 | 519 | if (!strcmp(method, "automatic")) { |
| 520 | if (purple_running_gnome()) { | |
| 521 | sink = gst_element_factory_make("gconfaudiosink", "sink"); | |
| 522 | } | |
| 523 | if (!sink) | |
| 524 | sink = gst_element_factory_make("autoaudiosink", "sink"); | |
| 525 | if (!sink) { | |
| 526 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 527 | return; | |
| 528 | } | |
| 529 | } else if (!strcmp(method, "esd")) { | |
| 530 | sink = gst_element_factory_make("esdsink", "sink"); | |
| 531 | if (!sink) { | |
| 532 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 533 | return; | |
| 534 | } | |
| 535 | } else if (!strcmp(method, "alsa")) { | |
| 536 | sink = gst_element_factory_make("alsasink", "sink"); | |
| 537 | if (!sink) { | |
| 538 | purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); | |
| 539 | return; | |
| 540 | } | |
| 541 | } else { | |
| 542 | purple_debug_error("sound", "Unknown sound method '%s'\n", method); | |
| 543 | return; | |
| 544 | } | |
| 545 | ||
|
33509
60647bc63acc
Bump GStreamer checks to 1.0.0 instead of 0.11.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33486
diff
changeset
|
546 | #if GST_CHECK_VERSION(1,0,0) |
|
33486
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33372
diff
changeset
|
547 | play = gst_element_factory_make("playbin", "play"); |
|
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33372
diff
changeset
|
548 | #else |
|
33372
0cd6239fcec9
Use GstPlayBin2 instead of GstPlayBin.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32438
diff
changeset
|
549 | play = gst_element_factory_make("playbin2", "play"); |
|
33486
894eb9576159
GstPlayBin2 was renamed to GstPlayBin in GStreamer-1.0.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33372
diff
changeset
|
550 | #endif |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
551 | |
| 18155 | 552 | if (play == NULL) { |
| 553 | return; | |
| 554 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
555 | |
| 18155 | 556 | uri = g_strdup_printf("file://%s", filename); |
| 557 | ||
| 558 | g_object_set(G_OBJECT(play), "uri", uri, | |
| 559 | "volume", volume, | |
| 560 | "audio-sink", sink, NULL); | |
| 561 | ||
| 562 | bus = gst_pipeline_get_bus(GST_PIPELINE(play)); | |
| 563 | gst_bus_add_watch(bus, bus_call, play); | |
| 564 | ||
| 565 | gst_element_set_state(play, GST_STATE_PLAYING); | |
| 566 | ||
| 567 | gst_object_unref(bus); | |
| 568 | g_free(uri); | |
| 569 | ||
| 570 | #else /* USE_GSTREAMER */ | |
| 571 | beep(); | |
| 572 | return; | |
| 573 | #endif /* USE_GSTREAMER */ | |
| 574 | #else /* _WIN32 */ | |
| 575 | purple_debug_info("sound", "Playing %s\n", filename); | |
| 576 | ||
|
29509
334fa8c0c750
Remove some win9x specific code.
Daniel Atallah <datallah@pidgin.im>
parents:
27953
diff
changeset
|
577 | { |
| 18155 | 578 | wchar_t *wc_filename = g_utf8_to_utf16(filename, |
| 579 | -1, NULL, NULL, NULL); | |
| 580 | if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) | |
| 581 | purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); | |
| 582 | g_free(wc_filename); | |
| 583 | } | |
| 584 | #endif /* _WIN32 */ | |
| 585 | } | |
| 586 | ||
| 587 | static void | |
| 588 | finch_sound_play_event(PurpleSoundEventID event) | |
| 589 | { | |
| 590 | char *enable_pref; | |
| 591 | char *file_pref; | |
| 592 | if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds) | |
| 593 | return; | |
| 594 | ||
|
30501
c484f0dfc19b
Fix a crash in Finch < 2.7.0 with purple >= 2.7.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29509
diff
changeset
|
595 | if (event >= PURPLE_NUM_SOUNDS || |
|
c484f0dfc19b
Fix a crash in Finch < 2.7.0 with purple >= 2.7.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29509
diff
changeset
|
596 | event >= G_N_ELEMENTS(sounds)) { |
| 18155 | 597 | purple_debug_error("sound", "got request for unknown sound: %d\n", event); |
| 598 | return; | |
| 599 | } | |
| 600 | ||
| 18683 | 601 | enable_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s", |
| 602 | finch_sound_get_active_profile(), | |
| 18155 | 603 | 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
|
604 | file_pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s", finch_sound_get_active_profile(), sounds[event].pref); |
| 18155 | 605 | |
| 606 | /* check NULL for sounds that don't have an option, ie buddy pounce */ | |
| 607 | if (purple_prefs_get_bool(enable_pref)) { | |
| 608 | 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
|
609 | if (!filename || !strlen(filename)) { |
| 18155 | 610 | g_free(filename); |
| 18292 | 611 | /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */ |
| 612 | filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL); | |
| 18155 | 613 | } |
| 614 | ||
| 615 | purple_sound_play_file(filename, NULL); | |
| 616 | g_free(filename); | |
| 617 | } | |
| 618 | ||
| 619 | g_free(enable_pref); | |
| 620 | g_free(file_pref); | |
| 621 | } | |
| 622 | ||
| 18683 | 623 | GList * |
| 624 | finch_sound_get_profiles() | |
| 625 | { | |
|
18693
399da3ec358f
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18691
diff
changeset
|
626 | GList *list = NULL, *iter; |
|
399da3ec358f
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18691
diff
changeset
|
627 | 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
|
628 | while (iter) { |
|
399da3ec358f
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18691
diff
changeset
|
629 | 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
|
630 | g_free(iter->data); |
|
399da3ec358f
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18691
diff
changeset
|
631 | 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
|
632 | } |
|
399da3ec358f
Update the way _get_children_names is used.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18691
diff
changeset
|
633 | return list; |
| 18683 | 634 | } |
| 635 | ||
|
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
|
636 | /* This will also create it if it doesn't exist */ |
| 18683 | 637 | void |
| 638 | finch_sound_set_active_profile(const char *name) | |
| 639 | { | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
640 | purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile", name); |
| 18683 | 641 | } |
| 642 | ||
|
19315
0bc6119bbf7b
Fix a memory leak.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18717
diff
changeset
|
643 | static gboolean |
|
18717
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
644 | finch_sound_profile_exists(const char *name) |
|
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
645 | { |
|
18697
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
646 | gchar * tmp; |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
647 | 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
|
648 | g_free(tmp); |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
649 | return ret; |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
650 | } |
| 18683 | 651 | |
|
18438
972b13b06ba0
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
18437
diff
changeset
|
652 | static void |
|
972b13b06ba0
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
18437
diff
changeset
|
653 | save_cb(GntWidget *button, gpointer win) |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
654 | { |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
655 | GList * itr; |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
656 | |
| 18683 | 657 | purple_prefs_set_string(make_pref("/method"), gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->method))); |
| 658 | 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
|
659 | 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
|
660 | 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
|
661 | purple_prefs_set_int(make_pref("/volume"), gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume))); |
| 18437 | 662 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
663 | 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
|
664 | 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
|
665 | 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
|
666 | 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
|
667 | 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
|
668 | 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
|
669 | g_free(filepref); |
| 18618 | 670 | g_free(boolpref); |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
671 | } |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
672 | gnt_widget_destroy(GNT_WIDGET(win)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
673 | } |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
674 | |
|
18438
972b13b06ba0
Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents:
18437
diff
changeset
|
675 | static void |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
676 | 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
|
677 | { |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
678 | FinchSoundEvent *event = data; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
679 | |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
680 | g_free(event->file); |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
681 | 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
|
682 | |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
683 | 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
|
684 | gnt_tree_set_choice(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), TRUE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
685 | |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
686 | gnt_widget_destroy(GNT_WIDGET(w)); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
687 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
688 | |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
689 | static void |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
690 | test_cb(GntWidget *button, gpointer null) |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
691 | { |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
692 | 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
|
693 | FinchSoundEvent * event = &sounds[id]; |
|
19582
34527ff09932
Use the changed volume when 'Test'ing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19564
diff
changeset
|
694 | char *enabled, *file, *tmpfile, *volpref; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
695 | gboolean temp_value; |
|
19582
34527ff09932
Use the changed volume when 'Test'ing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19564
diff
changeset
|
696 | int volume; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
697 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
698 | 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
|
699 | finch_sound_get_active_profile(), event->pref); |
|
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
700 | 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
|
701 | 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
|
702 | volpref = g_strdup(make_pref("/volume")); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
703 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
704 | 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
|
705 | 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
|
706 | volume = purple_prefs_get_int(volpref); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
707 | |
|
19933
258c1ca27063
Fix a small bug in sound-test, thanks to igungor in #pidgin.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19859
diff
changeset
|
708 | 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
|
709 | 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
|
710 | 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
|
711 | |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
712 | purple_sound_play_event(id, NULL); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
713 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
714 | 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
|
715 | 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
|
716 | purple_prefs_set_int(volpref, volume); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
717 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
718 | g_free(enabled); |
|
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
719 | g_free(file); |
|
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
720 | g_free(tmpfile); |
|
19582
34527ff09932
Use the changed volume when 'Test'ing.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19564
diff
changeset
|
721 | g_free(volpref); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
722 | } |
|
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 | static void |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
725 | reset_cb(GntWidget *button, gpointer null) |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
726 | { |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
727 | /* Don't dereference this pointer ! */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
728 | 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
|
729 | |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
730 | 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
|
731 | g_free(event->file); |
|
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
732 | event->file = NULL; |
|
19321
28c9dd86c4dc
Mark a string for translation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19320
diff
changeset
|
733 | 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
|
734 | } |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
735 | |
| 18683 | 736 | |
| 737 | static void | |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
738 | choose_cb(GntWidget *button, gpointer null) |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
739 | { |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
740 | GntWidget *w = gnt_file_sel_new(); |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
741 | GntFileSel *sel = GNT_FILE_SEL(w); |
|
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
742 | 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
|
743 | 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
|
744 | char *path = NULL; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
745 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
746 | 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
|
747 | 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
|
748 | (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
|
749 | : purple_home_dir()); |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
750 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
751 | 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
|
752 | 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
|
753 | 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
|
754 | |
|
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
|
755 | /* 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
|
756 | 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
|
757 | 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
|
758 | |
|
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
|
759 | pref_dialog->selector = w; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
760 | |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
761 | 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
|
762 | g_free(path); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
763 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
764 | |
| 18435 | 765 | static void |
| 766 | 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
|
767 | { |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
768 | 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
|
769 | 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
|
770 | 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
|
771 | FinchSoundEvent * e = &sounds[id]; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
772 | g_free(e->file); |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
773 | e->file = NULL; |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
774 | } |
|
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
|
775 | 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
|
776 | gnt_widget_destroy(pref_dialog->selector); |
|
19403
e391da646b62
leak fix, and fix nosound
Richard Nelson <wabz@pidgin.im>
parents:
19323
diff
changeset
|
777 | g_free(pref_dialog->original_profile); |
| 18435 | 778 | g_free(pref_dialog); |
| 779 | pref_dialog = NULL; | |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
780 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
781 | |
| 18683 | 782 | 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
|
783 | load_pref_window(const char * profile) |
| 18683 | 784 | { |
| 785 | 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
|
786 | |
|
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 | 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
|
788 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
789 | 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
|
790 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
791 | 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
|
792 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
793 | 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
|
794 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
795 | 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
|
796 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
797 | 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
|
798 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
799 | for (i = 0; i < PURPLE_NUM_SOUNDS; i++) { |
| 18683 | 800 | FinchSoundEvent * event = &sounds[i]; |
| 801 | gchar *boolpref; | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
802 | gchar *filepref, *basename = NULL; |
| 18683 | 803 | const char * profile = finch_sound_get_active_profile(); |
| 804 | ||
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
805 | 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
|
806 | |
|
19322
658540eb7eb1
Fix a couple of memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19321
diff
changeset
|
807 | g_free(event->file); |
| 18683 | 808 | 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
|
809 | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
810 | g_free(filepref); |
|
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
811 | if (event->label == NULL) { |
| 18683 | 812 | continue; |
| 813 | } | |
| 814 | ||
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
815 | 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
|
816 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | 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
|
821 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
822 | 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
|
823 | |
| 18683 | 824 | g_free(boolpref); |
| 825 | } | |
|
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
|
826 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
827 | 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
|
828 | |
|
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
|
829 | 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
|
830 | } |
|
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 | |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
832 | 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
|
833 | 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
|
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, 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
|
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 | 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
|
838 | } |
|
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 | |
|
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 | 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
|
841 | 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
|
842 | { |
|
18704
26282ae9a28e
Deleting profile is now from the entry.
Eric Polino <aluink@pidgin.im>
parents:
18703
diff
changeset
|
843 | 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
|
844 | 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
|
845 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
846 | 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
|
847 | 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
|
848 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
849 | 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
|
850 | 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
|
851 | 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
|
852 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
853 | 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
|
854 | g_free(pref_dialog->original_profile); |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
855 | 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
|
856 | } |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
857 | |
|
18717
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
858 | 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
|
859 | 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
|
860 | |
|
18717
4c0284a98465
Whitespace fix.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18704
diff
changeset
|
861 | 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
|
862 | } |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
863 | |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
864 | static void |
|
18697
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
865 | 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
|
866 | { |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
867 | 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
|
868 | 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
|
869 | if (!finch_sound_profile_exists(profile)) { |
|
18697
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
870 | 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
|
871 | 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
|
872 | 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
|
873 | row, |
|
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
874 | NULL, NULL); |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
875 | 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
|
876 | 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
|
877 | finch_sound_set_active_profile(key); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
878 | } else |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
879 | 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
|
880 | } |
|
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 | |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
882 | static void |
|
18697
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
883 | 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
|
884 | { |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
885 | reload_pref_window(newkey); |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
886 | } |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
887 | |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
888 | 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
|
889 | 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
|
890 | { |
|
48f64b271ad6
Added sound profiles. First revision that's anywhere near stable, _shouldn't_ crash though.
Eric Polino <aluink@pidgin.im>
parents:
18694
diff
changeset
|
891 | 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
|
892 | gnt_widget_destroy(GNT_WIDGET(win)); |
| 18683 | 893 | } |
| 894 | ||
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
895 | void |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
896 | finch_sounds_show_all(void) |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
897 | { |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
898 | GntWidget *box, *tmpbox, *splitbox, *cmbox, *slider; |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
899 | GntWidget *entry; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
900 | GntWidget *chkbox; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
901 | GntWidget *button; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
902 | GntWidget *label; |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
903 | GntWidget *tree; |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
904 | GntWidget *win; |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
905 | |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
906 | gint i; |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
907 | GList *itr, *list; |
|
18434
48c2aa1fc3a9
Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents:
18433
diff
changeset
|
908 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
909 | if (pref_dialog) { |
| 18435 | 910 | gnt_window_present(pref_dialog->window); |
|
18295
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
911 | return; |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
912 | } |
|
bd26c37841f8
Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents:
18294
diff
changeset
|
913 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
914 | pref_dialog = g_new0(SoundPrefDialog, 1); |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
915 | |
|
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
|
916 | 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
|
917 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
918 | 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
|
919 | 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
|
920 | 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
|
921 | 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
|
922 | 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
|
923 | 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
|
924 | |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
925 | /* Profiles */ |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
926 | splitbox = gnt_hbox_new(FALSE); |
|
18699
d8bc90509020
Reduce some of the paddings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18698
diff
changeset
|
927 | gnt_box_set_pad(GNT_BOX(splitbox), 0); |
|
d8bc90509020
Reduce some of the paddings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18698
diff
changeset
|
928 | 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
|
929 | |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
930 | box = gnt_vbox_new(FALSE); |
|
18699
d8bc90509020
Reduce some of the paddings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18698
diff
changeset
|
931 | 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
|
932 | 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
|
933 | 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
|
934 | 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
|
935 | 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
|
936 | 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
|
937 | |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
938 | 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
|
939 | for (; itr; itr = itr->next) { |
| 19320 | 940 | /* Do not free itr->data. It's the stored as a key for the tree, and will |
| 941 | * be freed when the tree is destroyed. */ | |
| 942 | gnt_tree_add_row_after(GNT_TREE(tree), itr->data, | |
| 943 | 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
|
944 | } |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
945 | g_list_free(list); |
|
5821988c1c4c
Profiles now work with the new layout
Eric Polino <aluink@pidgin.im>
parents:
18696
diff
changeset
|
946 | |
|
18698
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(box), tree); |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
948 | |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
949 | 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
|
950 | 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
|
951 | |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
952 | tmpbox = gnt_hbox_new(FALSE); |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
953 | 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
|
954 | 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
|
955 | 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
|
956 | 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
|
957 | 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
|
958 | 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
|
959 | 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
|
960 | 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
|
961 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
962 | 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
|
963 | |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
964 | /* Sound method */ |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
965 | |
|
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
966 | box = gnt_vbox_new(FALSE); |
|
18699
d8bc90509020
Reduce some of the paddings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18698
diff
changeset
|
967 | 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
|
968 | |
| 18435 | 969 | pref_dialog->method = cmbox = gnt_combo_box_new(); |
| 18437 | 970 | 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
|
971 | 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
|
972 | 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
|
973 | 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
|
974 | 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
|
975 | 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
|
976 | 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
|
977 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
978 | label = gnt_label_new_with_format(_("Sound Method"), GNT_TEXT_FLAG_BOLD); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
979 | 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
|
980 | 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
|
981 | 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
|
982 | 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
|
983 | 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
|
984 | gnt_box_add_widget(GNT_BOX(tmpbox), cmbox); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
985 | 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
|
986 | |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
987 | 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
|
988 | 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
|
989 | 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
|
990 | gnt_box_add_widget(GNT_BOX(tmpbox), gnt_label_new(_("Sound Command\n(%s for filename)"))); |
| 18683 | 991 | 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
|
992 | 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
|
993 | 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
|
994 | |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
995 | 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
|
996 | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
997 | /* Sound options */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
998 | gnt_box_add_widget(GNT_BOX(box), gnt_label_new_with_format(_("Sound Options"), GNT_TEXT_FLAG_BOLD)); |
| 18437 | 999 | 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
|
1000 | 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
|
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("Enable Sounds:")); |
| 18435 | 1006 | 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
|
1007 | 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
|
1008 | 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
|
1009 | 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
|
1010 | 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
|
1011 | 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
|
1012 | |
|
18696
6036397c0038
Redid the look to the Sound Prefs
Eric Polino <aluink@pidgin.im>
parents:
18695
diff
changeset
|
1013 | 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
|
1014 | 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
|
1015 | 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
|
1016 | 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
|
1017 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
1018 | 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
|
1019 | 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
|
1020 | 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
|
1021 | 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
|
1022 | 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
|
1023 | 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
|
1024 | 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
|
1025 | 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
|
1026 | 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
|
1027 | 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
|
1028 | 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
|
1029 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
1030 | 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
|
1031 | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
1032 | 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
|
1033 | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
1034 | /* Sound events */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30502
diff
changeset
|
1035 | 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
|
1036 | 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
|
1037 | 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
|
1038 | gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
1039 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
1040 | 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
|
1041 | 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
|
1042 | |
|
18700
1cc3e27756ef
Fix some crashes when adding new profiles with the same name.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18699
diff
changeset
|
1043 | if (event->label == NULL) { |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
1044 | continue; |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
1045 | } |
|
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
1046 | |
|
18616
ce2f681adadf
merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents:
18440
diff
changeset
|
1047 | 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
|
1048 | 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
|
1049 | NULL, NULL); |
|
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
1050 | } |
|
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
1051 | |
|
18440
9d1e67686dfb
Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents:
18439
diff
changeset
|
1052 | 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
|
1053 | gnt_box_add_widget(GNT_BOX(win), tree); |
|
18439
5b6c9a328910
Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents:
18438
diff
changeset
|
1054 | |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
1055 | box = gnt_hbox_new(FALSE); |
|
18679
c81c8ce38789
Mark some strings for translation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18678
diff
changeset
|
1056 | 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
|
1057 | 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
|
1058 | 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
|
1059 | 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
|
1060 | 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
|
1061 | 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
|
1062 | 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
|
1063 | 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
|
1064 | 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
|
1065 | 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
|
1066 | |
| 18683 | 1067 | gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); |
| 1068 | ||
| 1069 | /* Add new stuff before this */ | |
|
18678
2fc084ec99cd
Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18620
diff
changeset
|
1070 | 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
|
1071 | 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
|
1072 | 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
|
1073 | 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
|
1074 | 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
|
1075 | 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
|
1076 | 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
|
1077 | 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
|
1078 | 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
|
1079 | |
|
18698
c4a9247e5b5c
In case some decide to get anal about spaces after commas.
Eric Polino <aluink@pidgin.im>
parents:
18697
diff
changeset
|
1080 | 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
|
1081 | |
|
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
|
1082 | load_pref_window(finch_sound_get_active_profile()); |
| 18683 | 1083 | |
|
18296
9461f264ee5f
Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents:
18295
diff
changeset
|
1084 | gnt_widget_show(win); |
|
19612
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1085 | } |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1086 | |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1087 | gboolean finch_sound_is_enabled(void) |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1088 | { |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1089 | const char *pref = make_pref("/method"); |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1090 | 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
|
1091 | |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1092 | if (!method) |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1093 | return FALSE; |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1094 | if (strcmp(method, "nosound") == 0) |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1095 | return FALSE; |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1096 | 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
|
1097 | return FALSE; |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1098 | |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1099 | return TRUE; |
|
043dcbf3a36e
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19588
diff
changeset
|
1100 | } |
|
18294
8186bc6ffbb4
Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents:
18292
diff
changeset
|
1101 | |
| 18155 | 1102 | static PurpleSoundUiOps sound_ui_ops = |
| 1103 | { | |
| 1104 | finch_sound_init, | |
| 1105 | finch_sound_uninit, | |
| 1106 | finch_sound_play_file, | |
| 1107 | finch_sound_play_event, | |
| 1108 | NULL, | |
| 1109 | NULL, | |
| 1110 | NULL, | |
| 1111 | NULL | |
| 1112 | }; | |
| 1113 | ||
| 1114 | PurpleSoundUiOps * | |
| 1115 | finch_sound_get_ui_ops(void) | |
| 1116 | { | |
| 1117 | return &sound_ui_ops; | |
| 1118 | } | |
|
18691
bde2c3303cae
One leak fix. Mostly cosmetic changes.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18686
diff
changeset
|
1119 |