diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-03-09 04:18:44 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-03-09 04:18:44 +0800 |
commit | 2283d38637adf2d7d00572ba5a81bba0f6e9560c (patch) | |
tree | 580f0221936a200747ea3940df25f86212c785ea /src/empathy-call-window.c | |
parent | 8f73d98bc357c0a4b8991e86113250fcdcea31b0 (diff) | |
download | gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar.gz gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar.bz2 gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar.lz gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar.xz gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.tar.zst gsoc2013-empathy-2283d38637adf2d7d00572ba5a81bba0f6e9560c.zip |
Hook up audio mute button
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
svn path=/trunk/; revision=2642
Diffstat (limited to 'src/empathy-call-window.c')
-rw-r--r-- | src/empathy-call-window.c | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index efc304811..745fde3c6 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -75,8 +75,12 @@ struct _EmpathyCallWindowPriv GtkWidget *sidebar_button; GtkWidget *statusbar; GtkWidget *volume_button; + GtkWidget *mic_button; GtkWidget *camera_button; + gdouble volume; + GtkAdjustment *audio_input_adj; + GtkWidget *dtmf_panel; GstElement *video_input; @@ -118,6 +122,9 @@ static void empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle, static void empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle, EmpathyCallWindow *window); +static void empathy_call_window_mic_toggled_cb ( + GtkToggleToolButton *toggle, EmpathyCallWindow *window); + static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar, EmpathyCallWindow *window); @@ -162,6 +169,10 @@ empathy_call_window_setup_toolbar (EmpathyCallWindow *self) mic = glade_xml_get_widget (priv->glade, "microphone"); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (mic), TRUE); + priv->mic_button = mic; + g_signal_connect (G_OBJECT (priv->mic_button), "toggled", + G_CALLBACK (empathy_call_window_mic_toggled_cb), self); + toolbar = glade_xml_get_widget (priv->glade, "toolbar"); /* Add an empty expanded GtkToolItem so the volume button is at the end of @@ -184,7 +195,6 @@ empathy_call_window_setup_toolbar (EmpathyCallWindow *self) gtk_widget_show_all (GTK_WIDGET (tool_item)); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), tool_item, -1); - camera = glade_xml_get_widget (priv->glade, "camera"); priv->camera_button = camera; gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (camera), FALSE); @@ -399,9 +409,24 @@ empathy_call_window_mic_volume_changed_cb (GtkAdjustment *adj, EmpathyCallWindow *self) { EmpathyCallWindowPriv *priv = GET_PRIV (self); + gdouble volume; + + volume = gtk_adjustment_get_value (adj)/100.0; + + /* Don't store the volume because of muting */ + if (volume > 0 || gtk_toggle_tool_button_get_active ( + GTK_TOGGLE_TOOL_BUTTON (priv->mic_button))) + priv->volume = volume; + + /* Ensure that the toggle button is active if the volume is > 0 and inactive + * if it's smaller then 0 */ + if ((volume > 0) != gtk_toggle_tool_button_get_active ( + GTK_TOGGLE_TOOL_BUTTON (priv->mic_button))) + gtk_toggle_tool_button_set_active ( + GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0); empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input), - gtk_adjustment_get_value (adj)/100); + volume); } static void @@ -430,10 +455,10 @@ empathy_call_window_create_audio_input (EmpathyCallWindow *self) gtk_range_set_inverted (GTK_RANGE (scale), TRUE); label = gtk_label_new (_("Volume")); - adj = gtk_range_get_adjustment (GTK_RANGE (scale)); - gtk_adjustment_set_value (adj, - empathy_audio_src_get_volume ( - EMPATHY_GST_AUDIO_SRC (priv->audio_input)) * 100); + priv->audio_input_adj = adj = gtk_range_get_adjustment (GTK_RANGE (scale)); + priv->volume = empathy_audio_src_get_volume (EMPATHY_GST_AUDIO_SRC + (priv->audio_input)); + gtk_adjustment_set_value (adj, priv->volume * 100); g_signal_connect (G_OBJECT (adj), "value-changed", G_CALLBACK (empathy_call_window_mic_volume_changed_cb), self); @@ -1125,6 +1150,34 @@ empathy_call_window_camera_toggled_cb (GtkToggleToolButton *toggle, } static void +empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle, + EmpathyCallWindow *window) +{ + EmpathyCallWindowPriv *priv = GET_PRIV (window); + gboolean active; + + active = (gtk_toggle_tool_button_get_active (toggle)); + + if (active) + { + empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input), + priv->volume); + gtk_adjustment_set_value (priv->audio_input_adj, priv->volume * 100); + } + else + { + /* TODO, Instead of setting the input volume to 0 we should probably + * stop sending but this would cause the audio call to drop if both + * sides mute at the same time on certain CMs AFAIK. Need to revisit this + * in the future + */ + empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input), + 0); + gtk_adjustment_set_value (priv->audio_input_adj, 0); + } +} + +static void empathy_call_window_sidebar_hidden_cb (EmpathySidebar *sidebar, EmpathyCallWindow *window) { |