diff pidgin/gtkconv.c @ 25643:befeece4dd48

Change a few things: * call purple_media_wait to notify that we are waiting on a response from the remote end * fix the /call command in finch * keep track of the PidginMedia for a PidginConversation * fix the two-widget bug in pidgin. We probably should have a way to get the PidginMedia from a PurpleMedia. Should we use _set/_get_ui_data for this?
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 22 Mar 2008 09:17:34 +0000
parents 92e71f6e10d4
children 69d54f84350a
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Sat Mar 22 05:10:29 2008 +0000
+++ b/pidgin/gtkconv.c	Sat Mar 22 09:17:34 2008 +0000
@@ -7629,43 +7629,22 @@
 menu_initiate_voice_call_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	PidginWindow *win = (PidginWindow *)data;
-	GtkWidget *gtkmedia = NULL;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
-	PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
-
 	PurpleConnection *gc = purple_conversation_get_gc(conv);
-	PurplePluginProtocolInfo *prpl = gc->prpl;
-	PurpleMediaManager *manager = purple_media_manager_get();
 
 	PurpleMedia *media =
 		serv_initiate_media(gc,
 							purple_conversation_get_name(conv),
 							PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
-	GstElement *sendbin, *src, *sendlevel;
-	GstElement *recvbin, *sink, *recvlevel;
-	GstPad *pad, *ghost;
-
-	purple_media_audio_init_src(&sendbin, &sendlevel);
-	purple_media_audio_init_recv(&recvbin, &recvlevel);
-
-	purple_media_set_audio_src(media, sendbin);
-	purple_media_set_audio_sink(media, recvbin);
-
-	gtkmedia = pidgin_media_new(media, PIDGIN_MEDIA_WAITING, sendlevel, recvlevel);
-
-	gtk_box_pack_start(GTK_BOX(gtkconv->topvbox), gtkmedia, FALSE, FALSE, 0);
-	gtk_widget_show(gtkmedia);
-	g_signal_connect(G_OBJECT(gtkmedia), "message",
-					 G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
-	/* need to setup handler for accept, reject and if we hangup here... */
+
+	purple_media_wait(media);
 }
 
 static void
 pidgin_conv_new_media_cb(PurpleMediaManager *manager, PurpleMedia *media, gpointer nul)
 {
-	GstElement *sendbin, *src, *sendlevel;
-	GstElement *recvbin, *sink, *recvlevel;
-	GstPad *pad, *ghost;
+	GstElement *sendbin, *sendlevel;
+	GstElement *recvbin, *recvlevel;
 
 	GtkWidget *gtkmedia;
 	PurpleConversation *conv;
@@ -7677,14 +7656,20 @@
 	purple_media_set_audio_src(media, sendbin);
 	purple_media_set_audio_sink(media, recvbin);
 
-	gtkmedia = pidgin_media_new(media, PIDGIN_MEDIA_REQUESTED, sendlevel, recvlevel);
 	conv = purple_conversation_new(PURPLE_CONV_TYPE_IM,
 				       purple_connection_get_account(purple_media_get_connection(media)),
 				       purple_media_get_screenname(media));
 	gtkconv = PIDGIN_CONVERSATION(conv);
+	if (gtkconv->gtkmedia)
+		gtk_widget_destroy(gtkconv->gtkmedia);
+
+	gtkmedia = pidgin_media_new(media, sendlevel, recvlevel);
 	gtk_box_pack_start(GTK_BOX(gtkconv->topvbox), gtkmedia, FALSE, FALSE, 0);
 	gtk_widget_show(gtkmedia);
 	g_signal_connect(G_OBJECT(gtkmedia), "message", G_CALLBACK(pidgin_gtkmedia_message_cb), conv);
+
+	gtkconv->gtkmedia = gtkmedia;
+	g_signal_connect(G_OBJECT(gtkmedia), "destroy", G_CALLBACK(gtk_widget_destroyed), &(gtkconv->gtkmedia));
 }
 
 #endif