3
* Copyright (C) 2007 Jan Arne Petersen <jap@gnome.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2, or (at your option)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27
#include <glib/glist.h>
28
#include <glib/gi18n.h>
29
#include <gst/audio/mixerutils.h>
31
#include <gtk/gtkliststore.h>
33
#include "mixer-support.h"
36
create_mixer_device_tree_model (void)
38
GtkListStore *device_store;
39
GList *mixer_list, *l;
42
device_store = gtk_list_store_new (MIXER_DEVICE_MODEL_COLUMN_COUNT,
43
G_TYPE_STRING, G_TYPE_STRING, GST_TYPE_ELEMENT);
45
mixer_list = gst_audio_default_registry_mixer_filter(NULL, FALSE, NULL);
47
for (l = mixer_list; l != NULL; l = l->next) {
48
GstElement *mixer = GST_ELEMENT (l->data);
49
gchar *device_name = NULL, *device = NULL;
50
GstElementFactory *factory;
51
const gchar *longname, *factory_name;
53
GtkTreeIter tree_iter;
55
gst_element_set_state (mixer, GST_STATE_READY);
58
if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (mixer)), "device-name")) {
59
g_object_get (mixer, "device-name", &device_name, NULL);
61
if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (mixer)), "device")) {
62
g_object_get (mixer, "device", &device, NULL);
65
factory = gst_element_get_factory (mixer);
66
longname = gst_element_factory_get_longname (factory);
67
factory_name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));
69
/* gst_element_set_state (mixer, GST_STATE_NULL); */
72
name = g_strdup_printf ("%s (%s)", device_name, longname);
79
title = g_strdup_printf (_("Unknown Volume Control %d"), unknown);
80
name = g_strdup_printf ("%s (%s)", title, longname);
87
tmp = g_strdup_printf ("%s:%s", factory_name, device);
91
device = g_strdup (factory_name);
94
gtk_list_store_insert_with_values (device_store, &tree_iter, -1,
95
MIXER_DEVICE_MODEL_NAME_COLUMN, name,
96
MIXER_DEVICE_MODEL_DEVICE_COLUMN, device,
97
MIXER_DEVICE_MODEL_MIXER_COLUMN, mixer,
100
gst_element_set_state (mixer, GST_STATE_NULL);
101
gst_object_unref (GST_OBJECT (mixer));
107
g_list_free (mixer_list);
109
return GTK_TREE_MODEL (device_store);
113
create_mixer_tracks_tree_model_for_mixer (GstMixer *mixer)
115
GtkListStore *tracks_store;
116
const GList *tracks, *l;
118
tracks_store = gtk_list_store_new (MIXER_TRACKS_MODEL_COLUMN_COUNT,
121
tracks = gst_mixer_list_tracks (mixer);
122
for (l = tracks; l != NULL; l = l->next) {
123
GstMixerTrack *track = l->data;
126
if (track->num_channels <= 0) {
130
gtk_list_store_insert_with_values (tracks_store, &iter, -1,
131
MIXER_TRACKS_MODEL_LABEL_COLUMN, track->label,
135
return GTK_TREE_MODEL (tracks_store);