changeset 25662:28ab41065172

Create a proper media menu with options for audio, video, and audio/video.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sat, 31 May 2008 06:29:38 +0000
parents d048100a43ab
children de644f7e3958
files libpurple/protocols/jabber/jabber.c pidgin/gtkconv.c pidgin/gtkconvwin.h pidgin/gtkimhtmltoolbar.c pidgin/pidginstock.c pidgin/pidginstock.h
diffstat 6 files changed, 89 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sat May 31 04:01:18 2008 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat May 31 06:29:38 2008 +0000
@@ -2640,7 +2640,10 @@
 gboolean jabber_can_do_media(PurpleConnection *gc, const char *who, 
                              PurpleMediaStreamType type)
 {
-	return TRUE;
+	if (type == PURPLE_MEDIA_AUDIO)
+		return TRUE;
+	else
+		return FALSE;
 }
 
 
--- a/pidgin/gtkconv.c	Sat May 31 04:01:18 2008 +0000
+++ b/pidgin/gtkconv.c	Sat May 31 06:29:38 2008 +0000
@@ -1200,7 +1200,11 @@
 /* Forward declare this here, because I want to keep VV-related stuff together
 for now */
 static void 
-menu_initiate_voice_call_cb(gpointer data, guint action, GtkWidget *widget);
+menu_initiate_audio_call_cb(gpointer data, guint action, GtkWidget *widget);
+static void 
+menu_initiate_video_call_cb(gpointer data, guint action, GtkWidget *widget);
+static void 
+menu_initiate_audio_video_call_cb(gpointer data, guint action, GtkWidget *widget);
 
 #endif
 
@@ -3064,8 +3068,14 @@
 	{ "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL },
 
 #ifdef USE_VV
-	{ N_("/Conversation/_Voice Call..."), NULL, menu_initiate_voice_call_cb, 0,
-		"<StockItem>", PIDGIN_STOCK_TOOLBAR_CALL},
+	{ N_("/Conversation/M_edia"), NULL, NULL, 0, "<Branch>", NULL },
+
+	{ N_("/Conversation/Media/_Audio Call"), NULL, menu_initiate_audio_call_cb, 0,
+		"<StockItem>", PIDGIN_STOCK_TOOLBAR_AUDIO_CALL },
+	{ N_("/Conversation/Media/_Video Call"), NULL, menu_initiate_video_call_cb, 0,
+		"<StockItem>", PIDGIN_STOCK_TOOLBAR_VIDEO_CALL },
+	{ N_("/Conversation/Media/Audio\\/Video _Call"), NULL, menu_initiate_audio_video_call_cb, 0,
+		"<StockItem>", PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL },
 #endif
 
 	{ N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_SEND_FILE },
@@ -3378,9 +3388,15 @@
 		                            N_("/Conversation/View Log"));
 
 #ifdef USE_VV
-	win->menu.call =
+	win->menu.audio_call =
+		gtk_item_factory_get_widget(win->menu.item_factory,
+					    N_("/Conversation/Media/Audio Call"));
+	win->menu.video_call =
 		gtk_item_factory_get_widget(win->menu.item_factory,
-									N_("/Conversation/Voice Call..."));
+					    N_("/Conversation/Media/Video Call"));
+	win->menu.audio_video_call =
+		gtk_item_factory_get_widget(win->menu.item_factory,
+					    N_("/Conversation/Media/Audio\\/Video Call"));
 #endif
 	
 	/* --- */
@@ -6346,21 +6362,33 @@
 		/* check if account support voice calls, and if the current buddy
 			supports it */
 		if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
-			if (serv_can_do_media(gc, purple_conversation_get_name(conv), 
-						PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO)) {
+			gboolean audio = serv_can_do_media(gc, purple_conversation_get_name(conv), 
+							   PURPLE_MEDIA_AUDIO);
+			gboolean video = serv_can_do_media(gc, purple_conversation_get_name(conv), 
+							   PURPLE_MEDIA_VIDEO);
+			gboolean av = serv_can_do_media(gc, purple_conversation_get_name(conv),
+							PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
+			if (audio) {
 				buttons |= GTK_IMHTML_CALL;
-				gtk_widget_set_sensitive(win->menu.call, TRUE);
+				gtk_widget_set_sensitive(win->menu.audio_call, TRUE);
 			} else {
 				buttons &= ~GTK_IMHTML_CALL;
-				gtk_widget_set_sensitive(win->menu.call, FALSE);
+				gtk_widget_set_sensitive(win->menu.audio_call, FALSE);
 			}
+
+			gtk_widget_set_sensitive(win->menu.video_call, video ? TRUE : FALSE);
+			gtk_widget_set_sensitive(win->menu.audio_video_call, av ? TRUE : FALSE);
 		} else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
 			/* for now, don't care about chats... */
 			buttons &= ~GTK_IMHTML_CALL;
-			gtk_widget_set_sensitive(win->menu.call, FALSE);
+			gtk_widget_set_sensitive(win->menu.audio_call, FALSE);
+			gtk_widget_set_sensitive(win->menu.video_call, FALSE);
+			gtk_widget_set_sensitive(win->menu.audio_video_call, FALSE);
 		} else {
 			buttons &= ~GTK_IMHTML_CALL;
-			gtk_widget_set_sensitive(win->menu.call, FALSE);
+			gtk_widget_set_sensitive(win->menu.audio_call, FALSE);
+			gtk_widget_set_sensitive(win->menu.video_call, FALSE);
+			gtk_widget_set_sensitive(win->menu.audio_video_call, FALSE);
 		}							
 #endif
 		
@@ -7641,7 +7669,7 @@
 }
 
 static void
-menu_initiate_voice_call_cb(gpointer data, guint action, GtkWidget *widget)
+menu_initiate_audio_call_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	PidginWindow *win = (PidginWindow *)data;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
@@ -7649,14 +7677,44 @@
 
 	PurpleMedia *media =
 		serv_initiate_media(gc,
-							purple_conversation_get_name(conv),
-							PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
+				    purple_conversation_get_name(conv),
+				    PURPLE_MEDIA_AUDIO);
 
 	if (media)
 		purple_media_wait(media);
 }
 
 static void
+menu_initiate_video_call_cb(gpointer data, guint action, GtkWidget *widget)
+{
+	PidginWindow *win = (PidginWindow *)data;
+	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
+	PurpleConnection *gc = purple_conversation_get_gc(conv);
+
+	PurpleMedia *media =
+		serv_initiate_media(gc,
+				    purple_conversation_get_name(conv),
+				    PURPLE_MEDIA_VIDEO);
+
+	purple_media_wait(media);
+}
+
+static void
+menu_initiate_audio_video_call_cb(gpointer data, guint action, GtkWidget *widget)
+{
+	PidginWindow *win = (PidginWindow *)data;
+	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
+	PurpleConnection *gc = purple_conversation_get_gc(conv);
+
+	PurpleMedia *media =
+		serv_initiate_media(gc,
+				    purple_conversation_get_name(conv),
+				    PURPLE_MEDIA_AUDIO & PURPLE_MEDIA_VIDEO);
+
+	purple_media_wait(media);
+}
+
+static void
 pidgin_conv_new_media_cb(PurpleMediaManager *manager, PurpleMedia *media, gpointer nul)
 {
 	GstElement *sendbin, *sendlevel;
--- a/pidgin/gtkconvwin.h	Sat May 31 04:01:18 2008 +0000
+++ b/pidgin/gtkconvwin.h	Sat May 31 06:29:38 2008 +0000
@@ -49,8 +49,11 @@
 		GtkWidget *menubar;
 
 		GtkWidget *view_log;
-
-		GtkWidget *call;
+#ifdef USE_VV
+		GtkWidget *audio_call;
+		GtkWidget *video_call;
+		GtkWidget *audio_video_call;
+#endif
 		GtkWidget *send_file;
 		GtkWidget *add_pounce;
 		GtkWidget *get_info;
--- a/pidgin/gtkimhtmltoolbar.c	Sat May 31 04:01:18 2008 +0000
+++ b/pidgin/gtkimhtmltoolbar.c	Sat May 31 06:29:38 2008 +0000
@@ -1236,7 +1236,7 @@
 		{PIDGIN_STOCK_TOOLBAR_SMILEY, insert_smiley_cb, &toolbar->smiley, _("Insert Smiley")},
 #ifdef USE_VV
 		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_TOOLBAR_CALL, init_voice_call_cb, &toolbar->call, _("Call")},
+		{PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, init_voice_call_cb, &toolbar->call, _("Call")},
 #endif
 		{NULL, NULL, NULL, NULL}
 	};
@@ -1460,7 +1460,7 @@
 	gtk_button_set_relief(GTK_BUTTON(call_button), GTK_RELIEF_NONE);
 	bbox = gtk_hbox_new(FALSE, 3);
 	gtk_container_add(GTK_CONTAINER(call_button), bbox);
-	image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_CALL,
+	image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_AUDIO_CALL,
 			gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
 	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
 	label = gtk_label_new_with_mnemonic(_("Call"));
--- a/pidgin/pidginstock.c	Sat May 31 04:01:18 2008 +0000
+++ b/pidgin/pidginstock.c	Sat May 31 06:29:38 2008 +0000
@@ -170,7 +170,9 @@
 	{ PIDGIN_STOCK_TOOLBAR_SEND_FILE, "toolbar", "send-file.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
 
 #ifdef USE_VV
-	{ PIDGIN_STOCK_TOOLBAR_CALL, "toolbar", "call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
+	{ PIDGIN_STOCK_TOOLBAR_AUDIO_CALL, "toolbar", "audio-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
+	{ PIDGIN_STOCK_TOOLBAR_VIDEO_CALL, "toolbar", "video-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
+	{ PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL, "toolbar", "audio-video-call.png", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL  },
 #endif
 
 	{ PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL  },
--- a/pidgin/pidginstock.h	Sat May 31 04:01:18 2008 +0000
+++ b/pidgin/pidginstock.h	Sat May 31 06:29:38 2008 +0000
@@ -130,7 +130,9 @@
 #define PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR "pidgin-select-avatar"
 #define PIDGIN_STOCK_TOOLBAR_SEND_FILE    "pidgin-send-file"
 #ifdef USE_VV
-#define PIDGIN_STOCK_TOOLBAR_CALL			"pidgin-call"
+#define PIDGIN_STOCK_TOOLBAR_AUDIO_CALL   "pidgin-audio-call"
+#define PIDGIN_STOCK_TOOLBAR_VIDEO_CALL   "pidgin-video-call"
+#define PIDGIN_STOCK_TOOLBAR_AUDIO_VIDEO_CALL "pidgin-audio-video-call"
 #endif
 
 /* Tray icons */