diff options
-rw-r--r-- | mate-volume-control/src/Makefile.am | 18 | ||||
-rw-r--r-- | mate-volume-control/src/dialog-main.c | 2 | ||||
-rw-r--r-- | mate-volume-control/src/gvc-channel-map.c | 245 | ||||
-rw-r--r-- | mate-volume-control/src/gvc-channel-map.h | 81 | ||||
-rw-r--r-- | mate-volume-control/src/gvc-mixer-dialog.c | 86 | ||||
-rw-r--r-- | mate-volume-control/src/gvc-mixer-dialog.h | 2 | ||||
-rw-r--r-- | mate-volume-control/src/gvc-speaker-test.c | 9 |
7 files changed, 47 insertions, 396 deletions
diff --git a/mate-volume-control/src/Makefile.am b/mate-volume-control/src/Makefile.am index 939814d..8dd1b93 100644 --- a/mate-volume-control/src/Makefile.am +++ b/mate-volume-control/src/Makefile.am @@ -19,24 +19,6 @@ AM_CPPFLAGS = \ noinst_LTLIBRARIES = libmatevolumecontrol.la libmatevolumecontrol_la_SOURCES = \ - gvc-mixer-card.h \ - gvc-mixer-card.c \ - gvc-mixer-stream.h \ - gvc-mixer-stream.c \ - gvc-channel-map.h \ - gvc-channel-map.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-channel-bar.h \ gvc-channel-bar.c \ mvc-helpers.c \ diff --git a/mate-volume-control/src/dialog-main.c b/mate-volume-control/src/dialog-main.c index f1d5bf4..2b139b1 100644 --- a/mate-volume-control/src/dialog-main.c +++ b/mate-volume-control/src/dialog-main.c @@ -30,7 +30,7 @@ #include "gvc-mixer-dialog.h" -#define DIALOG_POPUP_TIMEOUT 1 +#define DIALOG_POPUP_TIMEOUT 3 static guint popup_id = 0; static gboolean show_version = FALSE; diff --git a/mate-volume-control/src/gvc-channel-map.c b/mate-volume-control/src/gvc-channel-map.c deleted file mode 100644 index 38dad1c..0000000 --- a/mate-volume-control/src/gvc-channel-map.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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-channel-map.h" - -#define GVC_CHANNEL_MAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapPrivate)) - -struct GvcChannelMapPrivate -{ - pa_channel_map pa_map; - gboolean pa_volume_is_set; - pa_cvolume pa_volume; - gdouble extern_volume[NUM_TYPES]; /* volume, balance, fade, lfe */ - gboolean can_balance; - gboolean can_fade; -}; - -enum { - VOLUME_CHANGED, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = { 0, }; - -static void gvc_channel_map_class_init (GvcChannelMapClass *klass); -static void gvc_channel_map_init (GvcChannelMap *channel_map); -static void gvc_channel_map_finalize (GObject *object); - -G_DEFINE_TYPE (GvcChannelMap, gvc_channel_map, G_TYPE_OBJECT) - -guint -gvc_channel_map_get_num_channels (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), 0); - - if (!pa_channel_map_valid(&map->priv->pa_map)) - return 0; - - return map->priv->pa_map.channels; -} - -const gdouble * -gvc_channel_map_get_volume (GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL); - - if (!pa_channel_map_valid(&map->priv->pa_map)) - return NULL; - - map->priv->extern_volume[VOLUME] = (gdouble) pa_cvolume_max (&map->priv->pa_volume); - if (gvc_channel_map_can_balance (map)) - map->priv->extern_volume[BALANCE] = (gdouble) pa_cvolume_get_balance (&map->priv->pa_volume, &map->priv->pa_map); - else - map->priv->extern_volume[BALANCE] = 0; - if (gvc_channel_map_can_fade (map)) - map->priv->extern_volume[FADE] = (gdouble) pa_cvolume_get_fade (&map->priv->pa_volume, &map->priv->pa_map); - else - map->priv->extern_volume[FADE] = 0; - if (gvc_channel_map_has_lfe (map)) - map->priv->extern_volume[LFE] = (gdouble) pa_cvolume_get_position (&map->priv->pa_volume, &map->priv->pa_map, PA_CHANNEL_POSITION_LFE); - else - map->priv->extern_volume[LFE] = 0; - - return map->priv->extern_volume; -} - -gboolean -gvc_channel_map_can_balance (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE); - - return map->priv->can_balance; -} - -gboolean -gvc_channel_map_can_fade (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE); - - return map->priv->can_fade; -} - -const char * -gvc_channel_map_get_mapping (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL); - - if (!pa_channel_map_valid(&map->priv->pa_map)) - return NULL; - - return pa_channel_map_to_pretty_name (&map->priv->pa_map); -} - -gboolean -gvc_channel_map_has_position (const GvcChannelMap *map, - pa_channel_position_t position) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), FALSE); - - return pa_channel_map_has_position (&(map->priv->pa_map), position); -} - -const pa_channel_map * -gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL); - - if (!pa_channel_map_valid(&map->priv->pa_map)) - return NULL; - - return &map->priv->pa_map; -} - -const pa_cvolume * -gvc_channel_map_get_cvolume (const GvcChannelMap *map) -{ - g_return_val_if_fail (GVC_IS_CHANNEL_MAP (map), NULL); - - if (!pa_channel_map_valid(&map->priv->pa_map)) - return NULL; - - return &map->priv->pa_volume; -} - -static void -gvc_channel_map_class_init (GvcChannelMapClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->finalize = gvc_channel_map_finalize; - - signals [VOLUME_CHANGED] = - g_signal_new ("volume-changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GvcChannelMapClass, volume_changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, G_TYPE_BOOLEAN); - - g_type_class_add_private (klass, sizeof (GvcChannelMapPrivate)); -} - -void -gvc_channel_map_volume_changed (GvcChannelMap *map, - const pa_cvolume *cv, - gboolean set) -{ - g_return_if_fail (GVC_IS_CHANNEL_MAP (map)); - g_return_if_fail (cv != NULL); - g_return_if_fail (pa_cvolume_compatible_with_channel_map(cv, &map->priv->pa_map)); - - if (pa_cvolume_equal(cv, &map->priv->pa_volume)) - return; - - map->priv->pa_volume = *cv; - - if (map->priv->pa_volume_is_set == FALSE) { - map->priv->pa_volume_is_set = TRUE; - return; - } - g_signal_emit (map, signals[VOLUME_CHANGED], 0, set); -} - -static void -gvc_channel_map_init (GvcChannelMap *map) -{ - map->priv = GVC_CHANNEL_MAP_GET_PRIVATE (map); - map->priv->pa_volume_is_set = FALSE; -} - -static void -gvc_channel_map_finalize (GObject *object) -{ - GvcChannelMap *channel_map; - - g_return_if_fail (object != NULL); - g_return_if_fail (GVC_IS_CHANNEL_MAP (object)); - - channel_map = GVC_CHANNEL_MAP (object); - - g_return_if_fail (channel_map->priv != NULL); - - G_OBJECT_CLASS (gvc_channel_map_parent_class)->finalize (object); -} - -GvcChannelMap * -gvc_channel_map_new (void) -{ - GObject *map; - map = g_object_new (GVC_TYPE_CHANNEL_MAP, NULL); - return GVC_CHANNEL_MAP (map); -} - -static void -set_from_pa_map (GvcChannelMap *map, - const pa_channel_map *pa_map) -{ - g_assert (pa_channel_map_valid(pa_map)); - - map->priv->can_balance = pa_channel_map_can_balance (pa_map); - map->priv->can_fade = pa_channel_map_can_fade (pa_map); - - map->priv->pa_map = *pa_map; - pa_cvolume_set(&map->priv->pa_volume, pa_map->channels, PA_VOLUME_NORM); -} - -GvcChannelMap * -gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *pa_map) -{ - GObject *map; - map = g_object_new (GVC_TYPE_CHANNEL_MAP, NULL); - - set_from_pa_map (GVC_CHANNEL_MAP (map), pa_map); - - return GVC_CHANNEL_MAP (map); -} diff --git a/mate-volume-control/src/gvc-channel-map.h b/mate-volume-control/src/gvc-channel-map.h deleted file mode 100644 index 3e23da9..0000000 --- a/mate-volume-control/src/gvc-channel-map.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __GVC_CHANNEL_MAP_H -#define __GVC_CHANNEL_MAP_H - -#include <glib-object.h> -#include <pulse/pulseaudio.h> - -G_BEGIN_DECLS - -#define GVC_TYPE_CHANNEL_MAP (gvc_channel_map_get_type ()) -#define GVC_CHANNEL_MAP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMap)) -#define GVC_CHANNEL_MAP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GVC_TYPE_CHANNEL_MAP, GvcChannelMapClass)) -#define GVC_IS_CHANNEL_MAP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GVC_TYPE_CHANNEL_MAP)) -#define GVC_IS_CHANNEL_MAP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GVC_TYPE_CHANNEL_MAP)) -#define GVC_CHANNEL_MAP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GVC_TYPE_CHANNEL_MAP, GvcChannelMapClass)) - -typedef struct GvcChannelMapPrivate GvcChannelMapPrivate; - -typedef struct -{ - GObject parent; - GvcChannelMapPrivate *priv; -} GvcChannelMap; - -typedef struct -{ - GObjectClass parent_class; - void (*volume_changed) (GvcChannelMap *channel_map, gboolean set); -} GvcChannelMapClass; - -enum { - VOLUME, - BALANCE, - FADE, - LFE, -}; - -#define NUM_TYPES LFE + 1 - -GType gvc_channel_map_get_type (void); - -GvcChannelMap * gvc_channel_map_new (void); -GvcChannelMap * gvc_channel_map_new_from_pa_channel_map (const pa_channel_map *map); -guint gvc_channel_map_get_num_channels (const GvcChannelMap *map); -const gdouble * gvc_channel_map_get_volume (GvcChannelMap *map); -gboolean gvc_channel_map_can_balance (const GvcChannelMap *map); -gboolean gvc_channel_map_can_fade (const GvcChannelMap *map); -gboolean gvc_channel_map_has_position (const GvcChannelMap *map, - pa_channel_position_t position); -#define gvc_channel_map_has_lfe(x) gvc_channel_map_has_position (x, PA_CHANNEL_POSITION_LFE) - -void gvc_channel_map_volume_changed (GvcChannelMap *map, - const pa_cvolume *cv, - gboolean set); -const char * gvc_channel_map_get_mapping (const GvcChannelMap *map); - -/* private */ -const pa_cvolume * gvc_channel_map_get_cvolume (const GvcChannelMap *map); -const pa_channel_map * gvc_channel_map_get_pa_channel_map (const GvcChannelMap *map); -G_END_DECLS - -#endif /* __GVC_CHANNEL_MAP_H */ diff --git a/mate-volume-control/src/gvc-mixer-dialog.c b/mate-volume-control/src/gvc-mixer-dialog.c index a29bdc9..e46ca1a 100644 --- a/mate-volume-control/src/gvc-mixer-dialog.c +++ b/mate-volume-control/src/gvc-mixer-dialog.c @@ -76,6 +76,7 @@ struct _GvcMixerDialogPrivate }; enum { + ICON_COLUMN, NAME_COLUMN, DESCRIPTION_COLUMN, DEVICE_COLUMN, @@ -408,26 +409,6 @@ update_input_peak (GvcMixerDialog *dialog, gdouble v) } static void -on_monitor_suspended_callback (pa_stream *s, - void *userdata) -{ - // XXX - /* - GvcMixerDialog *dialog; - - dialog = userdata; - - if (pa_stream_is_suspended (s)) { - g_debug ("Stream suspended"); - update_input_meter (dialog, - pa_stream_get_device_index (s), - PA_INVALID_INDEX, - -1); - } - */ -} - -static void on_stream_monitor_value (MateMixerStream *stream, gdouble value, GvcMixerDialog *dialog) @@ -860,10 +841,11 @@ add_stream (GvcMixerDialog *dialog, MateMixerStream *stream) } if (client == NULL) { - GtkTreeModel *model; + GtkTreeModel *model = NULL; GtkTreeIter iter; MateMixerStream *input; MateMixerStream *output; + const gchar *speakers = NULL; GtkAdjustment *adj; input = mate_mixer_control_get_default_input_stream (dialog->priv->control); @@ -883,18 +865,6 @@ add_stream (GvcMixerDialog *dialog, MateMixerStream *stream) model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), - &iter, - NAME_COLUMN, mate_mixer_stream_get_name (stream), - DESCRIPTION_COLUMN, mate_mixer_stream_get_description (stream), - DEVICE_COLUMN, "", - ACTIVE_COLUMN, is_default, - -1); - g_signal_connect (stream, - "notify::description", - G_CALLBACK (on_stream_description_notify), - dialog); } else if (flags & MATE_MIXER_STREAM_OUTPUT) { if (stream == output) { bar = dialog->priv->output_bar; @@ -911,16 +881,41 @@ add_stream (GvcMixerDialog *dialog, MateMixerStream *stream) } model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); + speakers = mvc_channel_map_to_pretty_string (stream); + } + + if (model != NULL) { + MateMixerDevice *device; + const gchar *name, + *description; + const gchar *device_name = NULL; + const gchar *icon = NULL; + + device = mate_mixer_stream_get_device (stream); + if (G_LIKELY (device != NULL)) { + device_name = mate_mixer_device_get_description (device); + if (device_name == NULL) + device_name = mate_mixer_device_get_name (device); + + icon = mate_mixer_device_get_icon (device); + } + + if (icon == NULL) + icon = "audio-card"; + + name = mate_mixer_stream_get_name (stream); + description = mate_mixer_stream_get_description (stream); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, - NAME_COLUMN, mate_mixer_stream_get_name (stream), - DESCRIPTION_COLUMN, mate_mixer_stream_get_description (stream), - DEVICE_COLUMN, "", + NAME_COLUMN, name, + DESCRIPTION_COLUMN, description, + DEVICE_COLUMN, device_name, ACTIVE_COLUMN, is_default, - SPEAKERS_COLUMN, mvc_channel_map_to_pretty_string (stream), + SPEAKERS_COLUMN, speakers, -1); + g_signal_connect (stream, "notify::description", G_CALLBACK (on_stream_description_notify), @@ -1062,9 +1057,9 @@ remove_stream (GvcMixerDialog *dialog, const gchar *name) } static void -on_control_stream_removed (GvcMixerControl *control, - const gchar *name, - GvcMixerDialog *dialog) +on_control_stream_removed (MateMixerControl *control, + const gchar *name, + GvcMixerDialog *dialog) { remove_stream (dialog, name); } @@ -1209,9 +1204,9 @@ remove_card (GvcMixerDialog *dialog, const gchar *name) } static void -on_control_device_removed (GvcMixerControl *control, - const gchar *name, - GvcMixerDialog *dialog) +on_control_device_removed (MateMixerControl *control, + const gchar *name, + GvcMixerDialog *dialog) { remove_card (dialog, name); } @@ -1344,6 +1339,7 @@ create_stream_treeview (GvcMixerDialog *dialog, GCallback on_toggled) gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); store = gtk_list_store_new (NUM_COLUMNS, + G_TYPE_ICON, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, @@ -1415,7 +1411,9 @@ on_test_speakers_clicked (GvcComboBox *widget, gpointer user_data) return; } - title = g_strdup_printf (_("Speaker Testing for %s"), mate_mixer_device_get_name (device)); + title = g_strdup_printf (_("Speaker Testing for %s"), + mate_mixer_device_get_description (device)); + d = gtk_dialog_new_with_buttons (title, GTK_WINDOW (dialog), GTK_DIALOG_MODAL | diff --git a/mate-volume-control/src/gvc-mixer-dialog.h b/mate-volume-control/src/gvc-mixer-dialog.h index 3c67d9f..cc6e665 100644 --- a/mate-volume-control/src/gvc-mixer-dialog.h +++ b/mate-volume-control/src/gvc-mixer-dialog.h @@ -25,8 +25,6 @@ #include <glib-object.h> #include <libmatemixer/matemixer.h> -#include "gvc-mixer-control.h" - G_BEGIN_DECLS #define GVC_DIALOG_DBUS_NAME "org.mate.VolumeControl" diff --git a/mate-volume-control/src/gvc-speaker-test.c b/mate-volume-control/src/gvc-speaker-test.c index 3fcf8d7..25b836c 100644 --- a/mate-volume-control/src/gvc-speaker-test.c +++ b/mate-volume-control/src/gvc-speaker-test.c @@ -493,7 +493,7 @@ update_channel_map (GvcSpeakerTest *test) static void gvc_speaker_test_init (GvcSpeakerTest *test) { - GtkWidget *face; + GtkWidget *icon; test->priv = GVC_SPEAKER_TEST_GET_PRIVATE (test); @@ -521,16 +521,15 @@ gvc_speaker_test_init (GvcSpeakerTest *test) create_channel_controls (test); - /* FIXME: what is the purpose of the smiley face? */ - face = gtk_image_new_from_icon_name ("face-smile", GTK_ICON_SIZE_DIALOG); + icon = gtk_image_new_from_icon_name ("computer", GTK_ICON_SIZE_DIALOG); - gtk_table_attach (GTK_TABLE (test), face, + gtk_table_attach (GTK_TABLE (test), icon, 2, 3, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); - gtk_widget_show (face); + gtk_widget_show (icon); } static void |