Mercurial > audlegacy
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 |
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 | 23 #include "i_configure_private.h" |
24 #include "i_backend.h" | |
25 #include "i_configure-ap.h" | |
26 #include "i_configure-alsa.h" | |
27 #include "i_configure-fluidsynth.h" | |
28 #include "i_configure-dummy.h" | |
29 #include "i_utils.h" | |
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 | 32 |
33 amidiplug_cfg_backend_t * amidiplug_cfg_backend; | |
34 | |
35 | |
36 void i_configure_ev_bcancel( gpointer ); | |
37 void i_configure_ev_bok( gpointer ); | |
38 void i_configure_cfg_backend_alloc( void ); | |
39 void i_configure_cfg_backend_free( void ); | |
40 void i_configure_cfg_backend_save( void ); | |
41 void i_configure_cfg_backend_read( void ); | |
42 void i_configure_cfg_ap_save( void ); | |
43 void i_configure_cfg_ap_read( void ); | |
44 | |
45 | |
46 GtkWidget * i_configure_gui_draw_title( gchar * title_string ) | |
47 { | |
48 GtkWidget *title_label, *title_evbox, *title_frame; | |
49 GtkStyle * style = gtk_widget_get_default_style(); | |
50 GdkColor title_fgcol = style->fg[GTK_STATE_SELECTED]; | |
51 GdkColor title_bgcol = style->bg[GTK_STATE_SELECTED]; | |
52 title_label = gtk_label_new( title_string ); | |
53 title_evbox = gtk_event_box_new(); | |
54 title_frame = gtk_frame_new( NULL ); | |
55 gtk_frame_set_shadow_type( GTK_FRAME(title_frame) , GTK_SHADOW_OUT ); | |
56 gtk_container_add( GTK_CONTAINER(title_evbox) , title_label ); | |
57 gtk_container_set_border_width( GTK_CONTAINER(title_evbox) , 5 ); | |
58 gtk_container_add( GTK_CONTAINER(title_frame) , title_evbox ); | |
59 gtk_widget_modify_fg( GTK_WIDGET(title_label) , GTK_STATE_NORMAL , &title_fgcol ); | |
60 gtk_widget_modify_bg( GTK_WIDGET(title_evbox) , GTK_STATE_NORMAL , &title_bgcol ); | |
61 return title_frame; | |
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 | 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 | 67 GtkWidget *parent_window = gtk_widget_get_toplevel( target_entry ); |
68 GtkFileChooserAction act = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(target_entry),"fc-act")); | |
69 if ( GTK_WIDGET_TOPLEVEL(parent_window) ) | |
70 { | |
71 GtkWidget *browse_dialog = gtk_file_chooser_dialog_new( _("AMIDI-Plug - select file") , | |
72 GTK_WINDOW(parent_window) , act , | |
73 GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL , | |
74 GTK_STOCK_OPEN , GTK_RESPONSE_ACCEPT , NULL ); | |
75 if ( strcmp( gtk_entry_get_text(GTK_ENTRY(target_entry)) , "" ) ) | |
76 gtk_file_chooser_set_filename( GTK_FILE_CHOOSER(browse_dialog) , | |
77 gtk_entry_get_text(GTK_ENTRY(target_entry)) ); | |
78 if ( gtk_dialog_run(GTK_DIALOG(browse_dialog)) == GTK_RESPONSE_ACCEPT ) | |
79 { | |
80 gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(browse_dialog) ); | |
81 gtk_entry_set_text( GTK_ENTRY(target_entry) , filename ); | |
82 DEBUGMSG( "selected file: %s\n" , filename ); | |
83 g_free( filename ); | |
84 } | |
85 gtk_widget_destroy( browse_dialog ); | |
86 } | |
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 | 89 |
90 void i_configure_gui( void ) | |
91 { | |
92 static GtkWidget *configwin = NULL; | |
93 GdkGeometry cw_hints; | |
94 GtkWidget *configwin_vbox; | |
95 GtkWidget *hseparator, *hbuttonbox, *button_ok, *button_cancel; | |
96 | |
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 | 99 GtkWidget *ap_page_alignment, *ap_pagelabel_alignment; /* amidi-plug */ |
100 GtkWidget *alsa_page_alignment, *alsa_pagelabel_alignment; /* alsa */ | |
101 GtkWidget *dumm_page_alignment, *dumm_pagelabel_alignment; /* dummy */ | |
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 | 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 | 106 if ( configwin != NULL ) |
107 { | |
108 DEBUGMSG( "config window is already open!\n" ); | |
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 | 112 /* get configuration information for backends */ |
113 i_configure_cfg_backend_alloc(); | |
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 | 116 configwin = gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
117 gtk_window_set_type_hint( GTK_WINDOW(configwin), GDK_WINDOW_TYPE_HINT_DIALOG ); | |
118 gtk_window_set_title( GTK_WINDOW(configwin), _("AMIDI-Plug - configuration") ); | |
119 gtk_container_set_border_width( GTK_CONTAINER(configwin), 10 ); | |
120 g_signal_connect( G_OBJECT(configwin) , "destroy" , | |
121 G_CALLBACK(gtk_widget_destroyed) , &configwin ); | |
122 button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); | |
123 cw_hints.min_width = 480; cw_hints.min_height = -1; | |
124 gtk_window_set_geometry_hints( GTK_WINDOW(configwin) , GTK_WIDGET(configwin) , | |
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 | 127 configwin_vbox = gtk_vbox_new( FALSE , 0 ); |
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 | 130 configwin_notebook = gtk_notebook_new(); |
131 gtk_notebook_set_tab_pos( GTK_NOTEBOOK(configwin_notebook) , GTK_POS_LEFT ); | |
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 | 134 /* GET A LIST OF BACKENDS */ |
135 backend_list = i_backend_list_lookup(); /* get a list of available backends */; | |
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 | 138 /* AMIDI-PLUG PREFERENCES TAB */ |
139 ap_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
140 ap_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
141 gtk_alignment_set_padding( GTK_ALIGNMENT(ap_page_alignment) , 3 , 3 , 8 , 3 ); | |
142 i_configure_gui_tab_ap( ap_page_alignment , backend_list , button_ok ); | |
143 i_configure_gui_tablabel_ap( ap_pagelabel_alignment , backend_list , button_ok ); | |
144 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , | |
145 ap_page_alignment , ap_pagelabel_alignment ); | |
146 | |
147 /* ALSA BACKEND CONFIGURATION TAB */ | |
148 alsa_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
149 alsa_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
150 gtk_alignment_set_padding( GTK_ALIGNMENT(alsa_page_alignment) , 3 , 3 , 8 , 3 ); | |
151 i_configure_gui_tab_alsa( alsa_page_alignment , backend_list , button_ok ); | |
152 i_configure_gui_tablabel_alsa( alsa_pagelabel_alignment , backend_list , button_ok ); | |
153 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , | |
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 | 156 /* FLUIDSYNTH BACKEND CONFIGURATION TAB */ |
157 fsyn_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
158 fsyn_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
159 gtk_alignment_set_padding( GTK_ALIGNMENT(fsyn_page_alignment) , 3 , 3 , 8 , 3 ); | |
160 i_configure_gui_tab_fsyn( fsyn_page_alignment , backend_list , button_ok ); | |
161 i_configure_gui_tablabel_fsyn( fsyn_pagelabel_alignment , backend_list , button_ok ); | |
162 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , | |
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 | 165 /* DUMMY BACKEND CONFIGURATION TAB */ |
166 dumm_pagelabel_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
167 dumm_page_alignment = gtk_alignment_new( 0.5 , 0.5 , 1 , 1 ); | |
168 gtk_alignment_set_padding( GTK_ALIGNMENT(dumm_page_alignment) , 3 , 3 , 8 , 3 ); | |
169 i_configure_gui_tab_dumm( dumm_page_alignment , backend_list , button_ok ); | |
170 i_configure_gui_tablabel_dumm( dumm_pagelabel_alignment , backend_list , button_ok ); | |
171 gtk_notebook_append_page( GTK_NOTEBOOK(configwin_notebook) , | |
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 | 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 | 182 g_signal_connect_swapped( G_OBJECT(button_cancel) , "clicked" , |
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 | 185 /* button_ok = gtk_button_new_from_stock( GTK_STOCK_OK ); created above */ |
186 g_signal_connect_swapped( G_OBJECT(button_ok) , "clicked" , | |
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 | 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 | 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 | 197 i_configure_cfg_backend_free(); |
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 | 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 | 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 | 206 /* we can't change settings while a song is being played */ |
207 static GtkWidget * configwin_warnmsg = NULL; | |
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 | 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 | 212 else |
213 { | |
214 configwin_warnmsg = (GtkWidget*)i_message_gui( _("AMIDI-Plug message") , | |
215 _("Please stop the player before changing AMIDI-Plug settings.") , | |
216 AMIDIPLUG_MESSAGE_WARN , configwin ); | |
217 g_signal_connect( G_OBJECT(configwin_warnmsg) , "destroy" , | |
218 G_CALLBACK(gtk_widget_destroyed) , &configwin_warnmsg ); | |
219 gtk_widget_show_all( configwin_warnmsg ); | |
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 | 224 DEBUGMSG( "saving configuration...\n" ); |
225 i_configure_cfg_ap_save(); /* save amidiplug settings */ | |
226 i_configure_cfg_backend_save(); /* save backend settings */ | |
227 i_configure_cfg_backend_free(); /* free backend settings */ | |
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 | 230 /* check if a different backend has been selected */ |
231 if ( strcmp( amidiplug_cfg_ap.ap_seq_backend , backend.name ) ) | |
232 { | |
233 DEBUGMSG( "a new backend has been selected, unloading previous and loading the new one\n" ); | |
234 i_backend_unload(); /* unload previous backend */ | |
235 i_backend_load( amidiplug_cfg_ap.ap_seq_backend ); /* load new backend */ | |
236 } | |
237 else /* same backend, just reload updated configuration */ | |
238 { | |
239 DEBUGMSG( "the selected backend is already loaded, so just perform backend cleanup and reinit\n" ); | |
240 backend.cleanup(); | |
241 backend.init(); | |
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 | 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 | 249 void i_configure_cfg_backend_alloc( void ) |
250 { | |
251 amidiplug_cfg_backend = g_malloc(sizeof(amidiplug_cfg_backend)); | |
252 | |
253 i_configure_cfg_alsa_alloc(); /* alloc alsa backend configuration */ | |
254 i_configure_cfg_fsyn_alloc(); /* alloc fluidsynth backend configuration */ | |
255 i_configure_cfg_dumm_alloc(); /* alloc dummy backend configuration */ | |
256 } | |
257 | |
258 | |
259 void i_configure_cfg_backend_free( void ) | |
260 { | |
261 i_configure_cfg_alsa_free(); /* free alsa backend configuration */ | |
262 i_configure_cfg_fsyn_free(); /* free fluidsynth backend configuration */ | |
263 i_configure_cfg_dumm_free(); /* free dummy backend configuration */ | |
264 | |
265 g_free( amidiplug_cfg_backend ); | |
266 } | |
267 | |
268 | |
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 | 271 pcfg_t *cfgfile; |
272 | |
273 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" , | |
274 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL ); | |
275 cfgfile = i_pcfg_new_from_file( config_pathfilename ); | |
276 | |
277 i_configure_cfg_alsa_read( cfgfile ); /* get alsa backend configuration */ | |
278 i_configure_cfg_fsyn_read( cfgfile ); /* get fluidsynth backend configuration */ | |
279 i_configure_cfg_dumm_read( cfgfile ); /* get dummy backend configuration */ | |
280 | |
281 if ( cfgfile != NULL ) | |
282 i_pcfg_free(cfgfile); | |
283 | |
284 g_free( config_pathfilename ); | |
285 } | |
286 | |
287 | |
288 void i_configure_cfg_backend_save( void ) | |
289 { | |
290 pcfg_t *cfgfile; | |
291 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" , | |
292 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL ); | |
293 cfgfile = i_pcfg_new_from_file( config_pathfilename ); | |
294 | |
295 if (!cfgfile) | |
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 | 298 i_configure_cfg_alsa_save( cfgfile ); /* save alsa backend configuration */ |
299 i_configure_cfg_fsyn_save( cfgfile ); /* save fluidsynth backend configuration */ | |
300 i_configure_cfg_dumm_save( cfgfile ); /* save dummy backend configuration */ | |
301 | |
302 i_pcfg_write_to_file( cfgfile , config_pathfilename ); | |
303 i_pcfg_free( cfgfile ); | |
304 g_free( config_pathfilename ); | |
305 } | |
306 | |
307 | |
308 /* read only the amidi-plug part of configuration */ | |
309 void i_configure_cfg_ap_read( void ) | |
310 { | |
311 pcfg_t *cfgfile; | |
312 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" , | |
313 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL ); | |
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 | 316 if (!cfgfile) |
317 { | |
318 /* amidi-plug defaults */ | |
319 amidiplug_cfg_ap.ap_seq_backend = g_strdup( "alsa" ); | |
320 amidiplug_cfg_ap.ap_opts_length_precalc = 0; | |
321 } | |
322 else | |
323 { | |
324 i_pcfg_read_string( cfgfile , "general" , "ap_seq_backend" , | |
325 &amidiplug_cfg_ap.ap_seq_backend , "alsa" ); | |
326 i_pcfg_read_integer( cfgfile , "general" , "ap_opts_length_precalc" , | |
327 &amidiplug_cfg_ap.ap_opts_length_precalc , 0 ); | |
328 i_pcfg_free( cfgfile ); | |
329 } | |
330 | |
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 | 333 |
334 | |
335 void i_configure_cfg_ap_save( void ) | |
336 { | |
337 pcfg_t *cfgfile; | |
338 gchar * config_pathfilename = g_strjoin( "" , g_get_home_dir() , "/" , | |
339 PLAYER_LOCALRCDIR , "/amidi-plug.conf" , NULL ); | |
340 cfgfile = i_pcfg_new_from_file( config_pathfilename ); | |
341 | |
342 if (!cfgfile) | |
343 cfgfile = i_pcfg_new(); | |
344 | |
345 /* save amidi-plug config information */ | |
346 i_pcfg_write_string( cfgfile , "general" , "ap_seq_backend" , amidiplug_cfg_ap.ap_seq_backend ); | |
347 i_pcfg_write_integer( cfgfile , "general" , "ap_opts_length_precalc" , amidiplug_cfg_ap.ap_opts_length_precalc ); | |
348 | |
349 i_pcfg_write_to_file( cfgfile , config_pathfilename ); | |
350 i_pcfg_free( cfgfile ); | |
351 g_free( config_pathfilename ); | |
352 } |