[gnome-shell] gvc: Update from gnome-control-center



commit f8cdaaae30b5a8fc8f80fd163d1380fef3c9d50d
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Mar 11 15:30:35 2011 +0000

    gvc: Update from gnome-control-center
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644511

 src/gvc/gvc-mixer-card.c          |    4 +-
 src/gvc/gvc-mixer-control.c       |  136 ++++++++++++++++++++++---------------
 src/gvc/gvc-mixer-control.h       |    3 +
 src/gvc/gvc-mixer-event-role.c    |   13 ----
 src/gvc/gvc-mixer-sink-input.c    |   24 -------
 src/gvc/gvc-mixer-sink.c          |   24 -------
 src/gvc/gvc-mixer-source-output.c |   13 ----
 src/gvc/gvc-mixer-source.c        |   24 -------
 src/gvc/gvc-mixer-stream.c        |   11 +++-
 src/gvc/gvc-mixer-stream.h        |    2 +
 10 files changed, 98 insertions(+), 156 deletions(-)
---
diff --git a/src/gvc/gvc-mixer-card.c b/src/gvc/gvc-mixer-card.c
index f198f1b..56502e3 100644
--- a/src/gvc/gvc-mixer-card.c
+++ b/src/gvc/gvc-mixer-card.c
@@ -157,7 +157,7 @@ gvc_mixer_card_get_profile (GvcMixerCard *card)
         GList *l;
 
         g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
-        g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
+        g_return_val_if_fail (card->priv->profiles != NULL, NULL);
 
         for (l = card->priv->profiles; l != NULL; l = l->next) {
                 GvcMixerCardProfile *p = l->data;
@@ -266,7 +266,7 @@ gvc_mixer_card_change_profile (GvcMixerCard *card,
 const GList *
 gvc_mixer_card_get_profiles (GvcMixerCard *card)
 {
-        g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE);
+        g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
         return card->priv->profiles;
 }
 
diff --git a/src/gvc/gvc-mixer-control.c b/src/gvc/gvc-mixer-control.c
index d8d80f6..0e64165 100644
--- a/src/gvc/gvc-mixer-control.c
+++ b/src/gvc/gvc-mixer-control.c
@@ -615,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;
         }
 
@@ -640,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;
         }
 
@@ -711,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)
 {
@@ -767,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));
@@ -856,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));
@@ -881,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)
 {
@@ -1121,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;
@@ -1989,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;
@@ -2230,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/src/gvc/gvc-mixer-control.h b/src/gvc/gvc-mixer-control.h
index d32b204..3aa2c94 100644
--- a/src/gvc/gvc-mixer-control.h
+++ b/src/gvc/gvc-mixer-control.h
@@ -91,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/src/gvc/gvc-mixer-event-role.c b/src/gvc/gvc-mixer-event-role.c
index 071722e..5a28767 100644
--- a/src/gvc/gvc-mixer-event-role.c
+++ b/src/gvc/gvc-mixer-event-role.c
@@ -156,25 +156,12 @@ gvc_mixer_event_role_get_property (GObject     *object,
         }
 }
 
-static GObject *
-gvc_mixer_event_role_constructor (GType                  type,
-                                  guint                  n_construct_properties,
-                                  GObjectConstructParam *construct_params)
-{
-        GObject       *object;
-
-        object = G_OBJECT_CLASS (gvc_mixer_event_role_parent_class)->constructor (type, n_construct_properties, construct_params);
-
-        return object;
-}
-
 static void
 gvc_mixer_event_role_class_init (GvcMixerEventRoleClass *klass)
 {
         GObjectClass        *object_class = G_OBJECT_CLASS (klass);
         GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
 
-        object_class->constructor = gvc_mixer_event_role_constructor;
         object_class->finalize = gvc_mixer_event_role_finalize;
         object_class->set_property = gvc_mixer_event_role_set_property;
         object_class->get_property = gvc_mixer_event_role_get_property;
diff --git a/src/gvc/gvc-mixer-sink-input.c b/src/gvc/gvc-mixer-sink-input.c
index 5cd665c..03ba3b2 100644
--- a/src/gvc/gvc-mixer-sink-input.c
+++ b/src/gvc/gvc-mixer-sink-input.c
@@ -43,7 +43,6 @@ struct GvcMixerSinkInputPrivate
 static void     gvc_mixer_sink_input_class_init (GvcMixerSinkInputClass *klass);
 static void     gvc_mixer_sink_input_init       (GvcMixerSinkInput      *mixer_sink_input);
 static void     gvc_mixer_sink_input_finalize   (GObject                *object);
-static void     gvc_mixer_sink_input_dispose    (GObject                *object);
 
 G_DEFINE_TYPE (GvcMixerSinkInput, gvc_mixer_sink_input, GVC_TYPE_MIXER_STREAM)
 
@@ -107,26 +106,12 @@ gvc_mixer_sink_input_change_is_muted (GvcMixerStream *stream,
         return TRUE;
 }
 
-static GObject *
-gvc_mixer_sink_input_constructor (GType                  type,
-                                  guint                  n_construct_properties,
-                                  GObjectConstructParam *construct_params)
-{
-        GObject       *object;
-
-        object = G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->constructor (type, n_construct_properties, construct_params);
-
-        return object;
-}
-
 static void
 gvc_mixer_sink_input_class_init (GvcMixerSinkInputClass *klass)
 {
         GObjectClass        *object_class = G_OBJECT_CLASS (klass);
         GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
 
-        object_class->constructor = gvc_mixer_sink_input_constructor;
-        object_class->dispose = gvc_mixer_sink_input_dispose;
         object_class->finalize = gvc_mixer_sink_input_finalize;
 
         stream_class->push_volume = gvc_mixer_sink_input_push_volume;
@@ -142,15 +127,6 @@ gvc_mixer_sink_input_init (GvcMixerSinkInput *sink_input)
 }
 
 static void
-gvc_mixer_sink_input_dispose (GObject *object)
-{
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (GVC_IS_MIXER_SINK_INPUT (object));
-
-        G_OBJECT_CLASS (gvc_mixer_sink_input_parent_class)->dispose (object);
-}
-
-static void
 gvc_mixer_sink_input_finalize (GObject *object)
 {
         GvcMixerSinkInput *mixer_sink_input;
diff --git a/src/gvc/gvc-mixer-sink.c b/src/gvc/gvc-mixer-sink.c
index 5b74a5e..a6f1493 100644
--- a/src/gvc/gvc-mixer-sink.c
+++ b/src/gvc/gvc-mixer-sink.c
@@ -43,7 +43,6 @@ struct GvcMixerSinkPrivate
 static void     gvc_mixer_sink_class_init (GvcMixerSinkClass *klass);
 static void     gvc_mixer_sink_init       (GvcMixerSink      *mixer_sink);
 static void     gvc_mixer_sink_finalize   (GObject           *object);
-static void     gvc_mixer_sink_dispose    (GObject           *object);
 
 G_DEFINE_TYPE (GvcMixerSink, gvc_mixer_sink, GVC_TYPE_MIXER_STREAM)
 
@@ -139,26 +138,12 @@ gvc_mixer_sink_change_port (GvcMixerStream *stream,
 #endif /* PA_MICRO > 15 */
 }
 
-static GObject *
-gvc_mixer_sink_constructor (GType                  type,
-                            guint                  n_construct_properties,
-                            GObjectConstructParam *construct_params)
-{
-        GObject      *object;
-
-        object = G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->constructor (type, n_construct_properties, construct_params);
-
-        return object;
-}
-
 static void
 gvc_mixer_sink_class_init (GvcMixerSinkClass *klass)
 {
         GObjectClass        *object_class = G_OBJECT_CLASS (klass);
         GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
 
-        object_class->constructor = gvc_mixer_sink_constructor;
-        object_class->dispose = gvc_mixer_sink_dispose;
         object_class->finalize = gvc_mixer_sink_finalize;
 
         stream_class->push_volume = gvc_mixer_sink_push_volume;
@@ -175,15 +160,6 @@ gvc_mixer_sink_init (GvcMixerSink *sink)
 }
 
 static void
-gvc_mixer_sink_dispose (GObject *object)
-{
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (GVC_IS_MIXER_SINK (object));
-
-        G_OBJECT_CLASS (gvc_mixer_sink_parent_class)->dispose (object);
-}
-
-static void
 gvc_mixer_sink_finalize (GObject *object)
 {
         GvcMixerSink *mixer_sink;
diff --git a/src/gvc/gvc-mixer-source-output.c b/src/gvc/gvc-mixer-source-output.c
index 8d76763..536487b 100644
--- a/src/gvc/gvc-mixer-source-output.c
+++ b/src/gvc/gvc-mixer-source-output.c
@@ -60,25 +60,12 @@ gvc_mixer_source_output_change_is_muted (GvcMixerStream *stream,
         return TRUE;
 }
 
-static GObject *
-gvc_mixer_source_output_constructor (GType                  type,
-                                  guint                  n_construct_properties,
-                                  GObjectConstructParam *construct_params)
-{
-        GObject       *object;
-
-        object = G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->constructor (type, n_construct_properties, construct_params);
-
-        return object;
-}
-
 static void
 gvc_mixer_source_output_class_init (GvcMixerSourceOutputClass *klass)
 {
         GObjectClass        *object_class = G_OBJECT_CLASS (klass);
         GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
 
-        object_class->constructor = gvc_mixer_source_output_constructor;
         object_class->finalize = gvc_mixer_source_output_finalize;
 
         stream_class->push_volume = gvc_mixer_source_output_push_volume;
diff --git a/src/gvc/gvc-mixer-source.c b/src/gvc/gvc-mixer-source.c
index 6fed25e..ebb05a6 100644
--- a/src/gvc/gvc-mixer-source.c
+++ b/src/gvc/gvc-mixer-source.c
@@ -43,7 +43,6 @@ struct GvcMixerSourcePrivate
 static void     gvc_mixer_source_class_init (GvcMixerSourceClass *klass);
 static void     gvc_mixer_source_init       (GvcMixerSource      *mixer_source);
 static void     gvc_mixer_source_finalize   (GObject            *object);
-static void     gvc_mixer_source_dispose    (GObject           *object);
 
 G_DEFINE_TYPE (GvcMixerSource, gvc_mixer_source, GVC_TYPE_MIXER_STREAM)
 
@@ -139,26 +138,12 @@ gvc_mixer_source_change_port (GvcMixerStream *stream,
 #endif /* PA_MICRO > 15 */
 }
 
-static GObject *
-gvc_mixer_source_constructor (GType                  type,
-                            guint                  n_construct_properties,
-                            GObjectConstructParam *construct_params)
-{
-        GObject        *object;
-
-        object = G_OBJECT_CLASS (gvc_mixer_source_parent_class)->constructor (type, n_construct_properties, construct_params);
-
-        return object;
-}
-
 static void
 gvc_mixer_source_class_init (GvcMixerSourceClass *klass)
 {
         GObjectClass        *object_class = G_OBJECT_CLASS (klass);
         GvcMixerStreamClass *stream_class = GVC_MIXER_STREAM_CLASS (klass);
 
-        object_class->constructor = gvc_mixer_source_constructor;
-        object_class->dispose = gvc_mixer_source_dispose;
         object_class->finalize = gvc_mixer_source_finalize;
 
         stream_class->push_volume = gvc_mixer_source_push_volume;
@@ -175,15 +160,6 @@ gvc_mixer_source_init (GvcMixerSource *source)
 }
 
 static void
-gvc_mixer_source_dispose (GObject *object)
-{
-        g_return_if_fail (object != NULL);
-        g_return_if_fail (GVC_IS_MIXER_SOURCE (object));
-
-        G_OBJECT_CLASS (gvc_mixer_source_parent_class)->dispose (object);
-}
-
-static void
 gvc_mixer_source_finalize (GObject *object)
 {
         GvcMixerSource *mixer_source;
diff --git a/src/gvc/gvc-mixer-stream.c b/src/gvc/gvc-mixer-stream.c
index 3b4953a..3637bb4 100644
--- a/src/gvc/gvc-mixer-stream.c
+++ b/src/gvc/gvc-mixer-stream.c
@@ -390,6 +390,15 @@ gvc_mixer_stream_get_icon_name (GvcMixerStream *stream)
         return stream->priv->icon_name;
 }
 
+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)
@@ -496,7 +505,7 @@ gvc_mixer_stream_change_port (GvcMixerStream *stream,
 const GList *
 gvc_mixer_stream_get_ports (GvcMixerStream *stream)
 {
-        g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), FALSE);
+        g_return_val_if_fail (GVC_IS_MIXER_STREAM (stream), NULL);
         return stream->priv->ports;
 }
 
diff --git a/src/gvc/gvc-mixer-stream.h b/src/gvc/gvc-mixer-stream.h
index 53b7eb6..1c38e6b 100644
--- a/src/gvc/gvc-mixer-stream.h
+++ b/src/gvc/gvc-mixer-stream.h
@@ -24,6 +24,7 @@
 #include <glib-object.h>
 #include "gvc-pulseaudio-fake.h"
 #include "gvc-channel-map.h"
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -84,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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]