annotate Plugins/Input/amidi-plug/i_configure.c @ 1387:b0590e16329f trunk

[svn] import amidi-plug 0.5
author giacomo
date Mon, 10 Jul 2006 04:52:51 -0700
parents bc14606391fc
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
1 /*
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
2 *
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2006
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
4 *
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify it
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
6 * under the terms of the GNU General Public License as published by the
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
7 * Free Software Foundation; either version 2 of the License, or (at your
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
8 * option) any later version.
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
9 *
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
13 * General Public License for more details.
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
14 *
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License along
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
16 * with this program; if not, write to the Free Software Foundation, Inc.,
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
18 *
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
19 */
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
20
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
21
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
22 #include "i_configure.h"
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
23 #include "i_configure_private.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
24 #include "i_backend.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
25 #include "i_configure-ap.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
26 #include "i_configure-alsa.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
27 #include "i_configure-fluidsynth.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
28 #include "i_configure-dummy.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
29 #include "i_utils.h"
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
30 #include "libaudacious/beepctrl.h"
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
31
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
32
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
33 amidiplug_cfg_backend_t * amidiplug_cfg_backend;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
34
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
35
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
36 void i_configure_ev_bcancel( gpointer );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
37 void i_configure_ev_bok( gpointer );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
38 void i_configure_cfg_backend_alloc( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
39 void i_configure_cfg_backend_free( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
40 void i_configure_cfg_backend_save( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
41 void i_configure_cfg_backend_read( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
42 void i_configure_cfg_ap_save( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
43 void i_configure_cfg_ap_read( void );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
44
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
45
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
46 GtkWidget * i_configure_gui_draw_title( gchar * title_string )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
47 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
48 GtkWidget *title_label, *title_evbox, *title_frame;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
49 GtkStyle * style = gtk_widget_get_default_style();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
50 GdkColor title_fgcol = style->fg[GTK_STATE_SELECTED];
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
51 GdkColor title_bgcol = style->bg[GTK_STATE_SELECTED];
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
52 title_label = gtk_label_new( title_string );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
53 title_evbox = gtk_event_box_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
54 title_frame = gtk_frame_new( NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
55 gtk_frame_set_shadow_type( GTK_FRAME(title_frame) , GTK_SHADOW_OUT );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
56 gtk_container_add( GTK_CONTAINER(title_evbox) , title_label );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
57 gtk_container_set_border_width( GTK_CONTAINER(title_evbox) , 5 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
58 gtk_container_add( GTK_CONTAINER(title_frame) , title_evbox );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
59 gtk_widget_modify_fg( GTK_WIDGET(title_label) , GTK_STATE_NORMAL , &title_fgcol );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
60 gtk_widget_modify_bg( GTK_WIDGET(title_evbox) , GTK_STATE_NORMAL , &title_bgcol );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
61 return title_frame;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
62 }
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
63
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
64
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
65 void i_configure_ev_browse_for_entry( GtkWidget * target_entry )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
66 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
67 GtkWidget *parent_window = gtk_widget_get_toplevel( target_entry );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
68 GtkFileChooserAction act = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(target_entry),"fc-act"));
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
69 if ( GTK_WIDGET_TOPLEVEL(parent_window) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
70 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
71 GtkWidget *browse_dialog = gtk_file_chooser_dialog_new( _("AMIDI-Plug - select file") ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
72 GTK_WINDOW(parent_window) , act ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
73 GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
74 GTK_STOCK_OPEN , GTK_RESPONSE_ACCEPT , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
75 if ( strcmp( gtk_entry_get_text(GTK_ENTRY(target_entry)) , "" ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
76 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(browse_dialog) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
77 gtk_entry_get_text(GTK_ENTRY(target_entry)) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
78 if ( gtk_dialog_run(GTK_DIALOG(browse_dialog)) == GTK_RESPONSE_ACCEPT )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
79 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
80 gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(browse_dialog) );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
81 gtk_entry_set_text( GTK_ENTRY(target_entry) , filename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
82 DEBUGMSG( "selected file: %s\n" , filename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
83 g_free( filename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
84 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
85 gtk_widget_destroy( browse_dialog );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
86 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
87 }
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
88
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
89
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
90 void i_configure_gui( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
91 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
92 static GtkWidget *configwin = NULL;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
93 GdkGeometry cw_hints;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
94 GtkWidget *configwin_vbox;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
95 GtkWidget *hseparator, *hbuttonbox, *button_ok, *button_cancel;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
96
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
97 GtkWidget *configwin_notebook;
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
98
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
99 GtkWidget *ap_page_alignment, *ap_pagelabel_alignment; /* amidi-plug */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
100 GtkWidget *alsa_page_alignment, *alsa_pagelabel_alignment; /* alsa */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
101 GtkWidget *dumm_page_alignment, *dumm_pagelabel_alignment; /* dummy */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
102 GtkWidget *fsyn_page_alignment, *fsyn_pagelabel_alignment; /* fluidsynth */
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
103
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
104 GSList *backend_list = NULL, *backend_list_h = NULL;
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
105
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
106 if ( configwin != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
107 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
108 DEBUGMSG( "config window is already open!\n" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
109 return;
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
110 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
111
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
112 /* get configuration information for backends */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
113 i_configure_cfg_backend_alloc();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
114 i_configure_cfg_backend_read();
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
115
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
116 configwin = gtk_window_new( GTK_WINDOW_TOPLEVEL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
117 gtk_window_set_type_hint( GTK_WINDOW(configwin), GDK_WINDOW_TYPE_HINT_DIALOG );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
118 gtk_window_set_title( GTK_WINDOW(configwin), _("AMIDI-Plug - configuration") );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
119 gtk_container_set_border_width( GTK_CONTAINER(configwin), 10 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
120 g_signal_connect( G_OBJECT(configwin) , "destroy" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
121 G_CALLBACK(gtk_widget_destroyed) , &configwin );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
122 button_ok = gtk_button_new_from_stock( GTK_STOCK_OK );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
123 cw_hints.min_width = 480; cw_hints.min_height = -1;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
124 gtk_window_set_geometry_hints( GTK_WINDOW(configwin) , GTK_WIDGET(configwin) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
125 &cw_hints , GDK_HINT_MIN_SIZE );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
126
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
127 configwin_vbox = gtk_vbox_new( FALSE , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
128 gtk_container_add( GTK_CONTAINER(configwin) , configwin_vbox );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
129
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
130 configwin_notebook = gtk_notebook_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
131 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(configwin_notebook) , GTK_POS_LEFT );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
132 gtk_box_pack_start( GTK_BOX(configwin_vbox) , configwin_notebook , TRUE , TRUE , 2 );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
133
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
134 /* GET A LIST OF BACKENDS */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
135 backend_list = i_backend_list_lookup(); /* get a list of available backends */;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
136 backend_list_h = backend_list;
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
137
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
138 /* AMIDI-PLUG PREFERENCES TAB */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
139 ap_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
140 ap_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
141 gtk_alignment_set_padding( GTK_ALIGNMENT(ap_page_alignment) , 3 , 3 , 8 , 3 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
142 i_configure_gui_tab_ap( ap_page_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
143 i_configure_gui_tablabel_ap( ap_pagelabel_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
144 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
145 ap_page_alignment , ap_pagelabel_alignment );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
146
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
147 /* ALSA BACKEND CONFIGURATION TAB */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
148 alsa_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
149 alsa_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
150 gtk_alignment_set_padding( GTK_ALIGNMENT(alsa_page_alignment) , 3 , 3 , 8 , 3 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
151 i_configure_gui_tab_alsa( alsa_page_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
152 i_configure_gui_tablabel_alsa( alsa_pagelabel_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
153 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
154 alsa_page_alignment , alsa_pagelabel_alignment );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
155
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
156 /* FLUIDSYNTH BACKEND CONFIGURATION TAB */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
157 fsyn_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
158 fsyn_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
159 gtk_alignment_set_padding( GTK_ALIGNMENT(fsyn_page_alignment) , 3 , 3 , 8 , 3 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
160 i_configure_gui_tab_fsyn( fsyn_page_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
161 i_configure_gui_tablabel_fsyn( fsyn_pagelabel_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
162 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
163 fsyn_page_alignment , fsyn_pagelabel_alignment );
805
b8b9d7f5d371 [svn] update amidi-plug towards 0.2; bug fixes and a new option (midi length pre-calculation)
giacomo
parents: 525
diff changeset
164
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
165 /* DUMMY BACKEND CONFIGURATION TAB */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
166 dumm_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
167 dumm_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
168 gtk_alignment_set_padding( GTK_ALIGNMENT(dumm_page_alignment) , 3 , 3 , 8 , 3 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
169 i_configure_gui_tab_dumm( dumm_page_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
170 i_configure_gui_tablabel_dumm( dumm_pagelabel_alignment , backend_list , button_ok );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
171 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
172 dumm_page_alignment , dumm_pagelabel_alignment );
805
b8b9d7f5d371 [svn] update amidi-plug towards 0.2; bug fixes and a new option (midi length pre-calculation)
giacomo
parents: 525
diff changeset
173
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
174 i_backend_list_free( backend_list_h ); /* done, free the list of available backends */
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
175
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
176 /* horizontal separator and buttons */
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
177 hseparator = gtk_hseparator_new();
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
178 gtk_box_pack_start( GTK_BOX(configwin_vbox) , hseparator , FALSE , FALSE , 4 );
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
179 hbuttonbox = gtk_hbutton_box_new();
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
180 gtk_button_box_set_layout( GTK_BUTTON_BOX(hbuttonbox) , GTK_BUTTONBOX_END );
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
181 button_cancel = gtk_button_new_from_stock( GTK_STOCK_CANCEL );
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
182 g_signal_connect_swapped( G_OBJECT(button_cancel) , "clicked" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
183 G_CALLBACK(i_configure_ev_bcancel) , configwin );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
184 gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_cancel );
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
185 /* button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); created above */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
186 g_signal_connect_swapped( G_OBJECT(button_ok) , "clicked" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
187 G_CALLBACK(i_configure_ev_bok) , configwin );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
188 gtk_container_add( GTK_CONTAINER(hbuttonbox) , button_ok );
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
189 gtk_box_pack_start( GTK_BOX(configwin_vbox) , hbuttonbox , FALSE , FALSE , 0 );
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
190
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
191 gtk_widget_show_all( configwin );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
192 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
193
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
194
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
195 void i_configure_ev_bcancel( gpointer configwin )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
196 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
197 i_configure_cfg_backend_free();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
198 gtk_widget_destroy(GTK_WIDGET(configwin));
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
199 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
200
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
201
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
202 void i_configure_ev_bok( gpointer configwin )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
203 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
204 if ( xmms_remote_is_playing(0) || xmms_remote_is_paused(0) )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
205 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
206 /* we can't change settings while a song is being played */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
207 static GtkWidget * configwin_warnmsg = NULL;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
208 if ( configwin_warnmsg != NULL )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
209 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
210 gdk_window_raise( configwin_warnmsg->window );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
211 }
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
212 else
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
213 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
214 configwin_warnmsg = (GtkWidget*)i_message_gui( _("AMIDI-Plug message") ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
215 _("Please stop the player before changing AMIDI-Plug settings.") ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
216 AMIDIPLUG_MESSAGE_WARN , configwin );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
217 g_signal_connect( G_OBJECT(configwin_warnmsg) , "destroy" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
218 G_CALLBACK(gtk_widget_destroyed) , &configwin_warnmsg );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
219 gtk_widget_show_all( configwin_warnmsg );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
220 }
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
221 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
222 else
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
223 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
224 DEBUGMSG( "saving configuration...\n" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
225 i_configure_cfg_ap_save(); /* save amidiplug settings */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
226 i_configure_cfg_backend_save(); /* save backend settings */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
227 i_configure_cfg_backend_free(); /* free backend settings */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
228 DEBUGMSG( "configuration saved\n" );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
229
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
230 /* check if a different backend has been selected */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
231 if ( strcmp( amidiplug_cfg_ap.ap_seq_backend , backend.name ) )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
232 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
233 DEBUGMSG( "a new backend has been selected, unloading previous and loading the new one\n" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
234 i_backend_unload(); /* unload previous backend */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
235 i_backend_load( amidiplug_cfg_ap.ap_seq_backend ); /* load new backend */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
236 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
237 else /* same backend, just reload updated configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
238 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
239 DEBUGMSG( "the selected backend is already loaded, so just perform backend cleanup and reinit\n" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
240 backend.cleanup();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
241 backend.init();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
242 }
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
243
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
244 gtk_widget_destroy(GTK_WIDGET(configwin));
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
245 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
246 }
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
247
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
248
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
249 void i_configure_cfg_backend_alloc( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
250 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
251 amidiplug_cfg_backend = g_malloc(sizeof(amidiplug_cfg_backend));
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
252
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
253 i_configure_cfg_alsa_alloc(); /* alloc alsa backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
254 i_configure_cfg_fsyn_alloc(); /* alloc fluidsynth backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
255 i_configure_cfg_dumm_alloc(); /* alloc dummy backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
256 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
257
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
258
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
259 void i_configure_cfg_backend_free( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
260 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
261 i_configure_cfg_alsa_free(); /* free alsa backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
262 i_configure_cfg_fsyn_free(); /* free fluidsynth backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
263 i_configure_cfg_dumm_free(); /* free dummy backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
264
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
265 g_free( amidiplug_cfg_backend );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
266 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
267
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
268
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
269 void i_configure_cfg_backend_read( void )
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
270 {
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
271 pcfg_t *cfgfile;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
272
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
273 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
274 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
275 cfgfile = i_pcfg_new_from_file( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
276
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
277 i_configure_cfg_alsa_read( cfgfile ); /* get alsa backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
278 i_configure_cfg_fsyn_read( cfgfile ); /* get fluidsynth backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
279 i_configure_cfg_dumm_read( cfgfile ); /* get dummy backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
280
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
281 if ( cfgfile != NULL )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
282 i_pcfg_free(cfgfile);
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
283
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
284 g_free( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
285 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
286
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
287
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
288 void i_configure_cfg_backend_save( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
289 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
290 pcfg_t *cfgfile;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
291 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
292 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
293 cfgfile = i_pcfg_new_from_file( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
294
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
295 if (!cfgfile)
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
296 cfgfile = i_pcfg_new();
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
297
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
298 i_configure_cfg_alsa_save( cfgfile ); /* save alsa backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
299 i_configure_cfg_fsyn_save( cfgfile ); /* save fluidsynth backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
300 i_configure_cfg_dumm_save( cfgfile ); /* save dummy backend configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
301
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
302 i_pcfg_write_to_file( cfgfile , config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
303 i_pcfg_free( cfgfile );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
304 g_free( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
305 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
306
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
307
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
308 /* read only the amidi-plug part of configuration */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
309 void i_configure_cfg_ap_read( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
310 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
311 pcfg_t *cfgfile;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
312 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
313 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
314 cfgfile = i_pcfg_new_from_file( config_pathfilename );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
315
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
316 if (!cfgfile)
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
317 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
318 /* amidi-plug defaults */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
319 amidiplug_cfg_ap.ap_seq_backend = g_strdup( "alsa" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
320 amidiplug_cfg_ap.ap_opts_length_precalc = 0;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
321 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
322 else
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
323 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
324 i_pcfg_read_string( cfgfile , "general" , "ap_seq_backend" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
325 &amidiplug_cfg_ap.ap_seq_backend , "alsa" );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
326 i_pcfg_read_integer( cfgfile , "general" , "ap_opts_length_precalc" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
327 &amidiplug_cfg_ap.ap_opts_length_precalc , 0 );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
328 i_pcfg_free( cfgfile );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
329 }
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
330
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
331 g_free( config_pathfilename );
522
60c744f652f4 [svn] amidi-plug (MIDI through ALSA seq) input plugin added, brand new and completely written from scratch :)
giacomo
parents:
diff changeset
332 }
1387
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
333
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
334
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
335 void i_configure_cfg_ap_save( void )
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
336 {
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
337 pcfg_t *cfgfile;
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
338 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" ,
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
339 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
340 cfgfile = i_pcfg_new_from_file( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
341
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
342 if (!cfgfile)
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
343 cfgfile = i_pcfg_new();
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
344
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
345 /* save amidi-plug config information */
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
346 i_pcfg_write_string( cfgfile , "general" , "ap_seq_backend" , amidiplug_cfg_ap.ap_seq_backend );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
347 i_pcfg_write_integer( cfgfile , "general" , "ap_opts_length_precalc" , amidiplug_cfg_ap.ap_opts_length_precalc );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
348
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
349 i_pcfg_write_to_file( cfgfile , config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
350 i_pcfg_free( cfgfile );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
351 g_free( config_pathfilename );
b0590e16329f [svn] import amidi-plug 0.5
giacomo
parents: 1015
diff changeset
352 }