Mercurial > hg > xmms-sid
annotate src/xs_config.c @ 45:84214a409d19
Minor fixes
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 20 Jun 2003 01:36:05 +0000 |
parents | 90cd38b28a72 |
children | dae6d3c2268d |
rev | line source |
---|---|
1 | 1 /* |
3 | 2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
4 Configuration dialog | |
5 | |
3 | 6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org> |
1 | 7 |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software | |
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
22 #include "xs_config.h" |
3 | 23 #include <xmms/configfile.h> |
24 #include <stdio.h> | |
25 #include "xs_glade.h" | |
26 #include "xs_interface.h" | |
1 | 27 |
28 | |
29 /* | |
3 | 30 * Global widgets |
1 | 31 */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
32 static GtkWidget *xs_configwin = NULL, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
33 *xs_sldb_fileselector = NULL, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
34 *xs_stil_fileselector = NULL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
35 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
36 #define LUW(x...) lookup_widget(xs_configwin, ## x) |
1 | 37 |
38 | |
39 /* | |
40 * Configuration specific stuff | |
41 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
42 t_xs_cfg_item xs_cfgtable[] = { |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
43 {ATYPE_INT, &xs_cfg.fmtBitsPerSample,"fmtBitsPerSample"}, |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
44 {ATYPE_INT, &xs_cfg.fmtChannels, "fmtChannels"}, |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
45 {ATYPE_INT, &xs_cfg.fmtFrequency, "fmtFrequency"}, |
3 | 46 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
47 {ATYPE_BOOL, &xs_cfg.mos8580, "mos8580"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
48 {ATYPE_BOOL, &xs_cfg.emulateFilters, "emulateFilters"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
49 {ATYPE_FLOAT, &xs_cfg.filterFs, "filterFs"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
50 {ATYPE_FLOAT, &xs_cfg.filterFm, "filterFm"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
51 {ATYPE_FLOAT, &xs_cfg.filterFt, "filterFt"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
52 {ATYPE_INT, &xs_cfg.memoryMode, "memoryMode"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
53 {ATYPE_INT, &xs_cfg.clockSpeed, "clockSpeed"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
54 {ATYPE_BOOL, &xs_cfg.forceSpeed, "forceSpeed"}, |
3 | 55 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
56 {ATYPE_BOOL, &xs_cfg.oversampleEnable,"oversampleEnable"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
57 {ATYPE_INT, &xs_cfg.oversampleFactor,"oversampleFactor"}, |
3 | 58 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
59 {ATYPE_BOOL, &xs_cfg.playMaxTimeEnable,"playMaxTimeEnable"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
60 {ATYPE_INT, &xs_cfg.playMaxTime, "playMaxTime"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
61 {ATYPE_BOOL, &xs_cfg.songlenDBEnable,"songlenDBEnable"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
62 {ATYPE_STR, &xs_cfg.songlenDBPath, "songlenDBPath"}, |
3 | 63 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
64 {ATYPE_BOOL, &xs_cfg.stilDBEnable, "stilDBEnable"}, |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
65 {ATYPE_STR, &xs_cfg.stilDBPath, "stilDBPath"}, |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
66 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
67 {ATYPE_BOOL, &xs_cfg.detectMagic, "detectMagic"}, |
3 | 68 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
69 {ATYPE_BOOL, &xs_cfg.titleOverride, "titleOverride"}, |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
70 {ATYPE_STR, &xs_cfg.titleFormat, "titleFormat"} |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
71 }; |
3 | 72 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
73 const gint XS_CFGTABLE_MAX = (sizeof(xs_cfgtable) / sizeof(t_xs_cfg_item)); |
1 | 74 |
75 | |
3 | 76 /* |
77 * Reset the filter settings | |
78 */ | |
79 void xs_reset_filters(void) | |
80 { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
81 /* Reset filter values */ |
3 | 82 /* |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
83 xs_cfg.filterFs = SIDEMU_DEFAULTFILTERFS; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
84 xs_cfg.filterFm = SIDEMU_DEFAULTFILTERFM; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
85 xs_cfg.filterFt = SIDEMU_DEFAULTFILTERFT; |
3 | 86 */ |
87 } | |
88 | |
1 | 89 |
90 /* | |
91 * Get the configuration (from file or default) | |
92 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
93 void xs_read_configuration(void) |
1 | 94 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
95 gchar *cfgFilename, *tmpStr; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
96 ConfigFile *cfgFile; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
97 gint i; |
3 | 98 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
99 XSDEBUG("initializing configuration ...\n"); |
3 | 100 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
101 /* Pre-initialize configuration structure */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
102 xs_cfg.fmtBitsPerSample = 16; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
103 xs_cfg.fmtChannels = XS_CHN_MONO; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
104 xs_cfg.fmtFrequency = 44100; |
3 | 105 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
106 xs_cfg.mos8580 = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
107 xs_cfg.emulateFilters = TRUE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
108 xs_reset_filters(); |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
109 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
110 #ifdef HAVE_SIDPLAY2 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
111 xs_cfg.memoryMode = XS_MPU_REAL; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
112 #else |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
113 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
114 #endif |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
115 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
116 xs_cfg.clockSpeed = XS_CLOCK_PAL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
117 xs_cfg.forceSpeed = FALSE; |
3 | 118 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
119 xs_cfg.oversampleEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
120 xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; |
1 | 121 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
122 xs_cfg.playMaxTimeEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
123 xs_cfg.playMaxTime = 150; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
124 xs_cfg.songlenDBEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
125 xs_strcalloc(&xs_cfg.songlenDBPath, "~/C64Music/Songlengths.txt"); |
3 | 126 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
127 xs_cfg.stilDBEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
128 xs_strcalloc(&xs_cfg.stilDBPath, "~/C64Music/DOCUMENTS/STIL.txt"); |
3 | 129 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
130 xs_cfg.detectMagic = FALSE; |
1 | 131 |
45 | 132 #ifdef HAVE_XMMSEXTRA |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
133 xs_cfg.titleOverride = FALSE; |
45 | 134 #else |
135 xs_cfg.titleOverride = TRUE; | |
136 #endif | |
137 xs_strcalloc(&xs_cfg.titleFormat, "%1 - %2 (%3)"); | |
3 | 138 |
139 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
140 /* Try to open the XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
141 XSDEBUG("loading from config-file ...\n"); |
3 | 142 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
143 cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
144 cfgFile = xmms_cfg_open_file(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
145 g_free(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
146 if (cfgFile == NULL) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
147 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
148 XSDEBUG("could not open configuration file, trying to write defaults...\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
149 xs_write_configuration(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
150 return; |
3 | 151 } |
1 | 152 |
153 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
154 /* Read the new settings from XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
155 for (i = 0; i < XS_CFGTABLE_MAX; i++) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
156 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
157 switch (xs_cfgtable[i].atype) { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
158 case ATYPE_INT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
159 xmms_cfg_read_int(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, (gint *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
160 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
161 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
162 case ATYPE_BOOL: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
163 xmms_cfg_read_boolean(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, (gboolean *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
164 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
165 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
166 case ATYPE_FLOAT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
167 xmms_cfg_read_float(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, (gfloat *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
168 break; |
3 | 169 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
170 case ATYPE_STR: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
171 if (xmms_cfg_read_string(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, (gchar **) &tmpStr)) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
172 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
173 /* Read was successfull */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
174 xs_strcalloc((gchar **) xs_cfgtable[i].adata, tmpStr); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
175 g_free(tmpStr); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
176 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
177 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
178 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
179 default: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
180 XSERR("Internal: Unsupported setting type found while reading configuration file. Please report to author!\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
181 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
182 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
183 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
184 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
185 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
186 /* Free the config file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
187 xmms_cfg_free(cfgFile); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
188 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
189 XSDEBUG("OK\n"); |
1 | 190 } |
191 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
192 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
193 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
194 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
195 * Write the current configuration |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
196 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
197 gint xs_write_configuration(void) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
198 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
199 gchar *cfgFilename; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
200 ConfigFile *cfgFile; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
201 gint i; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
202 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
203 XSDEBUG("writing configuration ...\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
204 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
205 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
206 * Try to open the XMMS configuration file |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
207 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
208 cfgFilename = g_strconcat(g_get_home_dir(), XS_CONFIG_FILE, NULL); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
209 cfgFile = xmms_cfg_open_file(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
210 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
211 if (!cfgFile) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
212 cfgFile = xmms_cfg_new(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
213 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
214 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
215 /* Write the new settings to XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
216 for (i = 0; i < XS_CFGTABLE_MAX; i++) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
217 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
218 switch (xs_cfgtable[i].atype) { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
219 case ATYPE_INT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
220 xmms_cfg_write_int(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, *(gint *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
221 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
222 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
223 case ATYPE_BOOL: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
224 xmms_cfg_write_boolean(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, *(gboolean *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
225 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
226 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
227 case ATYPE_FLOAT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
228 xmms_cfg_write_float(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, *(gfloat *) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
229 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
230 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
231 case ATYPE_STR: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
232 xmms_cfg_write_string(cfgFile, XS_CONFIG_IDENT, xs_cfgtable[i].aname, *(gchar **) xs_cfgtable[i].adata); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
233 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
234 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
235 default: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
236 XSERR("Internal: Unsupported setting type found while writing configuration file. Please report to author!\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
237 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
238 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
239 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
240 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
241 /* Flush the file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
242 xmms_cfg_write_file(cfgFile, cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
243 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
244 /* Free the memory areas */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
245 xmms_cfg_free(cfgFile); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
246 g_free(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
247 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
248 return 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
249 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
250 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
251 |
1 | 252 /* |
253 * Configuration panel was canceled | |
254 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
255 void xs_cfg_cancel(void) |
1 | 256 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
257 gtk_widget_destroy(xs_configwin); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
258 xs_configwin = NULL; |
1 | 259 } |
260 | |
261 | |
262 /* | |
263 * Configuration was accepted (OK), save the settings | |
264 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
265 void xs_cfg_ok(void) |
1 | 266 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
267 XSDEBUG("get data from widgets to config...\n"); |
3 | 268 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
269 /* Check the resolution settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
270 if (GTK_TOGGLE_BUTTON(LUW("cfg_res_16bit"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
271 xs_cfg.fmtBitsPerSample = XS_RES_16BIT; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
272 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
273 xs_cfg.fmtBitsPerSample = XS_RES_8BIT; |
1 | 274 |
3 | 275 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
276 /* Channel settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
277 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_mono"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
278 xs_cfg.fmtChannels = XS_CHN_MONO; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
279 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
280 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_stereo"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
281 xs_cfg.fmtChannels = XS_CHN_STEREO; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
282 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
283 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_autopan"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
284 xs_cfg.fmtChannels = XS_CHN_AUTOPAN; |
3 | 285 |
286 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
287 /* Frequency setting */ |
42 | 288 xs_cfg.fmtFrequency = (gint) GTK_ADJUSTMENT(LUW("cfg_samplerate"))->value; |
3 | 289 |
1 | 290 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
291 /* Filter and waveform settings */ |
42 | 292 xs_cfg.mos8580 = GTK_TOGGLE_BUTTON(LUW("cfg_emu_mos8580"))->active; |
1 | 293 |
42 | 294 xs_cfg.emulateFilters = GTK_TOGGLE_BUTTON(LUW("cfg_emu_filters"))->active; |
3 | 295 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
296 xs_cfg.filterFs = GTK_ADJUSTMENT(LUW("cfg_filt_fs_adj"))->value; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
297 xs_cfg.filterFm = GTK_ADJUSTMENT(LUW("cfg_filt_fm_adj"))->value; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
298 xs_cfg.filterFt = GTK_ADJUSTMENT(LUW("cfg_filt_ft_adj"))->value; |
1 | 299 |
300 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
301 /* Memorymode settings */ |
45 | 302 if (GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_real"))->active) |
303 xs_cfg.memoryMode = XS_MPU_REAL; | |
304 else | |
42 | 305 if (GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_banksw"))->active) |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
306 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
307 else |
42 | 308 if (GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_transrom"))->active) |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
309 xs_cfg.memoryMode = XS_MPU_TRANSPARENT_ROM; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
310 else |
42 | 311 if (GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_playsid"))->active) |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
312 xs_cfg.memoryMode = XS_MPU_PLAYSID_ENVIRONMENT; |
3 | 313 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
314 /* Clockspeed settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
315 if (GTK_TOGGLE_BUTTON(LUW("cfg_clock_ntsc"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
316 xs_cfg.clockSpeed = XS_CLOCK_NTSC; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
317 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
318 xs_cfg.clockSpeed = XS_CLOCK_PAL; |
3 | 319 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
320 xs_cfg.forceSpeed = GTK_TOGGLE_BUTTON(LUW("cfg_clock_force"))->active; |
3 | 321 |
1 | 322 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
323 /* Songlength-detection settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
324 xs_cfg.playMaxTimeEnable = GTK_TOGGLE_BUTTON(LUW("cfg_sld_usemaxtime"))->active; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
325 xs_cfg.playMaxTime = GTK_ADJUSTMENT(LUW("cfg_sld_maxtime_adj"))->value; |
3 | 326 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
327 xs_cfg.songlenDBEnable = (GTK_TOGGLE_BUTTON(LUW("cfg_sld"))->active); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
328 xs_strcalloc(&xs_cfg.songlenDBPath, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sld_dbpath")))); |
1 | 329 |
330 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
331 /* STIL and miscellaneous settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
332 xs_cfg.stilDBEnable = GTK_TOGGLE_BUTTON(LUW("cfg_stil_use"))->active; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
333 xs_strcalloc(&xs_cfg.stilDBPath, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_stil_path")))); |
3 | 334 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
335 xs_cfg.detectMagic = GTK_TOGGLE_BUTTON(LUW("cfg_detectmagic"))->active; |
3 | 336 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
337 /* Title settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
338 xs_cfg.titleOverride = GTK_TOGGLE_BUTTON(LUW("cfg_ftitle_override"))->active; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
339 xs_strcalloc(&xs_cfg.titleFormat, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_ftitle_format")))); |
1 | 340 |
341 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
342 /* Write settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
343 xs_write_configuration(); |
1 | 344 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
345 /* NOTICE/FIXME FIX ME: if songlendb or stildb settings changed, we need to flush and reread them */ |
1 | 346 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
347 /* Close window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
348 gtk_widget_destroy(xs_configwin); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
349 xs_configwin = NULL; |
1 | 350 } |
351 | |
352 | |
353 /* | |
354 * Update filter setting sliders | |
355 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
356 void xs_update_filters(void) |
1 | 357 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
358 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_filt_fs_adj")), xs_cfg.filterFs); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
359 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_filt_fm_adj")), xs_cfg.filterFm); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
360 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_filt_ft_adj")), xs_cfg.filterFt); |
1 | 361 } |
362 | |
363 | |
364 /* | |
365 * Reset filter settings to defaults | |
366 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
367 void xs_cfg_filter_reset(void) |
3 | 368 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
369 xs_reset_filters(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
370 xs_update_filters(); |
3 | 371 } |
372 | |
373 | |
374 /* | |
375 * HVSC songlength-database file selector response-functions | |
376 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
377 void xs_cfg_sld_dbbrowse(GtkButton *button, gpointer user_data) |
1 | 378 { |
42 | 379 if (xs_sldb_fileselector != NULL) |
380 { | |
381 gdk_window_raise(xs_sldb_fileselector->window); | |
382 return; | |
383 } | |
384 | |
385 xs_sldb_fileselector = create_xs_sldbfileselector(); | |
386 gtk_widget_show(xs_sldb_fileselector); | |
3 | 387 } |
388 | |
389 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
390 void xs_cfg_sldb_fs_ok(void) |
3 | 391 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
392 /* Selection was accepted! */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
393 gtk_entry_set_text(GTK_ENTRY(LUW("cfg_sld_dbpath")), |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
394 gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_sldb_fileselector)) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
395 ); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
396 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
397 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
398 gtk_widget_destroy(xs_sldb_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
399 xs_sldb_fileselector = NULL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
400 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
401 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
402 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
403 void xs_cfg_sldb_fs_cancel(void) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
404 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
405 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
406 gtk_widget_destroy(xs_sldb_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
407 xs_sldb_fileselector = NULL; |
1 | 408 } |
409 | |
410 | |
411 /* | |
412 * STIL-database file selector response-functions | |
413 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
414 void xs_cfg_stil_browse(GtkButton *button, gpointer user_data) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
415 { |
42 | 416 if (xs_stil_fileselector != NULL) |
417 { | |
418 gdk_window_raise(xs_stil_fileselector->window); | |
419 return; | |
420 } | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
421 |
42 | 422 xs_stil_fileselector = create_xs_stilfileselector(); |
423 gtk_widget_show(xs_stil_fileselector); | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
424 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
425 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
426 |
3 | 427 void xs_cfg_stil_fs_ok(void) |
1 | 428 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
429 /* Selection was accepted! */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
430 gtk_entry_set_text(GTK_ENTRY(LUW("cfg_stil_path")), |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
431 gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_stil_fileselector))); |
1 | 432 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
433 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
434 gtk_widget_destroy(xs_stil_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
435 xs_stil_fileselector = NULL; |
1 | 436 } |
437 | |
438 | |
3 | 439 void xs_cfg_stil_fs_cancel(void) |
1 | 440 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
441 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
442 gtk_widget_destroy(xs_stil_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
443 xs_stil_fileselector = NULL; |
1 | 444 } |
445 | |
446 | |
447 /* | |
448 * Execute the configuration panel | |
449 */ | |
450 void xs_configure(void) | |
451 { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
452 /* Check if the window already exists */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
453 if (xs_configwin != NULL) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
454 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
455 gdk_window_raise(xs_configwin->window); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
456 return; |
1 | 457 } |
458 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
459 /* Create the window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
460 xs_configwin = create_xs_configwin(); |
1 | 461 |
42 | 462 /* Based on selected emulation library, disable options */ |
463 #ifdef HAVE_SIDPLAY1 | |
464 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay1")), TRUE); | |
465 #else | |
466 gtk_widget_set_sensitive(LUW("cfg_emu_sidplay1"), FALSE); | |
467 #endif | |
468 | |
469 #ifdef HAVE_SIDPLAY2 | |
470 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_sidplay2")), TRUE); | |
471 #else | |
472 gtk_widget_set_sensitive(LUW("cfg_emu_sidplay2"), FALSE); | |
473 gtk_widget_set_sensitive(LUW("cfg_emu_sidplay2_opt"), FALSE); | |
45 | 474 |
475 gtk_widget_set_sensitive(LUW("cfg_emu_mem_real"), FALSE); | |
476 | |
477 gtk_widget_set_sensitive(LUW("cfg_oversample_grp"), FALSE); | |
478 gtk_widget_set_sensitive(LUW("cfg_oversample"), FALSE); | |
479 gtk_widget_set_sensitive(LUW("cfg_oversample_factor"), FALSE); | |
42 | 480 #endif |
1 | 481 |
45 | 482 #ifndef HAVE_XMMSEXTRA |
483 gtk_widget_set_sensitive(LUW("cfg_ftitle_override"), FALSE); | |
484 xs_cfg.titleOverride = TRUE; | |
485 #endif | |
42 | 486 |
487 /* Sound resolution settings */ | |
488 switch (xs_cfg.fmtBitsPerSample) { | |
489 case XS_RES_16BIT: | |
490 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_res_16bit")), TRUE); | |
491 break; | |
492 case XS_RES_8BIT: | |
493 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_res_8bit")), TRUE); | |
3 | 494 break; |
42 | 495 } |
496 | |
497 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_samplerate_adj")), xs_cfg.fmtFrequency); | |
498 | |
499 /* Channel settings */ | |
500 switch (xs_cfg.fmtChannels) { | |
501 case XS_CHN_MONO: | |
502 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_chn_mono")), TRUE); | |
3 | 503 break; |
42 | 504 case XS_CHN_STEREO: |
505 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_chn_stereo")), TRUE); | |
506 break; | |
507 case XS_CHN_AUTOPAN: | |
508 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_chn_autopan")), TRUE); | |
509 break; | |
510 } | |
3 | 511 |
512 | |
42 | 513 /* Memorymode settings */ |
514 switch (xs_cfg.memoryMode) { | |
45 | 515 case XS_MPU_REAL: |
516 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_real")), TRUE); | |
517 break; | |
518 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
519 case XS_MPU_BANK_SWITCHING: |
42 | 520 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_banksw")), TRUE); |
1 | 521 break; |
3 | 522 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
523 case XS_MPU_TRANSPARENT_ROM: |
42 | 524 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_transrom")), TRUE); |
1 | 525 break; |
3 | 526 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
527 case XS_MPU_PLAYSID_ENVIRONMENT: |
42 | 528 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mem_playsid")), TRUE); |
1 | 529 break; |
42 | 530 } |
3 | 531 |
1 | 532 |
42 | 533 /* Filter and waveform settings */ |
534 if (xs_cfg.mos8580) | |
535 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mos8580")), TRUE); | |
536 else | |
537 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_mos6581")), TRUE); | |
3 | 538 |
42 | 539 if (xs_cfg.emulateFilters) |
540 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_emu_filters")), TRUE); | |
3 | 541 |
42 | 542 xs_update_filters(); |
3 | 543 |
544 | |
42 | 545 /* Song-length database */ |
546 if (xs_cfg.playMaxTimeEnable) | |
547 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_sld_usemaxtime")), TRUE); | |
548 | |
549 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_sld_maxtime_adj")), xs_cfg.playMaxTime); | |
3 | 550 |
42 | 551 if (xs_cfg.songlenDBEnable) |
552 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_sld")), TRUE); | |
3 | 553 |
42 | 554 if (xs_cfg.songlenDBPath != NULL) |
555 gtk_entry_set_text(GTK_ENTRY(LUW("cfg_sld_dbpath")), xs_cfg.songlenDBPath); | |
3 | 556 |
1 | 557 |
42 | 558 /* STIL and miscellaneous settings */ |
559 if (xs_cfg.stilDBEnable) | |
560 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_stil_use")), TRUE); | |
1 | 561 |
42 | 562 if (xs_cfg.stilDBPath != NULL) |
563 gtk_entry_set_text(GTK_ENTRY(LUW("cfg_stil_path")), xs_cfg.stilDBPath); | |
3 | 564 |
42 | 565 if (xs_cfg.detectMagic) |
566 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_detectmagic")), TRUE); | |
1 | 567 |
568 | |
42 | 569 /* Title-settings */ |
570 if (xs_cfg.titleOverride) | |
571 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW("cfg_ftitle_override")), TRUE); | |
1 | 572 |
42 | 573 if (xs_cfg.titleFormat != NULL) |
574 gtk_entry_set_text(GTK_ENTRY(LUW("cfg_ftitle_format")), xs_cfg.titleFormat); | |
1 | 575 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
576 gtk_widget_show(xs_configwin); |
1 | 577 } |
578 |