aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-02-18 15:38:45 +0000
committerConor Curran <conor.curran@canonical.com>2011-02-18 15:38:45 +0000
commitfca4da8d8a9dd24d8abdf2a92cf19a0c6d596e48 (patch)
tree51f3baaa19ed8ce927cf92812b8ad1d377bd94ff
parentd8cc480485f8f46142298341ef5336a0572be5b4 (diff)
downloadayatana-indicator-sound-fca4da8d8a9dd24d8abdf2a92cf19a0c6d596e48.tar.gz
ayatana-indicator-sound-fca4da8d8a9dd24d8abdf2a92cf19a0c6d596e48.tar.bz2
ayatana-indicator-sound-fca4da8d8a9dd24d8abdf2a92cf19a0c6d596e48.zip
fully functional voip feature landed
-rw-r--r--src/common-defs.h1
-rw-r--r--src/voip-input-menu-item.c18
-rw-r--r--src/voip-input-widget.c43
3 files changed, 49 insertions, 13 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index a0c097c..1a4e71e 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -40,6 +40,7 @@ typedef enum {
#define DBUSMENU_VOIP_INPUT_MENUITEM_TYPE "x-canonical-ido-voip-input-type"
#define DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL "x-canonical-ido-voip-input-level"
+#define DBUSMENU_VOIP_INPUT_MENUITEM_MUTE "x-canonical-ido-voip-input-mute"
#define DBUSMENU_MUTE_MENUITEM_TYPE "x-canonical-sound-menu-mute-type"
#define DBUSMENU_MUTE_MENUITEM_VALUE "x-canonical-sound-menu-mute-value"
diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c
index 498fb77..337420b 100644
--- a/src/voip-input-menu-item.c
+++ b/src/voip-input-menu-item.c
@@ -48,6 +48,7 @@ static void voip_input_menu_item_dispose (GObject *object);
static void voip_input_menu_item_finalize (GObject *object);
static void handle_event (DbusmenuMenuitem * mi, const gchar * name,
GVariant * value, guint timestamp);
+// TODO:
// This method should really be shared between this and the volume slider obj
// perfectly static - wait until the device mgr wrapper is properly sorted and
// then consolidate
@@ -84,6 +85,7 @@ voip_input_menu_item_init (VoipInputMenuItem *self)
priv->source_index = DEVICE_NOT_ACTIVE;
priv->sink_input_index = DEVICE_NOT_ACTIVE;
priv->client_index = DEVICE_NOT_ACTIVE;
+ priv->mute = 0;
}
static void
@@ -153,6 +155,17 @@ voip_input_menu_item_update (VoipInputMenuItem* item,
priv->source_index = source->index;
}
priv->volume = voip_input_menu_item_construct_mono_volume (&source->volume);
+
+ // Only send over the mute updates if the state has changed.
+ if (priv->mute != source->mute){
+ g_debug ("voip menu item - update - mute = %i", priv->mute);
+
+ GVariant* new_mute_update = g_variant_new_int32 (source->mute);
+ dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(item),
+ DBUSMENU_VOIP_INPUT_MENUITEM_MUTE,
+ new_mute_update);
+ }
+
priv->mute = source->mute;
pa_volume_t vol = pa_cvolume_max (&source->volume);
@@ -178,10 +191,6 @@ voip_input_menu_item_is_interested (VoipInputMenuItem* item,
}
priv->sink_input_index = sink_input_index;
-
- g_debug ("vimi - siindex = %i", sink_input_index);
- g_debug ("vimi - siindex stored = %i", priv->sink_input_index);
-
priv->client_index = client_index;
return TRUE;
@@ -227,7 +236,6 @@ voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item)
voip_input_menu_item_enable (item, FALSE);
}
-
void
voip_input_menu_item_enable (VoipInputMenuItem* item,
gboolean active)
diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c
index de06c7c..9b29feb 100644
--- a/src/voip-input-widget.c
+++ b/src/voip-input-widget.c
@@ -76,7 +76,6 @@ voip_input_widget_class_init (VoipInputWidgetClass *klass)
static void
voip_input_widget_init (VoipInputWidget *self)
{
- //g_debug("VoipInputWidget::voip_input_widget_init");
VoipInputWidgetPrivate * priv = VOIP_INPUT_WIDGET_GET_PRIVATE(self);
priv->ido_voip_input_slider = ido_scale_menu_item_new_with_range ("VOLUME", IDO_RANGE_STYLE_DEFAULT, 0, 0, 100, 1);
@@ -122,8 +121,8 @@ voip_input_widget_finalize (GObject *object)
}
static void
-voip_input_widget_property_update( DbusmenuMenuitem* item, gchar* property,
- GVariant* value, gpointer userdata)
+voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property,
+ GVariant* value, gpointer userdata)
{
g_return_if_fail (IS_VOIP_INPUT_WIDGET (userdata));
VoipInputWidget* mitem = VOIP_INPUT_WIDGET(userdata);
@@ -138,6 +137,24 @@ voip_input_widget_property_update( DbusmenuMenuitem* item, gchar* property,
gtk_range_set_value(range, update);
}
}
+ if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, property) == 0){
+ if(priv->grabbed == FALSE){
+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider);
+ GtkRange *range = (GtkRange*)slider;
+ gint update = g_variant_get_int32 (value);
+ gdouble level;
+ if (update == 1){
+ level = 0;
+ }
+ else{
+ level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL));
+ }
+ gtk_range_set_value(range, level);
+
+ g_debug ("voip-item-widget - update mute with value %i", update);
+ }
+ }
}
static void
@@ -155,6 +172,12 @@ voip_input_widget_set_twin_item (VoipInputWidget* self,
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider);
GtkRange *range = (GtkRange*)slider;
gtk_range_set_value(range, initial_level);
+
+ gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOIP_INPUT_MENUITEM_MUTE));
+ if (mute == 1){
+ gtk_range_set_value (range, 0.0);
+ }
}
static gboolean
@@ -170,10 +193,12 @@ voip_input_widget_change_value_cb (GtkRange *range,
}
-/*
- We only want this callback to catch mouse icon press events
- which set the slider to 0 or 100. Ignore all other events.
-*/
+/**
+ * We only want this callback to catch mouse icon press events which set the
+ * slider to 0 or 100. Ignore all other events including the new Mute behaviour
+ * (slider to go to 0 on mute without setting the level to 0 and return to
+ * previous level on unmute)
+ **/
static gboolean
voip_input_widget_value_changed_cb(GtkRange *range, gpointer user_data)
{
@@ -183,7 +208,9 @@ voip_input_widget_value_changed_cb(GtkRange *range, gpointer user_data)
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider);
gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
- if(current_value == 0 || current_value == 100){
+ gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOIP_INPUT_MENUITEM_MUTE));
+ if ((current_value == 0 && mute != 1) || current_value == 100 ){
voip_input_widget_update(mitem, current_value);
}
return FALSE;