changeset 2580:86eaeb064e82

[gaim-migrate @ 2593] run-time committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 23 Oct 2001 04:05:52 +0000
parents d3b7c7b39963
children 3e9906e1e5f6
files ChangeLog src/gaim.h src/gaimrc.c src/prefs.c src/sound.c
diffstat 5 files changed, 130 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 23 03:19:28 2001 +0000
+++ b/ChangeLog	Tue Oct 23 04:05:52 2001 +0000
@@ -16,6 +16,8 @@
 	* When you are queueing away messages, double clicking on
 	  a buddy's name will cause the messages for that name to be
 	  dequeued.
+	* You can choose which sound player you use at run-time
+	  (thanks Ben Miller)
 
 version 0.46 (10/18/2001):
 	* New applet icons (courtesy David Raeman)
--- a/src/gaim.h	Tue Oct 23 03:19:28 2001 +0000
+++ b/src/gaim.h	Tue Oct 23 04:05:52 2001 +0000
@@ -272,6 +272,10 @@
 #define OPT_SOUND_BEEP			0x00000400
 #define OPT_SOUND_CHAT_PART		0x00000800
 #define OPT_SOUND_CHAT_YOU_SAY		0x00001000
+#define OPT_SOUND_NORMAL		0x00002000
+#define OPT_SOUND_NAS			0x00004000
+#define OPT_SOUND_ARTSC			0x00008000
+#define OPT_SOUND_ESD			0x00010000
 
 #define BUDDY_ARRIVE 0
 #define BUDDY_LEAVE 1
--- a/src/gaimrc.c	Tue Oct 23 03:19:28 2001 +0000
+++ b/src/gaimrc.c	Tue Oct 23 04:05:52 2001 +0000
@@ -1006,12 +1006,18 @@
 	for (i = 0; i < 7; i++)
 		sound_file[i] = NULL;
 	font_options = 0;
+	/* Enable all of the sound players that might be available.  The first
+	   available one will be used. */
 	sound_options =
 	    OPT_SOUND_LOGIN |
 	    OPT_SOUND_LOGOUT |
 	    OPT_SOUND_RECV |
 	    OPT_SOUND_SEND |
-	    OPT_SOUND_SILENT_SIGNON;
+	    OPT_SOUND_SILENT_SIGNON |
+	    OPT_SOUND_NORMAL |
+	    OPT_SOUND_NAS |
+	    OPT_SOUND_ARTSC |
+	    OPT_SOUND_ESD;
 
 	report_idle = IDLE_SCREENSAVER;
 	web_browser = BROWSER_NETSCAPE;
--- a/src/prefs.c	Tue Oct 23 03:19:28 2001 +0000
+++ b/src/prefs.c	Tue Oct 23 04:05:52 2001 +0000
@@ -1483,6 +1483,14 @@
 	return TRUE;
 }
 
+static void set_sound_driver(GtkWidget *w, int option)
+{
+	sound_options &= ~(OPT_SOUND_NORMAL | OPT_SOUND_BEEP |
+			   OPT_SOUND_NAS | OPT_SOUND_ARTSC | OPT_SOUND_ESD);
+	sound_options |= option;
+	save_prefs();
+}
+
 static void sound_page()
 {
 	GtkWidget *parent;
@@ -1493,6 +1501,10 @@
 	GtkWidget *hbox;
 	GtkWidget *vbox2;
 	GtkWidget *sep;
+	GtkWidget *omenu;
+	GtkWidget *menu;
+	GtkWidget *opt;
+	int i=1, driver=0;
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
@@ -1526,13 +1538,81 @@
 	gtk_widget_show(vbox2);
 
 	gaim_button(_("No sounds when you log in"), &sound_options, OPT_SOUND_SILENT_SIGNON, vbox2);
-	gaim_button(_("Sounds while away"), &sound_options, OPT_SOUND_WHEN_AWAY, vbox2);
 
 	vbox2 = gtk_vbox_new(FALSE, 5);
 	gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 5);
 	gtk_widget_show(vbox2);
 
-	gaim_button(_("Beep instead of playing sound"), &sound_options, OPT_SOUND_BEEP, vbox2);
+	gaim_button(_("Sounds while away"), &sound_options, OPT_SOUND_WHEN_AWAY, vbox2);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
+	gtk_widget_show(sep);
+
+	hbox = gtk_hbox_new(TRUE, 5);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Sound Player:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	omenu = gtk_option_menu_new();
+	menu = gtk_menu_new();
+
+#ifdef ESD_SOUND
+	opt = gtk_menu_item_new_with_label("ESD");
+	gtk_signal_connect(GTK_OBJECT(opt), "activate",
+			   GTK_SIGNAL_FUNC(set_sound_driver), 
+			   (gpointer)OPT_SOUND_ESD);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+	if ((sound_options & OPT_SOUND_ESD) && !driver) driver = i;
+	i++;
+#endif
+#ifdef ARTSC_SOUND
+	opt = gtk_menu_item_new_with_label("ArtsC");
+	gtk_signal_connect(GTK_OBJECT(opt), "activate",
+			   GTK_SIGNAL_FUNC(set_sound_driver), 
+			   (gpointer)OPT_SOUND_ARTSC);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+	if ((sound_options & OPT_SOUND_ARTSC) && !driver) driver = i;
+	i++;
+#endif
+#ifdef NAS_SOUND
+	opt = gtk_menu_item_new_with_label("NAS");
+	gtk_signal_connect(GTK_OBJECT(opt), "activate",
+			   GTK_SIGNAL_FUNC(set_sound_driver), 
+			   (gpointer)OPT_SOUND_NAS);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+	if ((sound_options & OPT_SOUND_NAS) && !driver) driver = i;
+	i++;
+#endif
+
+	opt = gtk_menu_item_new_with_label("Native");
+	gtk_signal_connect(GTK_OBJECT(opt), "activate",
+			   GTK_SIGNAL_FUNC(set_sound_driver), 
+			   (gpointer)OPT_SOUND_NORMAL);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+	if ((sound_options & OPT_SOUND_NORMAL) && !driver) driver = i;
+	i++;
+
+	opt = gtk_menu_item_new_with_label("Console Beep");
+	gtk_signal_connect(GTK_OBJECT(opt), "activate",
+			   GTK_SIGNAL_FUNC(set_sound_driver), 
+			   (gpointer)OPT_SOUND_BEEP);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+	if ((sound_options & OPT_SOUND_BEEP) && !driver) driver = i;
+	i++;
+
+	gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
+	gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), driver - 1);
+	gtk_box_pack_start(GTK_BOX(hbox), omenu, FALSE, FALSE, 5);
+	gtk_widget_show_all(omenu);
 
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
--- a/src/sound.c	Tue Oct 23 03:19:28 2001 +0000
+++ b/src/sound.c	Tue Oct 23 04:05:52 2001 +0000
@@ -404,7 +404,7 @@
 			else if ((ms = strstr(sound_cmd, "%s")) != NULL) {
 				*ms = 0;
 				g_snprintf(command, sizeof(command), "%s\"%s\"%s", sound_cmd,
-						filename, ms + 2);
+					   filename, ms + 2);
 			} else
 				g_snprintf(command, sizeof(command), sound_cmd);
 			args[0] = "sh";
@@ -415,21 +415,27 @@
 			_exit(0);
 		}
 #ifdef ESD_SOUND
-		if (esd_play_file(NULL, filename, 1))
-			_exit(0);
+		else if (sound_options & OPT_SOUND_ESD) {
+			if (esd_play_file(NULL, filename, 1))
+				_exit(0);
+		}
 #endif
 
 #ifdef ARTSC_SOUND
-		if (artsc_play_file(filename))
-			_exit(0);
+		else if (sound_options & OPT_SOUND_ARTSC) {
+			if (artsc_play_file(filename))
+				_exit(0);
+		}
 #endif
 
 #ifdef NAS_SOUND
-		if (play_nas_file(filename))
-			_exit(0);
+		else if (sound_options & OPT_SOUND_NAS) {
+			if (play_nas_file(filename))
+				_exit(0);
+		}
 #endif
-
-		if (can_play_audio()) {
+		else if ((sound_options & OPT_SOUND_NORMAL) && 
+			 can_play_audio()) {
 			play_audio_file(filename);
 			_exit(0);
 		}
@@ -460,32 +466,40 @@
 #ifdef ESD_SOUND
 		/* ESD is our player of choice.  Are we OK to
 		 * go there? */
-		if (can_play_esd()) {
-			if (play_esd(data, size))
-				_exit(0);
+		else if (sound_options & OPT_SOUND_ESD) {
+			if (can_play_esd()) {
+				if (play_esd(data, size))
+					_exit(0);
+			}
 		}
 #endif
 
 #ifdef ARTSC_SOUND
 		/* ArtsC is the new second choice. */
-		if (can_play_artsc()) {
-			if (play_artsc(data, size))
-				_exit(0);
+		else if (sound_options & OPT_SOUND_ARTSC) {
+			if (can_play_artsc()) {
+				if (play_artsc(data, size))
+					_exit(0);
+			}
 		}
 #endif
 
 #ifdef NAS_SOUND
 		/* NAS is our second choice setup. */
-		if (can_play_nas()) {
-			if (play_nas(data, size))
-				_exit(0);
+		else if (sound_options & OPT_SOUND_NAS) {
+			if (can_play_nas()) {
+				if (play_nas(data, size))
+					_exit(0);
+			}
 		}
 #endif
 
 		/* Lastly, we can try just plain old /dev/audio */
-		if (can_play_audio()) {
-			play_audio(data, size);
-			_exit(0);
+		else if (sound_options & OPT_SOUND_NORMAL) {
+			if (can_play_audio()) {
+				play_audio(data, size);
+				_exit(0);
+			}
 		}
 
 		_exit(0);