soc.2008.vv: 2b075cad: Added a mute button for the local microp...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Wed Jul 23 18:40:47 EDT 2008
-----------------------------------------------------------------
Revision: 2b075cade5bcad8687da90b39fb8cb6b3fe9651e
Ancestor: 37613689fde707599c3bd245b7d4a4564db5541e
Author: maiku at soc.pidgin.im
Date: 2008-07-23T22:34:22
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/2b075cade5bcad8687da90b39fb8cb6b3fe9651e
Modified files:
libpurple/media.c libpurple/media.h pidgin/gtkmedia.c
ChangeLog:
Added a mute button for the local microphone.
-------------- next part --------------
============================================================
--- libpurple/media.c 36a1e3ccde79bcbd7443d0d8ee04ccfdbd88b1d2
+++ libpurple/media.c 490b36364eb9b0e52b9056691549ea4bc04650ad
@@ -757,6 +757,7 @@ purple_media_audio_init_src(GstElement *
purple_media_audio_init_src(GstElement **sendbin, GstElement **sendlevel)
{
GstElement *src;
+ GstElement *volume;
GstPad *pad;
GstPad *ghost;
const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device");
@@ -765,9 +766,11 @@ purple_media_audio_init_src(GstElement *
*sendbin = gst_bin_new("purplesendaudiobin");
src = gst_element_factory_make("alsasrc", "asrc");
+ volume = gst_element_factory_make("volume", "purpleaudiovolume");
*sendlevel = gst_element_factory_make("level", "sendlevel");
- gst_bin_add_many(GST_BIN(*sendbin), src, *sendlevel, NULL);
- gst_element_link(src, *sendlevel);
+ gst_bin_add_many(GST_BIN(*sendbin), src, volume, *sendlevel, NULL);
+ gst_element_link(src, volume);
+ gst_element_link(volume, *sendlevel);
pad = gst_element_get_pad(*sendlevel, "src");
ghost = gst_ghost_pad_new("ghostsrc", pad);
gst_element_add_pad(*sendbin, ghost);
@@ -1253,4 +1256,20 @@ purple_media_set_send_codec(PurpleMedia
return TRUE;
}
+void purple_media_mute(PurpleMedia *media, gboolean active)
+{
+ GList *sessions = g_hash_table_get_values(media->priv->sessions);
+ purple_debug_info("media", "Turning mute %s\n", active ? "on" : "off");
+
+ for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+ PurpleMediaSession *session = sessions->data;
+ if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
+ GstElement *volume = gst_bin_get_by_name(
+ GST_BIN(session->src),
+ "purpleaudiovolume");
+ g_object_set(volume, "mute", active, NULL);
+ }
+ }
+}
+
#endif /* USE_VV */
============================================================
--- libpurple/media.h fa7d6013ba43279002d785d2c474142ec47d7c6a
+++ libpurple/media.h eb868a606143bb349a7775b47a2f6db420dd1412
@@ -149,6 +149,8 @@ gboolean purple_media_set_send_codec(Pur
gboolean purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, FsCodec *codec);
+void purple_media_mute(PurpleMedia *media, gboolean active);
+
G_END_DECLS
#endif /* USE_VV */
============================================================
--- pidgin/gtkmedia.c 61ab89eebb433e0af06f420c43287f8e33a5d8ba
+++ pidgin/gtkmedia.c 521eb0b7cb20626d09d36125fa391ff2ae1da39b
@@ -58,6 +58,7 @@ struct _PidginMediaPrivate
GtkWidget *accept;
GtkWidget *reject;
GtkWidget *hangup;
+ GtkWidget *mute;
GtkWidget *send_progress;
GtkWidget *recv_progress;
@@ -157,6 +158,12 @@ pidgin_media_class_init (PidginMediaClas
g_type_class_add_private(klass, sizeof(PidginMediaPrivate));
}
+static void
+pidgin_media_mute_toggled(GtkToggleButton *toggle, PidginMedia *media)
+{
+ purple_media_mute(media->priv->media,
+ gtk_toggle_button_get_active(toggle));
+}
static void
pidgin_media_init (PidginMedia *media)
@@ -166,11 +173,16 @@ pidgin_media_init (PidginMedia *media)
media->priv->hangup = gtk_button_new_with_label("Hangup");
media->priv->accept = gtk_button_new_with_label("Accept");
media->priv->reject = gtk_button_new_with_label("Reject");
+ media->priv->mute = gtk_toggle_button_new_with_label("Mute");
+ g_signal_connect(media->priv->mute, "toggled",
+ G_CALLBACK(pidgin_media_mute_toggled), media);
+
gtk_box_pack_start(GTK_BOX(media), media->priv->calling, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(media), media->priv->hangup, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(media), media->priv->accept, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(media), media->priv->reject, FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(media), media->priv->mute, FALSE, FALSE, 0);
gtk_widget_show_all(media->priv->accept);
gtk_widget_show_all(media->priv->reject);
@@ -572,18 +584,21 @@ pidgin_media_set_state(PidginMedia *gtkm
gtk_widget_hide(gtkmedia->priv->accept);
gtk_widget_hide(gtkmedia->priv->reject);
gtk_widget_show(gtkmedia->priv->hangup);
+ gtk_widget_hide(gtkmedia->priv->mute);
break;
case PIDGIN_MEDIA_REQUESTED:
gtk_widget_hide(gtkmedia->priv->calling);
gtk_widget_show(gtkmedia->priv->accept);
gtk_widget_show(gtkmedia->priv->reject);
gtk_widget_hide(gtkmedia->priv->hangup);
+ gtk_widget_hide(gtkmedia->priv->mute);
break;
case PIDGIN_MEDIA_ACCEPTED:
gtk_widget_show(gtkmedia->priv->hangup);
gtk_widget_hide(gtkmedia->priv->calling);
gtk_widget_hide(gtkmedia->priv->accept);
gtk_widget_hide(gtkmedia->priv->reject);
+ gtk_widget_show(gtkmedia->priv->mute);
break;
default:
break;
More information about the Commits
mailing list