gnome-media r4086 - in trunk/gnome-volume-control: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4086 - in trunk/gnome-volume-control: . src
- Date: Fri, 12 Dec 2008 04:27:35 +0000 (UTC)
Author: mccann
Date: Fri Dec 12 04:27:35 2008
New Revision: 4086
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4086&view=rev
Log:
2008-12-11 William Jon McCann <jmccann redhat com>
* src/Makefile.am:
* src/gvc-applet.c (maybe_show_status_icons), (gvc_applet_start),
(on_control_stream_removed), (on_control_stream_added),
(gvc_applet_constructor):
* src/gvc-mixer-control.c (gvc_mixer_control_get_source_outputs),
(update_source), (update_sink_input), (update_source_output),
(update_event_role_stream):
* src/gvc-mixer-control.h:
* src/gvc-mixer-source-output.c
(gvc_mixer_source_output_change_volume),
(gvc_mixer_source_output_change_is_muted),
(gvc_mixer_source_output_constructor),
(gvc_mixer_source_output_class_init),
(gvc_mixer_source_output_init), (gvc_mixer_source_output_finalize),
(gvc_mixer_source_output_new):
* src/gvc-mixer-source-output.h:
* src/gvc-stream-status-icon.c (update_icon),
(on_status_icon_visible_notify), (gvc_stream_status_icon_init):
Show/hide input level status icon based on presence of
a "source output" stream.
Added:
trunk/gnome-volume-control/src/gvc-mixer-source-output.c
trunk/gnome-volume-control/src/gvc-mixer-source-output.h
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/Makefile.am
trunk/gnome-volume-control/src/gvc-applet.c
trunk/gnome-volume-control/src/gvc-mixer-control.c
trunk/gnome-volume-control/src/gvc-mixer-control.h
trunk/gnome-volume-control/src/gvc-stream-status-icon.c
Modified: trunk/gnome-volume-control/src/Makefile.am
==============================================================================
--- trunk/gnome-volume-control/src/Makefile.am (original)
+++ trunk/gnome-volume-control/src/Makefile.am Fri Dec 12 04:27:35 2008
@@ -30,6 +30,8 @@
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 \
@@ -57,6 +59,8 @@
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 \
Modified: trunk/gnome-volume-control/src/gvc-applet.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-applet.c (original)
+++ trunk/gnome-volume-control/src/gvc-applet.c Fri Dec 12 04:27:35 2008
@@ -68,12 +68,36 @@
G_DEFINE_TYPE (GvcApplet, gvc_applet, G_TYPE_OBJECT)
+static void
+maybe_show_status_icons (GvcApplet *applet)
+{
+ gboolean show;
+ GvcMixerStream *stream;
+ GSList *source_outputs;
+
+ 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) {
+ show = TRUE;
+ }
+ gtk_status_icon_set_visible (GTK_STATUS_ICON (applet->priv->input_status_icon), show);
+}
+
void
gvc_applet_start (GvcApplet *applet)
{
g_return_if_fail (GVC_IS_APPLET (applet));
- //maybe_show_status_icon (applet);
+ maybe_show_status_icons (applet);
}
static void
@@ -141,6 +165,22 @@
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,
@@ -166,6 +206,14 @@
"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);
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.c Fri Dec 12 04:27:35 2008
@@ -37,6 +37,7 @@
#include "gvc-mixer-sink.h"
#include "gvc-mixer-source.h"
#include "gvc-mixer-sink-input.h"
+#include "gvc-mixer-source-output.h"
#include "gvc-mixer-event-role.h"
#define GVC_MIXER_CONTROL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_CONTROL, GvcMixerControlPrivate))
@@ -277,6 +278,20 @@
return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
}
+GSList *
+gvc_mixer_control_get_source_outputs (GvcMixerControl *control)
+{
+ GSList *retval;
+
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), NULL);
+
+ retval = NULL;
+ g_hash_table_foreach (control->priv->source_outputs,
+ listify_hash_values_hfunc,
+ &retval);
+ return g_slist_sort (retval, (GCompareFunc) gvc_stream_collate);
+}
+
static void
dec_outstanding (GvcMixerControl *control)
{
@@ -532,7 +547,7 @@
GvcMixerStream *stream;
gboolean is_new;
pa_volume_t avg_volume;
-#if 0
+#if 1
g_debug ("Updating source: index=%u name='%s' description='%s'",
info->index,
info->name,
@@ -634,7 +649,7 @@
pa_volume_t avg_volume;
const char *name;
-#if 1
+#if 0
g_debug ("Updating sink input: index=%u name='%s' client=%u sink=%u",
info->index,
info->name,
@@ -676,11 +691,41 @@
update_source_output (GvcMixerControl *control,
const pa_source_output_info *info)
{
-#if 0
- g_debug ("Updating source output: index=%u name='%s'",
+ GvcMixerStream *stream;
+ gboolean is_new;
+ const char *name;
+
+#if 1
+ g_debug ("Updating source output: index=%u name='%s' client=%u source=%u",
info->index,
- info->name);
+ info->name,
+ info->client,
+ info->source);
#endif
+
+ is_new = FALSE;
+ stream = g_hash_table_lookup (control->priv->source_outputs,
+ GUINT_TO_POINTER (info->index));
+ if (stream == NULL) {
+ stream = gvc_mixer_source_output_new (control->priv->pa_context,
+ info->index,
+ info->channel_map.channels);
+ is_new = TRUE;
+ }
+
+ name = (const char *)g_hash_table_lookup (control->priv->clients,
+ GUINT_TO_POINTER (info->client));
+
+ gvc_mixer_stream_set_name (stream, name);
+ gvc_mixer_stream_set_description (stream, info->name);
+ set_icon_name_from_proplist (stream, info->proplist, "applications-multimedia");
+
+ if (is_new) {
+ g_hash_table_insert (control->priv->source_outputs,
+ GUINT_TO_POINTER (info->index),
+ g_object_ref (stream));
+ add_stream (control, stream);
+ }
}
static void
@@ -857,7 +902,7 @@
return;
}
-#if 1
+#if 0
g_debug ("Updating event role: name='%s' device='%s'",
info->name,
info->device);
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.h (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.h Fri Dec 12 04:27:35 2008
@@ -68,6 +68,7 @@
GSList * gvc_mixer_control_get_sinks (GvcMixerControl *control);
GSList * gvc_mixer_control_get_sources (GvcMixerControl *control);
GSList * gvc_mixer_control_get_sink_inputs (GvcMixerControl *control);
+GSList * gvc_mixer_control_get_source_outputs (GvcMixerControl *control);
GvcMixerStream * gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
guint id);
Added: trunk/gnome-volume-control/src/gvc-mixer-source-output.c
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-mixer-source-output.c Fri Dec 12 04:27:35 2008
@@ -0,0 +1,128 @@
+/* -*- 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 <glib.h>
+#include <glib/gi18n.h>
+
+#include <pulse/pulseaudio.h>
+
+#include "gvc-mixer-source-output.h"
+
+#define GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputPrivate))
+
+struct GvcMixerSourceOutputPrivate
+{
+ gpointer dummy;
+};
+
+static void gvc_mixer_source_output_class_init (GvcMixerSourceOutputClass *klass);
+static void gvc_mixer_source_output_init (GvcMixerSourceOutput *mixer_source_output);
+static void gvc_mixer_source_output_finalize (GObject *object);
+
+G_DEFINE_TYPE (GvcMixerSourceOutput, gvc_mixer_source_output, GVC_TYPE_MIXER_STREAM)
+
+static gboolean
+gvc_mixer_source_output_change_volume (GvcMixerStream *stream,
+ guint volume)
+{
+ /* FIXME: */
+ return TRUE;
+}
+
+static gboolean
+gvc_mixer_source_output_change_is_muted (GvcMixerStream *stream,
+ gboolean is_muted)
+{
+ /* FIXME: */
+ return TRUE;
+}
+
+static GObject *
+gvc_mixer_source_output_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ GvcMixerSourceOutput *self;
+
+ object = G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->constructor (type, n_construct_properties, construct_params);
+
+ self = GVC_MIXER_SOURCE_OUTPUT (object);
+
+ 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->change_volume = gvc_mixer_source_output_change_volume;
+ stream_class->change_is_muted = gvc_mixer_source_output_change_is_muted;
+
+ g_type_class_add_private (klass, sizeof (GvcMixerSourceOutputPrivate));
+}
+
+static void
+gvc_mixer_source_output_init (GvcMixerSourceOutput *source_output)
+{
+ source_output->priv = GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE (source_output);
+
+}
+
+static void
+gvc_mixer_source_output_finalize (GObject *object)
+{
+ GvcMixerSourceOutput *mixer_source_output;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GVC_IS_MIXER_SOURCE_OUTPUT (object));
+
+ mixer_source_output = GVC_MIXER_SOURCE_OUTPUT (object);
+
+ g_return_if_fail (mixer_source_output->priv != NULL);
+ G_OBJECT_CLASS (gvc_mixer_source_output_parent_class)->finalize (object);
+}
+
+GvcMixerStream *
+gvc_mixer_source_output_new (pa_context *context,
+ guint index,
+ guint num_channels)
+{
+ GObject *object;
+
+ object = g_object_new (GVC_TYPE_MIXER_SOURCE_OUTPUT,
+ "pa-context", context,
+ "index", index,
+ "num-channels", num_channels,
+ NULL);
+
+ return GVC_MIXER_STREAM (object);
+}
Added: trunk/gnome-volume-control/src/gvc-mixer-source-output.h
==============================================================================
--- (empty file)
+++ trunk/gnome-volume-control/src/gvc-mixer-source-output.h Fri Dec 12 04:27:35 2008
@@ -0,0 +1,57 @@
+/* -*- 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_SOURCE_OUTPUT_H
+#define __GVC_MIXER_SOURCE_OUTPUT_H
+
+#include <glib-object.h>
+#include "gvc-mixer-stream.h"
+
+G_BEGIN_DECLS
+
+#define GVC_TYPE_MIXER_SOURCE_OUTPUT (gvc_mixer_source_output_get_type ())
+#define GVC_MIXER_SOURCE_OUTPUT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutput))
+#define GVC_MIXER_SOURCE_OUTPUT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputClass))
+#define GVC_IS_MIXER_SOURCE_OUTPUT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT))
+#define GVC_IS_MIXER_SOURCE_OUTPUT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_MIXER_SOURCE_OUTPUT))
+#define GVC_MIXER_SOURCE_OUTPUT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputClass))
+
+typedef struct GvcMixerSourceOutputPrivate GvcMixerSourceOutputPrivate;
+
+typedef struct
+{
+ GvcMixerStream parent;
+ GvcMixerSourceOutputPrivate *priv;
+} GvcMixerSourceOutput;
+
+typedef struct
+{
+ GvcMixerStreamClass parent_class;
+} GvcMixerSourceOutputClass;
+
+GType gvc_mixer_source_output_get_type (void);
+
+GvcMixerStream * gvc_mixer_source_output_new (pa_context *context,
+ guint index,
+ guint num_channels);
+
+G_END_DECLS
+
+#endif /* __GVC_MIXER_SOURCE_OUTPUT_H */
Modified: trunk/gnome-volume-control/src/gvc-stream-status-icon.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-stream-status-icon.c (original)
+++ trunk/gnome-volume-control/src/gvc-stream-status-icon.c Fri Dec 12 04:27:35 2008
@@ -355,24 +355,6 @@
}
static void
-maybe_show_status_icon (GvcStreamStatusIcon *icon)
-{
- gboolean show;
-
- show = TRUE;
-
- if (icon->priv->mixer_stream == NULL) {
- show = FALSE;
- }
-
- if (icon->priv->dock != NULL) {
- gtk_widget_hide (icon->priv->dock);
- }
-
- gtk_status_icon_set_visible (GTK_STATUS_ICON (icon), show);
-}
-
-static void
update_icon (GvcStreamStatusIcon *icon)
{
guint volume;
@@ -380,8 +362,6 @@
guint n;
char *markup;
- maybe_show_status_icon (icon);
-
if (icon->priv->mixer_stream == NULL) {
return;
}
@@ -691,6 +671,19 @@
}
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);
@@ -709,7 +702,10 @@
G_CALLBACK (on_status_icon_scroll_event),
icon);
#endif
-
+ g_signal_connect (icon,
+ "notify::visible",
+ G_CALLBACK (on_status_icon_visible_notify),
+ NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]