changeset 1214:0baf39dc5437

[gaim-migrate @ 1224] can choose to run command to play sounds committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 08 Dec 2000 07:46:22 +0000
parents 1bdb08cc5d59
children 29b708cde8a7
files ChangeLog src/gaim.h src/gaimrc.c src/prefs.c src/sound.c
diffstat 5 files changed, 54 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Dec 08 06:21:44 2000 +0000
+++ b/ChangeLog	Fri Dec 08 07:46:22 2000 +0000
@@ -3,6 +3,7 @@
 version 0.11.0:
 	* Away messages arranged alphabetically (Thanks Justin)
 	* More GUI adjustments
+	* Can optionally run command to play sound files
 
 version 0.11.0-pre2 (12/04/2000):
 	* Fixed a segfault with a bad util.c 
--- a/src/gaim.h	Fri Dec 08 06:21:44 2000 +0000
+++ b/src/gaim.h	Fri Dec 08 07:46:22 2000 +0000
@@ -495,6 +495,7 @@
 extern int report_idle;
 extern int web_browser;
 extern GList *aim_users;
+extern char sound_cmd[2048];
 extern char web_command[2048];
 extern char debug_buff[BUF_LONG];
 extern struct save_pos blist_pos;
--- a/src/gaimrc.c	Fri Dec 08 06:21:44 2000 +0000
+++ b/src/gaimrc.c	Fri Dec 08 07:46:22 2000 +0000
@@ -49,6 +49,7 @@
 char web_command[2048];
 char latest_ver[25];
 char *sound_file[NUM_SOUNDS];
+char sound_cmd[2048];
 
 struct parse {
         char option[256];
@@ -703,6 +704,7 @@
 
 	for (i = 0; i < NUM_SOUNDS; i++)
 		sound_file[i] = NULL;
+	sound_cmd[0] = 0;
         
 	while (buf[0] != '}') {
 		if (buf[0] == '#')
@@ -713,16 +715,15 @@
 
                 p = parse_line(buf);
                 
-		sscanf(p->option, "sound%c", (char *)&i);
-		i -= 'A';
-		
-		if (p->value[0][0])
-			sound_file[i] = g_strdup(p->value[0]);
-/*		else
-			sound_file[i] = NULL;
-		Removed by Rob.  Kill me if this is retarded.
-		Tis was causing segfaults on PPC machines, though.
-*/
+		if (!strcmp(p->option, "sound_cmd")) {
+			g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", p->value[0]);
+		} else if (!strncmp(p->option, "sound", strlen("sound"))) {
+			sscanf(p->option, "sound%c", (char *)&i);
+			i -= 'A';
+			
+			if (p->value[0][0])
+				sound_file[i] = g_strdup(p->value[0]);
+		}
 	}
 }
 
@@ -735,6 +736,7 @@
 			fprintf(f, "\tsound%c { %s }\n", i + 'A', sound_file[i]);
 		else
 			fprintf(f, "\tsound%c {  }\n", i + 'A');
+	fprintf(f, "\tsound_cmd { %s }\n", sound_cmd);
 	fprintf(f, "}\n");
 }
 
--- a/src/prefs.c	Fri Dec 08 06:21:44 2000 +0000
+++ b/src/prefs.c	Fri Dec 08 07:46:22 2000 +0000
@@ -909,6 +909,7 @@
 }
 
 static GtkWidget *sndent[NUM_SOUNDS];
+static GtkWidget *sndcmd = NULL;
 
 void close_sounddialog(GtkWidget *w, GtkWidget *w2) 
 {
@@ -1022,12 +1023,20 @@
 	gtk_widget_show(entry);
 }
 
+static gint sound_cmd_yeah(GtkEntry *entry, GdkEvent *event, gpointer d)
+{
+	g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", gtk_entry_get_text(GTK_ENTRY(sndcmd)));
+	save_prefs();
+	return TRUE;
+}
+
 static void event_page()
 {
 	GtkWidget *parent;
 	GtkWidget *box;
 	GtkWidget *label;
 	GtkWidget *sep;
+	GtkWidget *hbox;
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
@@ -1064,6 +1073,25 @@
 	sound_entry(_("Sound in chat rooms when you talk"), OPT_SOUND_CHAT_YOU_SAY, box, CHAT_YOU_SAY);
 	sound_entry(_("Sound in chat rooms when others talk"), OPT_SOUND_CHAT_SAY, box, CHAT_SAY);
 
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Command to play sound files (%s for filename; internal if empty):"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	sndcmd = gtk_entry_new();
+	gtk_entry_set_editable(GTK_ENTRY(sndcmd), TRUE);
+	gtk_entry_set_text(GTK_ENTRY(sndcmd), sound_cmd);
+	gtk_box_pack_end(GTK_BOX(hbox), sndcmd, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(sndcmd), "focus_out_event", GTK_SIGNAL_FUNC(sound_cmd_yeah), NULL);
+	gtk_widget_show(sndcmd);
+
 	gtk_widget_show(prefdialog);
 }
 
--- a/src/sound.c	Fri Dec 08 06:21:44 2000 +0000
+++ b/src/sound.c	Fri Dec 08 07:46:22 2000 +0000
@@ -320,6 +320,18 @@
 			_exit(0);
 		}
 
+		if (sound_cmd[0]) {
+			char *args[4];
+			char command[4096];
+			g_snprintf(command, sizeof command, sound_cmd, filename);
+			args[0] = "sh";
+			args[1] = "-c";
+			args[2] = command;
+			args[3] = NULL;
+			execvp(args[0], args);
+			_exit(0);
+		}
+
 #ifdef ESD_SOUND
 		if (play_esd_file(filename))
 			_exit(0);