| 113 * of conversation and checking for focus if conv_focus pref is set |
113 * of conversation and checking for focus if conv_focus pref is set |
| 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 /* If we should not play the sound for some reason, then exit early */ |
| 119 GaimGtkWindow *win; |
119 if (conv != NULL) |
| 120 gboolean has_focus; |
120 { |
| 121 |
121 GaimGtkConversation *gtkconv; |
| 122 if (conv==NULL) |
122 GaimGtkWindow *win; |
| 123 gaim_sound_play_event(event); |
123 gboolean has_focus; |
| 124 |
124 |
| 125 gtkconv = GAIM_GTK_CONVERSATION(conv); |
125 gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 126 win = gtkconv->win; |
126 win = gtkconv->win; |
| 127 |
127 |
| 128 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", |
128 has_focus = gaim_conversation_has_focus(conv); |
| 129 &has_focus, NULL); |
129 |
| 130 |
130 if (!gtkconv->make_sound || |
| 131 if (gtkconv->make_sound && |
131 (gaim_gtk_conv_window_get_active_conversation(win) == conv) || |
| 132 !((gaim_gtk_conv_window_get_active_conversation(win) == conv) && |
132 (gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) |
| 133 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
133 { |
| 134 |
134 return; |
| 135 gaim_sound_play_event(event); |
135 } |
| 136 } |
136 } |
| |
137 |
| |
138 gaim_sound_play_event(event, conv ? gaim_conversation_get_account(conv) : NULL); |
| 137 } |
139 } |
| 138 |
140 |
| 139 static void |
141 static void |
| 140 buddy_state_cb(GaimBuddy *buddy, GaimSoundEventID event) |
142 buddy_state_cb(GaimBuddy *buddy, GaimSoundEventID event) |
| 141 { |
143 { |
| 142 gaim_sound_play_event(event); |
144 gaim_sound_play_event(event, gaim_buddy_get_account(buddy)); |
| 143 } |
145 } |
| 144 |
146 |
| 145 static void |
147 static void |
| 146 im_msg_received_cb(GaimAccount *account, char *sender, |
148 im_msg_received_cb(GaimAccount *account, char *sender, |
| 147 char *message, GaimConversation *conv, |
149 char *message, GaimConversation *conv, |
| 148 int flags, GaimSoundEventID event) |
150 int flags, GaimSoundEventID event) |
| 149 { |
151 { |
| 150 if (conv==NULL) |
152 if (conv==NULL) |
| 151 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
153 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE, account); |
| 152 else |
154 else |
| 153 play_conv_event(conv, event); |
155 play_conv_event(conv, event); |
| 154 } |
156 } |
| 155 |
157 |
| 156 static void |
158 static void |
| 554 if(!filename || !strlen(filename)) { |
556 if(!filename || !strlen(filename)) { |
| 555 if(filename) g_free(filename); |
557 if(filename) g_free(filename); |
| 556 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); |
558 filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL); |
| 557 } |
559 } |
| 558 |
560 |
| 559 gaim_sound_play_file(filename); |
561 gaim_sound_play_file(filename, NULL); |
| 560 g_free(filename); |
562 g_free(filename); |
| 561 } |
563 } |
| 562 |
564 |
| 563 g_free(enable_pref); |
565 g_free(enable_pref); |
| 564 g_free(file_pref); |
566 g_free(file_pref); |