changeset 23794:52a753b67ebb

Fine tune the media (audio) widget in finch.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 22 Mar 2008 09:36:22 +0000
parents befeece4dd48
children 0d41d271227b
files finch/gntmedia.c
diffstat 1 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntmedia.c	Sat Mar 22 09:17:34 2008 +0000
+++ b/finch/gntmedia.c	Sat Mar 22 09:36:22 2008 +0000
@@ -33,6 +33,7 @@
 #include "gnt.h"
 #include "gntbutton.h"
 #include "gntbox.h"
+#include "gntlabel.h"
 
 #include "cmds.h"
 #include "conversation.h"
@@ -54,6 +55,7 @@
 	GntWidget *accept;
 	GntWidget *reject;
 	GntWidget *hangup;
+	GntWidget *calling;
 
 	PurpleConversation *conv;
 };
@@ -148,9 +150,10 @@
 {
 	media->priv = FINCH_MEDIA_GET_PRIVATE(media);
 
-	media->priv->hangup = gnt_button_new("Hangup");
-	media->priv->accept = gnt_button_new("Accept");
-	media->priv->reject = gnt_button_new("Reject");
+	media->priv->calling = gnt_label_new(_("Calling ... "));
+	media->priv->hangup = gnt_button_new(_("Hangup"));
+	media->priv->accept = gnt_button_new(_("Accept"));
+	media->priv->reject = gnt_button_new(_("Reject"));
 
 	gnt_box_set_alignment(GNT_BOX(media), GNT_ALIGN_MID);
 
@@ -230,6 +233,36 @@
 
 	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->accept);
 	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->reject);
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->hangup);
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->calling);
+
+	gnt_box_add_widget(GNT_BOX(gntmedia), gntmedia->priv->hangup);
+
+	gnt_widget_destroy(gntmedia->priv->accept);
+	gnt_widget_destroy(gntmedia->priv->reject);
+	gnt_widget_destroy(gntmedia->priv->calling);
+	gntmedia->priv->accept = NULL;
+	gntmedia->priv->reject = NULL;
+	gntmedia->priv->calling = NULL;
+
+	parent = GNT_WIDGET(gntmedia);
+	while (parent->parent)
+		parent = parent->parent;
+	gnt_box_readjust(GNT_BOX(parent));
+	gnt_widget_draw(parent);
+}
+
+static void
+finch_media_wait_cb(PurpleMedia *media, FinchMedia *gntmedia)
+{
+	GntWidget *parent;
+
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->accept);
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->reject);
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->hangup);
+	gnt_box_remove(GNT_BOX(gntmedia), gntmedia->priv->calling);
+
+	gnt_box_add_widget(GNT_BOX(gntmedia), gntmedia->priv->calling);
 	gnt_box_add_widget(GNT_BOX(gntmedia), gntmedia->priv->hangup);
 
 	gnt_widget_destroy(gntmedia->priv->accept);
@@ -292,12 +325,16 @@
 				G_CALLBACK(finch_media_accept_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media) ,"ready",
 				G_CALLBACK(finch_media_ready_cb), media);
+			g_signal_connect(G_OBJECT(media->priv->media), "wait",
+				G_CALLBACK(finch_media_wait_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "hangup",
 				G_CALLBACK(finch_media_hangup_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "reject",
 				G_CALLBACK(finch_media_reject_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "got-hangup",
 				G_CALLBACK(finch_media_got_hangup_cb), media);
+			g_signal_connect(G_OBJECT(media->priv->media), "got-accept",
+				G_CALLBACK(finch_media_accept_cb), media);
 			break;
 		case PROP_SEND_LEVEL:
 			if (media->priv->send_level)