diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-08-17 23:28:39 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-08-18 22:59:11 +0800 |
commit | fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f (patch) | |
tree | 030fa812dc027c4a5a39aa55c01d0c417ab010bb /src | |
parent | e5cd9e64870fbca5bc57d205ba4fe9aadb726614 (diff) | |
download | gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar.gz gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar.bz2 gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar.lz gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar.xz gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.tar.zst gsoc2013-empathy-fb90ae1ed068d4f0f0972b886cb8d1f643bf2f9f.zip |
mic-monitor: add set_default function
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-mic-monitor.c | 64 | ||||
-rw-r--r-- | src/empathy-mic-monitor.h | 5 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/empathy-mic-monitor.c b/src/empathy-mic-monitor.c index 2e1171b14..1628828e0 100644 --- a/src/empathy-mic-monitor.c +++ b/src/empathy-mic-monitor.c @@ -622,3 +622,67 @@ empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self, empathy_implement_finish_return_pointer (self, empathy_mic_monitor_get_default_async); } + +/* operation: set default */ +static void +empathy_mic_monitor_set_default_cb (pa_context *c, + int success, + void *userdata) +{ + GSimpleAsyncResult *result = userdata; + + if (!success) + { + g_simple_async_result_set_error (result, + G_IO_ERROR, G_IO_ERROR_FAILED, + "The operation failed for an unknown reason"); + } + + g_simple_async_result_complete (result); + g_object_unref (result); +} + +static void +operation_set_default (EmpathyMicMonitor *self, + GSimpleAsyncResult *result) +{ + EmpathyMicMonitorPrivate *priv = self->priv; + gchar *name; + + g_assert_cmpuint (pa_context_get_state (priv->context), ==, PA_CONTEXT_READY); + + name = g_simple_async_result_get_op_res_gpointer (result); + + pa_context_set_default_source (priv->context, name, + empathy_mic_monitor_set_default_cb, result); +} + +void +empathy_mic_monitor_set_default_async (EmpathyMicMonitor *self, + const gchar *name, + GAsyncReadyCallback callback, + gpointer user_data) +{ + EmpathyMicMonitorPrivate *priv = self->priv; + Operation *operation; + GSimpleAsyncResult *simple; + + simple = g_simple_async_result_new (G_OBJECT (self), callback, user_data, + empathy_mic_monitor_set_default_async); + + g_simple_async_result_set_op_res_gpointer (simple, g_strdup (name), g_free); + + operation = operation_new (operation_set_default, simple); + g_queue_push_tail (priv->operations, operation); + + operations_run (self); +} + +gboolean +empathy_mic_monitor_set_default_finish (EmpathyMicMonitor *self, + GAsyncResult *result, + GError **error) +{ + empathy_implement_finish_void (self, + empathy_mic_monitor_set_default_async); +} diff --git a/src/empathy-mic-monitor.h b/src/empathy-mic-monitor.h index 5e2a7c504..4ad4a28fa 100644 --- a/src/empathy-mic-monitor.h +++ b/src/empathy-mic-monitor.h @@ -80,6 +80,11 @@ void empathy_mic_monitor_get_default_async (EmpathyMicMonitor *self, const gchar * empathy_mic_monitor_get_default_finish (EmpathyMicMonitor *self, GAsyncResult *result, GError **error); +void empathy_mic_monitor_set_default_async (EmpathyMicMonitor *self, + const gchar *name, GAsyncReadyCallback callback, gpointer user_data); +gboolean empathy_mic_monitor_set_default_finish (EmpathyMicMonitor *self, + GAsyncResult *result, GError **error); + G_END_DECLS #endif /* __EMPATHY_MIC_MONITOR_H__ */ |