annotate src/alsa-ng/alsa-configure.c @ 3201:abe1b3195d6b

adapted header directory to audlegacy.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 18 Aug 2009 17:30:24 +0900
parents 16d4308fb36e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * Audacious ALSA Plugin (-ng)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (c) 2009 William Pitcock <nenolod@dereferenced.org>
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 * Portions copyright (C) 2001-2003 Matthieu Sozeau <mattam@altern.org>
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 * Portions copyright (C) 2003-2005 Haavard Kvaalen
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 *
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * (at your option) any later version.
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 *
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * GNU General Public License for more details.
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 *
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 */
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 #include "alsa-stdinc.h"
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23 #include <stdio.h>
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 #include <gtk/gtk.h>
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 #include <glib/gi18n.h>
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 static GtkWidget *configure_win = NULL;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 static GtkWidget *devices_combo, *mixer_devices_combo;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 static gint current_mixer_card;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 gint alsaplug_mixer_new_for_card(snd_mixer_t **mixer, const gchar *card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 #define GET_TOGGLE(tb) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(tb))
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36 #define GET_CHARS(edit) gtk_editable_get_chars(GTK_EDITABLE(edit), 0, -1)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 static void configure_win_ok_cb(GtkWidget * w, gpointer data)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 g_free(alsaplug_cfg.pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 alsaplug_cfg.pcm_device = GET_CHARS(GTK_COMBO(devices_combo)->entry);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 alsaplug_cfg.mixer_card = g_strdup_printf("hw:%d", current_mixer_card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 alsaplug_cfg.mixer_device = GET_CHARS(GTK_COMBO(mixer_devices_combo)->entry);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 gtk_widget_destroy(configure_win);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 /* Save configuration */
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 mcs_handle_t *cfgfile = aud_cfg_db_open();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 aud_cfg_db_set_string(cfgfile, "alsaplug", "pcm_device", alsaplug_cfg.pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 aud_cfg_db_set_string(cfgfile, "alsaplug", "mixer_card", alsaplug_cfg.mixer_card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 aud_cfg_db_set_string(cfgfile, "alsaplug","mixer_device", alsaplug_cfg.mixer_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 aud_cfg_db_close(cfgfile);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 void alsaplug_get_config(void)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 mcs_handle_t *cfgfile = aud_cfg_db_open();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58 aud_cfg_db_get_string(cfgfile, "alsaplug", "pcm_device", &alsaplug_cfg.pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 aud_cfg_db_get_string(cfgfile, "alsaplug", "mixer_card", &alsaplug_cfg.mixer_card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 aud_cfg_db_get_string(cfgfile, "alsaplug","mixer_device", &alsaplug_cfg.mixer_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 aud_cfg_db_close(cfgfile);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 static gint get_cards(GtkOptionMenu *omenu, GtkSignalFunc cb)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 GtkWidget *menu, *item;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 gint card = -1, err, set = 0, curr = -1;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 menu = gtk_menu_new();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 if ((err = snd_card_next(&card)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71 g_warning("snd_next_card() failed: %s", snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 while (card > -1)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 gchar *label;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77 curr++;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 if ((err = snd_card_get_name(card, &label)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 g_warning("snd_carg_get_name() failed: %s",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81 snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 break;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 item = gtk_menu_item_new_with_label(label);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 gtk_signal_connect(GTK_OBJECT(item), "activate", cb,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87 GINT_TO_POINTER(card));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 gtk_widget_show(item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 gtk_menu_append(GTK_MENU(menu), item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90 if ((err = snd_card_next(&card)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 g_warning("snd_next_card() failed: %s",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94 break;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 gtk_option_menu_set_menu(omenu, menu);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 return set;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 static gint get_mixer_devices(GtkCombo *combo, const gchar *card)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104 GList *items = NULL;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 gint err;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106 snd_mixer_t *mixer;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 snd_mixer_elem_t *current;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 if ((err = alsaplug_mixer_new_for_card(&mixer, card)) < 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 return err;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 current = snd_mixer_first_elem(mixer);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114 while (current)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 if (snd_mixer_selem_is_active(current) &&
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 snd_mixer_selem_has_playback_volume(current))
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 const gchar *sname = snd_mixer_selem_get_name(current);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 gint index = snd_mixer_selem_get_index(current);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 if (index)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 items = g_list_append(items, g_strdup_printf("%s,%d", sname, index));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 else
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 items = g_list_append(items, g_strdup(sname));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126 current = snd_mixer_elem_next(current);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129 gtk_combo_set_popdown_strings(combo, items);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 return 0;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134 static void get_devices_for_card(GtkCombo *combo, gint card)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 GtkWidget *item;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 gint pcm_device = -1, err;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 snd_pcm_info_t *pcm_info = NULL;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 snd_ctl_t *ctl;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140 gchar dev[64], *card_name;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 sprintf(dev, "hw:%i", card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 if ((err = snd_ctl_open(&ctl, dev, 0)) < 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 printf("snd_ctl_open() failed: %s", snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 return;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 if ((err = snd_card_get_name(card, &card_name)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 g_warning("snd_card_get_name() failed: %s", snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 card_name = _("Unknown soundcard");
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 snd_pcm_info_alloca(&pcm_info);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 for (;;)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 char *device, *descr;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 if ((err = snd_ctl_pcm_next_device(ctl, &pcm_device)) < 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 g_warning("snd_ctl_pcm_next_device() failed: %s",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165 pcm_device = -1;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 if (pcm_device < 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 break;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 snd_pcm_info_set_device(pcm_info, pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 snd_pcm_info_set_subdevice(pcm_info, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172 snd_pcm_info_set_stream(pcm_info, SND_PCM_STREAM_PLAYBACK);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 if ((err = snd_ctl_pcm_info(ctl, pcm_info)) < 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 if (err != -ENOENT)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177 g_warning("get_devices_for_card(): "
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 "snd_ctl_pcm_info() "
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 "failed (%d:%d): %s.", card,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 pcm_device, snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181 continue;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184 device = g_strdup_printf("hw:%d,%d", card, pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 descr = g_strconcat(card_name, ": ",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 snd_pcm_info_get_name(pcm_info),
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187 " (", device, ")", NULL);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188 item = gtk_list_item_new_with_label(descr);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189 gtk_widget_show(item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190 g_free(descr);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 gtk_combo_set_item_string(combo, GTK_ITEM(item), device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 g_free(device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
193 gtk_container_add(GTK_CONTAINER(combo->list), item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196 snd_ctl_close(ctl);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201 static void get_devices(GtkCombo *combo)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203 GtkWidget *item;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 gint card = -1;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205 gint err = 0;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206 gchar *descr;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 descr = g_strdup_printf(_("Default PCM device (%s)"), "default");
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
209 item = gtk_list_item_new_with_label(descr);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
210 gtk_widget_show(item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
211 g_free(descr);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
212 gtk_combo_set_item_string(combo, GTK_ITEM(item), "default");
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
213 gtk_container_add(GTK_CONTAINER(combo->list), item);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215 if ((err = snd_card_next(&card)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 g_warning("snd_next_card() failed: %s", snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 return;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 while (card > -1)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223 get_devices_for_card(combo, card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224 if ((err = snd_card_next(&card)) != 0)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226 g_warning("snd_next_card() failed: %s",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 snd_strerror(err));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 break;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 static void mixer_card_cb(GtkWidget * widget, gpointer card)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235 gchar scratch[128];
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
236
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237 if (current_mixer_card == GPOINTER_TO_INT(card))
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 return;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239 current_mixer_card = GPOINTER_TO_INT(card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 snprintf(scratch, 128, "hw:%d", current_mixer_card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242 get_mixer_devices(GTK_COMBO(mixer_devices_combo),
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 scratch);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246 void alsaplug_configure(void)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 {
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
248 GtkWidget * vbox, * adevice_frame, * adevice_box;
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249 GtkWidget *mixer_frame, *mixer_box, *mixer_table, *mixer_card_om;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 GtkWidget *mixer_card_label, *mixer_device_label;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251 GtkWidget *bbox, *ok, *cancel;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 gint mset;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255 if (configure_win)
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 {
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257 gtk_window_present(GTK_WINDOW(configure_win));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
258 return;
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
259 }
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
261 configure_win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
262 gtk_window_set_title ((GtkWindow *) configure_win, _ ("ALSA Output "
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
263 "Plugin Preferences"));
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
264 gtk_window_set_type_hint ((GtkWindow *) configure_win,
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
265 GDK_WINDOW_TYPE_HINT_DIALOG);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
266 gtk_window_set_resizable ((GtkWindow *) configure_win, FALSE);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
267 gtk_container_set_border_width ((GtkContainer *) configure_win, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
268 g_signal_connect ((GObject *) configure_win, "destroy", (GCallback)
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
269 gtk_widget_destroyed, & configure_win);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
270
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
271 vbox = gtk_vbox_new (FALSE, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
272 gtk_container_add ((GtkContainer *) configure_win, vbox);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
273
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
274 adevice_frame = gtk_frame_new (_ ("Device:"));
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
275 gtk_box_pack_start ((GtkBox *) vbox, adevice_frame, FALSE, FALSE, 0);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
276
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
277 adevice_box = gtk_vbox_new (FALSE, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
278 gtk_container_set_border_width ((GtkContainer *) adevice_box, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
279 gtk_container_add ((GtkContainer *) adevice_frame, adevice_box);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
280
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
281 devices_combo = gtk_combo_new();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282 gtk_box_pack_start(GTK_BOX(adevice_box), devices_combo,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
283 FALSE, FALSE, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
284 get_devices(GTK_COMBO(devices_combo));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
285 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(devices_combo)->entry),
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286 alsaplug_cfg.pcm_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
288 mixer_frame = gtk_frame_new (_ ("Mixer:"));
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
289 gtk_box_pack_start ((GtkBox *) vbox, mixer_frame, FALSE, FALSE, 0);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290
3195
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
291 mixer_box = gtk_vbox_new (FALSE, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
292 gtk_container_set_border_width ((GtkContainer *) mixer_box, 6);
16d4308fb36e alsa-ng: Set type hint on prefs window, and don't use deprecated GTK funcs.
John Lindgren <john.lindgren@tds.net>
parents: 3192
diff changeset
293 gtk_container_add ((GtkContainer *) mixer_frame, mixer_box);
3192
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
294
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
295 mixer_table = gtk_table_new(2, 2, FALSE);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
296 gtk_table_set_row_spacings(GTK_TABLE(mixer_table), 5);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 gtk_table_set_col_spacings(GTK_TABLE(mixer_table), 5);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298 gtk_box_pack_start(GTK_BOX(mixer_box), mixer_table, FALSE, FALSE, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300 mixer_card_label = gtk_label_new(_("Mixer card:"));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
301 gtk_label_set_justify(GTK_LABEL(mixer_card_label), GTK_JUSTIFY_LEFT);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
302 gtk_misc_set_alignment(GTK_MISC(mixer_card_label), 0, 0.5);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303 gtk_table_attach(GTK_TABLE(mixer_table), mixer_card_label,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
304 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
305
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 mixer_card_om = gtk_option_menu_new();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
307 mset = get_cards(GTK_OPTION_MENU(mixer_card_om),
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
308 (GtkSignalFunc)mixer_card_cb);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
310 gtk_table_attach(GTK_TABLE(mixer_table), mixer_card_om,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 mixer_device_label = gtk_label_new(_("Mixer device:"));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
314 gtk_label_set_justify(GTK_LABEL(mixer_device_label), GTK_JUSTIFY_LEFT);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
315 gtk_misc_set_alignment(GTK_MISC(mixer_device_label), 0, 0.5);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
316 gtk_table_attach(GTK_TABLE(mixer_table), mixer_device_label,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
318 mixer_devices_combo = gtk_combo_new();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
319 gtk_option_menu_set_history(GTK_OPTION_MENU(mixer_card_om), mset);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320 get_mixer_devices(GTK_COMBO(mixer_devices_combo), alsaplug_cfg.mixer_card);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(mixer_devices_combo)->entry),
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322 alsaplug_cfg.mixer_device);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
323
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
324 gtk_table_attach(GTK_TABLE(mixer_table), mixer_devices_combo,
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
326
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
327 bbox = gtk_hbutton_box_new();
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
329 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
332 ok = gtk_button_new_with_label(_("OK"));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333 gtk_signal_connect(GTK_OBJECT(ok), "clicked", (GCallback)configure_win_ok_cb, NULL);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
335 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
336 gtk_widget_grab_default(ok);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
337
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
338 cancel = gtk_button_new_with_label(_("Cancel"));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339 gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked",
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
340 (GCallback)gtk_widget_destroy, GTK_OBJECT(configure_win));
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 gtk_widget_show_all(configure_win);
d1d9b159801a alsa-ng: Add configuration settings.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
345 }