changeset 3280:c98c1e0281ff

[gaim-migrate @ 3298] Perl can play sounds! committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 29 May 2002 01:44:40 +0000
parents 86fdd015f40e
children 941eb47c5bd4
files ChangeLog plugins/PERL-HOWTO src/conversation.c src/perl.c
diffstat 4 files changed, 43 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 29 01:23:38 2002 +0000
+++ b/ChangeLog	Wed May 29 01:44:40 2002 +0000
@@ -22,7 +22,8 @@
 	  Priddy and Paul Miller)
 	* Zephyr fixes (thanks, Arun A. Tharuvai)
 	* Aliases in buddy ticker
-
+	* Perl scripts can play Gaim sounds (thanks Andrew Rodland)
+	
 version 0.58 (05/13/2002):
 	* Bulgarian translation added (Thanks, Igel Itzo)
 	* Traditional Chinese  translation added (Thanks, Paladin Liu)
--- a/plugins/PERL-HOWTO	Wed May 29 01:23:38 2002 +0000
+++ b/plugins/PERL-HOWTO	Wed May 29 01:44:40 2002 +0000
@@ -141,3 +141,19 @@
 	once, so if you want to keep calling function, keep readding the handler.
 	Args is a string that you'd like to have passed to your timeout handler; it's
 	optional.
+
+GAIM::play_sound(int sound)
+	Plays a sound using whatever method the user has selected. The argument is
+	one of the following numbers:
+
+	0	Buddy logs in
+	1	Buddy logs out
+	2	Message received
+	3	Message received begins conversation
+	4	Message sent
+	5	Person enters chat
+	6	Person leaves chat
+	7	You talk in chat
+	8	Others talk in chat
+	9	Default buddy pounce sound
+	10	Someone says your name in chat
--- a/src/conversation.c	Wed May 29 01:23:38 2002 +0000
+++ b/src/conversation.c	Wed May 29 01:44:40 2002 +0000
@@ -2822,7 +2822,12 @@
 	gtk_object_set_user_data(GTK_OBJECT(entry), c);
 	gtk_text_set_editable(GTK_TEXT(entry), TRUE);
 	gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE);
-	gtk_widget_set_usize(entry, conv_size.width - 20, MAX(conv_size.entry_height, 25));
+	/* I hate hackish workarounds.  According to Ari Pollak, a gtk bug causes Gaim to loop
+	 * infinitely if the entry is smaller than the text height.  This is a hackish workaround */ 
+	gtk_widget_set_usize(entry, conv_size.width - 20, 
+		MAX(conv_size.entry_height, 
+			gdk_char_height(gtk_widget_get_default_style()->font, '0') +
+			gtk_widget_get_default_style()->font->ascent + 1));
 
 	gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_callback), c);
 	gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(keypress_callback), c);
--- a/src/perl.c	Wed May 29 01:23:38 2002 +0000
+++ b/src/perl.c	Wed May 29 01:44:40 2002 +0000
@@ -105,6 +105,9 @@
 XS(XS_GAIM_add_event_handler); /* when servers talk */
 XS(XS_GAIM_add_timeout_handler); /* figure it out */
 
+/* play sound */
+XS(XS_GAIM_play_sound); /*play a sound*/
+
 void xs_init()
 {
 	char *file = __FILE__;
@@ -238,6 +241,8 @@
 
 	newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
 	newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
+
+	newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
 }
 
 void perl_end()
@@ -617,6 +622,8 @@
 	XSRETURN(0);
 }
 
+
+	
 XS (XS_GAIM_print_to_chat)
 {
 	struct gaim_connection *gc;
@@ -833,6 +840,18 @@
 	XSRETURN_EMPTY;
 }
 
+XS (XS_GAIM_play_sound)
+{
+	int id;
+	dXSARGS;
+
+	id = SvIV(ST(0));
+
+	play_sound(id);
+
+	XSRETURN_EMPTY;
+}
+
 extern void unload_perl_scripts()
 {
 	perl_end();