pidgin: 3ec6c363: Add pause capability for local video.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Fri Aug 7 07:35:56 EDT 2009


-----------------------------------------------------------------
Revision: 3ec6c363917ec3d2ab175d9e68ed1b9b8bb848fa
Ancestor: c5a017ca69d826e43efef171aa5e724438c1fe50
Author: maiku at soc.pidgin.im
Date: 2009-08-07T11:31:13
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3ec6c363917ec3d2ab175d9e68ed1b9b8bb848fa

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkmedia.c

ChangeLog: 

Add pause capability for local video.

-------------- next part --------------
============================================================
--- libpurple/media.c	0c1cc87dff5a43175631467e08b168aabfb1a07e
+++ libpurple/media.c	3e0113a557daee00ad00be22515d931de1e261a5
@@ -274,6 +274,10 @@ purple_media_info_type_get_type()
 					"PURPLE_MEDIA_INFO_MUTE", "mute" },
 			{ PURPLE_MEDIA_INFO_UNMUTE,
 					"PURPLE_MEDIA_INFO_UNMUTE", "unmute" },
+			{ PURPLE_MEDIA_INFO_PAUSE,
+					"PURPLE_MEDIA_INFO_PAUSE", "pause" },
+			{ PURPLE_MEDIA_INFO_UNPAUSE,
+					"PURPLE_MEDIA_INFO_UNPAUSE", "unpause" },
 			{ PURPLE_MEDIA_INFO_HOLD,
 					"PURPLE_MEDIA_INFO_HOLD", "hold" },
 			{ PURPLE_MEDIA_INFO_UNHOLD,
@@ -2258,6 +2262,21 @@ purple_media_stream_info(PurpleMedia *me
 				g_object_set(volume, "mute", active, NULL);
 			}
 		}
+	} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_PAUSE ||
+			type == PURPLE_MEDIA_INFO_UNPAUSE)) {
+		gboolean active = (type == PURPLE_MEDIA_INFO_PAUSE);
+		GList *streams = purple_media_get_streams(media,
+				session_id, participant);
+		for (; streams; streams = g_list_delete_link(streams, streams)) {
+			PurpleMediaStream *stream = streams->data;
+			if (stream->session->type & PURPLE_MEDIA_SEND_VIDEO) {
+				g_object_set(stream->stream, "direction",
+						purple_media_to_fs_stream_direction(
+						stream->session->type & ((active) ?
+						~PURPLE_MEDIA_SEND_VIDEO :
+						PURPLE_MEDIA_VIDEO)), NULL);
+			}
+		}
 	}
 
 	g_signal_emit(media, purple_media_signals[STREAM_INFO],
============================================================
--- libpurple/media.h	a35b9aa089df10452659a68600369139f4f7ca9d
+++ libpurple/media.h	1f586b239e7de613ba1012f01269d2444fe08702
@@ -103,6 +103,8 @@ typedef enum {
 	PURPLE_MEDIA_INFO_REJECT,
 	PURPLE_MEDIA_INFO_MUTE,
 	PURPLE_MEDIA_INFO_UNMUTE,
+	PURPLE_MEDIA_INFO_PAUSE,
+	PURPLE_MEDIA_INFO_UNPAUSE,
 	PURPLE_MEDIA_INFO_HOLD,
 	PURPLE_MEDIA_INFO_UNHOLD,
 } PurpleMediaInfoType;
============================================================
--- pidgin/gtkmedia.c	8f69a8ebac5f2949da0dcbc37ba7fe654012543c
+++ pidgin/gtkmedia.c	08955ab2f1470612616ded4410fabd48dd1745be
@@ -89,6 +89,7 @@ struct _PidginMediaPrivate
 	GtkWidget *statusbar;
 
 	GtkWidget *mute;
+	GtkWidget *pause;
 
 	GtkWidget *send_progress;
 	GtkWidget *recv_progress;
@@ -98,6 +99,7 @@ struct _PidginMediaPrivate
 	GtkWidget *display;
 	GtkWidget *send_widget;
 	GtkWidget *recv_widget;
+	GtkWidget *button_widget;
 	GtkWidget *local_video;
 	GtkWidget *remote_video;
 
@@ -192,6 +194,15 @@ pidgin_media_mute_toggled(GtkToggleButto
 			NULL, NULL, TRUE);
 }
 
+static void
+pidgin_media_pause_toggled(GtkToggleButton *toggle, PidginMedia *media)
+{
+	purple_media_stream_info(media->priv->media,
+			gtk_toggle_button_get_active(toggle) ?
+			PURPLE_MEDIA_INFO_PAUSE : PURPLE_MEDIA_INFO_UNPAUSE,
+			NULL, NULL, TRUE);
+}
+
 static gboolean
 pidgin_media_delete_event_cb(GtkWidget *widget,
 		GdkEvent *event, PidginMedia *media)
@@ -595,7 +606,7 @@ pidgin_media_ready_cb(PurpleMedia *media
 static void
 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia, const gchar *sid)
 {
-	GtkWidget *send_widget = NULL, *recv_widget = NULL;
+	GtkWidget *send_widget = NULL, *recv_widget = NULL, *button_widget = NULL;
 	PurpleMediaSessionType type =
 			purple_media_get_session_type(media, sid);
 
@@ -614,9 +625,15 @@ pidgin_media_ready_cb(PurpleMedia *media
 		send_widget = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
 				send_widget, TRUE, TRUE, 0);
+		button_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
+		gtk_box_pack_end(GTK_BOX(send_widget), button_widget,
+				FALSE, FALSE, 0);
+		gtk_widget_show(GTK_WIDGET(button_widget));
 		gtk_widget_show(send_widget);
-	} else
+	} else {
 		send_widget = gtkmedia->priv->send_widget;
+		button_widget = gtkmedia->priv->button_widget;
+	}
 
 	if (type & PURPLE_MEDIA_RECV_VIDEO) {
 		PidginMediaRealizeData *data;
@@ -669,6 +686,15 @@ pidgin_media_ready_cb(PurpleMedia *media
 		gtk_widget_show(local_video);
 		gtk_widget_show(aspect);
 
+		gtkmedia->priv->pause =
+				gtk_toggle_button_new_with_mnemonic(_("_Pause"));
+		g_signal_connect(gtkmedia->priv->pause, "toggled",
+				G_CALLBACK(pidgin_media_pause_toggled),
+				gtkmedia);
+		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->pause,
+				FALSE, FALSE, 0);
+		gtk_widget_show(gtkmedia->priv->pause);
+
 		gtkmedia->priv->local_video = local_video;
 	}
 
@@ -678,25 +704,18 @@ pidgin_media_ready_cb(PurpleMedia *media
 				PURPLE_MEDIA_RECV_AUDIO), FALSE, FALSE, 0);
 	}
 	if (type & PURPLE_MEDIA_SEND_AUDIO) {
-		GtkWidget *hbox;
-
-		hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
-		gtk_box_pack_end(GTK_BOX(send_widget), hbox, FALSE, FALSE, 0);
 		gtkmedia->priv->mute =
 				gtk_toggle_button_new_with_mnemonic("_Mute");
 		g_signal_connect(gtkmedia->priv->mute, "toggled",
 				G_CALLBACK(pidgin_media_mute_toggled),
 				gtkmedia);
-		gtk_box_pack_end(GTK_BOX(hbox), gtkmedia->priv->mute,
+		gtk_box_pack_end(GTK_BOX(button_widget), gtkmedia->priv->mute,
 				FALSE, FALSE, 0);
 		gtk_widget_show(gtkmedia->priv->mute);
-		gtk_widget_show(GTK_WIDGET(hbox));
 
 		gtk_box_pack_end(GTK_BOX(send_widget),
 				pidgin_media_add_audio_widget(gtkmedia,
 				PURPLE_MEDIA_SEND_AUDIO), FALSE, FALSE, 0);
-
-		gtk_widget_show(gtkmedia->priv->mute);
 	}
 
 
@@ -711,6 +730,8 @@ pidgin_media_ready_cb(PurpleMedia *media
 		gtkmedia->priv->send_widget = send_widget;
 	if (recv_widget != NULL)
 		gtkmedia->priv->recv_widget = recv_widget;
+	if (button_widget != NULL)
+		gtkmedia->priv->button_widget = button_widget;
 
 	if (purple_media_is_initiator(media, sid, NULL) == FALSE) {
 		if (gtkmedia->priv->timeout_id != 0)


More information about the Commits mailing list