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