[gnome-media] Add a _change_profile function
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-media] Add a _change_profile function
- Date: Thu, 23 Jul 2009 15:31:15 +0000 (UTC)
commit 422f3c6599c00abb487bde7f474b1bdc5f91da6b
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jul 23 14:06:52 2009 +0100
Add a _change_profile function
Otherwise we wouldn't know the difference between switching
profiles, and storing one that happened outside our realm.
gnome-volume-control/src/gvc-mixer-card.c | 60 +++++++++++++++++++----------
gnome-volume-control/src/gvc-mixer-card.h | 4 +-
2 files changed, 43 insertions(+), 21 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-card.c b/gnome-volume-control/src/gvc-mixer-card.c
index c22c422..2382e8f 100644
--- a/gnome-volume-control/src/gvc-mixer-card.c
+++ b/gnome-volume-control/src/gvc-mixer-card.c
@@ -169,31 +169,51 @@ _pa_context_set_card_profile_by_index_cb (pa_context *cont
{
GvcMixerCard *card = GVC_MIXER_CARD (userdata);
+ g_assert (card->priv->target_profile);
+
if (success > 0) {
- GList *l;
+ gvc_mixer_card_set_profile (card, card->priv->target_profile);
+ } else {
+ g_debug ("Failed to switch profile on '%s' from '%s' to '%s'",
+ card->priv->name,
+ card->priv->profile,
+ card->priv->target_profile);
+ }
+ g_free (card->priv->target_profile);
+ card->priv->target_profile = NULL;
+}
- g_free (card->priv->profile);
- card->priv->profile = card->priv->target_profile;
- card->priv->target_profile = NULL;
+gboolean
+gvc_mixer_card_set_profile (GvcMixerCard *card,
+ const char *profile)
+{
+ GList *l;
- g_free (card->priv->human_profile);
- card->priv->human_profile = NULL;
+ g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
+ g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
- for (l = card->priv->profiles; l != NULL; l = l->next) {
- GvcMixerCardProfile *p = l->data;
- if (g_str_equal (card->priv->profile, p->profile)) {
- card->priv->human_profile = g_strdup (p->human_profile);
- break;
- }
- }
+ g_free (card->priv->profile);
+ card->priv->profile = g_strdup (profile);
- g_object_notify (G_OBJECT (card), "profile");
+ g_free (card->priv->human_profile);
+ card->priv->human_profile = NULL;
+
+ for (l = card->priv->profiles; l != NULL; l = l->next) {
+ GvcMixerCardProfile *p = l->data;
+ if (g_str_equal (card->priv->profile, p->profile)) {
+ card->priv->human_profile = g_strdup (p->human_profile);
+ break;
+ }
}
+
+ g_object_notify (G_OBJECT (card), "profile");
+
+ return TRUE;
}
gboolean
-gvc_mixer_card_set_profile (GvcMixerCard *card,
- const char *profile)
+gvc_mixer_card_change_profile (GvcMixerCard *card,
+ const char *profile)
{
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
@@ -211,10 +231,10 @@ gvc_mixer_card_set_profile (GvcMixerCard *card,
card->priv->target_profile = g_strdup (profile);
o = pa_context_set_card_profile_by_index (card->priv->pa_context,
- card->priv->index,
- card->priv->target_profile,
- _pa_context_set_card_profile_by_index_cb,
- card);
+ card->priv->index,
+ card->priv->target_profile,
+ _pa_context_set_card_profile_by_index_cb,
+ card);
if (o == NULL) {
g_warning ("pa_context_set_card_profile_by_index() failed");
diff --git a/gnome-volume-control/src/gvc-mixer-card.h b/gnome-volume-control/src/gvc-mixer-card.h
index 68d3ea2..cdf4a01 100644
--- a/gnome-volume-control/src/gvc-mixer-card.h
+++ b/gnome-volume-control/src/gvc-mixer-card.h
@@ -66,7 +66,9 @@ const char * gvc_mixer_card_get_icon_name (GvcMixerCard *card);
GvcMixerCardProfile * gvc_mixer_card_get_profile (GvcMixerCard *card);
const GList * gvc_mixer_card_get_profiles (GvcMixerCard *card);
-pa_context * gvc_mixer_card_get_pa_context (GvcMixerCard *card);
+pa_context * gvc_mixer_card_get_pa_context (GvcMixerCard *card);
+gboolean gvc_mixer_card_change_profile (GvcMixerCard *card,
+ const char *profile);
/* private */
gboolean gvc_mixer_card_set_name (GvcMixerCard *card,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]