finch/gntsound.c

Tue, 07 Apr 2020 00:55:43 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 07 Apr 2020 00:55:43 -0500
changeset 40383
dbc5c2d601ab
parent 39887
9c8f874c74a0
child 40359
ca141ea93b83
permissions
-rw-r--r--

Move the menu trac to PidginBuddyListMenu

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

mercurial