changeset 1694:bea407767ac1

[gaim-migrate @ 1704] Sounds on buddy pounce. This may need a better AU file, im not sure yet. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Mon, 09 Apr 2001 08:33:09 +0000
parents 6ccd49e6f24c
children c0ab844d4790
files ChangeLog sounds/.cvsignore sounds/Makefile.am sounds/RedAlert.au src/buddy.c src/dialogs.c src/gaim.h src/gaimrc.c src/sound.c
diffstat 9 files changed, 68 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Apr 08 20:20:56 2001 +0000
+++ b/ChangeLog	Mon Apr 09 08:33:09 2001 +0000
@@ -7,6 +7,7 @@
 	* IRC Plugin can do whois (right click and info)
 	* IRC Plugin got away message support
 	* Gaim blist to WinAIM blt perl script (courtesy Andy Harrison)
+	* Sound on buddy pounce (Thanks Andrew Echols)
 	* Can view all group chats in one tabbed window (same keybindings
 	  as for tabbed normal conversations)
 
--- a/sounds/.cvsignore	Sun Apr 08 20:20:56 2001 +0000
+++ b/sounds/.cvsignore	Mon Apr 09 08:33:09 2001 +0000
@@ -7,3 +7,4 @@
 BuddyLeave.h
 Send.h
 Receive.h
+RedAlert.h
--- a/sounds/Makefile.am	Sun Apr 08 20:20:56 2001 +0000
+++ b/sounds/Makefile.am	Mon Apr 09 08:33:09 2001 +0000
@@ -2,12 +2,12 @@
 
 au2h_SOURCES = au2h.c
 
-EXTRA_DIST = BuddyArrive.au BuddyLeave.au Send.au Receive.au
+EXTRA_DIST = BuddyArrive.au BuddyLeave.au Send.au Receive.au RedAlert.au
 
-all: BuddyArrive.h BuddyLeave.h Send.h Receive.h
+all: BuddyArrive.h BuddyLeave.h Send.h Receive.h RedAlert.h
 
 clean distclean:
-	rm -f BuddyArrive.h BuddyLeave.h Send.h Receive.h
+	rm -f BuddyArrive.h BuddyLeave.h Send.h Receive.h RedAlert.h
 
 BuddyArrive.h: BuddyArrive.au au2h
 	./au2h $< $@
@@ -20,3 +20,6 @@
 
 Receive.h: Receive.au au2h
 	./au2h $< $@
+
+RedAlert.h: RedAlert.au au2h
+	./au2h $< $@
Binary file sounds/RedAlert.au has changed
--- a/src/buddy.c	Sun Apr 08 20:20:56 2001 +0000
+++ b/src/buddy.c	Mon Apr 09 08:33:09 2001 +0000
@@ -1482,6 +1482,13 @@
 					gtk_timeout_add(100, (GtkFunction)clean_pid, NULL);
 				}
 			}
+			if (b->options & OPT_POUNCE_SOUND)
+			{
+				if(strlen(b->sound))
+					play_file(b->sound); //play given sound
+				else
+					play_sound(POUNCE_DEFAULT); //play default sound
+			}
                         
 			if (!(b->options & OPT_POUNCE_SAVE))
 				rem_bp(NULL, b);
--- a/src/dialogs.c	Sun Apr 08 20:20:56 2001 +0000
+++ b/src/dialogs.c	Mon Apr 09 08:33:09 2001 +0000
@@ -134,6 +134,8 @@
 	GtkWidget *p_unidle;
 	GtkWidget *save;
 	GtkWidget *menu;
+	GtkWidget *sound;
+	GtkWidget *soundentry;
 
 	struct aim_user *user;
 };
@@ -1014,6 +1016,7 @@
 	g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
 	g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
 	g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry)));
+	g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry)));
 	g_snprintf(bp->pouncer, 80, "%s", b->user->username);
 
 	bp->protocol = b->user->protocol;
@@ -1029,6 +1032,9 @@
 	if (GTK_TOGGLE_BUTTON(b->command)->active)
 		bp->options |= OPT_POUNCE_COMMAND;
 	
+	if (GTK_TOGGLE_BUTTON(b->sound)->active)
+		bp->options |= OPT_POUNCE_SOUND;
+	
 	if (GTK_TOGGLE_BUTTON(b->p_signon)->active)
 		bp->options |= OPT_POUNCE_SIGNON;
 	
@@ -1175,7 +1181,7 @@
 	gtk_box_pack_start(GTK_BOX(vbox), b->openwindow, FALSE, FALSE, 0);
 	gtk_widget_show(b->openwindow);
 	
-	b->sendim = gtk_check_button_new_with_label(_("Send IM on pounce")); 
+	b->sendim = gtk_check_button_new_with_label(_("Send IM on pounce"));
 	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE);
 	gtk_box_pack_start(GTK_BOX(vbox), b->sendim, FALSE, FALSE, 0);
 	gtk_widget_show(b->sendim);
@@ -1217,6 +1223,28 @@
 
 	gtk_widget_set_sensitive(b->commentry, FALSE);
 	gtk_signal_connect(GTK_OBJECT(b->command), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->commentry);
+	
+	b->sound = gtk_check_button_new_with_label(_("Play sound on pounce"));
+	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound), FALSE);
+	gtk_box_pack_start(GTK_BOX(vbox), b->sound, FALSE, FALSE, 0);
+	gtk_widget_show(b->sound);
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Sound:"));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
+				gtk_widget_show(label);
+
+	b->soundentry = gtk_entry_new();
+	gtk_box_pack_start(GTK_BOX(hbox), b->soundentry, TRUE, TRUE, 0);
+	gtk_signal_connect(GTK_OBJECT(b->soundentry), "activate",
+				GTK_SIGNAL_FUNC(do_new_bp), b);
+	gtk_widget_show(b->soundentry);
+
+	gtk_widget_set_sensitive(b->soundentry, FALSE);
+	gtk_signal_connect(GTK_OBJECT(b->sound), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->soundentry);
 
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
--- a/src/gaim.h	Sun Apr 08 20:20:56 2001 +0000
+++ b/src/gaim.h	Mon Apr 09 08:33:09 2001 +0000
@@ -262,6 +262,7 @@
 #define OPT_POUNCE_POPUP    0x001
 #define OPT_POUNCE_SEND_IM  0x002
 #define OPT_POUNCE_COMMAND  0x004
+#define OPT_POUNCE_SOUND		0x008
 
 #define OPT_POUNCE_SIGNON   0x010
 #define OPT_POUNCE_UNAWAY   0x020
@@ -273,6 +274,7 @@
         char name[80];
         char message[2048];
 	char command[2048];
+	char sound[2048];
 	
 	char pouncer[80];
 	int protocol;
@@ -392,7 +394,8 @@
 #define CHAT_LEAVE 6
 #define CHAT_YOU_SAY 7
 #define CHAT_SAY 8
-#define NUM_SOUNDS 9
+#define POUNCE_DEFAULT 9
+#define NUM_SOUNDS 10
 
 
 #ifdef USE_APPLET
--- a/src/gaimrc.c	Sun Apr 08 20:20:56 2001 +0000
+++ b/src/gaimrc.c	Mon Apr 09 08:33:09 2001 +0000
@@ -281,6 +281,8 @@
 			g_snprintf(b->pouncer, sizeof(b->pouncer), "%s", p->value[4]);
 			b->protocol = atoi(p->value[5]);
 
+			g_snprintf(b->sound, sizeof(b->sound), "%s", p->value[6]);
+			
 			filter_break(b->message);
 			buddy_pounces = g_list_append(buddy_pounces, b);
 		}
@@ -295,7 +297,7 @@
 	fprintf(f, "pounce {\n");
 
 	while (pnc) {
-		char *str1, *str2, *str3;
+		char *str1, *str2, *str3, *str4;
 
 		b = (struct buddy_pounce *)pnc->data;
 
@@ -312,14 +314,21 @@
 			str3 = malloc(1);
 			str3[0] = 0;
 		}
+		if (strlen(b->sound))
+			str4 = escape_text2(b->sound);
+		else {
+			str4 = malloc(1);
+			str4[0] = 0;
+		}
 
-		fprintf(f, "\tentry { %s } { %s } { %s } { %d } { %s } { %d }\n",
-			str1, str2, str3, b->options, b->pouncer, b->protocol);
+		fprintf(f, "\tentry { %s } { %s } { %s } { %d } { %s } { %d } { %s }\n",
+			str1, str2, str3, b->options, b->pouncer, b->protocol, str4);
 
 		/* escape_text2 uses malloc(), so we don't want to g_free these */
 		free(str1);
 		free(str2);
 		free(str3);
+		free(str4);
 
 		pnc = pnc->next;
 	}
--- a/src/sound.c	Sun Apr 08 20:20:56 2001 +0000
+++ b/src/sound.c	Mon Apr 09 08:33:09 2001 +0000
@@ -48,6 +48,7 @@
 #include "sounds/BuddyLeave.h"
 #include "sounds/Send.h"
 #include "sounds/Receive.h"
+#include "sounds/RedAlert.h"
 
 static int check_dev(char *dev)
 {
@@ -484,5 +485,12 @@
 			}
 		}
 		break;
+	case POUNCE_DEFAULT:
+		if (sound_file[POUNCE_DEFAULT]) {
+			play_file(sound_file[POUNCE_DEFAULT]);
+		} else {
+			play(RedAlert, sizeof(RedAlert));
+		}
+		break;
 	}
 }