[gnome-settings-daemon] media-keys: Update gvc copy/paste from control-center
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] media-keys: Update gvc copy/paste from control-center
- Date: Mon, 14 Mar 2011 15:24:07 +0000 (UTC)
commit d78d8b1d227289583b37de052fcf110a2e7c1e1f
Author: Bastien Nocera <hadess hadess net>
Date: Mon Mar 14 15:21:14 2011 +0000
media-keys: Update gvc copy/paste from control-center
configure.ac | 2 +-
plugins/media-keys/cut-n-paste/Makefile.am | 5 +
.../cut-n-paste/gvc-channel-map-private.h | 39 ++++
plugins/media-keys/cut-n-paste/gvc-channel-map.c | 9 +
plugins/media-keys/cut-n-paste/gvc-channel-map.h | 12 +-
.../cut-n-paste/gvc-mixer-card-private.h | 35 +++
plugins/media-keys/cut-n-paste/gvc-mixer-card.c | 8 +
plugins/media-keys/cut-n-paste/gvc-mixer-card.h | 4 -
.../cut-n-paste/gvc-mixer-control-private.h | 35 +++
plugins/media-keys/cut-n-paste/gvc-mixer-control.c | 218 +++++++++++++++-----
plugins/media-keys/cut-n-paste/gvc-mixer-control.h | 5 +-
.../media-keys/cut-n-paste/gvc-mixer-event-role.c | 11 +
.../media-keys/cut-n-paste/gvc-mixer-sink-input.c | 11 +
plugins/media-keys/cut-n-paste/gvc-mixer-sink.c | 11 +
.../cut-n-paste/gvc-mixer-source-output.c | 9 +
plugins/media-keys/cut-n-paste/gvc-mixer-source.c | 11 +
.../cut-n-paste/gvc-mixer-stream-private.h | 34 +++
plugins/media-keys/cut-n-paste/gvc-mixer-stream.c | 47 +++++
plugins/media-keys/cut-n-paste/gvc-mixer-stream.h | 6 +-
.../media-keys/cut-n-paste/gvc-pulseaudio-fake.h | 34 +++
plugins/media-keys/gsd-media-keys-manager.c | 1 +
21 files changed, 472 insertions(+), 75 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 41f4db4..a7bd77b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,7 +253,7 @@ AC_ARG_ENABLE(pulse,
if test x$WANT_PULSE = xyes ; then
PA_REQUIRED_VERSION=0.9.16
- PKG_CHECK_MODULES(PULSE, glib-2.0 libpulse >= $PA_REQUIRED_VERSION libpulse-mainloop-glib >= $PA_REQUIRED_VERSION libcanberra-gtk3,
+ PKG_CHECK_MODULES(PULSE, glib-2.0 gio-2.0 libpulse >= $PA_REQUIRED_VERSION libpulse-mainloop-glib >= $PA_REQUIRED_VERSION libcanberra-gtk3,
[have_pulse=true
AC_DEFINE(HAVE_PULSE, 1, [Define if PULSE sound server should be used])],
[have_pulse=false])
diff --git a/plugins/media-keys/cut-n-paste/Makefile.am b/plugins/media-keys/cut-n-paste/Makefile.am
index bc59a10..70fcac8 100644
--- a/plugins/media-keys/cut-n-paste/Makefile.am
+++ b/plugins/media-keys/cut-n-paste/Makefile.am
@@ -16,10 +16,13 @@ libgvc_la_LIBADD = \
libgvc_la_SOURCES = \
gvc-mixer-stream.h \
gvc-mixer-stream.c \
+ gvc-mixer-stream-private.h \
gvc-channel-map.h \
gvc-channel-map.c \
+ gvc-channel-map-private.h \
gvc-mixer-card.c \
gvc-mixer-card.h \
+ gvc-mixer-card-private.h \
gvc-mixer-sink.h \
gvc-mixer-sink.c \
gvc-mixer-source.h \
@@ -32,6 +35,8 @@ libgvc_la_SOURCES = \
gvc-mixer-event-role.c \
gvc-mixer-control.h \
gvc-mixer-control.c \
+ gvc-mixer-control-private.h \
+ gvc-pulseaudio-fake.h \
$(NULL)
MAINTAINERCLEANFILES = \
diff --git a/plugins/media-keys/cut-n-paste/gvc-channel-map-private.h b/plugins/media-keys/cut-n-paste/gvc-channel-map-private.h
new file mode 100644
index 0000000..3949de3
--- /dev/null
+++ b/plugins/media-keys/cut-n-paste/gvc-channel-map-private.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_CHANNEL_MAP_PRIVATE_H
+#define __GVC_CHANNEL_MAP_PRIVATE_H
+
+#include <glib-object.h>
+#include <pulse/pulseaudio.h>
+
+G_BEGIN_DECLS
+
+GvcChannelMap * gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *map);
+const pa_channel_map * gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map);
+
+void gvc_channel_map_volume_changed (GvcChannelMap *map,
+ const pa_cvolume *cv,
+ gboolean set);
+const pa_cvolume * gvc_channel_map_get_cvolume (const GvcChannelMap *map);
+
+G_END_DECLS
+
+#endif /* __GVC_CHANNEL_MAP_PRIVATE_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-channel-map.c b/plugins/media-keys/cut-n-paste/gvc-channel-map.c
index 644774a..a2073fd 100644
--- a/plugins/media-keys/cut-n-paste/gvc-channel-map.c
+++ b/plugins/media-keys/cut-n-paste/gvc-channel-map.c
@@ -30,6 +30,7 @@
#include <pulse/pulseaudio.h>
#include "gvc-channel-map.h"
+#include "gvc-channel-map-private.h"
#define GVC_CHANNEL_MAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapPrivate))
@@ -119,6 +120,14 @@ gvc_channel_map_get_mapping (const GvcChannelMap *map)
return pa_channel_map_to_pretty_name (&map->priv->pa_map);
}
+/**
+ * gvc_channel_map_has_position: (skip)
+ *
+ * @map:
+ * @position:
+ *
+ * Returns:
+ */
gboolean
gvc_channel_map_has_position (const GvcChannelMap *map,
pa_channel_position_t position)
diff --git a/plugins/media-keys/cut-n-paste/gvc-channel-map.h b/plugins/media-keys/cut-n-paste/gvc-channel-map.h
index a149ee3..85c5772 100644
--- a/plugins/media-keys/cut-n-paste/gvc-channel-map.h
+++ b/plugins/media-keys/cut-n-paste/gvc-channel-map.h
@@ -22,7 +22,7 @@
#define __GVC_CHANNEL_MAP_H
#include <glib-object.h>
-#include <pulse/pulseaudio.h>
+#include <gvc-pulseaudio-fake.h>
G_BEGIN_DECLS
@@ -52,14 +52,12 @@ enum {
BALANCE,
FADE,
LFE,
+ NUM_TYPES
};
-#define NUM_TYPES LFE + 1
-
GType gvc_channel_map_get_type (void);
GvcChannelMap * gvc_channel_map_new (void);
-GvcChannelMap * gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *map);
guint gvc_channel_map_get_num_channels (const GvcChannelMap *map);
const gdouble * gvc_channel_map_get_volume (GvcChannelMap *map);
gboolean gvc_channel_map_can_balance (const GvcChannelMap *map);
@@ -68,14 +66,8 @@ gboolean gvc_channel_map_has_position (const GvcChanne
pa_channel_position_t position);
#define gvc_channel_map_has_lfe(x) gvc_channel_map_has_position (x, PA_CHANNEL_POSITION_LFE)
-void gvc_channel_map_volume_changed (GvcChannelMap *map,
- const pa_cvolume *cv,
- gboolean set);
const char * gvc_channel_map_get_mapping (const GvcChannelMap *map);
-/* private */
-const pa_cvolume * gvc_channel_map_get_cvolume (const GvcChannelMap *map);
-const pa_channel_map * gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map);
G_END_DECLS
#endif /* __GVC_CHANNEL_MAP_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-card-private.h b/plugins/media-keys/cut-n-paste/gvc-mixer-card-private.h
new file mode 100644
index 0000000..e190f7f
--- /dev/null
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-card-private.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_MIXER_CARD_PRIVATE_H
+#define __GVC_MIXER_CARD_PRIVATE_H
+
+#include <pulse/pulseaudio.h>
+#include "gvc-mixer-card.h"
+
+G_BEGIN_DECLS
+
+GvcMixerCard * gvc_mixer_card_new (pa_context *context,
+ guint index);
+pa_context * gvc_mixer_card_get_pa_context (GvcMixerCard *card);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_CARD_PRIVATE_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-card.c b/plugins/media-keys/cut-n-paste/gvc-mixer-card.c
index c80b212..56502e3 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-card.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-card.c
@@ -31,6 +31,7 @@
#include <pulse/pulseaudio.h>
#include "gvc-mixer-card.h"
+#include "gvc-mixer-card-private.h"
#define GVC_MIXER_CARD_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_CARD, GvcMixerCardPrivate))
@@ -143,6 +144,13 @@ gvc_mixer_card_set_icon_name (GvcMixerCard *card,
return TRUE;
}
+/**
+ * gvc_mixer_card_get_profile: (skip)
+ *
+ * @card:
+ *
+ * Returns:
+ */
GvcMixerCardProfile *
gvc_mixer_card_get_profile (GvcMixerCard *card)
{
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-card.h b/plugins/media-keys/cut-n-paste/gvc-mixer-card.h
index ad24cd6..5a3a7bc 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-card.h
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-card.h
@@ -22,7 +22,6 @@
#define __GVC_MIXER_CARD_H
#include <glib-object.h>
-#include <pulse/pulseaudio.h>
G_BEGIN_DECLS
@@ -58,8 +57,6 @@ typedef struct
} GvcMixerCardProfile;
GType gvc_mixer_card_get_type (void);
-GvcMixerCard * gvc_mixer_card_new (pa_context *context,
- guint index);
guint gvc_mixer_card_get_id (GvcMixerCard *card);
guint gvc_mixer_card_get_index (GvcMixerCard *card);
@@ -68,7 +65,6 @@ 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);
gboolean gvc_mixer_card_change_profile (GvcMixerCard *card,
const char *profile);
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-control-private.h b/plugins/media-keys/cut-n-paste/gvc-mixer-control-private.h
new file mode 100644
index 0000000..ac79975
--- /dev/null
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-control-private.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_MIXER_CONTROL_PRIVATE_H
+#define __GVC_MIXER_CONTROL_PRIVATE_H
+
+#include <glib-object.h>
+#include <pulse/pulseaudio.h>
+#include "gvc-mixer-stream.h"
+#include "gvc-mixer-card.h"
+
+G_BEGIN_DECLS
+
+pa_context * gvc_mixer_control_get_pa_context (GvcMixerControl *control);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_CONTROL_PRIVATE_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-control.c b/plugins/media-keys/cut-n-paste/gvc-mixer-control.c
index 60ee9c2..0e64165 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-control.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-control.c
@@ -40,6 +40,9 @@
#include "gvc-mixer-source-output.h"
#include "gvc-mixer-event-role.h"
#include "gvc-mixer-card.h"
+#include "gvc-mixer-card-private.h"
+#include "gvc-channel-map-private.h"
+#include "gvc-mixer-control-private.h"
#define GVC_MIXER_CONTROL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControlPrivate))
@@ -107,6 +110,13 @@ gvc_mixer_control_get_pa_context (GvcMixerControl *control)
return control->priv->pa_context;
}
+/**
+ * gvc_mixer_control_get_event_sink_input:
+ *
+ * @control:
+ *
+ * Returns: (transfer none):
+ */
GvcMixerStream *
gvc_mixer_control_get_event_sink_input (GvcMixerControl *control)
{
@@ -218,6 +228,13 @@ gvc_mixer_control_set_default_source (GvcMixerControl *control,
return TRUE;
}
+/**
+ * gvc_mixer_control_get_default_sink:
+ *
+ * @control:
+ *
+ * Returns: (transfer none):
+ */
GvcMixerStream *
gvc_mixer_control_get_default_sink (GvcMixerControl *control)
{
@@ -235,6 +252,13 @@ gvc_mixer_control_get_default_sink (GvcMixerControl *control)
return stream;
}
+/**
+ * gvc_mixer_control_get_default_source:
+ *
+ * @control:
+ *
+ * Returns: (transfer none):
+ */
GvcMixerStream *
gvc_mixer_control_get_default_source (GvcMixerControl *control)
{
@@ -260,6 +284,14 @@ gvc_mixer_control_lookup_id (GHashTable *hash_table,
GUINT_TO_POINTER (id));
}
+/**
+ * gvc_mixer_control_lookup_stream_id:
+ *
+ * @control:
+ * @id:
+ *
+ * Returns: (transfer none):
+ */
GvcMixerStream *
gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
guint id)
@@ -269,6 +301,14 @@ gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
return gvc_mixer_control_lookup_id (control->priv->all_streams, id);
}
+/**
+ * gvc_mixer_control_lookup_card_id:
+ *
+ * @control:
+ * @id:
+ *
+ * Returns: (transfer none):
+ */
GvcMixerCard *
gvc_mixer_control_lookup_card_id (GvcMixerControl *control,
guint id)
@@ -318,6 +358,13 @@ gvc_card_collate (GvcMixerCard *a,
return gvc_name_collate (namea, nameb);
}
+/**
+ * gvc_mixer_control_get_cards:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerCard):
+ */
GSList *
gvc_mixer_control_get_cards (GvcMixerControl *control)
{
@@ -348,6 +395,13 @@ gvc_stream_collate (GvcMixerStream *a,
return gvc_name_collate (namea, nameb);
}
+/**
+ * gvc_mixer_control_get_streams:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerStream):
+ */
GSList *
gvc_mixer_control_get_streams (GvcMixerControl *control)
{
@@ -362,6 +416,13 @@ gvc_mixer_control_get_streams (GvcMixerControl *control)
return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
}
+/**
+ * gvc_mixer_control_get_sinks:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerSink):
+ */
GSList *
gvc_mixer_control_get_sinks (GvcMixerControl *control)
{
@@ -376,6 +437,13 @@ gvc_mixer_control_get_sinks (GvcMixerControl *control)
return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
}
+/**
+ * gvc_mixer_control_get_sources:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerSource):
+ */
GSList *
gvc_mixer_control_get_sources (GvcMixerControl *control)
{
@@ -390,6 +458,13 @@ gvc_mixer_control_get_sources (GvcMixerControl *control)
return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
}
+/**
+ * gvc_mixer_control_get_sink_inputs:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerSinkInput):
+ */
GSList *
gvc_mixer_control_get_sink_inputs (GvcMixerControl *control)
{
@@ -404,6 +479,13 @@ gvc_mixer_control_get_sink_inputs (GvcMixerControl *control)
return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
}
+/**
+ * gvc_mixer_control_get_source_outputs:
+ *
+ * @control:
+ *
+ * Returns: (transfer container) (element-type Gvc.MixerSourceOutput):
+ */
GSList *
gvc_mixer_control_get_source_outputs (GvcMixerControl *control)
{
@@ -533,13 +615,13 @@ static void
update_default_source_from_name (GvcMixerControl *control,
const char *name)
{
- gboolean changed;
+ gboolean changed = FALSE;
if ((control->priv->default_source_name == NULL
&& name != NULL)
|| (control->priv->default_source_name != NULL
&& name == NULL)
- || strcmp (control->priv->default_source_name, name) != 0) {
+ || (name != NULL && strcmp (control->priv->default_source_name, name) != 0)) {
changed = TRUE;
}
@@ -558,13 +640,13 @@ static void
update_default_sink_from_name (GvcMixerControl *control,
const char *name)
{
- gboolean changed;
+ gboolean changed = FALSE;
if ((control->priv->default_sink_name == NULL
&& name != NULL)
|| (control->priv->default_sink_name != NULL
&& name == NULL)
- || strcmp (control->priv->default_sink_name, name) != 0) {
+ || (name != NULL && strcmp (control->priv->default_sink_name, name) != 0)) {
changed = TRUE;
}
@@ -629,6 +711,58 @@ add_stream (GvcMixerControl *control,
}
static void
+set_icon_name_from_proplist (GvcMixerStream *stream,
+ pa_proplist *l,
+ const char *default_icon_name)
+{
+ const char *t;
+
+ if ((t = pa_proplist_gets (l, PA_PROP_DEVICE_ICON_NAME))) {
+ goto finish;
+ }
+
+ if ((t = pa_proplist_gets (l, PA_PROP_MEDIA_ICON_NAME))) {
+ goto finish;
+ }
+
+ if ((t = pa_proplist_gets (l, PA_PROP_WINDOW_ICON_NAME))) {
+ goto finish;
+ }
+
+ if ((t = pa_proplist_gets (l, PA_PROP_APPLICATION_ICON_NAME))) {
+ goto finish;
+ }
+
+ if ((t = pa_proplist_gets (l, PA_PROP_MEDIA_ROLE))) {
+
+ if (strcmp (t, "video") == 0 ||
+ strcmp (t, "phone") == 0) {
+ goto finish;
+ }
+
+ if (strcmp (t, "music") == 0) {
+ t = "audio";
+ goto finish;
+ }
+
+ if (strcmp (t, "game") == 0) {
+ t = "applications-games";
+ goto finish;
+ }
+
+ if (strcmp (t, "event") == 0) {
+ t = "dialog-information";
+ goto finish;
+ }
+ }
+
+ t = default_icon_name;
+
+ finish:
+ gvc_mixer_stream_set_icon_name (stream, t);
+}
+
+static void
update_sink (GvcMixerControl *control,
const pa_sink_info *info)
{
@@ -685,7 +819,7 @@ update_sink (GvcMixerControl *control,
gvc_mixer_stream_set_name (stream, info->name);
gvc_mixer_stream_set_card_index (stream, info->card);
gvc_mixer_stream_set_description (stream, info->description);
- gvc_mixer_stream_set_icon_name (stream, "audio-card");
+ set_icon_name_from_proplist (stream, info->proplist, "audio-card");
gvc_mixer_stream_set_volume (stream, (guint)max_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
gvc_mixer_stream_set_can_decibel (stream, !!(info->flags & PA_SINK_DECIBEL_VOLUME));
@@ -774,7 +908,7 @@ update_source (GvcMixerControl *control,
gvc_mixer_stream_set_name (stream, info->name);
gvc_mixer_stream_set_card_index (stream, info->card);
gvc_mixer_stream_set_description (stream, info->description);
- gvc_mixer_stream_set_icon_name (stream, "audio-input-microphone");
+ set_icon_name_from_proplist (stream, info->proplist, "audio-input-microphone");
gvc_mixer_stream_set_volume (stream, (guint)max_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
gvc_mixer_stream_set_can_decibel (stream, !!(info->flags & PA_SOURCE_DECIBEL_VOLUME));
@@ -799,54 +933,6 @@ update_source (GvcMixerControl *control,
}
static void
-set_icon_name_from_proplist (GvcMixerStream *stream,
- pa_proplist *l,
- const char *default_icon_name)
-{
- const char *t;
-
- if ((t = pa_proplist_gets (l, PA_PROP_MEDIA_ICON_NAME))) {
- goto finish;
- }
-
- if ((t = pa_proplist_gets (l, PA_PROP_WINDOW_ICON_NAME))) {
- goto finish;
- }
-
- if ((t = pa_proplist_gets (l, PA_PROP_APPLICATION_ICON_NAME))) {
- goto finish;
- }
-
- if ((t = pa_proplist_gets (l, PA_PROP_MEDIA_ROLE))) {
-
- if (strcmp (t, "video") == 0 ||
- strcmp (t, "phone") == 0) {
- goto finish;
- }
-
- if (strcmp (t, "music") == 0) {
- t = "audio";
- goto finish;
- }
-
- if (strcmp (t, "game") == 0) {
- t = "applications-games";
- goto finish;
- }
-
- if (strcmp (t, "event") == 0) {
- t = "dialog-information";
- goto finish;
- }
- }
-
- t = default_icon_name;
-
- finish:
- gvc_mixer_stream_set_icon_name (stream, t);
-}
-
-static void
set_is_event_stream_from_proplist (GvcMixerStream *stream,
pa_proplist *l)
{
@@ -1039,7 +1125,7 @@ update_card (GvcMixerControl *control,
const pa_card_info *info)
{
GvcMixerCard *card;
- gboolean is_new;
+ gboolean is_new = FALSE;
#if 1
guint i;
const char *key;
@@ -1907,6 +1993,11 @@ gvc_mixer_control_dispose (GObject *object)
{
GvcMixerControl *control = GVC_MIXER_CONTROL (object);
+ if (control->priv->reconnect_id != 0) {
+ g_source_remove (control->priv->reconnect_id);
+ control->priv->reconnect_id = 0;
+ }
+
if (control->priv->pa_context != NULL) {
pa_context_unref (control->priv->pa_context);
control->priv->pa_context = NULL;
@@ -2148,3 +2239,20 @@ gvc_mixer_control_new (const char *name)
NULL);
return GVC_MIXER_CONTROL (control);
}
+
+/* FIXME: Remove when PA 0.9.23 is used */
+#ifndef PA_VOLUME_UI_MAX
+#define PA_VOLUME_UI_MAX pa_sw_volume_from_dB(+11.0)
+#endif
+
+gdouble
+gvc_mixer_control_get_vol_max_norm (GvcMixerControl *control)
+{
+ return (gdouble) PA_VOLUME_NORM;
+}
+
+gdouble
+gvc_mixer_control_get_vol_max_amplified (GvcMixerControl *control)
+{
+ return (gdouble) PA_VOLUME_UI_MAX;
+}
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-control.h b/plugins/media-keys/cut-n-paste/gvc-mixer-control.h
index d49e5a3..3aa2c94 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-control.h
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-control.h
@@ -22,7 +22,6 @@
#define __GVC_MIXER_CONTROL_H
#include <glib-object.h>
-#include <pulse/pulseaudio.h>
#include "gvc-mixer-stream.h"
#include "gvc-mixer-card.h"
@@ -71,7 +70,6 @@ gboolean gvc_mixer_control_open (GvcMixerControl *cont
gboolean gvc_mixer_control_close (GvcMixerControl *control);
gboolean gvc_mixer_control_is_ready (GvcMixerControl *control);
-pa_context * gvc_mixer_control_get_pa_context (GvcMixerControl *control);
GSList * gvc_mixer_control_get_cards (GvcMixerControl *control);
GSList * gvc_mixer_control_get_streams (GvcMixerControl *control);
GSList * gvc_mixer_control_get_sinks (GvcMixerControl *control);
@@ -93,6 +91,9 @@ gboolean gvc_mixer_control_set_default_sink (GvcMixerControl *con
gboolean gvc_mixer_control_set_default_source (GvcMixerControl *control,
GvcMixerStream *stream);
+gdouble gvc_mixer_control_get_vol_max_norm (GvcMixerControl *control);
+gdouble gvc_mixer_control_get_vol_max_amplified (GvcMixerControl *control);
+
G_END_DECLS
#endif /* __GVC_MIXER_CONTROL_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-event-role.c b/plugins/media-keys/cut-n-paste/gvc-mixer-event-role.c
index 2a2e787..5a28767 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-event-role.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-event-role.c
@@ -31,6 +31,8 @@
#include <pulse/ext-stream-restore.h>
#include "gvc-mixer-event-role.h"
+#include "gvc-mixer-stream-private.h"
+#include "gvc-channel-map-private.h"
#define GVC_MIXER_EVENT_ROLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_EVENT_ROLE, GvcMixerEventRolePrivate))
@@ -202,6 +204,15 @@ gvc_mixer_event_role_finalize (GObject *object)
G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->finalize (object);
}
+/**
+ * gvc_mixer_event_role_new: (skip)
+ *
+ * @context:
+ * @index:
+ * @channel_map:
+ *
+ * Returns:
+ */
GvcMixerStream *
gvc_mixer_event_role_new (pa_context *context,
const char *device,
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-sink-input.c b/plugins/media-keys/cut-n-paste/gvc-mixer-sink-input.c
index be918c0..03ba3b2 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-sink-input.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-sink-input.c
@@ -30,6 +30,8 @@
#include <pulse/pulseaudio.h>
#include "gvc-mixer-sink-input.h"
+#include "gvc-mixer-stream-private.h"
+#include "gvc-channel-map-private.h"
#define GVC_MIXER_SINK_INPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK_INPUT, GvcMixerSinkInputPrivate))
@@ -138,6 +140,15 @@ gvc_mixer_sink_input_finalize (GObject *object)
G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->finalize (object);
}
+/**
+ * gvc_mixer_sink_input_new: (skip)
+ *
+ * @context:
+ * @index:
+ * @channel_map:
+ *
+ * Returns:
+ */
GvcMixerStream *
gvc_mixer_sink_input_new (pa_context *context,
guint index,
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-sink.c b/plugins/media-keys/cut-n-paste/gvc-mixer-sink.c
index c6512cd..a6f1493 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-sink.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-sink.c
@@ -30,6 +30,8 @@
#include <pulse/pulseaudio.h>
#include "gvc-mixer-sink.h"
+#include "gvc-mixer-stream-private.h"
+#include "gvc-channel-map-private.h"
#define GVC_MIXER_SINK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SINK, GvcMixerSinkPrivate))
@@ -171,6 +173,15 @@ gvc_mixer_sink_finalize (GObject *object)
G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->finalize (object);
}
+/**
+ * gvc_mixer_sink_new: (skip)
+ *
+ * @context:
+ * @index:
+ * @channel_map:
+ *
+ * Returns:
+ */
GvcMixerStream *
gvc_mixer_sink_new (pa_context *context,
guint index,
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-source-output.c b/plugins/media-keys/cut-n-paste/gvc-mixer-source-output.c
index 38b109f..536487b 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-source-output.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-source-output.c
@@ -95,6 +95,15 @@ gvc_mixer_source_output_finalize (GObject *object)
G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->finalize (object);
}
+/**
+ * gvc_mixer_source_output_new: (skip)
+ *
+ * @context:
+ * @index:
+ * @channel_map:
+ *
+ * Returns:
+ */
GvcMixerStream *
gvc_mixer_source_output_new (pa_context *context,
guint index,
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-source.c b/plugins/media-keys/cut-n-paste/gvc-mixer-source.c
index 1c5f185..ebb05a6 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-source.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-source.c
@@ -30,6 +30,8 @@
#include <pulse/pulseaudio.h>
#include "gvc-mixer-source.h"
+#include "gvc-mixer-stream-private.h"
+#include "gvc-channel-map-private.h"
#define GVC_MIXER_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE, GvcMixerSourcePrivate))
@@ -171,6 +173,15 @@ gvc_mixer_source_finalize (GObject *object)
G_OBJECT_CLASS (gvc_mixer_source_parent_class)->finalize (object);
}
+/**
+ * gvc_mixer_source_new: (skip)
+ *
+ * @context:
+ * @index:
+ * @channel_map:
+ *
+ * Returns:
+ */
GvcMixerStream *
gvc_mixer_source_new (pa_context *context,
guint index,
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-stream-private.h b/plugins/media-keys/cut-n-paste/gvc-mixer-stream-private.h
new file mode 100644
index 0000000..b97ecf5
--- /dev/null
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-stream-private.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_MIXER_STREAM_PRIVATE_H
+#define __GVC_MIXER_STREAM_PRIVATE_H
+
+#include <glib-object.h>
+
+#include "gvc-channel-map.h"
+
+G_BEGIN_DECLS
+
+pa_context * gvc_mixer_stream_get_pa_context (GvcMixerStream *stream);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_STREAM_PRIVATE_H */
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-stream.c b/plugins/media-keys/cut-n-paste/gvc-mixer-stream.c
index 4e82fb1..78de6b3 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-stream.c
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-stream.c
@@ -30,6 +30,8 @@
#include <pulse/pulseaudio.h>
#include "gvc-mixer-stream.h"
+#include "gvc-mixer-stream-private.h"
+#include "gvc-channel-map-private.h"
#define GVC_MIXER_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_STREAM, GvcMixerStreamPrivate))
@@ -126,6 +128,13 @@ gvc_mixer_stream_get_channel_map (GvcMixerStream *stream)
return stream->priv->channel_map;
}
+/**
+ * gvc_mixer_stream_get_volume:
+ *
+ * @stream:
+ *
+ * Returns: (type guint32) (transfer none):
+ */
pa_volume_t
gvc_mixer_stream_get_volume (GvcMixerStream *stream)
{
@@ -143,6 +152,14 @@ gvc_mixer_stream_get_decibel (GvcMixerStream *stream)
(pa_volume_t) gvc_channel_map_get_volume(stream->priv->channel_map)[VOLUME]);
}
+/**
+ * gvc_mixer_stream_set_volume:
+ *
+ * @stream:
+ * @volume: (type guint32):
+ *
+ * Returns:
+ */
gboolean
gvc_mixer_stream_set_volume (GvcMixerStream *stream,
pa_volume_t volume)
@@ -373,6 +390,21 @@ gvc_mixer_stream_get_icon_name (GvcMixerStream *stream)
return stream->priv->icon_name;
}
+/**
+ * gvc_mixer_stream_get_gicon:
+ * @stream: a #GvcMixerStream
+ *
+ * Returns: (transfer full): a new #GIcon
+ */
+GIcon *
+gvc_mixer_stream_get_gicon (GvcMixerStream *stream)
+{
+ g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
+ if (stream->priv->icon_name == NULL)
+ return NULL;
+ return g_themed_icon_new_with_default_fallbacks (stream->priv->icon_name);
+}
+
gboolean
gvc_mixer_stream_set_icon_name (GvcMixerStream *stream,
const char *icon_name)
@@ -386,6 +418,13 @@ gvc_mixer_stream_set_icon_name (GvcMixerStream *stream,
return TRUE;
}
+/**
+ * gvc_mixer_stream_get_base_volume:
+ *
+ * @stream:
+ *
+ * Returns: (type guint32) (transfer none):
+ */
pa_volume_t
gvc_mixer_stream_get_base_volume (GvcMixerStream *stream)
{
@@ -394,6 +433,14 @@ gvc_mixer_stream_get_base_volume (GvcMixerStream *stream)
return stream->priv->base_volume;
}
+/**
+ * gvc_mixer_stream_set_base_volume:
+ *
+ * @stream:
+ * @base_volume: (type guint32):
+ *
+ * Returns:
+ */
gboolean
gvc_mixer_stream_set_base_volume (GvcMixerStream *stream,
pa_volume_t base_volume)
diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-stream.h b/plugins/media-keys/cut-n-paste/gvc-mixer-stream.h
index bbeb8a3..1c38e6b 100644
--- a/plugins/media-keys/cut-n-paste/gvc-mixer-stream.h
+++ b/plugins/media-keys/cut-n-paste/gvc-mixer-stream.h
@@ -22,9 +22,9 @@
#define __GVC_MIXER_STREAM_H
#include <glib-object.h>
-#include <pulse/pulseaudio.h>
-
+#include "gvc-pulseaudio-fake.h"
#include "gvc-channel-map.h"
+#include <gio/gio.h>
G_BEGIN_DECLS
@@ -65,7 +65,6 @@ typedef struct
GType gvc_mixer_stream_get_type (void);
-pa_context * gvc_mixer_stream_get_pa_context (GvcMixerStream *stream);
guint gvc_mixer_stream_get_index (GvcMixerStream *stream);
guint gvc_mixer_stream_get_id (GvcMixerStream *stream);
const GvcChannelMap *gvc_mixer_stream_get_channel_map(GvcMixerStream *stream);
@@ -86,6 +85,7 @@ gboolean gvc_mixer_stream_change_is_muted (GvcMixerStream *stream,
gboolean gvc_mixer_stream_is_running (GvcMixerStream *stream);
const char * gvc_mixer_stream_get_name (GvcMixerStream *stream);
const char * gvc_mixer_stream_get_icon_name (GvcMixerStream *stream);
+GIcon * gvc_mixer_stream_get_gicon (GvcMixerStream *stream);
const char * gvc_mixer_stream_get_description (GvcMixerStream *stream);
const char * gvc_mixer_stream_get_application_id (GvcMixerStream *stream);
gboolean gvc_mixer_stream_is_event_stream (GvcMixerStream *stream);
diff --git a/plugins/media-keys/cut-n-paste/gvc-pulseaudio-fake.h b/plugins/media-keys/cut-n-paste/gvc-pulseaudio-fake.h
new file mode 100644
index 0000000..ab8f6b4
--- /dev/null
+++ b/plugins/media-keys/cut-n-paste/gvc-pulseaudio-fake.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GVC_PULSEAUDIO_FAKE_H
+#define __GVC_PULSEAUDIO_FAKE_H
+
+#ifdef WITH_INTROSPECTION
+
+#ifndef PA_API_VERSION
+#define pa_channel_position_t int
+#define pa_volume_t guint32
+#define pa_context gpointer
+#endif /* PA_API_VERSION */
+
+#endif /* WITH_INTROSPECTION */
+
+#endif /* __GVC_PULSEAUDIO_FAKE_H */
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 52ba6df..dce7ae2 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -49,6 +49,7 @@
#ifdef HAVE_PULSE
#include <canberra-gtk.h>
+#include <pulse/pulseaudio.h>
#include "gvc-mixer-control.h"
#endif /* HAVE_PULSE */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]