soc.2008.vv: 9aaebaa4: Create a proper media menu with options ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat May 31 02:51:00 EDT 2008


-----------------------------------------------------------------
Revision: 9aaebaa4b28711839968dc79aae0080fbb23a7ed
Ancestor: bb8f798d1ef29d6376415e99e72a083d4b43b779
Author: maiku at soc.pidgin.im
Date: 2008-05-31T06:29:38
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/9aaebaa4b28711839968dc79aae0080fbb23a7ed

Modified files:
        libpurple/protocols/jabber/jabber.c pidgin/gtkconv.c
        pidgin/gtkconvwin.h pidgin/gtkimhtmltoolbar.c
        pidgin/pidginstock.c pidgin/pidginstock.h

ChangeLog: 

Create a proper media menu with options for audio, video, and 
audio/video.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	c32d13dc31399dff88221fec09595ae3f41294d8
+++ libpurple/protocols/jabber/jabber.c	de3dcb7f334740c54c723c5cb03a4edbf2e82eed
@@ -2640,7 +2640,10 @@ gboolean jabber_can_do_media(PurpleConne
 gboolean jabber_can_do_media(PurpleConnection *gc, const char *who, 
                              PurpleMediaStreamType type)
 {
-	return TRUE;
+	if (type == PURPLE_MEDIA_AUDIO)
+		return TRUE;
+	else
+		return FALSE;
 }
 
 
============================================================
--- pidgin/gtkconv.c	cf0c226ee1acb46b2c9b60b439e4121f10464c72
+++ pidgin/gtkconv.c	2df409289ce49b00003dea0a146cb46b0f6cd719
@@ -1200,7 +1200,11 @@ static void 
 /* 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 @@ static GtkItemFactoryEntry menu_items[] 
 	{ "/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 @@ setup_menubar(PidginWindow *win)
 		                            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/Voice Call..."));
+					    N_("/Conversation/Media/Audio Call"));
+	win->menu.video_call =
+		gtk_item_factory_get_widget(win->menu.item_factory,
+					    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 @@ gray_stuff_out(PidginConversation *gtkco
 		/* 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
 }
 
 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 @@ menu_initiate_voice_call_cb(gpointer dat
 
 	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;
============================================================
--- pidgin/gtkconvwin.h	114f5a7abe58724574a5f55fcb8da4b6e129c9cc
+++ pidgin/gtkconvwin.h	d465ce91335268efa990ef944cd2b8ba8322f4c8
@@ -49,8 +49,11 @@ struct _PidginWindow
 		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;
============================================================
--- pidgin/gtkimhtmltoolbar.c	c2bb091fd67cac7882787c50284e25748ba0508e
+++ pidgin/gtkimhtmltoolbar.c	85fd4c384c192c484290496f815974166c2f9341
@@ -1236,7 +1236,7 @@ static void gtk_imhtmltoolbar_create_old
 		{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 @@ static void gtk_imhtmltoolbar_init (GtkI
 	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"));
============================================================
--- pidgin/pidginstock.c	5adc2d205d6a4fce46d6f7a4c0c27f1fd696e8fa
+++ pidgin/pidginstock.c	a99c52e652caeb5296f1fa5eee528e8c01c07e70
@@ -170,7 +170,9 @@ static struct SizedStockIcon {
 	{ 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  },
============================================================
--- pidgin/pidginstock.h	1a1208b11aedbfa4b73cd66606dec4d7c5db8b04
+++ pidgin/pidginstock.h	19f062fa1ab49d3cea6fb3a0956ad7a59464d883
@@ -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 */


More information about the Commits mailing list