annotate finch/gntsound.c @ 19149:5a6f174bf6dd

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