aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-mic-menu.c
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-28 22:29:44 +0800
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-07-29 18:02:08 +0800
commit302af77150e52cb625bc3e164808bd812979cc32 (patch)
treeae02a3857c1c4eef824a4440f5403c6c2c825865 /src/empathy-mic-menu.c
parent90eaac49d3f279ae20fa061adbe8ba9ac8aaf023 (diff)
downloadgsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar.gz
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar.bz2
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar.lz
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar.xz
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.tar.zst
gsoc2013-empathy-302af77150e52cb625bc3e164808bd812979cc32.zip
mic-menu: display monitors when they're the current mic
...but otherwise hide them. Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src/empathy-mic-menu.c')
-rw-r--r--src/empathy-mic-menu.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/empathy-mic-menu.c b/src/empathy-mic-menu.c
index 1053b7129..3ebd31c27 100644
--- a/src/empathy-mic-menu.c
+++ b/src/empathy-mic-menu.c
@@ -51,6 +51,8 @@ struct _EmpathyMicMenuPrivate
G_DEFINE_TYPE (EmpathyMicMenu, empathy_mic_menu, G_TYPE_OBJECT);
+#define MONITOR_KEY "empathy-mic-menu-is-monitor"
+
enum
{
PROP_WINDOW = 1,
@@ -186,16 +188,28 @@ empathy_mic_menu_update (EmpathyMicMenu *self)
GtkRadioAction *action = l->data;
const gchar *name = gtk_action_get_name (GTK_ACTION (action));
gint value;
+ gboolean active;
g_object_get (action, "value", &value, NULL);
- if (value == (gint) current_mic)
+ active = (value == (gint) current_mic);
+
+ if (active)
{
priv->in_update = TRUE;
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
priv->in_update = FALSE;
}
+ /* If action is a monitor then don't show it in the UI, BUT do
+ * display it regardless if it is the current device. This is so
+ * we don't have a rubbish UI by showing monitor devices in
+ * Empathy, but still show the correct device when someone plays
+ * with pavucontrol. */
+ if (g_object_get_data (G_OBJECT (action), MONITOR_KEY) != NULL
+ && !active)
+ continue;
+
gtk_ui_manager_add_ui (ui_manager, priv->ui_id,
/* TODO: this should probably be passed from the call
* window, seeing that it's a reference to
@@ -209,7 +223,8 @@ static void
empathy_mic_menu_add_microphone (EmpathyMicMenu *self,
const gchar *name,
const gchar *description,
- guint source_idx)
+ guint source_idx,
+ gboolean is_monitor)
{
EmpathyMicMenuPrivate *priv = self->priv;
GtkRadioAction *action;
@@ -219,6 +234,14 @@ empathy_mic_menu_add_microphone (EmpathyMicMenu *self,
gtk_action_group_add_action_with_accel (priv->action_group,
GTK_ACTION (action), NULL);
+ /* Set MONITOR_KEY on the action to non-NULL if it's a monitor
+ * because we don't want to show monitors if we can help it. */
+ if (is_monitor)
+ {
+ g_object_set_data (G_OBJECT (action), MONITOR_KEY,
+ GUINT_TO_POINTER (TRUE));
+ }
+
group = gtk_radio_action_get_group (GTK_RADIO_ACTION (priv->anchor_action));
gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);
@@ -244,7 +267,8 @@ empathy_mic_menu_microphone_added_cb (EmpathyGstAudioSrc *audio,
gboolean is_monitor,
EmpathyMicMenu *self)
{
- empathy_mic_menu_add_microphone (self, name, description, source_idx);
+ empathy_mic_menu_add_microphone (self, name, description,
+ source_idx, is_monitor);
empathy_mic_menu_update (self);
}
@@ -305,7 +329,7 @@ empathy_mic_menu_get_microphones_cb (GObject *source_object,
EmpathyAudioSrcMicrophone *mic = mics->data;
empathy_mic_menu_add_microphone (self, mic->name,
- mic->description, mic->index);
+ mic->description, mic->index, mic->is_monitor);
}
empathy_mic_menu_update (self);