empathy r2642 - trunk/src



Author: xclaesse
Date: Sun Mar  8 20:18:44 2009
New Revision: 2642
URL: http://svn.gnome.org/viewvc/empathy?rev=2642&view=rev

Log:
Hook up audio mute button

Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>

Modified:
   trunk/src/empathy-call-window.c

Modified: trunk/src/empathy-call-window.c
==============================================================================
--- trunk/src/empathy-call-window.c	(original)
+++ trunk/src/empathy-call-window.c	Sun Mar  8 20:18:44 2009
@@ -75,8 +75,12 @@
   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_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 @@
   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 @@
   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 @@
   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 @@
   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 @@
 }
 
 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)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]