| 114 */ |
114 */ |
| 115 static void |
115 static void |
| 116 play_conv_event(GaimConversation *conv, GaimSoundEventID event) |
116 play_conv_event(GaimConversation *conv, GaimSoundEventID event) |
| 117 { |
117 { |
| 118 GaimGtkConversation *gtkconv; |
118 GaimGtkConversation *gtkconv; |
| 119 GaimConvWindow *gaimwin; |
119 GaimGtkWindow *win; |
| 120 GaimGtkWindow *gtkwin; |
|
| 121 gboolean has_focus; |
120 gboolean has_focus; |
| 122 |
121 |
| 123 if (conv==NULL) |
122 if (conv==NULL) |
| 124 gaim_sound_play_event(event); |
123 gaim_sound_play_event(event); |
| 125 |
124 |
| 126 gtkconv = GAIM_GTK_CONVERSATION(conv); |
125 gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 127 gaimwin = gaim_conversation_get_window(conv); |
126 win = gtkconv->win; |
| 128 gtkwin = GAIM_GTK_WINDOW(gaimwin); |
127 |
| 129 |
128 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", |
| 130 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", |
|
| 131 &has_focus, NULL); |
129 &has_focus, NULL); |
| 132 |
130 |
| 133 if (gtkconv->make_sound && |
131 if (gtkconv->make_sound && |
| 134 !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
132 !((gaim_gtk_conv_window_get_active_conversation(win) == conv) && |
| 135 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
133 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
| 136 |
134 |
| 137 gaim_sound_play_event(event); |
135 gaim_sound_play_event(event); |
| 138 } |
136 } |
| 139 } |
137 } |
| 144 gaim_sound_play_event(event); |
142 gaim_sound_play_event(event); |
| 145 } |
143 } |
| 146 |
144 |
| 147 static void |
145 static void |
| 148 im_msg_received_cb(GaimAccount *account, char *sender, |
146 im_msg_received_cb(GaimAccount *account, char *sender, |
| 149 char *message, GaimConversation *conv, |
147 char *message, GaimConversation *conv, |
| 150 int flags, GaimSoundEventID event) |
148 int flags, GaimSoundEventID event) |
| 151 { |
149 { |
| 152 if (conv==NULL) |
150 if (conv==NULL) |
| 153 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
151 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
| 154 else |
152 else |
| 166 |
164 |
| 167 static void |
165 static void |
| 168 chat_buddy_join_cb(GaimConversation *conv, const char *name, |
166 chat_buddy_join_cb(GaimConversation *conv, const char *name, |
| 169 GaimConvChatBuddyFlags flags, GaimSoundEventID event) |
167 GaimConvChatBuddyFlags flags, GaimSoundEventID event) |
| 170 { |
168 { |
| 171 if (!chat_nick_matches_name(conv, name)) |
169 if (!chat_nick_matches_name(conv, name)) |
| 172 play_conv_event(conv, event); |
170 play_conv_event(conv, event); |
| 173 } |
171 } |
| 174 |
172 |
| 175 static void |
173 static void |
| 176 chat_buddy_left_cb(GaimConversation *conv, const char *name, |
174 chat_buddy_left_cb(GaimConversation *conv, const char *name, |
| 177 const char *reason, GaimSoundEventID event) |
175 const char *reason, GaimSoundEventID event) |
| 178 { |
176 { |
| 179 if (!chat_nick_matches_name(conv, name)) |
177 if (!chat_nick_matches_name(conv, name)) |
| 180 play_conv_event(conv, event); |
178 play_conv_event(conv, event); |
| 181 } |
179 } |
| 182 |
180 |
| 183 static void |
181 static void |
| 184 chat_msg_sent_cb(GaimAccount *account, const char *message, |
182 chat_msg_sent_cb(GaimAccount *account, const char *message, |
| 185 int id, GaimSoundEventID event) |
183 int id, GaimSoundEventID event) |
| 186 { |
184 { |
| 187 GaimConnection *conn = gaim_account_get_connection(account); |
185 GaimConnection *conn = gaim_account_get_connection(account); |
| 188 GaimConversation *conv = NULL; |
186 GaimConversation *conv = NULL; |
| 189 |
187 |
| 190 if (conn!=NULL) |
188 if (conn!=NULL) |
| 191 conv = gaim_find_chat(conn,id); |
189 conv = gaim_find_chat(conn,id); |
| 192 |
190 |
| 193 play_conv_event(conv, event); |
191 play_conv_event(conv, event); |
| 194 } |
192 } |
| 195 |
193 |