finch/gntsound.c

Wed, 11 Jul 2007 19:40:49 +0000

author
Eric Polino <aluink@pidgin.im>
date
Wed, 11 Jul 2007 19:40:49 +0000
branch
soc.2007.finchfeat
changeset 18687
ab74f830abfd
parent 18686
91d02f5707d0
child 18688
63410823a172
permissions
-rw-r--r--

Cleaned up a few missing NULL checks in GntWM
Put a few comments about a warning and other potential NULL checks missing.

18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
1 /**
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
2 * @file gntsound.c GNT Sound API
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
3 * @ingroup finch
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
4 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
5 * finch
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
6 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
7 * Finch is the legal property of its developers, whose names are too numerous
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
9 * source distribution.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
10 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
15 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
20 *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
24 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
25 #include "internal.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
26 #include "finch.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
27
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
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
43 #include "gntbox.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
44 #include "gntwindow.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
45 #include "gntcombobox.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
46 #include "gntlabel.h"
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
47 #include "gntconv.h"
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
48 #include "gntsound.h"
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
49 #include "gntwidget.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
50 #include "gntentry.h"
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
51 #include "gntcheckbox.h"
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
52 #include "gntline.h"
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
53 #include "gntslider.h"
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
54 #include "gnttree.h"
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
55 #include "gntfilesel.h"
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
56
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
57 typedef struct {
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
58 PurpleSoundEventID id;
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
59 char *label;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
60 char *pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
61 char *def;
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
62 char *file;
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
63 } FinchSoundEvent;
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
64
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
65 typedef struct {
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
66 GntWidget *method;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
67 GntWidget *command;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
68 GntWidget *conv_focus;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
69 GntWidget *while_status;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
70 GntWidget *volume;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
71 GntWidget *events;
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
72 GntWidget *window;
18680
1e8e7b2d644e Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18679
diff changeset
73 GntWidget *selector;
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
74 GntWidget *profiles;
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
75 } SoundPrefDialog;
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
76
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
77 SoundPrefDialog *pref_dialog;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
78
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
79 #define PLAY_SOUND_TIMEOUT 15000
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
80
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
81 static guint mute_login_sounds_timeout = 0;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
82 static gboolean mute_login_sounds = FALSE;
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
83 static gchar * pref_string = NULL;
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
84
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
85 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
86 static gboolean gst_init_failed;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
87 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
88
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
89 static FinchSoundEvent sounds[PURPLE_NUM_SOUNDS] = {
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
90 {PURPLE_SOUND_BUDDY_ARRIVE, N_("Buddy logs in"), "login", "login.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
91 {PURPLE_SOUND_BUDDY_LEAVE, N_("Buddy logs out"), "logout", "logout.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
92 {PURPLE_SOUND_RECEIVE, N_("Message received"), "im_recv", "receive.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
93 {PURPLE_SOUND_FIRST_RECEIVE,N_("Message received begins conversation"), "first_im_recv", "receive.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
94 {PURPLE_SOUND_SEND, N_("Message sent"), "send_im", "send.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
95 {PURPLE_SOUND_CHAT_JOIN, N_("Person enters chat"), "join_chat", "login.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
96 {PURPLE_SOUND_CHAT_LEAVE, N_("Person leaves chat"), "left_chat", "logout.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
97 {PURPLE_SOUND_CHAT_YOU_SAY, N_("You talk in chat"), "send_chat_msg", "send.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
98 {PURPLE_SOUND_CHAT_SAY, N_("Others talk in chat"), "chat_msg_recv", "receive.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
99 {PURPLE_SOUND_POUNCE_DEFAULT, NULL, "pounce_default", "alert.wav",NULL},
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
100 {PURPLE_SOUND_CHAT_NICK, N_("Someone says your screen name in chat"), "nick_said", "alert.wav",NULL}
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
101 };
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
102
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
103 const char *
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
104 finch_sound_get_active_profile()
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
105 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
106 return purple_prefs_get_string(FINCH_PREFS_ROOT "/sound/actprofile");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
107 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
108
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
109 /* 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
110 * So if "Home" is the current active profile the pref name
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
111 * [FINCH_PREFS_ROOT "/sound/profiles/Home/$NAME"] is created.
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 static gchar *
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
114 make_pref(const char *name)
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
115 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
116 g_free(pref_string);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
117 pref_string = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s%s",finch_sound_get_active_profile(),name);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
118 return pref_string;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
119 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
120
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
121
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
122 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
123 unmute_login_sounds_cb(gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
124 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
125 mute_login_sounds = FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
126 mute_login_sounds_timeout = 0;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
127 return FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
128 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
129
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
130 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
131 chat_nick_matches_name(PurpleConversation *conv, const char *aname)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
132 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
133 PurpleConvChat *chat = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
134 char *nick = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
135 char *name = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
136 gboolean ret = FALSE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
137 chat = purple_conversation_get_chat_data(conv);
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 if (chat==NULL)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
140 return ret;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
141
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
142 nick = g_strdup(purple_normalize(conv->account, chat->nick));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
143 name = g_strdup(purple_normalize(conv->account, aname));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
144
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
145 if (g_utf8_collate(nick, name) == 0)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
146 ret = TRUE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
147
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
148 g_free(nick);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
149 g_free(name);
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 return ret;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
152 }
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 /*
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
155 * play a sound event for a conversation, honoring make_sound flag
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
156 * 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
157 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
158 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
159 play_conv_event(PurpleConversation *conv, PurpleSoundEventID event)
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 /* 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
162 if (conv != NULL)
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 FinchConv *gntconv;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
165 gboolean has_focus;
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 gntconv = FINCH_CONV(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
168
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
169 has_focus = purple_conversation_has_focus(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
170
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
171 if (has_focus && !purple_prefs_get_bool(make_pref("/conv_focus")))
18155
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 return;
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 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
176
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
177 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
178 }
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 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
181 buddy_state_cb(PurpleBuddy *buddy, PurpleSoundEventID event)
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 purple_sound_play_event(event, purple_buddy_get_account(buddy));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
184 }
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 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
187 im_msg_received_cb(PurpleAccount *account, char *sender,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
188 char *message, PurpleConversation *conv,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
189 PurpleMessageFlags flags, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
190 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
191 if (flags & PURPLE_MESSAGE_DELAYED)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
192 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
193
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
194 if (conv==NULL){
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
195 purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
196 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
197 else{
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
198 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
199 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
200 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
201
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
202 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
203 im_msg_sent_cb(PurpleAccount *account, const char *receiver,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
204 const char *message, PurpleSoundEventID 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 PurpleConversation *conv = purple_find_conversation_with_account(
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
207 PURPLE_CONV_TYPE_ANY, receiver, account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
208 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
209 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
210
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
211 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
212 chat_buddy_join_cb(PurpleConversation *conv, const char *name,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
213 PurpleConvChatBuddyFlags flags, gboolean new_arrival,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
214 PurpleSoundEventID event)
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 if (new_arrival && !chat_nick_matches_name(conv, name))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
217 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
218 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
219
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
220 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
221 chat_buddy_left_cb(PurpleConversation *conv, const char *name,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
222 const char *reason, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
223 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
224 if (!chat_nick_matches_name(conv, name))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
225 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
226 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
227
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
228 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
229 chat_msg_sent_cb(PurpleAccount *account, const char *message,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
230 int id, PurpleSoundEventID event)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
231 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
232 PurpleConnection *conn = purple_account_get_connection(account);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
233 PurpleConversation *conv = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
234
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
235 if (conn!=NULL)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
236 conv = purple_find_chat(conn,id);
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 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
239 }
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 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
242 chat_msg_received_cb(PurpleAccount *account, char *sender,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
243 char *message, PurpleConversation *conv,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
244 PurpleMessageFlags flags, PurpleSoundEventID event)
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 PurpleConvChat *chat;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
247
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
248 if (flags & PURPLE_MESSAGE_DELAYED)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
249 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
250
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
251 chat = purple_conversation_get_chat_data(conv);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
252 g_return_if_fail(chat != NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
253
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
254 if (purple_conv_chat_is_user_ignored(chat, sender))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
255 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
256
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
257 if (chat_nick_matches_name(conv, sender))
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
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
260 if (flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(message, chat->nick))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
261 play_conv_event(conv, PURPLE_SOUND_CHAT_NICK);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
262 else
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
263 play_conv_event(conv, event);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
264 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
265
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
266 /*
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
267 * 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
268 * 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
269 * your buddies logging in.
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
270 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
271 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
272 account_signon_cb(PurpleConnection *gc, gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
273 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
274 if (mute_login_sounds_timeout != 0)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
275 g_source_remove(mute_login_sounds_timeout);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
276 mute_login_sounds = TRUE;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
277 mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
278 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
279
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
280 void *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
281 finch_sound_get_handle()
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
282 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
283 static int handle;
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 return &handle;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
286 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
287
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
288
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
289 /* This gets called when the active profile changes */
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
290 static void
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
291 load_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null)
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
292 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
293 if(!purple_prefs_exists(make_pref(""))){
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
294 purple_prefs_add_none(make_pref(""));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
295 purple_prefs_add_none(make_pref("/enabled"));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
296 purple_prefs_add_none(make_pref("/file"));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
297 purple_prefs_add_bool(make_pref("/enabled/login"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
298 purple_prefs_add_path(make_pref("/file/login"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
299 purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
300 purple_prefs_add_path(make_pref("/file/logout"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
301 purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
302 purple_prefs_add_path(make_pref("/file/im_recv"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
303 purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
304 purple_prefs_add_path(make_pref("/file/first_im_recv"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
305 purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
306 purple_prefs_add_path(make_pref("/file/send_im"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
307 purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
308 purple_prefs_add_path(make_pref("/file/join_chat"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
309 purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
310 purple_prefs_add_path(make_pref("/file/left_chat"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
311 purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
312 purple_prefs_add_path(make_pref("/file/send_chat_msg"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
313 purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
314 purple_prefs_add_path(make_pref("/file/chat_msg_recv"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
315 purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
316 purple_prefs_add_path(make_pref("/file/nick_said"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
317 purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
318 purple_prefs_add_path(make_pref("/file/pounce_default"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
319 purple_prefs_add_bool(make_pref("/conv_focus"), TRUE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
320 purple_prefs_add_bool(make_pref("/mute"), FALSE);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
321 purple_prefs_add_path(make_pref("/command"), "");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
322 purple_prefs_add_string(make_pref("/method"), "automatic");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
323 purple_prefs_add_int(make_pref("/volume"), 50);
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 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
326
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
327 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
328 finch_sound_init(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
329 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
330 void *gnt_sound_handle = finch_sound_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
331 void *blist_handle = purple_blist_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
332 void *conv_handle = purple_conversations_get_handle();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
333 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
334 GError *error = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
335 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
336
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
337 purple_signal_connect(purple_connections_get_handle(), "signed-on",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
338 gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
339 NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
340
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
341 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound");
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
342 purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", "default");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
343 purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles");
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
344
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
345 purple_prefs_connect_callback(gnt_sound_handle,FINCH_PREFS_ROOT "/sound/actprofile",load_profile,NULL);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
346 purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
347
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
348
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
349 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
350 purple_debug_info("sound", "Initializing sound output drivers.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
351 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
352 purple_notify_error(NULL, _("GStreamer Failure"),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
353 _("GStreamer failed to initialize."),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
354 error ? error->message : "");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
355 if (error) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
356 g_error_free(error);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
357 error = 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 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
360 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
361
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
362 purple_signal_connect(blist_handle, "buddy-signed-on",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
363 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
364 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
365 purple_signal_connect(blist_handle, "buddy-signed-off",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
366 gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
367 GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
368 purple_signal_connect(conv_handle, "received-im-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
369 gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
370 GINT_TO_POINTER(PURPLE_SOUND_RECEIVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
371 purple_signal_connect(conv_handle, "sent-im-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
372 gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
373 GINT_TO_POINTER(PURPLE_SOUND_SEND));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
374 purple_signal_connect(conv_handle, "chat-buddy-joined",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
375 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
376 GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
377 purple_signal_connect(conv_handle, "chat-buddy-left",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
378 gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
379 GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
380 purple_signal_connect(conv_handle, "sent-chat-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
381 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
382 GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
383 purple_signal_connect(conv_handle, "received-chat-msg",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
384 gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
385 GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
386 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
387
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
388 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
389 finch_sound_uninit(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
390 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
391 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
392 if (!gst_init_failed)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
393 gst_deinit();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
394 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
395
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
396 purple_signals_disconnect_by_handle(finch_sound_get_handle());
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
397 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
398
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
399 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
400 static gboolean
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
401 bus_call (GstBus *bus, GstMessage *msg, gpointer data)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
402 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
403 GstElement *play = data;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
404 GError *err = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
405
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
406 switch (GST_MESSAGE_TYPE (msg)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
407 case GST_MESSAGE_EOS:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
408 gst_element_set_state(play, GST_STATE_NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
409 gst_object_unref(GST_OBJECT(play));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
410 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
411 case GST_MESSAGE_ERROR:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
412 gst_message_parse_error(msg, &err, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
413 purple_debug_error("gstreamer", err->message);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
414 g_error_free(err);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
415 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
416 case GST_MESSAGE_WARNING:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
417 gst_message_parse_warning(msg, &err, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
418 purple_debug_warning("gstreamer", err->message);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
419 g_error_free(err);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
420 break;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
421 default:
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
422 break;
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 return TRUE;
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 #endif
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
427
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
428 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
429 finch_sound_play_file(const char *filename)
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 const char *method;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
432 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
433 float volume;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
434 char *uri;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
435 GstElement *sink = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
436 GstElement *play = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
437 GstBus *bus = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
438 #endif
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
439 if (purple_prefs_get_bool(make_pref("/mute")))
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
440 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
441
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
442 method = purple_prefs_get_string(make_pref("/method"));
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
443
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
444 if (!strcmp(method, "none")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
445 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
446 } else if (!strcmp(method, "beep")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
447 beep();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
448 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
449 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
450
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
451 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
452 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
453 return;
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
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
456 #ifndef _WIN32
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
457 if (!strcmp(method, "custom")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
458 const char *sound_cmd;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
459 char *command;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
460 char *esc_filename;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
461 GError *error = NULL;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
462
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
463 sound_cmd = purple_prefs_get_path(make_pref("/command"));
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
464
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
465 if (!sound_cmd || *sound_cmd == '\0') {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
466 purple_debug_error("gntsound",
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
467 "'Command' sound method has been chosen, "
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
468 "but no command has been set.");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
469 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
470 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
471
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
472 esc_filename = g_shell_quote(filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
473
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
474 if(strstr(sound_cmd, "%s"))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
475 command = purple_strreplace(sound_cmd, "%s", esc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
476 else
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
477 command = g_strdup_printf("%s %s", sound_cmd, esc_filename);
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_spawn_command_line_async(command, &error)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
480 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
481 g_error_free(error);
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 g_free(esc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
485 g_free(command);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
486 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
487 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
488 #ifdef USE_GSTREAMER
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
489 if (gst_init_failed) /* Perhaps do beep instead? */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
490 return;
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
491 volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100)) / 50;
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
492 if (!strcmp(method, "automatic")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
493 if (purple_running_gnome()) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
494 sink = gst_element_factory_make("gconfaudiosink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
495 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
496 if (!sink)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
497 sink = gst_element_factory_make("autoaudiosink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
498 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
499 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
500 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
501 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
502 } else if (!strcmp(method, "esd")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
503 sink = gst_element_factory_make("esdsink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
504 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
505 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
506 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
507 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
508 } else if (!strcmp(method, "alsa")) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
509 sink = gst_element_factory_make("alsasink", "sink");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
510 if (!sink) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
511 purple_debug_error("sound", "Unable to create GStreamer audiosink.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
512 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
513 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
514 } else {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
515 purple_debug_error("sound", "Unknown sound method '%s'\n", method);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
516 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
517 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
518
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
519 play = gst_element_factory_make("playbin", "play");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
520
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
521 if (play == NULL) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
522 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
523 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
524
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
525 uri = g_strdup_printf("file://%s", filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
526
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
527 g_object_set(G_OBJECT(play), "uri", uri,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
528 "volume", volume,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
529 "audio-sink", sink, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
530
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
531 bus = gst_pipeline_get_bus(GST_PIPELINE(play));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
532 gst_bus_add_watch(bus, bus_call, play);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
533
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
534 gst_element_set_state(play, GST_STATE_PLAYING);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
535
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
536 gst_object_unref(bus);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
537 g_free(uri);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
538
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
539 #else /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
540 beep();
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
541 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
542 #endif /* USE_GSTREAMER */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
543 #else /* _WIN32 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
544 purple_debug_info("sound", "Playing %s\n", filename);
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 if (G_WIN32_HAVE_WIDECHAR_API ()) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
547 wchar_t *wc_filename = g_utf8_to_utf16(filename,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
548 -1, NULL, NULL, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
549 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
550 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
551 g_free(wc_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
552 } else {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
553 char *l_filename = g_locale_from_utf8(filename,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
554 -1, NULL, NULL, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
555 if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME))
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
556 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
557 g_free(l_filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
558 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
559 #endif /* _WIN32 */
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
560 }
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 static void
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
563 finch_sound_play_event(PurpleSoundEventID event)
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 char *enable_pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
566 char *file_pref;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
567 if ((event == PURPLE_SOUND_BUDDY_ARRIVE) && mute_login_sounds)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
568 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
569
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
570 if (event >= PURPLE_NUM_SOUNDS) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
571 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
572 return;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
573 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
574
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
575 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
576 finch_sound_get_active_profile(),
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
577 sounds[event].pref);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
578 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
579
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
580 /* 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
581 if (purple_prefs_get_bool(enable_pref)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
582 char *filename = g_strdup(purple_prefs_get_path(file_pref));
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
583 if(!filename || !strlen(filename)) {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
584 g_free(filename);
18292
Eric Polino <aluink@pidgin.im>
parents: 18155
diff changeset
585 /* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */
Eric Polino <aluink@pidgin.im>
parents: 18155
diff changeset
586 filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
587 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
588
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
589 purple_sound_play_file(filename, NULL);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
590 g_free(filename);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
591 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
592
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
593 g_free(enable_pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
594 g_free(file_pref);
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
595 }
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
596
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
597 GList *
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
598 finch_sound_get_profiles()
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
599 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
600 return purple_prefs_get_children_names(FINCH_PREFS_ROOT "/sound/profiles");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
601 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
602
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
603 static gboolean
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
604 profile_exists(const char *name)
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
605 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
606 GList *itr = NULL;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
607 for(itr = finch_sound_get_profiles();itr;itr = itr->next){
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
608 if(!strcmp(itr->data,name))
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
609 return TRUE;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
610 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
611 return FALSE;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
612 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
613
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
614 void
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
615 finch_sound_set_active_profile(const char *name)
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
616 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
617 if(profile_exists(name)){
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
618 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
619 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
620 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
621
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
622
18438
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
623 static void
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
624 save_cb(GntWidget *button, gpointer win)
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
625 {
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
626 GList * itr;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
627
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
628 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
629 purple_prefs_set_path(make_pref("/command"), gnt_entry_get_text(GNT_ENTRY(pref_dialog->command)));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
630 purple_prefs_set_bool(make_pref("/conv_focus"),gnt_check_box_get_checked(GNT_CHECK_BOX(pref_dialog->conv_focus)));
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
631 purple_prefs_set_int("/purple/sound/while_status",GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(pref_dialog->while_status))));
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
632 purple_prefs_set_int(make_pref("/volume"),gnt_slider_get_value(GNT_SLIDER(pref_dialog->volume)));
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
633
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
634 for(itr = gnt_tree_get_rows(GNT_TREE(pref_dialog->events));itr;itr = itr->next){
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
635 FinchSoundEvent * event = &sounds[GPOINTER_TO_INT(itr->data)];
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
636 char * filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",finch_sound_get_active_profile(),event->pref);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
637 char * boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",finch_sound_get_active_profile(),event->pref);
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
638 purple_prefs_set_bool(boolpref,gnt_tree_get_choice(GNT_TREE(pref_dialog->events),itr->data));
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
639 purple_prefs_set_path(filepref,event->file ? event->file : "");
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
640 g_free(filepref);
18618
68f30db28e96 Fixed a few merge errors
Eric Polino <aluink@pidgin.im>
parents: 18617
diff changeset
641 g_free(boolpref);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
642 }
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
643 gnt_widget_destroy(GNT_WIDGET(win));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
644 }
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
645
18438
972b13b06ba0 Cleaned up a few poorly written "activate" callbacks.
Eric Polino <aluink@pidgin.im>
parents: 18437
diff changeset
646 static void
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
647 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
648 {
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
649 FinchSoundEvent *event = data;
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
650
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
651 g_free(event->file);
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
652 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
653
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
654 gnt_tree_change_text(GNT_TREE(pref_dialog->events), GINT_TO_POINTER(event->id), 1, file);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
655
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
656 gnt_widget_destroy(GNT_WIDGET(w));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
657 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
658
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
659 static void
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
660 test_cb(GntWidget *button, gpointer null)
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
661 {
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
662 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
663 FinchSoundEvent * event = &sounds[id];
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
664 char *pref;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
665 gboolean temp_value;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
666
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
667 pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",finch_sound_get_active_profile(),
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
668 event->pref);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
669
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
670 temp_value = purple_prefs_get_bool(pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
671
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
672 if (!temp_value) purple_prefs_set_bool(pref, TRUE);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
673
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
674 purple_sound_play_event(id, NULL);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
675
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
676 if (!temp_value) purple_prefs_set_bool(pref, FALSE);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
677
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
678 g_free(pref);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
679 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
680
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
681 static void
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
682 reset_cb(GntWidget *button,gpointer null)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
683 {
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
684 /* Don't dereference this pointer ! */
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
685 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
686
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
687 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
688 g_free(event->file);
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
689 event->file = NULL;
18620
8e8d99ffa1f6 Made the display of files for sound events cleaner
Eric Polino <aluink@pidgin.im>
parents: 18618
diff changeset
690 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
691 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
692
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
693 static void
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
694 prof_del_cb(GntWidget *button, gpointer null)
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
695 {
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
696 const gchar * value = gnt_entry_get_text(GNT_ENTRY(pref_dialog->profiles));
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
697 gchar * pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s",value);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
698
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
699 if(purple_prefs_exists(pref))
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
700 purple_prefs_remove(pref);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
701
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
702 g_free(pref);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
703 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
704
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
705 static void
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
706 choose_cb(GntWidget *button, gpointer null)
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
707 {
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
708 GntWidget *w = gnt_file_sel_new();
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
709 GntFileSel *sel = GNT_FILE_SEL(w);
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
710 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
711 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
712 char *path = NULL;
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
713
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
714 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
715 (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
716 : purple_home_dir());
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
717
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
718 g_signal_connect_swapped(G_OBJECT(sel->cancel),"activate",G_CALLBACK(gnt_widget_destroy),sel);
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
719 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
720 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
721
1e8e7b2d644e Fix a potential crash if the file-selector window is closed after the pref-window.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18679
diff changeset
722 /* 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
723 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
724 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
725
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
726 pref_dialog->selector = w;
18440
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 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
729 g_free(path);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
730 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
731
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
732 static void
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
733 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
734 {
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
735 GList * itr;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
736 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
737 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
738 FinchSoundEvent * e = &sounds[id];
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
739 g_free(e->file);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
740 }
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 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
742 gnt_widget_destroy(pref_dialog->selector);
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
743 g_free(pref_dialog);
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
744 pref_dialog = NULL;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
745 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
746
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
747 static void
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
748 reload_pref_window(const char * newkey)
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
749 {
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
750 gint i;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
751 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",(gchar *)newkey);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
752 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->method),(gchar *)purple_prefs_get_string(make_pref("/method")));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
753 gnt_entry_set_text(GNT_ENTRY(pref_dialog->command),purple_prefs_get_path(make_pref("/command")));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
754 gnt_check_box_set_checked(GNT_CHECK_BOX(pref_dialog->conv_focus),purple_prefs_get_bool(make_pref("/conv_focus")));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
755 gnt_combo_box_set_selected(GNT_COMBO_BOX(pref_dialog->while_status),GINT_TO_POINTER(purple_prefs_get_int("/purple" "/sound/while_status")));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
756 gnt_slider_set_value(GNT_SLIDER(pref_dialog->volume),CLAMP(purple_prefs_get_int(make_pref("/volume")),0,100));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
757 for(i = 0;i < PURPLE_NUM_SOUNDS;i++){
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
758 FinchSoundEvent * event = &sounds[i];
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
759 gchar *boolpref;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
760 gchar *filepref;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
761 const char * profile = finch_sound_get_active_profile();
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
762
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
763 boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",profile,event->pref);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
764
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
765 filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",profile,event->pref);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
766 event->file = g_strdup(purple_prefs_get_path(filepref));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
767 if(event->label == NULL){
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
768 continue;
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
769 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
770
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
771 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),0,event->label);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
772 gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),1,event->file[0] ? g_path_get_basename(event->file) : "(default)");
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
773 gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
774 g_free(boolpref);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
775 g_free(filepref);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
776 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
777 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
778
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
779 static void
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
780 profile_text_load(GntEntry *entry, gpointer null)
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
781 {
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
782 const char * profile = gnt_entry_get_text(entry);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
783 gchar * pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s",profile);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
784 if(purple_prefs_exists(pref))
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
785 reload_pref_window(profile);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
786 g_free(pref);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
787 }
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
788
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
789 static void
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
790 profile_text_completion(GntEntry *entry, gpointer val1, gpointer val2, gpointer null)
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
791 {
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
792 profile_text_load(entry,null);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
793 }
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
794
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
795 void
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
796 finch_sounds_show_all(void)
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
797 {
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
798 GntWidget *box; GntWidget *cmbox; GntWidget *slider;
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
799 GntWidget *entry;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
800 GntWidget *chkbox;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
801 GntWidget *button;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
802 GntWidget *label;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
803 GntWidget *tree;
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
804 GntWidget *win;
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
805
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
806 GList *itr,*list;
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
807 gint i;
18434
48c2aa1fc3a9 Made sound_pref_data a pointer
Eric Polino <aluink@pidgin.im>
parents: 18433
diff changeset
808
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
809 if(pref_dialog){
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
810 gnt_window_present(pref_dialog->window);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
811 return;
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
812 }
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
813
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
814 pref_dialog = g_new0(SoundPrefDialog,1);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
815
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
816 pref_dialog->window = win = gnt_window_box_new(FALSE,TRUE);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
817 gnt_box_set_pad(GNT_BOX(win),0);
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
818 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
819 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
820 gnt_box_set_fill(GNT_BOX(win), TRUE);
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
821 gnt_box_set_alignment(GNT_BOX(win),GNT_ALIGN_LEFT);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
822
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
823 pref_dialog->method = cmbox = gnt_combo_box_new();
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
824 gnt_tree_set_hash_fns(GNT_TREE(GNT_COMBO_BOX(cmbox)->dropdown), g_str_hash, g_str_equal, NULL);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
825 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"automatic",_("Automatic"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
826 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"alsa","ALSA");
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
827 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"esd","ESD");
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
828 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"beep",_("Console Beep"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
829 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
830 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound"));
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
831
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
832 label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
833 gnt_box_add_widget(GNT_BOX(win),label);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
834 box = gnt_hbox_new(TRUE);
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
835 gnt_box_set_fill(GNT_BOX(box),FALSE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
836 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
837 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Method: ")));
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
838 gnt_box_add_widget(GNT_BOX(box),cmbox);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
839 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
840
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
841 box = gnt_hbox_new(TRUE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
842 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
843 gnt_box_set_fill(GNT_BOX(box),FALSE);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
844 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Sound Command\n(%s for filename)")));
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
845 pref_dialog->command = entry = gnt_entry_new("");
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
846 gnt_box_add_widget(GNT_BOX(box),entry);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
847 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
848
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
849 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
850
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
851 gnt_box_add_widget(GNT_BOX(win),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
852 pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus"));
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
853 gnt_box_add_widget(GNT_BOX(win),chkbox);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
854
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
855 box = gnt_hbox_new(TRUE);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
856 gnt_box_set_pad(GNT_BOX(box),0);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
857 gnt_box_set_fill(GNT_BOX(box),FALSE);
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
858 gnt_box_add_widget(GNT_BOX(box),gnt_label_new("Enable Sounds:"));
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
859 pref_dialog->while_status = cmbox = gnt_combo_box_new();
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
860 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(3),_("Always"));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
861 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(1),_("Only when available"));
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
862 gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),GINT_TO_POINTER(2),_("Only when not available"));
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
863 gnt_box_add_widget(GNT_BOX(box),cmbox);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
864 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
865
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
866 box = gnt_hbox_new(TRUE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
867 gnt_box_set_pad(GNT_BOX(box),0);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
868 gnt_box_set_fill(GNT_BOX(box),FALSE);
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
869 gnt_box_add_widget(GNT_BOX(box),gnt_label_new(_("Volume(0-100):")));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
870
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
871 pref_dialog->volume = slider = gnt_slider_new(FALSE,100,0);
18432
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
872 gnt_slider_set_step(GNT_SLIDER(slider),5);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
873 label = gnt_label_new("");
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
874 gnt_slider_reflect_label(GNT_SLIDER(slider),GNT_LABEL(label));
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
875 gnt_box_set_pad(GNT_BOX(box),1);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
876 gnt_box_add_widget(GNT_BOX(box),slider);
8fd3963b9ce0 Changed the volume changer to a GntSlider.
Eric Polino <aluink@pidgin.im>
parents: 18296
diff changeset
877 gnt_box_add_widget(GNT_BOX(box),label);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
878 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
879
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
880 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
881
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
882 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
883 pref_dialog->events = tree = gnt_tree_new_with_columns(2);
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
884 gnt_tree_set_column_titles(GNT_TREE(tree),_("Event"),_("File"));
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
885 gnt_tree_set_show_title(GNT_TREE(tree),TRUE);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
886
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
887 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
888 FinchSoundEvent * event = &sounds[i];
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
889
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
890 if(event->label == NULL){
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
891 continue;
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
892 }
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
893
18616
ce2f681adadf merged FinchSoundPrefEvent with FinchSoundEvent and removed id from FSE
Eric Polino <aluink@pidgin.im>
parents: 18440
diff changeset
894 gnt_tree_add_choice(GNT_TREE(tree), GINT_TO_POINTER(i),
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
895 gnt_tree_create_row(GNT_TREE(tree),"",""),
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
896 NULL, NULL);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
897 }
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
898
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
899 gnt_tree_adjust_columns(GNT_TREE(tree));
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
900 gnt_box_add_widget(GNT_BOX(win),tree);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
901
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
902 box = gnt_hbox_new(FALSE);
18679
c81c8ce38789 Mark some strings for translation.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18678
diff changeset
903 button = gnt_button_new(_("Test"));
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
904 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(test_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
905 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
906 button = gnt_button_new(_("Reset"));
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
907 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(reset_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
908 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
909 button = gnt_button_new(_("Choose..."));
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
910 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(choose_cb),NULL);
18439
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
911 gnt_box_add_widget(GNT_BOX(box),button);
5b6c9a328910 Fixed Cancel button callback
Eric Polino <aluink@pidgin.im>
parents: 18438
diff changeset
912 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
913
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
914 gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
915
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
916 gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD));
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
917 box = gnt_hbox_new(FALSE);
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
918 pref_dialog->profiles = entry = gnt_entry_new("");
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
919 list = itr = finch_sound_get_profiles();
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
920 for(;itr;itr = itr->next){
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
921 gnt_entry_add_suggest(GNT_ENTRY(entry),itr->data);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
922 }
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
923 g_list_free(list);
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
924 g_signal_connect(G_OBJECT(entry),"text_changed",G_CALLBACK(profile_text_load),NULL);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
925 g_signal_connect(G_OBJECT(entry),"completion",G_CALLBACK(profile_text_completion),NULL);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
926 g_signal_connect(G_OBJECT(entry),"activate",G_CALLBACK(profile_text_load),NULL);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
927 gnt_box_add_widget(GNT_BOX(box),entry);
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
928 button = gnt_button_new("Delete");
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
929 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(prof_del_cb),NULL);
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
930 gnt_box_add_widget(GNT_BOX(box),button);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
931 gnt_box_add_widget(GNT_BOX(win),box);
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
932
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
933 /* Add new stuff before this */
18678
2fc084ec99cd Fix a potential bug.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 18620
diff changeset
934 box = gnt_hbox_new(FALSE);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
935 gnt_box_set_pad(GNT_BOX(box),0);
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
936 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
937 button = gnt_button_new(_("Save"));
18437
df5e551ea4a8 Sound prefs now save.
Eric Polino <aluink@pidgin.im>
parents: 18435
diff changeset
938 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(save_cb),win);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
939 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
940 button = gnt_button_new(_("Cancel"));
18440
9d1e67686dfb Some more work to the sound prefs
Eric Polino <aluink@pidgin.im>
parents: 18439
diff changeset
941 g_signal_connect_swapped(G_OBJECT(button),"activate",G_CALLBACK(gnt_widget_destroy),win);
18295
bd26c37841f8 Added more to the Sounds Preferences
Eric Polino <aluink@pidgin.im>
parents: 18294
diff changeset
942 gnt_box_add_widget(GNT_BOX(box),button);
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
943 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
944
18435
d2cfad03e891 Removed sound_pref_data
Eric Polino <aluink@pidgin.im>
parents: 18434
diff changeset
945 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
946
18687
ab74f830abfd Cleaned up a few missing NULL checks in GntWM
Eric Polino <aluink@pidgin.im>
parents: 18686
diff changeset
947 reload_pref_window(finch_sound_get_active_profile());
18683
3bc4a997ad14 Added sound profiles
Eric Polino <aluink@pidgin.im>
parents: 18680
diff changeset
948
18296
9461f264ee5f Created SoundPrefDialog to store dialog data.
Eric Polino <aluink@pidgin.im>
parents: 18295
diff changeset
949 gnt_widget_show(win);
18294
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
950
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
951 }
8186bc6ffbb4 Added Sounds to the actions list
Eric Polino <aluink@pidgin.im>
parents: 18292
diff changeset
952
18155
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
953 static PurpleSoundUiOps sound_ui_ops =
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
954 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
955 finch_sound_init,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
956 finch_sound_uninit,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
957 finch_sound_play_file,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
958 finch_sound_play_event,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
959 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
960 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
961 NULL,
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
962 NULL
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
963 };
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
964
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
965 PurpleSoundUiOps *
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
966 finch_sound_get_ui_ops(void)
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
967 {
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
968 return &sound_ui_ops;
3bb5605ea11e Added sound to Finch.
Eric Polino <aluink@pidgin.im>
parents:
diff changeset
969 }

mercurial