[gnome-flashback] libsound-applet: add files



commit f1ffb4975d1f6a5d46c305d6536babb7c6fe4f24
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Aug 29 15:06:39 2014 +0300

    libsound-applet: add files
    
    Sound applet has been removed from gnome-control-center. See bug:
    https://bugzilla.gnome.org/show_bug.cgi?id=682861
    
    This commit adds all removed files except .desktop file as we will
    not use it.

 gnome-flashback/libsound-applet/Makefile.am        |  113 +++
 gnome-flashback/libsound-applet/applet-main.c      |  110 +++
 gnome-flashback/libsound-applet/gvc-applet.c       |  305 ++++++++
 gnome-flashback/libsound-applet/gvc-applet.h       |   55 ++
 gnome-flashback/libsound-applet/gvc-log.c          |   64 ++
 gnome-flashback/libsound-applet/gvc-log.h          |   35 +
 .../libsound-applet/gvc-stream-status-icon.c       |  781 ++++++++++++++++++++
 .../libsound-applet/gvc-stream-status-icon.h       |   63 ++
 8 files changed, 1526 insertions(+), 0 deletions(-)
---
diff --git a/gnome-flashback/libsound-applet/Makefile.am b/gnome-flashback/libsound-applet/Makefile.am
new file mode 100644
index 0000000..4f93246
--- /dev/null
+++ b/gnome-flashback/libsound-applet/Makefile.am
@@ -0,0 +1,113 @@
+SUBDIRS = data
+
+# This is used in PANEL_CFLAGS
+cappletname = sound
+NULL =
+
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libsound.la
+
+bin_PROGRAMS =                                 \
+       gnome-sound-applet                      \
+       $(NULL)
+
+AM_CPPFLAGS =                                  \
+       $(PANEL_CFLAGS)                         \
+       $(SOUND_PANEL_CFLAGS)                   \
+       -DLOCALE_DIR=\""$(datadir)/locale"\"    \
+       -DLIBEXECDIR=\"$(libexecdir)\"          \
+       -DGLADEDIR=\""$(pkgdatadir)"\"          \
+        -DSOUND_DATA_DIR="\"$(datadir)/sounds\""       \
+        -DSOUND_SET_DIR="\"$(pkgdatadir)/sounds\""     \
+       -DICON_DATA_DIR="\"$(pkgdatadir)/icons\"" \
+       $(NULL)
+
+noinst_LTLIBRARIES = libgnomevolumecontrol.la
+libgnomevolumecontrol_la_SOURCES =             \
+       gvc-mixer-card.h                        \
+       gvc-mixer-card.c                        \
+       gvc-mixer-card-private.h                \
+       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-ui-device.h                   \
+       gvc-mixer-ui-device.c                   \
+       gvc-mixer-sink.h                        \
+       gvc-mixer-sink.c                        \
+       gvc-mixer-source.h                      \
+       gvc-mixer-source.c                      \
+       gvc-mixer-sink-input.h                  \
+       gvc-mixer-sink-input.c                  \
+       gvc-mixer-source-output.h               \
+       gvc-mixer-source-output.c               \
+       gvc-mixer-event-role.h                  \
+       gvc-mixer-event-role.c                  \
+       gvc-mixer-control.h                     \
+       gvc-mixer-control.c                     \
+       gvc-mixer-control-private.h             \
+       gvc-channel-bar.h                       \
+       gvc-channel-bar.c                       \
+       gvc-pulseaudio-fake.h                   \
+       $(NULL)
+
+gnome_sound_applet_LDADD =                     \
+       -lm                                     \
+       libgnomevolumecontrol.la                \
+       $(SOUND_PANEL_LIBS)                     \
+       $(NULL)
+
+gnome_sound_applet_SOURCES =                   \
+       gvc-stream-status-icon.h                \
+       gvc-stream-status-icon.c                \
+       gvc-applet.h                            \
+       gvc-applet.c                            \
+       gvc-log.h                               \
+       gvc-log.c                               \
+       applet-main.c                           \
+       $(NULL)
+
+libsound_la_LIBADD =                           \
+       -lm                                     \
+       libgnomevolumecontrol.la                \
+       $(PANEL_LIBS)                           \
+       $(SOUND_PANEL_LIBS)                     \
+       $(NULL)
+
+libsound_la_LDFLAGS =                          \
+       $(PANEL_LDFLAGS)                        \
+       $(NULL)
+
+libsound_la_SOURCES =                          \
+       gvc-balance-bar.h                       \
+       gvc-balance-bar.c                       \
+       gvc-mixer-dialog.h                      \
+       gvc-mixer-dialog.c                      \
+       gvc-level-bar.h                         \
+       gvc-level-bar.c                         \
+       gvc-combo-box.h                         \
+       gvc-combo-box.c                         \
+       gvc-speaker-test.h                      \
+       gvc-speaker-test.c                      \
+       gvc-sound-theme-chooser.c               \
+       gvc-sound-theme-chooser.h               \
+       sound-theme-file-utils.c                \
+       sound-theme-file-utils.h                \
+       cc-sound-panel.c                        \
+       cc-sound-panel.h                        \
+       $(NULL)
+
+BUILT_SOURCES =                                \
+       $(NULL)
+
+CLEANFILES =                           \
+       $(BUILT_SOURCES)                \
+       $(NULL)
+
+MAINTAINERCLEANFILES =                  \
+        *~                              \
+        Makefile.in
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libsound-applet/applet-main.c b/gnome-flashback/libsound-applet/applet-main.c
new file mode 100644
index 0000000..0335fa1
--- /dev/null
+++ b/gnome-flashback/libsound-applet/applet-main.c
@@ -0,0 +1,110 @@
+/* -*- 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
+ * Lesser 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.
+ */
+
+#include "config.h"
+
+#include <libintl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <glib/gi18n.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+
+#include "gvc-applet.h"
+#include "gvc-log.h"
+
+#define GVCA_DBUS_NAME "org.gnome.VolumeControlApplet"
+
+static gboolean show_version = FALSE;
+static gboolean debug = FALSE;
+
+int
+main (int argc, char **argv)
+{
+        GError             *error;
+        GvcApplet          *applet;
+        GApplication       *app = NULL;
+        static GOptionEntry entries[] = {
+                { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL },
+                { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL 
},
+                { NULL, 0, 0, 0, NULL, NULL, NULL }
+        };
+
+        bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+        textdomain (GETTEXT_PACKAGE);
+
+        gvc_log_init ();
+
+        error = NULL;
+        gtk_init_with_args (&argc, &argv,
+                            (char *) _(" — GNOME Volume Control Applet"),
+                            entries, GETTEXT_PACKAGE,
+                            &error);
+
+        if (error != NULL) {
+                g_warning ("%s", error->message);
+                exit (1);
+        }
+
+        if (show_version) {
+                g_print ("%s %s\n", argv [0], VERSION);
+                exit (1);
+        }
+
+        gvc_log_set_debug (debug);
+
+        if (debug == FALSE) {
+                GError *error = NULL;
+
+                app = g_application_new (GVCA_DBUS_NAME,
+                                         G_APPLICATION_FLAGS_NONE);
+                if (!g_application_register (app, NULL, &error)) {
+                       g_warning ("%s", error->message);
+                       g_error_free (error);
+                       return 1;
+                }
+                if (g_application_get_is_remote (app)) {
+                        g_warning ("Applet is already running, exiting");
+                        return 0;
+                }
+        }
+
+        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
+                                           ICON_DATA_DIR);
+
+        applet = gvc_applet_new ();
+        gvc_applet_start (applet);
+
+        gtk_main ();
+
+        if (applet != NULL) {
+                g_object_unref (applet);
+        }
+        if (app != NULL) {
+                g_object_unref (app);
+        }
+
+        return 0;
+}
diff --git a/gnome-flashback/libsound-applet/gvc-applet.c b/gnome-flashback/libsound-applet/gvc-applet.c
new file mode 100644
index 0000000..a73a845
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-applet.c
@@ -0,0 +1,305 @@
+/* -*- 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.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <pulse/pulseaudio.h>
+
+#include "gvc-applet.h"
+#include "gvc-mixer-control.h"
+#include "gvc-stream-status-icon.h"
+
+#define GVC_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_APPLET, GvcAppletPrivate))
+
+#define SCALE_SIZE 128
+
+static const char *output_icon_names[] = {
+        "audio-volume-muted-symbolic",
+        "audio-volume-low-symbolic",
+        "audio-volume-medium-symbolic",
+        "audio-volume-high-symbolic",
+        NULL
+};
+
+static const char *input_icon_names[] = {
+        "audio-input-microphone-muted-symbolic",
+        "audio-input-microphone-low-symbolic",
+        "audio-input-microphone-medium-symbolic",
+        "audio-input-microphone-high-symbolic",
+        NULL
+};
+
+struct GvcAppletPrivate
+{
+        GvcStreamStatusIcon *input_status_icon;
+        GvcStreamStatusIcon *output_status_icon;
+        GvcMixerControl     *control;
+};
+
+static void     gvc_applet_class_init (GvcAppletClass *klass);
+static void     gvc_applet_init       (GvcApplet      *applet);
+static void     gvc_applet_finalize   (GObject        *object);
+
+G_DEFINE_TYPE (GvcApplet, gvc_applet, G_TYPE_OBJECT)
+
+static void
+maybe_show_status_icons (GvcApplet *applet)
+{
+        gboolean        show;
+        GvcMixerStream *stream;
+        GSList         *source_outputs, *l;
+
+        show = TRUE;
+        stream = gvc_mixer_control_get_default_sink (applet->priv->control);
+        if (stream == NULL) {
+                show = FALSE;
+        }
+        gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->output_status_icon), show);
+
+
+        show = FALSE;
+        stream = gvc_mixer_control_get_default_source (applet->priv->control);
+        source_outputs = gvc_mixer_control_get_source_outputs (applet->priv->control);
+        if (stream != NULL && source_outputs != NULL) {
+                /* Check that we're not trying to add the peak detector
+                 * as an application doing recording */
+                for (l = source_outputs ; l ; l = l->next) {
+                        GvcMixerStream *s = l->data;
+                        const char *id;
+
+                        id = gvc_mixer_stream_get_application_id (s);
+                        if (id == NULL) {
+                                show = TRUE;
+                                break;
+                        }
+
+                        if (!g_str_equal (id, "org.gnome.VolumeControl") &&
+                            !g_str_equal (id, "org.PulseAudio.pavucontrol")) {
+                                show = TRUE;
+                                break;
+                        }
+                }
+        }
+        gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->input_status_icon), show);
+
+        g_slist_free (source_outputs);
+}
+
+void
+gvc_applet_start (GvcApplet *applet)
+{
+        g_return_if_fail (GVC_IS_APPLET (applet));
+
+        maybe_show_status_icons (applet);
+}
+
+static void
+gvc_applet_dispose (GObject *object)
+{
+        GvcApplet *applet = GVC_APPLET (object);
+
+        if (applet->priv->control != NULL) {
+                g_object_unref (applet->priv->control);
+                applet->priv->control = NULL;
+        }
+
+        G_OBJECT_CLASS (gvc_applet_parent_class)->dispose (object);
+}
+
+static void
+update_default_source (GvcApplet *applet)
+{
+        GvcMixerStream *stream;
+
+        stream = gvc_mixer_control_get_default_source (applet->priv->control);
+        if (stream != NULL) {
+                gvc_stream_status_icon_set_mixer_stream (applet->priv->input_status_icon,
+                                                         stream);
+                maybe_show_status_icons(applet);
+        } else {
+                g_debug ("Unable to get default source, or no source available");
+        }
+}
+
+static void
+update_default_sink (GvcApplet *applet)
+{
+        GvcMixerStream *stream;
+
+        stream = gvc_mixer_control_get_default_sink (applet->priv->control);
+        if (stream != NULL) {
+                gvc_stream_status_icon_set_mixer_stream (applet->priv->output_status_icon,
+                                                         stream);
+                maybe_show_status_icons(applet);
+        } else {
+                g_warning ("Unable to get default sink");
+        }
+}
+
+static void
+on_control_state_changed (GvcMixerControl      *control,
+                          GvcMixerControlState  new_state,
+                          GvcApplet            *applet)
+{
+        if (new_state == GVC_STATE_READY)  {
+                update_default_sink (applet);
+                update_default_source (applet);
+        } else if (new_state == GVC_STATE_CONNECTING) {
+                g_debug ("Connecting...");
+        }
+}
+
+static void
+on_control_default_sink_changed (GvcMixerControl *control,
+                                 guint            id,
+                                 GvcApplet       *applet)
+{
+        update_default_sink (applet);
+}
+
+static void
+on_control_default_source_changed (GvcMixerControl *control,
+                                   guint            id,
+                                   GvcApplet       *applet)
+{
+        update_default_source (applet);
+}
+
+static void
+on_control_stream_removed (GvcMixerControl *control,
+                           guint            id,
+                           GvcApplet       *applet)
+{
+        maybe_show_status_icons (applet);
+}
+
+static void
+on_control_stream_added (GvcMixerControl *control,
+                         guint            id,
+                         GvcApplet       *applet)
+{
+        maybe_show_status_icons (applet);
+}
+
+static GObject *
+gvc_applet_constructor (GType                  type,
+                        guint                  n_construct_properties,
+                        GObjectConstructParam *construct_params)
+{
+        GObject   *object;
+        GvcApplet *self;
+
+        object = G_OBJECT_CLASS (gvc_applet_parent_class)->constructor (type, n_construct_properties, 
construct_params);
+
+        self = GVC_APPLET (object);
+
+        self->priv->control = gvc_mixer_control_new ("GNOME Volume Control Applet");
+        g_signal_connect (self->priv->control,
+                          "state-changed",
+                          G_CALLBACK (on_control_state_changed),
+                          self);
+        g_signal_connect (self->priv->control,
+                          "default-sink-changed",
+                          G_CALLBACK (on_control_default_sink_changed),
+                          self);
+        g_signal_connect (self->priv->control,
+                          "default-source-changed",
+                          G_CALLBACK (on_control_default_source_changed),
+                          self);
+        g_signal_connect (self->priv->control,
+                          "stream-added",
+                          G_CALLBACK (on_control_stream_added),
+                          self);
+        g_signal_connect (self->priv->control,
+                          "stream-removed",
+                          G_CALLBACK (on_control_stream_removed),
+                          self);
+
+        gvc_mixer_control_open (self->priv->control);
+
+        return object;
+}
+
+static void
+gvc_applet_class_init (GvcAppletClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gvc_applet_finalize;
+        object_class->dispose = gvc_applet_dispose;
+        object_class->constructor = gvc_applet_constructor;
+
+        g_type_class_add_private (klass, sizeof (GvcAppletPrivate));
+}
+
+static void
+gvc_applet_init (GvcApplet *applet)
+{
+        applet->priv = GVC_APPLET_GET_PRIVATE (applet);
+
+        applet->priv->output_status_icon = gvc_stream_status_icon_new (NULL,
+                                                                       output_icon_names);
+        gvc_stream_status_icon_set_display_name (applet->priv->output_status_icon,
+                                                 _("Output"));
+        gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->output_status_icon),
+                                   _("Sound Output Volume"));
+        applet->priv->input_status_icon = gvc_stream_status_icon_new (NULL,
+                                                                      input_icon_names);
+        gvc_stream_status_icon_set_display_name (applet->priv->input_status_icon,
+                                                 _("Input"));
+        gtk_status_icon_set_title (GTK_STATUS_ICON (applet->priv->input_status_icon),
+                                   _("Microphone Volume"));
+}
+
+static void
+gvc_applet_finalize (GObject *object)
+{
+        GvcApplet *applet;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GVC_IS_APPLET (object));
+
+        applet = GVC_APPLET (object);
+
+        g_return_if_fail (applet->priv != NULL);
+
+
+        G_OBJECT_CLASS (gvc_applet_parent_class)->finalize (object);
+}
+
+GvcApplet *
+gvc_applet_new (void)
+{
+        GObject *applet;
+
+        applet = g_object_new (GVC_TYPE_APPLET, NULL);
+
+        return GVC_APPLET (applet);
+}
diff --git a/gnome-flashback/libsound-applet/gvc-applet.h b/gnome-flashback/libsound-applet/gvc-applet.h
new file mode 100644
index 0000000..d9e0311
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-applet.h
@@ -0,0 +1,55 @@
+/* -*- 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_APPLET_H
+#define __GVC_APPLET_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_APPLET         (gvc_applet_get_type ())
+#define GVC_APPLET(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_APPLET, GvcApplet))
+#define GVC_APPLET_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_APPLET, GvcAppletClass))
+#define GVC_IS_APPLET(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_APPLET))
+#define GVC_IS_APPLET_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_APPLET))
+#define GVC_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_APPLET, GvcAppletClass))
+
+typedef struct GvcAppletPrivate GvcAppletPrivate;
+
+typedef struct
+{
+        GObject            parent;
+        GvcAppletPrivate *priv;
+} GvcApplet;
+
+typedef struct
+{
+        GObjectClass   parent_class;
+} GvcAppletClass;
+
+GType               gvc_applet_get_type            (void);
+
+GvcApplet *         gvc_applet_new                 (void);
+void                gvc_applet_start               (GvcApplet     *applet);
+
+G_END_DECLS
+
+#endif /* __GVC_APPLET_H */
diff --git a/gnome-flashback/libsound-applet/gvc-log.c b/gnome-flashback/libsound-applet/gvc-log.c
new file mode 100644
index 0000000..3e78e79
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-log.c
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 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.
+ *
+ */
+
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#include "gvc-log.h"
+
+
+static int log_levels = G_LOG_LEVEL_CRITICAL |
+                        G_LOG_LEVEL_ERROR    |
+                        G_LOG_LEVEL_WARNING  |
+                        G_LOG_LEVEL_MESSAGE  |
+                        G_LOG_LEVEL_INFO     |
+                        G_LOG_LEVEL_DEBUG;
+
+static void
+gvc_log_default_handler (const gchar    *log_domain,
+                         GLogLevelFlags  log_level,
+                         const gchar    *message,
+                         gpointer        unused_data)
+{
+        if ((log_level & log_levels) == 0)
+                return;
+
+        g_log_default_handler (log_domain, log_level, message, unused_data);
+}
+
+void
+gvc_log_init (void)
+{
+        g_log_set_default_handler (gvc_log_default_handler, NULL);
+}
+
+void
+gvc_log_set_debug (gboolean debug)
+{
+        if (debug) {
+                log_levels |= (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
+                g_debug ("Enabling debugging");
+        } else {
+                log_levels &= ~ (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO);
+        }
+}
diff --git a/gnome-flashback/libsound-applet/gvc-log.h b/gnome-flashback/libsound-applet/gvc-log.h
new file mode 100644
index 0000000..bc1cdd5
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-log.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 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_LOG_H
+#define __GVC_LOG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+void gvc_log_init      (void);
+void gvc_log_set_debug (gboolean debug);
+
+
+G_END_DECLS
+
+#endif /* __GVC_LOG_H */
diff --git a/gnome-flashback/libsound-applet/gvc-stream-status-icon.c 
b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
new file mode 100644
index 0000000..88d5198
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-stream-status-icon.c
@@ -0,0 +1,781 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann
+ *
+ * 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.
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <math.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <pulse/pulseaudio.h>
+
+#include "gvc-mixer-stream.h"
+#include "gvc-channel-bar.h"
+#include "gvc-stream-status-icon.h"
+
+#define GVC_STREAM_STATUS_ICON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), 
GVC_TYPE_STREAM_STATUS_ICON, GvcStreamStatusIconPrivate))
+
+struct GvcStreamStatusIconPrivate
+{
+        char          **icon_names;
+        GvcMixerStream *mixer_stream;
+        GtkWidget      *dock;
+        GtkWidget      *bar;
+        guint           current_icon;
+        char           *display_name;
+        gboolean        thaw;
+};
+
+enum
+{
+        PROP_0,
+        PROP_DISPLAY_NAME,
+        PROP_MIXER_STREAM,
+        PROP_ICON_NAMES,
+};
+
+static void     gvc_stream_status_icon_class_init (GvcStreamStatusIconClass *klass);
+static void     gvc_stream_status_icon_init       (GvcStreamStatusIcon      *stream_status_icon);
+static void     gvc_stream_status_icon_finalize   (GObject                  *object);
+
+G_DEFINE_TYPE (GvcStreamStatusIcon, gvc_stream_status_icon, GTK_TYPE_STATUS_ICON)
+
+static void
+on_adjustment_value_changed (GtkAdjustment *adjustment,
+                             GvcStreamStatusIcon     *icon)
+{
+        gdouble volume;
+
+        if (icon->priv->thaw)
+                return;
+
+        volume = gtk_adjustment_get_value (adjustment);
+
+        /* Only push the volume if it's actually changed */
+        if (gvc_mixer_stream_set_volume(icon->priv->mixer_stream,
+                                    (pa_volume_t) round (volume)) != FALSE) {
+                gvc_mixer_stream_push_volume(icon->priv->mixer_stream);
+        }
+}
+
+static void
+update_dock (GvcStreamStatusIcon *icon)
+{
+        GtkAdjustment *adj;
+        gboolean       is_muted;
+
+        g_return_if_fail (icon);
+
+        adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (icon->priv->bar)));
+
+        icon->priv->thaw = TRUE;
+        gtk_adjustment_set_value (adj,
+                                  gvc_mixer_stream_get_volume (icon->priv->mixer_stream));
+        is_muted = gvc_mixer_stream_get_is_muted (icon->priv->mixer_stream);
+        gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (icon->priv->bar), is_muted);
+        icon->priv->thaw = FALSE;
+}
+
+static gboolean
+popup_dock (GvcStreamStatusIcon *icon,
+            guint                time)
+{
+        GdkRectangle   area;
+        GtkOrientation orientation;
+        GdkDisplay    *display;
+        GdkScreen     *screen;
+        gboolean       res;
+        int            x;
+        int            y;
+        int            monitor_num;
+        GdkRectangle   monitor;
+        GtkRequisition dock_req;
+
+        update_dock (icon);
+
+        screen = gtk_status_icon_get_screen (GTK_STATUS_ICON (icon));
+        res = gtk_status_icon_get_geometry (GTK_STATUS_ICON (icon),
+                                            &screen,
+                                            &area,
+                                            &orientation);
+        if (! res) {
+                g_warning ("Unable to determine geometry of status icon");
+                return FALSE;
+        }
+
+        /* position roughly */
+        gtk_window_set_screen (GTK_WINDOW (icon->priv->dock), screen);
+        gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
+                                         1 - orientation);
+
+        monitor_num = gdk_screen_get_monitor_at_point (screen, area.x, area.y);
+        gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+        gtk_container_foreach (GTK_CONTAINER (icon->priv->dock),
+                               (GtkCallback) gtk_widget_show_all, NULL);
+        gtk_widget_get_preferred_size (icon->priv->dock, &dock_req, NULL);
+
+        if (orientation == GTK_ORIENTATION_VERTICAL) {
+                if (area.x + area.width + dock_req.width <= monitor.x + monitor.width) {
+                        x = area.x + area.width;
+                } else {
+                        x = area.x - dock_req.width;
+                }
+                if (area.y + dock_req.height <= monitor.y + monitor.height) {
+                        y = area.y;
+                } else {
+                        y = monitor.y + monitor.height - dock_req.height;
+                }
+        } else {
+                if (area.y + area.height + dock_req.height <= monitor.y + monitor.height) {
+                        y = area.y + area.height;
+                } else {
+                        y = area.y - dock_req.height;
+                }
+                if (area.x + dock_req.width <= monitor.x + monitor.width) {
+                        x = area.x;
+                } else {
+                        x = monitor.x + monitor.width - dock_req.width;
+                }
+        }
+
+        gtk_window_move (GTK_WINDOW (icon->priv->dock), x, y);
+
+        /* FIXME: without this, the popup window appears as a square
+         * after changing the orientation
+         */
+        gtk_window_resize (GTK_WINDOW (icon->priv->dock), 1, 1);
+
+        gtk_widget_show_all (icon->priv->dock);
+
+        /* grab focus */
+        gtk_grab_add (icon->priv->dock);
+
+        if (gdk_pointer_grab (gtk_widget_get_window (icon->priv->dock), TRUE,
+                              GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
+                              GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK, NULL, NULL,
+                              time)
+            != GDK_GRAB_SUCCESS) {
+                gtk_grab_remove (icon->priv->dock);
+                gtk_widget_hide (icon->priv->dock);
+                return FALSE;
+        }
+
+        if (gdk_keyboard_grab (gtk_widget_get_window (icon->priv->dock), TRUE, time) != GDK_GRAB_SUCCESS) {
+                display = gtk_widget_get_display (icon->priv->dock);
+                gdk_display_pointer_ungrab (display, time);
+                gtk_grab_remove (icon->priv->dock);
+                gtk_widget_hide (icon->priv->dock);
+                return FALSE;
+        }
+
+        gtk_widget_grab_focus (icon->priv->dock);
+
+        return TRUE;
+}
+
+static void
+on_status_icon_activate (GtkStatusIcon       *status_icon,
+                         GvcStreamStatusIcon *icon)
+{
+        popup_dock (icon, GDK_CURRENT_TIME);
+}
+
+static void
+on_menu_mute_toggled (GtkMenuItem         *item,
+                      GvcStreamStatusIcon *icon)
+{
+        gboolean is_muted;
+        is_muted = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item));
+        gvc_channel_bar_set_is_muted (GVC_CHANNEL_BAR (icon->priv->bar), is_muted);
+}
+
+static void
+on_menu_activate_open_volume_control (GtkMenuItem *item,
+                                      GvcStreamStatusIcon   *icon)
+{
+        GAppInfo *app;
+        GdkAppLaunchContext *context;
+        GError *error;
+
+        error = NULL;
+        context = gdk_app_launch_context_new ();
+        app = g_app_info_create_from_commandline ("gnome-control-center sound", "Sound preferences", 0, 
&error);
+        if (app)
+                g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (context), &error);
+
+        if (error != NULL) {
+                GtkWidget *dialog;
+
+                dialog = gtk_message_dialog_new (NULL,
+                                                 0,
+                                                 GTK_MESSAGE_ERROR,
+                                                 GTK_BUTTONS_CLOSE,
+                                                 _("Failed to start Sound Preferences: %s"),
+                                                 error->message);
+                g_signal_connect (dialog,
+                                  "response",
+                                  G_CALLBACK (gtk_widget_destroy),
+                                  NULL);
+                gtk_widget_show (dialog);
+                g_error_free (error);
+        }
+
+        g_object_unref (context);
+        g_object_unref (app);
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon       *status_icon,
+                           guint                button,
+                           guint                activate_time,
+                           GvcStreamStatusIcon *icon)
+{
+        GtkWidget *menu;
+        GtkWidget *item;
+        GtkWidget *image;
+
+        menu = gtk_menu_new ();
+
+        item = gtk_check_menu_item_new_with_mnemonic (_("_Mute"));
+        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
+                                        gvc_mixer_stream_get_is_muted (icon->priv->mixer_stream));
+        g_signal_connect (item,
+                          "toggled",
+                          G_CALLBACK (on_menu_mute_toggled),
+                          icon);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+        item = gtk_image_menu_item_new_with_mnemonic (_("_Sound Preferences"));
+        image = gtk_image_new_from_icon_name ("multimedia-volume-control",
+                                              GTK_ICON_SIZE_MENU);
+        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+        g_signal_connect (item,
+                          "activate",
+                          G_CALLBACK (on_menu_activate_open_volume_control),
+                          icon);
+        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+        gtk_widget_show_all (menu);
+        gtk_menu_popup (GTK_MENU (menu),
+                        NULL,
+                        NULL,
+                        gtk_status_icon_position_menu,
+                        status_icon,
+                        button,
+                        activate_time);
+}
+
+static gboolean
+on_status_icon_scroll_event (GtkStatusIcon       *status_icon,
+                             GdkEventScroll      *event,
+                             GvcStreamStatusIcon *icon)
+{
+        return gvc_channel_bar_scroll (GVC_CHANNEL_BAR (icon->priv->bar), event);
+}
+
+static void
+gvc_icon_release_grab (GvcStreamStatusIcon *icon,
+                         GdkEventButton    *event)
+{
+        GdkDisplay     *display;
+
+        /* ungrab focus */
+        display = gtk_widget_get_display (GTK_WIDGET (icon->priv->dock));
+        gdk_display_keyboard_ungrab (display, event->time);
+        gdk_display_pointer_ungrab (display, event->time);
+        gtk_grab_remove (icon->priv->dock);
+
+        /* hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+static gboolean
+on_dock_button_press (GtkWidget      *widget,
+                      GdkEventButton *event,
+                      GvcStreamStatusIcon      *icon)
+{
+        if (event->type == GDK_BUTTON_PRESS) {
+                gvc_icon_release_grab (icon, event);
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+static void
+popdown_dock (GvcStreamStatusIcon *icon)
+{
+        GdkDisplay *display;
+
+        /* ungrab focus */
+        display = gtk_widget_get_display (icon->priv->dock);
+        gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
+        gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
+        gtk_grab_remove (icon->priv->dock);
+
+        /* hide again */
+        gtk_widget_hide (icon->priv->dock);
+}
+
+static gboolean
+on_dock_key_release (GtkWidget           *widget,
+                     GdkEventKey         *event,
+                     GvcStreamStatusIcon *icon)
+{
+        if (event->keyval == GDK_KEY_Escape) {
+                popdown_dock (icon);
+                return TRUE;
+        }
+
+#if 0
+        if (!gtk_bindings_activate_event (GTK_OBJECT (widget), event)) {
+                /* The popup hasn't managed the event, pass onto the button */
+                gtk_bindings_activate_event (GTK_OBJECT (user_data), event);
+        }
+#endif
+        return TRUE;
+}
+
+static gboolean
+on_dock_scroll_event (GtkWidget           *widget,
+                      GdkEventScroll      *event,
+                      GvcStreamStatusIcon *icon)
+{
+        /* Forward event to the status icon */
+        on_status_icon_scroll_event (NULL, event, icon);
+        return TRUE;
+}
+
+static void
+update_icon (GvcStreamStatusIcon *icon)
+{
+        guint    volume;
+        gboolean is_muted;
+        guint    n;
+        char    *markup;
+        gboolean can_decibel;
+        gdouble  db;
+
+        if (icon->priv->mixer_stream == NULL) {
+                return;
+        }
+
+        volume = gvc_mixer_stream_get_volume (icon->priv->mixer_stream);
+        is_muted = gvc_mixer_stream_get_is_muted (icon->priv->mixer_stream);
+        db = gvc_mixer_stream_get_decibel (icon->priv->mixer_stream);
+        can_decibel = gvc_mixer_stream_get_can_decibel (icon->priv->mixer_stream);
+
+        /* select image */
+        if (volume == 0 || is_muted) {
+                n = 0;
+        } else {
+                n = 3 * volume / PA_VOLUME_NORM + 1;
+                if (n < 1) {
+                        n = 1;
+                } else if (n > 3) {
+                        n = 3;
+                }
+        }
+
+        /* apparently status icon will reset icon even if
+         * if doesn't change */
+        if (icon->priv->current_icon != n) {
+                gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (icon),
+                                                    icon->priv->icon_names [n]);
+                icon->priv->current_icon = n;
+        }
+
+
+        if (is_muted) {
+                markup = g_strdup_printf (
+                                          "<b>%s: %s</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          _("Muted"),
+                                          gvc_mixer_stream_get_description (icon->priv->mixer_stream));
+        } else if (can_decibel && (db > PA_DECIBEL_MININFTY)) {
+                markup = g_strdup_printf (
+                                          "<b>%s: %.0f%%</b>\n<small>%0.2f dB\n%s</small>",
+                                          icon->priv->display_name,
+                                          100 * (float)volume / PA_VOLUME_NORM,
+                                          db,
+                                          gvc_mixer_stream_get_description (icon->priv->mixer_stream));
+        } else if (can_decibel) {
+                markup = g_strdup_printf (
+                                          "<b>%s: %.0f%%</b>\n<small>-&#8734; dB\n%s</small>",
+                                          icon->priv->display_name,
+                                          100 * (float)volume / PA_VOLUME_NORM,
+                                          gvc_mixer_stream_get_description (icon->priv->mixer_stream));
+        } else {
+                markup = g_strdup_printf (
+                                          "<b>%s: %.0f%%</b>\n<small>%s</small>",
+                                          icon->priv->display_name,
+                                          100 * (float)volume / PA_VOLUME_NORM,
+                                          gvc_mixer_stream_get_description (icon->priv->mixer_stream));
+        }
+        gtk_status_icon_set_tooltip_markup (GTK_STATUS_ICON (icon), markup);
+        g_free (markup);
+}
+
+void
+gvc_stream_status_icon_set_icon_names (GvcStreamStatusIcon  *icon,
+                                       const char          **names)
+{
+        g_return_if_fail (GVC_IS_STREAM_STATUS_ICON (icon));
+
+        g_strfreev (icon->priv->icon_names);
+        icon->priv->icon_names = g_strdupv ((char **)names);
+        update_icon (icon);
+        g_object_notify (G_OBJECT (icon), "icon-names");
+}
+
+static void
+on_stream_volume_notify (GObject             *object,
+                         GParamSpec          *pspec,
+                         GvcStreamStatusIcon *icon)
+{
+        update_icon (icon);
+        update_dock (icon);
+}
+
+static void
+on_stream_is_muted_notify (GObject             *object,
+                           GParamSpec          *pspec,
+                           GvcStreamStatusIcon *icon)
+{
+        update_icon (icon);
+        update_dock (icon);
+}
+
+void
+gvc_stream_status_icon_set_display_name (GvcStreamStatusIcon *icon,
+                                         const char          *name)
+{
+        g_return_if_fail (GVC_STREAM_STATUS_ICON (icon));
+
+        g_free (icon->priv->display_name);
+        icon->priv->display_name = g_strdup (name);
+        update_icon (icon);
+        g_object_notify (G_OBJECT (icon), "display-name");
+}
+
+void
+gvc_stream_status_icon_set_mixer_stream (GvcStreamStatusIcon *icon,
+                                         GvcMixerStream      *stream)
+{
+        g_return_if_fail (GVC_STREAM_STATUS_ICON (icon));
+
+        if (stream != NULL) {
+                g_object_ref (stream);
+        }
+
+        if (icon->priv->mixer_stream != NULL) {
+                g_signal_handlers_disconnect_by_func (icon->priv->mixer_stream,
+                                                      G_CALLBACK (on_stream_volume_notify),
+                                                      icon);
+                g_signal_handlers_disconnect_by_func (icon->priv->mixer_stream,
+                                                      G_CALLBACK (on_stream_is_muted_notify),
+                                                      icon);
+                g_object_unref (icon->priv->mixer_stream);
+                icon->priv->mixer_stream = NULL;
+        }
+
+        icon->priv->mixer_stream = stream;
+
+        if (icon->priv->mixer_stream != NULL) {
+                GtkAdjustment *adj;
+
+                g_object_ref (icon->priv->mixer_stream);
+
+                icon->priv->thaw = TRUE;
+                adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (icon->priv->bar)));
+                gtk_adjustment_set_value (adj,
+                                          gvc_mixer_stream_get_volume (icon->priv->mixer_stream));
+                icon->priv->thaw = FALSE;
+
+                g_signal_connect (icon->priv->mixer_stream,
+                                  "notify::volume",
+                                  G_CALLBACK (on_stream_volume_notify),
+                                  icon);
+                g_signal_connect (icon->priv->mixer_stream,
+                                  "notify::is-muted",
+                                  G_CALLBACK (on_stream_is_muted_notify),
+                                  icon);
+        }
+
+        update_icon (icon);
+
+        g_object_notify (G_OBJECT (icon), "mixer-stream");
+}
+
+static void
+gvc_stream_status_icon_set_property (GObject       *object,
+                                     guint          prop_id,
+                                     const GValue  *value,
+                                     GParamSpec    *pspec)
+{
+        GvcStreamStatusIcon *self = GVC_STREAM_STATUS_ICON (object);
+
+        switch (prop_id) {
+        case PROP_MIXER_STREAM:
+                gvc_stream_status_icon_set_mixer_stream (self, g_value_get_object (value));
+                break;
+        case PROP_DISPLAY_NAME:
+                gvc_stream_status_icon_set_display_name (self, g_value_get_string (value));
+                break;
+        case PROP_ICON_NAMES:
+                gvc_stream_status_icon_set_icon_names (self, g_value_get_boxed (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gvc_stream_status_icon_get_property (GObject     *object,
+                                     guint        prop_id,
+                                     GValue      *value,
+                                     GParamSpec  *pspec)
+{
+        GvcStreamStatusIcon *self = GVC_STREAM_STATUS_ICON (object);
+        GvcStreamStatusIconPrivate *priv = self->priv;
+
+        switch (prop_id) {
+        case PROP_MIXER_STREAM:
+                g_value_set_object (value, priv->mixer_stream);
+                break;
+        case PROP_DISPLAY_NAME:
+                g_value_set_string (value, priv->display_name);
+                break;
+        case PROP_ICON_NAMES:
+                g_value_set_boxed (value, priv->icon_names);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+on_bar_is_muted_notify (GObject             *object,
+                        GParamSpec          *pspec,
+                        GvcStreamStatusIcon *icon)
+{
+        gboolean is_muted;
+
+        is_muted = gvc_channel_bar_get_is_muted (GVC_CHANNEL_BAR (object));
+
+        if (gvc_mixer_stream_get_is_muted (icon->priv->mixer_stream) != is_muted) {
+                /* Update the stream before pushing the change */
+                gvc_mixer_stream_set_is_muted (icon->priv->mixer_stream, is_muted);
+                gvc_mixer_stream_change_is_muted (icon->priv->mixer_stream,
+                                                  is_muted);
+        }
+}
+
+static GObject *
+gvc_stream_status_icon_constructor (GType                  type,
+                                    guint                  n_construct_properties,
+                                    GObjectConstructParam *construct_params)
+{
+        GObject             *object;
+        GvcStreamStatusIcon *icon;
+        GtkWidget           *frame;
+        GtkWidget           *box;
+        GtkAdjustment       *adj;
+
+        object = G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->constructor (type, 
n_construct_properties, construct_params);
+
+        icon = GVC_STREAM_STATUS_ICON (object);
+
+        gtk_status_icon_set_from_icon_name (GTK_STATUS_ICON (icon),
+                                            icon->priv->icon_names[0]);
+
+        /* window */
+        icon->priv->dock = gtk_window_new (GTK_WINDOW_POPUP);
+        gtk_widget_set_name (icon->priv->dock, "gvc-stream-status-icon-popup-window");
+        g_signal_connect (icon->priv->dock,
+                          "button-press-event",
+                          G_CALLBACK (on_dock_button_press),
+                          icon);
+        g_signal_connect (icon->priv->dock,
+                          "key-release-event",
+                          G_CALLBACK (on_dock_key_release),
+                          icon);
+        g_signal_connect (icon->priv->dock,
+                          "scroll-event",
+                          G_CALLBACK (on_dock_scroll_event),
+                          icon);
+
+        gtk_window_set_decorated (GTK_WINDOW (icon->priv->dock), FALSE);
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+        gtk_container_add (GTK_CONTAINER (icon->priv->dock), frame);
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+        gtk_container_set_border_width (GTK_CONTAINER (box), 2);
+        gtk_container_add (GTK_CONTAINER (frame), box);
+
+        icon->priv->bar = gvc_channel_bar_new ();
+        gvc_channel_bar_set_orientation (GVC_CHANNEL_BAR (icon->priv->bar),
+                                         GTK_ORIENTATION_VERTICAL);
+
+        gtk_box_pack_start (GTK_BOX (box), icon->priv->bar, TRUE, FALSE, 0);
+        g_signal_connect (icon->priv->bar,
+                          "notify::is-muted",
+                          G_CALLBACK (on_bar_is_muted_notify),
+                          icon);
+
+        adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (icon->priv->bar)));
+        g_signal_connect (adj,
+                          "value-changed",
+                          G_CALLBACK (on_adjustment_value_changed),
+                          icon);
+
+        return object;
+}
+
+static void
+gvc_stream_status_icon_dispose (GObject *object)
+{
+        GvcStreamStatusIcon *icon = GVC_STREAM_STATUS_ICON (object);
+
+        if (icon->priv->dock != NULL) {
+                gtk_widget_destroy (icon->priv->dock);
+                icon->priv->dock = NULL;
+        }
+
+        if (icon->priv->mixer_stream != NULL) {
+                g_object_unref (icon->priv->mixer_stream);
+                icon->priv->mixer_stream = NULL;
+        }
+
+        G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->dispose (object);
+}
+
+static void
+gvc_stream_status_icon_class_init (GvcStreamStatusIconClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->constructor = gvc_stream_status_icon_constructor;
+        object_class->finalize = gvc_stream_status_icon_finalize;
+        object_class->dispose = gvc_stream_status_icon_dispose;
+        object_class->set_property = gvc_stream_status_icon_set_property;
+        object_class->get_property = gvc_stream_status_icon_get_property;
+
+        g_object_class_install_property (object_class,
+                                         PROP_MIXER_STREAM,
+                                         g_param_spec_object ("mixer-stream",
+                                                              "mixer stream",
+                                                              "mixer stream",
+                                                              GVC_TYPE_MIXER_STREAM,
+                                                              G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_DISPLAY_NAME,
+                                         g_param_spec_string ("display-name",
+                                                              "Display Name",
+                                                              "Name to display for this stream",
+                                                              NULL,
+                                                              G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_ICON_NAMES,
+                                         g_param_spec_boxed ("icon-names",
+                                                             "Icon Names",
+                                                             "Name of icon to display for this stream",
+                                                              G_TYPE_STRV,
+                                                              G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+
+        g_type_class_add_private (klass, sizeof (GvcStreamStatusIconPrivate));
+}
+
+static void
+on_status_icon_visible_notify (GvcStreamStatusIcon *icon)
+{
+        gboolean visible;
+
+        g_object_get (icon, "visible", &visible, NULL);
+        if (! visible) {
+                if (icon->priv->dock != NULL) {
+                        gtk_widget_hide (icon->priv->dock);
+                }
+        }
+}
+
+static void
+gvc_stream_status_icon_init (GvcStreamStatusIcon *icon)
+{
+        icon->priv = GVC_STREAM_STATUS_ICON_GET_PRIVATE (icon);
+
+        g_signal_connect (icon,
+                          "activate",
+                          G_CALLBACK (on_status_icon_activate),
+                          icon);
+        g_signal_connect (icon,
+                          "popup-menu",
+                          G_CALLBACK (on_status_icon_popup_menu),
+                          icon);
+        g_signal_connect (icon,
+                          "scroll-event",
+                          G_CALLBACK (on_status_icon_scroll_event),
+                          icon);
+        g_signal_connect (icon,
+                          "notify::visible",
+                          G_CALLBACK (on_status_icon_visible_notify),
+                          NULL);
+
+        icon->priv->thaw = FALSE;
+}
+
+static void
+gvc_stream_status_icon_finalize (GObject *object)
+{
+        GvcStreamStatusIcon *stream_status_icon;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GVC_IS_STREAM_STATUS_ICON (object));
+
+        stream_status_icon = GVC_STREAM_STATUS_ICON (object);
+
+        g_return_if_fail (stream_status_icon->priv != NULL);
+
+        g_strfreev (stream_status_icon->priv->icon_names);
+
+        G_OBJECT_CLASS (gvc_stream_status_icon_parent_class)->finalize (object);
+}
+
+GvcStreamStatusIcon *
+gvc_stream_status_icon_new (GvcMixerStream *stream,
+                            const char    **icon_names)
+{
+        GObject *icon;
+        icon = g_object_new (GVC_TYPE_STREAM_STATUS_ICON,
+                             "mixer-stream", stream,
+                             "icon-names", icon_names,
+                             NULL);
+        return GVC_STREAM_STATUS_ICON (icon);
+}
diff --git a/gnome-flashback/libsound-applet/gvc-stream-status-icon.h 
b/gnome-flashback/libsound-applet/gvc-stream-status-icon.h
new file mode 100644
index 0000000..55887f3
--- /dev/null
+++ b/gnome-flashback/libsound-applet/gvc-stream-status-icon.h
@@ -0,0 +1,63 @@
+/* -*- 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_STREAM_STATUS_ICON_H
+#define __GVC_STREAM_STATUS_ICON_H
+
+#include <glib-object.h>
+#include "gvc-mixer-stream.h"
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_STREAM_STATUS_ICON         (gvc_stream_status_icon_get_type ())
+#define GVC_STREAM_STATUS_ICON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_STREAM_STATUS_ICON, 
GvcStreamStatusIcon))
+#define GVC_STREAM_STATUS_ICON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_STREAM_STATUS_ICON, 
GvcStreamStatusIconClass))
+#define GVC_IS_STREAM_STATUS_ICON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_STREAM_STATUS_ICON))
+#define GVC_IS_STREAM_STATUS_ICON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_STREAM_STATUS_ICON))
+#define GVC_STREAM_STATUS_ICON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_STREAM_STATUS_ICON, 
GvcStreamStatusIconClass))
+
+typedef struct GvcStreamStatusIconPrivate GvcStreamStatusIconPrivate;
+
+typedef struct
+{
+        GtkStatusIcon               parent;
+        GvcStreamStatusIconPrivate *priv;
+} GvcStreamStatusIcon;
+
+typedef struct
+{
+        GtkStatusIconClass          parent_class;
+} GvcStreamStatusIconClass;
+
+GType                 gvc_stream_status_icon_get_type            (void);
+
+GvcStreamStatusIcon * gvc_stream_status_icon_new                 (GvcMixerStream      *stream,
+                                                                  const char         **icon_names);
+
+void                  gvc_stream_status_icon_set_icon_names      (GvcStreamStatusIcon *icon,
+                                                                  const char         **icon_names);
+void                  gvc_stream_status_icon_set_display_name    (GvcStreamStatusIcon *icon,
+                                                                  const char          *display_name);
+void                  gvc_stream_status_icon_set_mixer_stream    (GvcStreamStatusIcon *icon,
+                                                                  GvcMixerStream      *stream);
+
+G_END_DECLS
+
+#endif /* __GVC_STREAM_STATUS_ICON_H */


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