annotate Plugins/Input/amidi-plug/i_configure-alsa.c @ 1708:1c1a08962c83 trunk

[svn] - change Makefile / filename
author nenolod
date Fri, 15 Sep 2006 19:59:32 -0700
parents daabad781796
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
1 /*
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
2 *
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2006
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
4 *
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify it
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
6 * under the terms of the GNU General Public License as published by the
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
7 * Free Software Foundation; either version 2 of the License, or (at your
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
8 * option) any later version.
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
9 *
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
13 * General Public License for more details.
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
14 *
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License along
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
16 * with this program; if not, write to the Free Software Foundation, Inc.,
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
18 *
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
19 */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
20
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
21
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
22 #include "i_configure-alsa.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
23 #include "backend-alsa/b-alsa-config.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
24 #include "backend-alsa/backend-alsa-icon.xpm"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
25
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
26
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
27 enum
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
28 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
29 LISTPORT_TOGGLE_COLUMN = 0,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
30 LISTPORT_PORTNUM_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
31 LISTPORT_CLIENTNAME_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
32 LISTPORT_PORTNAME_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
33 LISTPORT_POINTER_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
34 LISTPORT_N_COLUMNS
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
35 };
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
36
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
37 enum
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
38 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
39 LISTCARD_NAME_COLUMN = 0,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
40 LISTCARD_ID_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
41 LISTCARD_MIXERPTR_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
42 LISTCARD_N_COLUMNS
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
43 };
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
44
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
45 enum
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
46 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
47 LISTMIXER_NAME_COLUMN = 0,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
48 LISTMIXER_ID_COLUMN,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
49 LISTMIXER_N_COLUMNS
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
50 };
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
51
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
52
1671
daabad781796 [svn] - amidi-plug 0.6 imported; among other improvements, multiple soundfont loading for fluidsynth backend and option to extract/display lyrics and comments contained in midi files
giacomo
parents: 1459
diff changeset
53
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
54 void i_configure_ev_portlv_changetoggle( GtkCellRendererToggle * rdtoggle ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
55 gchar * path_str , gpointer data )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
56 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
57 GtkTreeModel *model = (GtkTreeModel*)data;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
58 GtkTreeIter iter;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
59 GtkTreePath *path = gtk_tree_path_new_from_string( path_str );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
60 gboolean toggled;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
61
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
62 gtk_tree_model_get_iter( model , &iter , path );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
63 gtk_tree_model_get( model , &iter , LISTPORT_TOGGLE_COLUMN , &toggled , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
64
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
65 toggled ^= 1;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
66 gtk_list_store_set( GTK_LIST_STORE(model), &iter , LISTPORT_TOGGLE_COLUMN , toggled , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
67
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
68 gtk_tree_path_free (path);
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
69 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
70
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
71
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
72 gboolean i_configure_ev_mixctlcmb_inspect( GtkTreeModel * store , GtkTreePath * path,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
73 GtkTreeIter * iter , gpointer mixctl_cmb )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
74 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
75 gint ctl_id;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
76 gchar * ctl_name;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
77 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
78 gtk_tree_model_get( GTK_TREE_MODEL(store) , iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
79 LISTMIXER_ID_COLUMN , &ctl_id ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
80 LISTMIXER_NAME_COLUMN , &ctl_name , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
81 if (( !strcmp( ctl_name , alsacfg->alsa_mixer_ctl_name ) ) &&
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
82 ( ctl_id == alsacfg->alsa_mixer_ctl_id ))
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
83 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
84 /* this is the selected control in the mixer control combobox */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
85 gtk_combo_box_set_active_iter( GTK_COMBO_BOX(mixctl_cmb) , iter );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
86 return TRUE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
87 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
88 g_free( ctl_name );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
89 return FALSE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
90 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
91
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
92
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
93 void i_configure_ev_cardcmb_changed( GtkWidget * card_cmb , gpointer mixctl_cmb )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
94 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
95 GtkTreeIter iter;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
96 if( gtk_combo_box_get_active_iter( GTK_COMBO_BOX(card_cmb) , &iter ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
97 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
98 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
99 gpointer mixctl_store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
100 gint card_id;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
101 GtkTreeModel * store = gtk_combo_box_get_model( GTK_COMBO_BOX(card_cmb) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
102 gtk_tree_model_get( GTK_TREE_MODEL(store) , &iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
103 LISTCARD_ID_COLUMN , &card_id ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
104 LISTCARD_MIXERPTR_COLUMN , &mixctl_store , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
105 gtk_combo_box_set_model( GTK_COMBO_BOX(mixctl_cmb) , GTK_TREE_MODEL(mixctl_store) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
106
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
107 /* check if the selected card is the one contained in configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
108 if ( card_id == alsacfg->alsa_mixer_card_id )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
109 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
110 /* search for the selected mixer control in combo box */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
111 gtk_tree_model_foreach( GTK_TREE_MODEL(mixctl_store) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
112 i_configure_ev_mixctlcmb_inspect , mixctl_cmb );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
113 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
114 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
115 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
116
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
117
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
118 gboolean i_configure_ev_portlv_inspecttoggle( GtkTreeModel * model , GtkTreePath * path ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
119 GtkTreeIter * iter , gpointer wpp )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
120 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
121 gboolean toggled = FALSE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
122 gchar * portstring;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
123 GString * wps = wpp;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
124 gtk_tree_model_get ( model , iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
125 LISTPORT_TOGGLE_COLUMN , &toggled ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
126 LISTPORT_PORTNUM_COLUMN , &portstring , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
127 if ( toggled ) /* check if the row points to an enabled port */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
128 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
129 /* if this is not the first port added to wp, use comma as separator */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
130 if ( wps->str[0] != '\0' ) g_string_append_c( wps , ',' );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
131 g_string_append( wps , portstring );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
132 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
133 g_free( portstring );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
134 return FALSE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
135 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
136
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
137
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
138 void i_configure_ev_portlv_commit( gpointer port_lv )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
139 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
140 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
141 GtkTreeModel * store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
142 GString *wp = g_string_new( "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
143 /* get the model of the port listview */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
144 store = gtk_tree_view_get_model( GTK_TREE_VIEW(port_lv) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
145 /* after going through this foreach, wp contains a comma-separated list of selected ports */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
146 gtk_tree_model_foreach( store , i_configure_ev_portlv_inspecttoggle , wp );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
147 g_free( alsacfg->alsa_seq_wports ); /* free previous */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
148 alsacfg->alsa_seq_wports = g_strdup( wp->str ); /* set with new */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
149 g_string_free( wp , TRUE ); /* not needed anymore */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
150 return;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
151 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
152
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
153 void i_configure_ev_cardcmb_commit( gpointer card_cmb )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
154 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
155 GtkTreeModel * store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
156 GtkTreeIter iter;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
157 store = gtk_combo_box_get_model( GTK_COMBO_BOX(card_cmb) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
158 /* get the selected item */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
159 if ( gtk_combo_box_get_active_iter( GTK_COMBO_BOX(card_cmb) , &iter ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
160 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
161 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
162 /* update amidiplug_cfg.alsa_mixer_card_id */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
163 gtk_tree_model_get( GTK_TREE_MODEL(store) , &iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
164 LISTCARD_ID_COLUMN ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
165 &alsacfg->alsa_mixer_card_id , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
166 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
167 return;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
168 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
169
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
170 void i_configure_ev_mixctlcmb_commit( gpointer mixctl_cmb )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
171 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
172 GtkTreeModel * store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
173 GtkTreeIter iter;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
174 store = gtk_combo_box_get_model( GTK_COMBO_BOX(mixctl_cmb) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
175 /* get the selected item */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
176 if ( gtk_combo_box_get_active_iter( GTK_COMBO_BOX(mixctl_cmb) , &iter ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
177 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
178 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
179 g_free( alsacfg->alsa_mixer_ctl_name ); /* free previous */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
180 /* update amidiplug_cfg.alsa_mixer_card_id */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
181 gtk_tree_model_get( GTK_TREE_MODEL(store) , &iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
182 LISTMIXER_NAME_COLUMN ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
183 &alsacfg->alsa_mixer_ctl_name ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
184 LISTMIXER_ID_COLUMN ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
185 &alsacfg->alsa_mixer_ctl_id , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
186 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
187 return;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
188 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
189
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
190
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
191 void i_configure_gui_ctlcmb_datafunc( GtkCellLayout *cell_layout , GtkCellRenderer *cr ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
192 GtkTreeModel *store , GtkTreeIter *iter , gpointer p )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
193 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
194 gchar *ctl_display, *ctl_name;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
195 gint ctl_id;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
196 gtk_tree_model_get( store , iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
197 LISTMIXER_NAME_COLUMN , &ctl_name ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
198 LISTMIXER_ID_COLUMN , &ctl_id , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
199 if ( ctl_id == 0 )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
200 ctl_display = g_strdup_printf( "%s" , ctl_name );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
201 else
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
202 ctl_display = g_strdup_printf( "%s (%i)" , ctl_name , ctl_id );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
203 g_object_set( G_OBJECT(cr) , "text" , ctl_display , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
204 g_free( ctl_display );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
205 g_free( ctl_name );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
206 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
207
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
208
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
209 void i_configure_gui_tab_alsa( GtkWidget * alsa_page_alignment ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
210 gpointer backend_list_p ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
211 gpointer commit_button )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
212 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
213 GtkWidget *alsa_page_vbox;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
214 GtkWidget *title_widget;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
215 GtkWidget *content_vbox; /* this vbox will contain two items of equal space (50%/50%) */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
216 GSList * backend_list = backend_list_p;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
217 gboolean alsa_module_ok = FALSE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
218 gchar * alsa_module_pathfilename;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
219
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
220 alsa_page_vbox = gtk_vbox_new( FALSE , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
221
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
222 title_widget = i_configure_gui_draw_title( _("ALSA BACKEND CONFIGURATION") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
223 gtk_box_pack_start( GTK_BOX(alsa_page_vbox) , title_widget , FALSE , FALSE , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
224
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
225 content_vbox = gtk_vbox_new( TRUE , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
226
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
227 /* check if the ALSA module is available */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
228 while ( backend_list != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
229 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
230 amidiplug_sequencer_backend_name_t * mn = backend_list->data;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
231 if ( !strcmp( mn->name , "alsa" ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
232 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
233 alsa_module_ok = TRUE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
234 alsa_module_pathfilename = mn->filename;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
235 break;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
236 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
237 backend_list = backend_list->next;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
238 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
239
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
240 if ( alsa_module_ok )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
241 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
242 GtkListStore *port_store, *mixer_card_store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
243 GtkWidget *port_lv, *port_lv_sw, *port_lv_frame;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
244 GtkCellRenderer *port_lv_toggle_rndr, *port_lv_text_rndr;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
245 GtkTreeViewColumn *port_lv_toggle_col, *port_lv_portnum_col;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
246 GtkTreeViewColumn *port_lv_clientname_col, *port_lv_portname_col;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
247 GtkTreeSelection *port_lv_sel;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
248 GtkTreeIter iter;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
249 GtkWidget *mixer_table, *mixer_frame;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
250 GtkCellRenderer *mixer_card_cmb_text_rndr, *mixer_ctl_cmb_text_rndr;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
251 GtkWidget *mixer_card_cmb_evbox, *mixer_card_cmb, *mixer_card_label;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
252 GtkWidget *mixer_ctl_cmb_evbox, *mixer_ctl_cmb, *mixer_ctl_label;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
253 GtkTooltips *tips;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
254
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
255 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
256
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
257 gchar **portstring_from_cfg = NULL;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
258
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
259 GModule * alsa_module;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
260 GSList *wports = NULL, *wports_h = NULL, *scards = NULL, *scards_h = NULL;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
261 GSList * (*get_port_list)( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
262 void (*free_port_list)( GSList * );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
263 GSList * (*get_card_list)( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
264 void (*free_card_list)( GSList * );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
265
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
266 if ( strlen( alsacfg->alsa_seq_wports ) > 0 )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
267 portstring_from_cfg = g_strsplit( alsacfg->alsa_seq_wports , "," , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
268
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
269 tips = gtk_tooltips_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
270 g_object_set_data_full( G_OBJECT(alsa_page_alignment) , "tt" , tips , g_object_unref );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
271
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
272 /* it's legit to assume that this can't fail,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
273 since the module is present in the backend_list */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
274 alsa_module = g_module_open( alsa_module_pathfilename , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
275 g_module_symbol( alsa_module , "sequencer_port_get_list" , (gpointer*)&get_port_list );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
276 g_module_symbol( alsa_module , "sequencer_port_free_list" , (gpointer*)&free_port_list );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
277 g_module_symbol( alsa_module , "alsa_card_get_list" , (gpointer*)&get_card_list );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
278 g_module_symbol( alsa_module , "alsa_card_free_list" , (gpointer*)&free_card_list );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
279 /* get an updated list of writable ALSA MIDI ports and ALSA-enabled sound cards*/
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
280 wports = get_port_list(); wports_h = wports;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
281 scards = get_card_list(); scards_h = scards;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
282
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
283 /* ALSA MIDI PORT LISTVIEW */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
284 port_store = gtk_list_store_new( LISTPORT_N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
285 G_TYPE_STRING , G_TYPE_STRING , G_TYPE_POINTER );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
286 while ( wports != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
287 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
288 gboolean toggled = FALSE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
289 data_bucket_t * portinfo = (data_bucket_t *)wports->data;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
290 GString * portstring = g_string_new("");
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
291 G_STRING_PRINTF( portstring , "%i:%i" , portinfo->bint[0] , portinfo->bint[1] );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
292 gtk_list_store_append( port_store , &iter );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
293 /* in the existing configuration there may be previously selected ports */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
294 if ( portstring_from_cfg != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
295 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
296 gint i = 0;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
297 /* check if current row contains a port selected by user */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
298 for ( i = 0 ; portstring_from_cfg[i] != NULL ; i++ )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
299 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
300 /* if it's one of the selected ports, toggle its checkbox */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
301 if ( !strcmp( portstring->str, portstring_from_cfg[i] ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
302 toggled = TRUE;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
303 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
304 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
305 gtk_list_store_set( port_store , &iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
306 LISTPORT_TOGGLE_COLUMN , toggled ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
307 LISTPORT_PORTNUM_COLUMN , portstring->str ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
308 LISTPORT_CLIENTNAME_COLUMN , portinfo->bcharp[0] ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
309 LISTPORT_PORTNAME_COLUMN , portinfo->bcharp[1] ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
310 LISTPORT_POINTER_COLUMN , portinfo , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
311 g_string_free( portstring , TRUE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
312 /* on with next */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
313 wports = wports->next;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
314 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
315 g_strfreev( portstring_from_cfg ); /* not needed anymore */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
316 port_lv = gtk_tree_view_new_with_model( GTK_TREE_MODEL(port_store) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
317 gtk_tree_view_set_rules_hint( GTK_TREE_VIEW(port_lv), TRUE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
318 g_object_unref( port_store );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
319 port_lv_toggle_rndr = gtk_cell_renderer_toggle_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
320 gtk_cell_renderer_toggle_set_radio( GTK_CELL_RENDERER_TOGGLE(port_lv_toggle_rndr) , FALSE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
321 gtk_cell_renderer_toggle_set_active( GTK_CELL_RENDERER_TOGGLE(port_lv_toggle_rndr) , TRUE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
322 g_signal_connect( port_lv_toggle_rndr , "toggled" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
323 G_CALLBACK(i_configure_ev_portlv_changetoggle) , port_store );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
324 port_lv_text_rndr = gtk_cell_renderer_text_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
325 port_lv_toggle_col = gtk_tree_view_column_new_with_attributes( "", port_lv_toggle_rndr,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
326 "active", LISTPORT_TOGGLE_COLUMN, NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
327 port_lv_portnum_col = gtk_tree_view_column_new_with_attributes( _("Port"), port_lv_text_rndr,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
328 "text", LISTPORT_PORTNUM_COLUMN, NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
329 port_lv_clientname_col = gtk_tree_view_column_new_with_attributes( _("Client name"), port_lv_text_rndr,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
330 "text", LISTPORT_CLIENTNAME_COLUMN, NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
331 port_lv_portname_col = gtk_tree_view_column_new_with_attributes( _("Port name"), port_lv_text_rndr,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
332 "text", LISTPORT_PORTNAME_COLUMN, NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
333 gtk_tree_view_append_column( GTK_TREE_VIEW(port_lv), port_lv_toggle_col );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
334 gtk_tree_view_append_column( GTK_TREE_VIEW(port_lv), port_lv_portnum_col );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
335 gtk_tree_view_append_column( GTK_TREE_VIEW(port_lv), port_lv_clientname_col );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
336 gtk_tree_view_append_column( GTK_TREE_VIEW(port_lv), port_lv_portname_col );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
337 port_lv_sel = gtk_tree_view_get_selection( GTK_TREE_VIEW(port_lv) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
338 gtk_tree_selection_set_mode( GTK_TREE_SELECTION(port_lv_sel) , GTK_SELECTION_NONE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
339 port_lv_sw = gtk_scrolled_window_new( NULL , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
340 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(port_lv_sw),
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
341 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
342 port_lv_frame = gtk_frame_new( _("ALSA output ports") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
343 gtk_container_add( GTK_CONTAINER(port_lv_sw) , port_lv );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
344 gtk_container_add( GTK_CONTAINER(port_lv_frame) , port_lv_sw );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
345 gtk_box_pack_start( GTK_BOX(content_vbox) , port_lv_frame , TRUE , TRUE , 0 );
1671
daabad781796 [svn] - amidi-plug 0.6 imported; among other improvements, multiple soundfont loading for fluidsynth backend and option to extract/display lyrics and comments contained in midi files
giacomo
parents: 1459
diff changeset
346 g_signal_connect_swapped( G_OBJECT(commit_button) , "ap-commit" ,
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
347 G_CALLBACK(i_configure_ev_portlv_commit) , port_lv );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
348
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
349 /* MIXER CARD/CONTROL COMBOBOXES */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
350 mixer_card_store = gtk_list_store_new( LISTCARD_N_COLUMNS , G_TYPE_STRING , G_TYPE_INT , G_TYPE_POINTER );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
351 mixer_card_cmb = gtk_combo_box_new_with_model( GTK_TREE_MODEL(mixer_card_store) ); /* soundcard combo box */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
352 mixer_ctl_cmb = gtk_combo_box_new(); /* mixer control combo box */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
353 g_signal_connect( mixer_card_cmb , "changed" , G_CALLBACK(i_configure_ev_cardcmb_changed) , mixer_ctl_cmb );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
354 while ( scards != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
355 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
356 GtkListStore *mixer_ctl_store;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
357 GtkTreeIter itermix;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
358 data_bucket_t * cardinfo = (data_bucket_t *)scards->data;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
359 GSList *mixctl_list = cardinfo->bpointer[0];
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
360 mixer_ctl_store = gtk_list_store_new( LISTMIXER_N_COLUMNS , G_TYPE_STRING , G_TYPE_INT );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
361 while ( mixctl_list != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
362 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
363 data_bucket_t * mixctlinfo = (data_bucket_t *)mixctl_list->data;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
364 gtk_list_store_append( mixer_ctl_store , &itermix );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
365 gtk_list_store_set( mixer_ctl_store , &itermix ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
366 LISTMIXER_NAME_COLUMN , mixctlinfo->bcharp[0] ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
367 LISTMIXER_ID_COLUMN , mixctlinfo->bint[0] , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
368 mixctl_list = mixctl_list->next; /* on with next mixer control */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
369 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
370 gtk_list_store_append( mixer_card_store , &iter );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
371 gtk_list_store_set( mixer_card_store , &iter ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
372 LISTCARD_NAME_COLUMN , cardinfo->bcharp[0] ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
373 LISTCARD_ID_COLUMN , cardinfo->bint[0] ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
374 LISTCARD_MIXERPTR_COLUMN , mixer_ctl_store , -1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
375 /* check if this corresponds to the value previously selected by user */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
376 if ( cardinfo->bint[0] == alsacfg->alsa_mixer_card_id )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
377 gtk_combo_box_set_active_iter( GTK_COMBO_BOX(mixer_card_cmb) , &iter );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
378 scards = scards->next; /* on with next card */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
379 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
380 g_object_unref( mixer_card_store ); /* free a reference, no longer needed */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
381 /* create renderer to display text in the mixer combo box */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
382 mixer_card_cmb_text_rndr = gtk_cell_renderer_text_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
383 gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(mixer_card_cmb) , mixer_card_cmb_text_rndr , TRUE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
384 gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(mixer_card_cmb) , mixer_card_cmb_text_rndr ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
385 "text" , LISTCARD_NAME_COLUMN );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
386 mixer_ctl_cmb_text_rndr = gtk_cell_renderer_text_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
387 gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(mixer_ctl_cmb) , mixer_ctl_cmb_text_rndr , TRUE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
388 gtk_cell_layout_set_cell_data_func( GTK_CELL_LAYOUT(mixer_ctl_cmb) , mixer_ctl_cmb_text_rndr ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
389 i_configure_gui_ctlcmb_datafunc , NULL , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
390 /* the event box is needed to display a tooltip for the mixer combo box */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
391 mixer_card_cmb_evbox = gtk_event_box_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
392 gtk_container_add( GTK_CONTAINER(mixer_card_cmb_evbox) , mixer_card_cmb );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
393 mixer_ctl_cmb_evbox = gtk_event_box_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
394 gtk_container_add( GTK_CONTAINER(mixer_ctl_cmb_evbox) , mixer_ctl_cmb );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
395 mixer_card_label = gtk_label_new( _("Soundcard: ") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
396 gtk_misc_set_alignment( GTK_MISC(mixer_card_label) , 0 , 0.5 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
397 mixer_ctl_label = gtk_label_new( _("Mixer control: ") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
398 gtk_misc_set_alignment( GTK_MISC(mixer_ctl_label) , 0 , 0.5 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
399 mixer_table = gtk_table_new( 3 , 2 , FALSE );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
400 gtk_container_set_border_width( GTK_CONTAINER(mixer_table), 4 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
401 gtk_table_attach( GTK_TABLE(mixer_table) , mixer_card_label , 0 , 1 , 0 , 1 ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
402 GTK_FILL , 0 , 1 , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
403 gtk_table_attach( GTK_TABLE(mixer_table) , mixer_card_cmb_evbox , 1 , 2 , 0 , 1 ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
404 GTK_EXPAND | GTK_FILL , 0 , 1 , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
405 gtk_table_attach( GTK_TABLE(mixer_table) , mixer_ctl_label , 0 , 1 , 1 , 2 ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
406 GTK_FILL , 0 , 1 , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
407 gtk_table_attach( GTK_TABLE(mixer_table) , mixer_ctl_cmb_evbox , 1 , 2 , 1 , 2 ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
408 GTK_EXPAND | GTK_FILL , 0 , 1 , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
409 mixer_frame = gtk_frame_new( _("Mixer settings") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
410 gtk_container_add( GTK_CONTAINER(mixer_frame) , mixer_table );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
411 gtk_box_pack_start( GTK_BOX(content_vbox) , mixer_frame , TRUE , TRUE , 0 );
1671
daabad781796 [svn] - amidi-plug 0.6 imported; among other improvements, multiple soundfont loading for fluidsynth backend and option to extract/display lyrics and comments contained in midi files
giacomo
parents: 1459
diff changeset
412 g_signal_connect_swapped( G_OBJECT(commit_button) , "ap-commit" ,
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
413 G_CALLBACK(i_configure_ev_cardcmb_commit) , mixer_card_cmb );
1671
daabad781796 [svn] - amidi-plug 0.6 imported; among other improvements, multiple soundfont loading for fluidsynth backend and option to extract/display lyrics and comments contained in midi files
giacomo
parents: 1459
diff changeset
414 g_signal_connect_swapped( G_OBJECT(commit_button) , "ap-commit" ,
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
415 G_CALLBACK(i_configure_ev_mixctlcmb_commit) , mixer_ctl_cmb );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
416
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
417 free_card_list( scards_h );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
418 free_port_list( wports_h );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
419 g_module_close( alsa_module );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
420
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
421 gtk_tooltips_set_tip( GTK_TOOLTIPS(tips) , port_lv ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
422 _("* Select ALSA output ports *\n"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
423 "MIDI events will be sent to the ports selected here. In example, if your "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
424 "audio card provides a hardware synth and you want to play MIDI with it, "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
425 "you'll probably want to select the wavetable synthesizer ports.") , "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
426 gtk_tooltips_set_tip( GTK_TOOLTIPS(tips) , mixer_card_cmb_evbox ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
427 _("* Select ALSA mixer card *\n"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
428 "The ALSA backend outputs directly through ALSA, it doesn't use effect "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
429 "and ouput plugins from the player. During playback, the player volume"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
430 "slider will manipulate the mixer control you select here. "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
431 "If you're using wavetable synthesizer ports, you'll probably want to "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
432 "select the Synth control here.") , "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
433 gtk_tooltips_set_tip( GTK_TOOLTIPS(tips) , mixer_ctl_cmb_evbox ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
434 _("* Select ALSA mixer control *\n"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
435 "The ALSA backend outputs directly through ALSA, it doesn't use effect "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
436 "and ouput plugins from the player. During playback, the player volume "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
437 "slider will manipulate the mixer control you select here. "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
438 "If you're using wavetable synthesizer ports, you'll probably want to "
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
439 "select the Synth control here.") , "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
440 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
441 else
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
442 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
443 /* display "not available" information */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
444 GtkWidget * info_label;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
445 info_label = gtk_label_new( _("ALSA Backend not loaded or not available") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
446 gtk_box_pack_start( GTK_BOX(alsa_page_vbox) , info_label , FALSE , FALSE , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
447 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
448
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
449 gtk_box_pack_start( GTK_BOX(alsa_page_vbox) , content_vbox , TRUE , TRUE , 2 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
450 gtk_container_add( GTK_CONTAINER(alsa_page_alignment) , alsa_page_vbox );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
451 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
452
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
453
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
454 void i_configure_gui_tablabel_alsa( GtkWidget * alsa_page_alignment ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
455 gpointer backend_list_p ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
456 gpointer commit_button )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
457 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
458 GtkWidget *pagelabel_vbox, *pagelabel_image, *pagelabel_label;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
459 GdkPixbuf *pagelabel_image_pix;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
460 pagelabel_vbox = gtk_vbox_new( FALSE , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
461 pagelabel_image_pix = gdk_pixbuf_new_from_xpm_data( (const gchar **)backend_alsa_icon_xpm );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
462 pagelabel_image = gtk_image_new_from_pixbuf( pagelabel_image_pix ); g_object_unref( pagelabel_image_pix );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
463 pagelabel_label = gtk_label_new( "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
464 gtk_label_set_markup( GTK_LABEL(pagelabel_label) , "<span size=\"smaller\">ALSA\nbackend</span>" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
465 gtk_label_set_justify( GTK_LABEL(pagelabel_label) , GTK_JUSTIFY_CENTER );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
466 gtk_box_pack_start( GTK_BOX(pagelabel_vbox) , pagelabel_image , FALSE , FALSE , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
467 gtk_box_pack_start( GTK_BOX(pagelabel_vbox) , pagelabel_label , FALSE , FALSE , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
468 gtk_container_add( GTK_CONTAINER(alsa_page_alignment) , pagelabel_vbox );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
469 gtk_widget_show_all( alsa_page_alignment );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
470 return;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
471 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
472
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
473
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
474 gchar * i_configure_read_seq_ports_default( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
475 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
476 FILE * fp = NULL;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
477 /* first try, get seq ports from proc on card0 */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
478 fp = fopen( "/proc/asound/card0/wavetableD1" , "rb" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
479 if ( fp )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
480 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
481 gchar buffer[100];
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
482 while ( !feof( fp ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
483 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
484 fgets( buffer , 100 , fp );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
485 if (( strlen( buffer ) > 11 ) && ( !strncasecmp( buffer , "addresses: " , 11 ) ))
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
486 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
487 /* change spaces between ports (65:0 65:1 65:2 ...)
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
488 into commas (65:0,65:1,65:2,...) */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
489 g_strdelimit( &buffer[11] , " " , ',' );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
490 /* remove lf and cr from the end of the string */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
491 g_strdelimit( &buffer[11] , "\r\n" , '\0' );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
492 /* ready to go */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
493 DEBUGMSG( "init, default values for seq ports detected: %s\n" , &buffer[11] );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
494 fclose( fp );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
495 return g_strdup( &buffer[11] );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
496 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
497 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
498 fclose( fp );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
499 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
500
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
501 /* second option: do not set ports at all, let the user
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
502 select the right ones in the nice config window :) */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
503 return g_strdup( "" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
504 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
505
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
506
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
507
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
508 void i_configure_cfg_alsa_alloc( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
509 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
510 amidiplug_cfg_alsa_t * alsacfg = g_malloc(sizeof(amidiplug_cfg_alsa_t));
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
511 amidiplug_cfg_backend->alsa = alsacfg;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
512 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
513
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
514
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
515 void i_configure_cfg_alsa_free( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
516 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
517 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
518 g_free( alsacfg->alsa_seq_wports );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
519 g_free( alsacfg->alsa_mixer_ctl_name );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
520 g_free( amidiplug_cfg_backend->alsa );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
521 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
522
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
523
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
524 void i_configure_cfg_alsa_read( pcfg_t * cfgfile )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
525 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
526 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
527
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
528 if (!cfgfile)
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
529 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
530 /* alsa backend defaults */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
531 alsacfg->alsa_seq_wports = i_configure_read_seq_ports_default();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
532 alsacfg->alsa_mixer_card_id = 0;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
533 alsacfg->alsa_mixer_ctl_name = g_strdup( "Synth" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
534 alsacfg->alsa_mixer_ctl_id = 0;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
535 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
536 else
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
537 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
538 i_pcfg_read_string( cfgfile , "alsa" , "alsa_seq_wports" , &alsacfg->alsa_seq_wports , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
539 if ( alsacfg->alsa_seq_wports == NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
540 alsacfg->alsa_seq_wports = i_configure_read_seq_ports_default(); /* pick default values */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
541 i_pcfg_read_integer( cfgfile , "alsa" , "alsa_mixer_card_id" , &alsacfg->alsa_mixer_card_id , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
542 i_pcfg_read_string( cfgfile , "alsa" , "alsa_mixer_ctl_name" , &alsacfg->alsa_mixer_ctl_name , "Synth" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
543 i_pcfg_read_integer( cfgfile , "alsa" , "alsa_mixer_ctl_id" , &alsacfg->alsa_mixer_ctl_id , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
544 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
545 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
546
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
547
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
548 void i_configure_cfg_alsa_save( pcfg_t * cfgfile )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
549 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
550 amidiplug_cfg_alsa_t * alsacfg = amidiplug_cfg_backend->alsa;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
551
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
552 i_pcfg_write_string( cfgfile , "alsa" , "alsa_seq_wports" , alsacfg->alsa_seq_wports );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
553 i_pcfg_write_integer( cfgfile , "alsa" , "alsa_mixer_card_id" , alsacfg->alsa_mixer_card_id );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
554 i_pcfg_write_string( cfgfile , "alsa" , "alsa_mixer_ctl_name" , alsacfg->alsa_mixer_ctl_name );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
555 i_pcfg_write_integer( cfgfile , "alsa" , "alsa_mixer_ctl_id" , alsacfg->alsa_mixer_ctl_id );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents:
diff changeset
556 }