diff src/gtksound.c @ 11642:58bc500cf226

[gaim-migrate @ 13919] sf patch #1324285, from Casey Harkins fix "sounds while away" in HEAD This patch adds a GaimAccount as a parameter to the sound playing functions, allowing the caller to specify the account the sound is related to. If the account is not NULL and the while_away preference is not set, then the account is checked to see if it is away, if so, the sound is not played. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 12 Oct 2005 02:27:32 +0000
parents 9b3833da6840
children 941aa045f9f6
line wrap: on
line diff
--- a/src/gtksound.c	Tue Oct 11 16:20:29 2005 +0000
+++ b/src/gtksound.c	Wed Oct 12 02:27:32 2005 +0000
@@ -115,31 +115,33 @@
 static void
 play_conv_event(GaimConversation *conv, GaimSoundEventID event)
 {
-	GaimGtkConversation *gtkconv;
-	GaimGtkWindow *win;
-	gboolean has_focus;
+	/* If we should not play the sound for some reason, then exit early */
+	if (conv != NULL)
+	{
+		GaimGtkConversation *gtkconv;
+		GaimGtkWindow *win;
+		gboolean has_focus;
 
-	if (conv==NULL)
-		gaim_sound_play_event(event);
-
-	gtkconv = GAIM_GTK_CONVERSATION(conv);
-	win = gtkconv->win;
+		gtkconv = GAIM_GTK_CONVERSATION(conv);
+		win = gtkconv->win;
 
-	g_object_get(G_OBJECT(win->window), "has-toplevel-focus",
-				 &has_focus, NULL);
+		has_focus = gaim_conversation_has_focus(conv);
 
-	if (gtkconv->make_sound &&
-		!((gaim_gtk_conv_window_get_active_conversation(win) == conv) &&
-		!gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) {
+		if (!gtkconv->make_sound ||
+			(gaim_gtk_conv_window_get_active_conversation(win) == conv) ||
+			(gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus))
+		{
+			return;
+		}
+	}
 
-		gaim_sound_play_event(event);
-	}
+	gaim_sound_play_event(event, conv ? gaim_conversation_get_account(conv) : NULL);
 }
 
 static void
 buddy_state_cb(GaimBuddy *buddy, GaimSoundEventID event)
 {
-	gaim_sound_play_event(event);
+	gaim_sound_play_event(event, gaim_buddy_get_account(buddy));
 }
 
 static void
@@ -148,7 +150,7 @@
 				   int flags, GaimSoundEventID event)
 {
 	if (conv==NULL)
-		gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE);
+		gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE, account);
 	else
 		play_conv_event(conv, event);
 }
@@ -556,7 +558,7 @@
 			filename = g_build_filename(DATADIR, "sounds", "gaim", sounds[event].def, NULL);
 		}
 
-		gaim_sound_play_file(filename);
+		gaim_sound_play_file(filename, NULL);
 		g_free(filename);
 	}