Mercurial > hg > xmms-sid
annotate src/xs_config.c @ 40:1788f4ce6a44
Numerous changes towards 0.8
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 19 Jun 2003 22:38:01 +0000 |
parents | 271be59be975 |
children | 0f00ebab063d |
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[] = { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
43 {ATYPE_INT, &xs_cfg.fmtBitsPerSample,"bitsPerSample"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
44 {ATYPE_INT, &xs_cfg.fmtChannels, "channels"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
45 {ATYPE_INT, &xs_cfg.fmtFrequency, "frequency"}, |
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 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
64 {ATYPE_BOOL, &xs_cfg.stilDBEnable, "useSTIL"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
65 {ATYPE_STR, &xs_cfg.stilDBPath, "STILpath"}, |
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"}, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
70 {ATYPE_STR, &xs_cfg.titleFormat, "fileInfo"} |
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(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
109 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
110 xs_cfg.clockSpeed = XS_CLOCK_PAL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
111 xs_cfg.forceSpeed = FALSE; |
3 | 112 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
113 xs_cfg.oversampleEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
114 xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE; |
1 | 115 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
116 xs_cfg.playMaxTimeEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
117 xs_cfg.playMaxTime = 150; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
118 xs_cfg.songlenDBEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
119 xs_strcalloc(&xs_cfg.songlenDBPath, "~/C64Music/Songlengths.txt"); |
3 | 120 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
121 xs_cfg.stilDBEnable = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
122 xs_strcalloc(&xs_cfg.stilDBPath, "~/C64Music/DOCUMENTS/STIL.txt"); |
3 | 123 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
124 xs_cfg.detectMagic = FALSE; |
1 | 125 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
126 xs_cfg.titleOverride = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
127 xs_strcalloc(&xs_cfg.titleFormat, "%1 - %2"); |
3 | 128 |
129 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
130 /* Try to open the XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
131 XSDEBUG("loading from config-file ...\n"); |
3 | 132 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
133 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
|
134 cfgFile = xmms_cfg_open_file(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
135 g_free(cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
136 if (cfgFile == NULL) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
137 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
138 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
|
139 xs_write_configuration(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
140 return; |
3 | 141 } |
1 | 142 |
143 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
144 /* Read the new settings from XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
145 for (i = 0; i < XS_CFGTABLE_MAX; i++) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
146 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
147 switch (xs_cfgtable[i].atype) { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
148 case ATYPE_INT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
149 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
|
150 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
151 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
152 case ATYPE_BOOL: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
153 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
|
154 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
155 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
156 case ATYPE_FLOAT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
157 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
|
158 break; |
3 | 159 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
160 case ATYPE_STR: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
161 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
|
162 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
163 /* Read was successfull */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
164 xs_strcalloc((gchar **) xs_cfgtable[i].adata, tmpStr); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
165 g_free(tmpStr); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
166 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
167 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
168 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
169 default: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
170 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
|
171 break; |
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 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
174 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
175 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
176 /* Free the config file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
177 xmms_cfg_free(cfgFile); |
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 xs_write_configuration(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
180 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
181 XSDEBUG("OK\n"); |
1 | 182 } |
183 | |
40
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 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
187 * Write the current configuration |
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 gint xs_write_configuration(void) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
190 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
191 gchar *cfgFilename; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
192 ConfigFile *cfgFile; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
193 gint i; |
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 XSDEBUG("writing configuration ...\n"); |
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 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
198 * Try to open the XMMS configuration file |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
199 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
200 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
|
201 cfgFile = xmms_cfg_open_file(cfgFilename); |
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 if (!cfgFile) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
204 cfgFile = xmms_cfg_new(); |
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 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
207 /* Write the new settings to XMMS configuration file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
208 for (i = 0; i < XS_CFGTABLE_MAX; i++) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
209 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
210 switch (xs_cfgtable[i].atype) { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
211 case ATYPE_INT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
212 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
|
213 break; |
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 case ATYPE_BOOL: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
216 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
|
217 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
218 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
219 case ATYPE_FLOAT: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
220 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
|
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_STR: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
224 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
|
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 default: |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
228 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
|
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 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
232 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
233 /* Flush the file */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
234 xmms_cfg_write_file(cfgFile, cfgFilename); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
235 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
236 /* Free the memory areas */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
237 xmms_cfg_free(cfgFile); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
238 g_free(cfgFilename); |
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 return 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
241 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
242 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
243 |
1 | 244 /* |
245 * Configuration panel was canceled | |
246 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
247 void xs_cfg_cancel(void) |
1 | 248 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
249 gtk_widget_destroy(xs_configwin); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
250 xs_configwin = NULL; |
1 | 251 } |
252 | |
253 | |
254 /* | |
255 * Configuration was accepted (OK), save the settings | |
256 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
257 void xs_cfg_ok(void) |
1 | 258 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
259 XSDEBUG("get data from widgets to config...\n"); |
3 | 260 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
261 /* Check the resolution settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
262 if (GTK_TOGGLE_BUTTON(LUW("cfg_res_16bit"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
263 xs_cfg.fmtBitsPerSample = XS_RES_16BIT; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
264 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
265 xs_cfg.fmtBitsPerSample = XS_RES_8BIT; |
1 | 266 |
3 | 267 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
268 /* Channel settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
269 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_mono"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
270 xs_cfg.fmtChannels = XS_CHN_MONO; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
271 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
272 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_stereo"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
273 xs_cfg.fmtChannels = XS_CHN_STEREO; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
274 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
275 if (GTK_TOGGLE_BUTTON(LUW("cfg_chn_autopan"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
276 xs_cfg.fmtChannels = XS_CHN_AUTOPAN; |
3 | 277 |
278 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
279 /* Frequency setting */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
280 xs_cfg.fmtFrequency = (gint) GTK_ADJUSTMENT(LUW("cfg_samplerate_adj"))->value; |
3 | 281 |
1 | 282 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
283 /* Filter and waveform settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
284 xs_cfg.mos8580 = GTK_TOGGLE_BUTTON(LUW("cfg_wav_mos8580"))->active; |
1 | 285 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
286 xs_cfg.emulateFilters = GTK_TOGGLE_BUTTON(LUW("cfg_emufilters"))->active; |
3 | 287 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
288 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
|
289 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
|
290 xs_cfg.filterFt = GTK_ADJUSTMENT(LUW("cfg_filt_ft_adj"))->value; |
1 | 291 |
292 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
293 /* Memorymode settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
294 if (GTK_TOGGLE_BUTTON(LUW("cfg_mem_banksw"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
295 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
296 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
297 if (GTK_TOGGLE_BUTTON(LUW("cfg_mem_transrom"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
298 xs_cfg.memoryMode = XS_MPU_TRANSPARENT_ROM; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
299 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
300 if (GTK_TOGGLE_BUTTON(LUW("cfg_mem_playsid"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
301 xs_cfg.memoryMode = XS_MPU_PLAYSID_ENVIRONMENT; |
3 | 302 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
303 /* Clockspeed settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
304 if (GTK_TOGGLE_BUTTON(LUW("cfg_clock_ntsc"))->active) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
305 xs_cfg.clockSpeed = XS_CLOCK_NTSC; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
306 else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
307 xs_cfg.clockSpeed = XS_CLOCK_PAL; |
3 | 308 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
309 xs_cfg.forceSpeed = GTK_TOGGLE_BUTTON(LUW("cfg_clock_force"))->active; |
3 | 310 |
1 | 311 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
312 /* Songlength-detection settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
313 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
|
314 xs_cfg.playMaxTime = GTK_ADJUSTMENT(LUW("cfg_sld_maxtime_adj"))->value; |
3 | 315 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
316 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
|
317 xs_strcalloc(&xs_cfg.songlenDBPath, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sld_dbpath")))); |
1 | 318 |
319 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
320 /* STIL and miscellaneous settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
321 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
|
322 xs_strcalloc(&xs_cfg.stilDBPath, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_stil_path")))); |
3 | 323 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
324 xs_cfg.detectMagic = GTK_TOGGLE_BUTTON(LUW("cfg_detectmagic"))->active; |
3 | 325 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
326 /* Title settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
327 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
|
328 xs_strcalloc(&xs_cfg.titleFormat, gtk_entry_get_text(GTK_ENTRY(LUW("cfg_ftitle_format")))); |
1 | 329 |
330 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
331 /* Write settings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
332 xs_write_configuration(); |
1 | 333 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
334 /* NOTICE/FIXME FIX ME: if songlendb or stildb settings changed, we need to flush and reread them */ |
1 | 335 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
336 /* Close window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
337 gtk_widget_destroy(xs_configwin); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
338 xs_configwin = NULL; |
1 | 339 } |
340 | |
341 | |
342 /* | |
343 * Update filter setting sliders | |
344 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
345 void xs_update_filters(void) |
1 | 346 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
347 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
|
348 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
|
349 gtk_adjustment_set_value(GTK_ADJUSTMENT(LUW("cfg_filt_ft_adj")), xs_cfg.filterFt); |
1 | 350 } |
351 | |
352 | |
353 /* | |
354 * Reset filter settings to defaults | |
355 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
356 void xs_cfg_filter_reset(void) |
3 | 357 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
358 xs_reset_filters(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
359 xs_update_filters(); |
3 | 360 } |
361 | |
362 | |
363 /* | |
364 * HVSC songlength-database file selector response-functions | |
365 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
366 void xs_cfg_sld_dbbrowse(GtkButton *button, gpointer user_data) |
1 | 367 { |
3 | 368 } |
369 | |
370 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
371 void xs_cfg_sldb_fs_ok(void) |
3 | 372 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
373 /* Selection was accepted! */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
374 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
|
375 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
|
376 ); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
377 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
378 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
379 gtk_widget_destroy(xs_sldb_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
380 xs_sldb_fileselector = NULL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
381 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
382 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
383 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
384 void xs_cfg_sldb_fs_cancel(void) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
385 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
386 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
387 gtk_widget_destroy(xs_sldb_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
388 xs_sldb_fileselector = NULL; |
1 | 389 } |
390 | |
391 | |
392 /* | |
393 * STIL-database file selector response-functions | |
394 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
395 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
|
396 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
397 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
398 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
399 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
400 |
3 | 401 void xs_cfg_stil_fs_ok(void) |
1 | 402 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
403 /* Selection was accepted! */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
404 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
|
405 gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_stil_fileselector))); |
1 | 406 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
407 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
408 gtk_widget_destroy(xs_stil_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
409 xs_stil_fileselector = NULL; |
1 | 410 } |
411 | |
412 | |
3 | 413 void xs_cfg_stil_fs_cancel(void) |
1 | 414 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
415 /* Close file selector window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
416 gtk_widget_destroy(xs_stil_fileselector); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
417 xs_stil_fileselector = NULL; |
1 | 418 } |
419 | |
420 | |
421 /* | |
422 * Execute the configuration panel | |
423 */ | |
424 void xs_configure(void) | |
425 { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
426 /* Check if the window already exists */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
427 if (xs_configwin != NULL) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
428 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
429 gdk_window_raise(xs_configwin->window); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
430 return; |
1 | 431 } |
432 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
433 /* Create the window */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
434 xs_configwin = create_xs_configwin(); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
435 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
436 #if 0 |
1 | 437 |
438 /* Set the states of widgets */ | |
439 | |
440 /* Sound resolution settings */ | |
3 | 441 switch (xs_cfg.fmtBitsPerSample) { |
442 case 16: | |
443 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_res_16bit), TRUE); | |
444 break; | |
445 case 8: | |
446 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_res_8bit), TRUE); | |
447 break; | |
1 | 448 } |
449 | |
3 | 450 gtk_adjustment_set_value(GTK_ADJUSTMENT(cfg_samplerate_adj), xs_cfg.fmtFrequency); |
451 | |
452 | |
1 | 453 /* Channel settings */ |
3 | 454 switch (xs_cfg.fmtChannels) { |
455 case 0: | |
456 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_chn_mono), TRUE); | |
457 break; | |
458 case 1: | |
459 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_chn_stereo), TRUE); | |
460 break; | |
461 case 2: | |
462 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_chn_autopan), TRUE); | |
463 break; | |
1 | 464 } |
3 | 465 |
466 | |
1 | 467 /* Memorymode settings */ |
468 switch (xs_cfg.memoryMode) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
469 case XS_MPU_BANK_SWITCHING: |
1 | 470 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_mem_banksw), TRUE); |
471 break; | |
3 | 472 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
473 case XS_MPU_TRANSPARENT_ROM: |
1 | 474 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_mem_transrom), TRUE); |
475 break; | |
3 | 476 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
477 case XS_MPU_PLAYSID_ENVIRONMENT: |
1 | 478 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_mem_playsid), TRUE); |
479 break; | |
480 } | |
481 | |
482 | |
483 /* Filter and waveform settings */ | |
484 if (xs_cfg.mos8580) { | |
3 | 485 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_wav_mos8580), TRUE); |
486 } else { | |
487 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_wav_mos6581), TRUE); | |
488 } | |
489 | |
1 | 490 |
491 if (xs_cfg.emulateFilter) { | |
492 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_emufilters), TRUE); | |
493 } | |
494 | |
495 xs_cfg_filt_update(); | |
3 | 496 |
497 | |
498 /* Song-length detection */ | |
499 switch (xs_cfg.playMethod) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
500 case XS_PMETHOD_NONE: |
3 | 501 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_sld_none), TRUE); |
502 break; | |
503 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
504 case XS_PMETHOD_MAXSILENCE: |
3 | 505 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_sld_maxsilence), TRUE); |
506 break; | |
507 | |
508 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
509 case XS_PMETHOD_DATABASE: |
3 | 510 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_sld_database), TRUE); |
511 break; | |
512 } | |
513 | |
514 if (xs_cfg.playUseMaxTime) { | |
515 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_sld_usemaxtime), TRUE); | |
516 } | |
517 | |
518 gtk_adjustment_set_value(GTK_ADJUSTMENT(cfg_sld_maxtime_adj), xs_cfg.playMaxTime); | |
519 gtk_adjustment_set_value(GTK_ADJUSTMENT(cfg_sld_silencetime_adj), xs_cfg.playMaxSilentTime); | |
520 gtk_adjustment_set_value(GTK_ADJUSTMENT(cfg_sld_percentage_adj), xs_cfg.playSilentPercent); | |
521 | |
522 if (xs_cfg.playDBPath != NULL) { | |
523 gtk_entry_set_text(GTK_ENTRY(cfg_sld_dbpath), xs_cfg.playDBPath); | |
524 } | |
525 | |
1 | 526 |
527 /* STIL and miscellaneous settings */ | |
3 | 528 if (xs_cfg.useSTIL) { |
1 | 529 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_stil_use), TRUE); |
530 } | |
531 | |
3 | 532 if (xs_cfg.STILpath != NULL) { |
533 gtk_entry_set_text(GTK_ENTRY(cfg_stil_path), xs_cfg.STILpath); | |
534 } | |
535 | |
536 if (xs_cfg.finfoUseColors) { | |
537 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_finfo_usecolors), TRUE); | |
538 } | |
539 | |
1 | 540 if (xs_cfg.detectMagic) { |
3 | 541 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_detectmagic), TRUE); |
1 | 542 } |
543 | |
544 | |
3 | 545 /* Title-settings */ |
546 if (xs_cfg.titleOverride) { | |
547 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cfg_ftitle_override), TRUE); | |
548 } | |
1 | 549 |
3 | 550 if (xs_cfg.titleFormat != NULL) { |
551 gtk_entry_set_text(GTK_ENTRY(cfg_ftitle_format), xs_cfg.titleFormat); | |
552 } | |
553 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
554 #endif |
1 | 555 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
556 gtk_widget_show(xs_configwin); |
1 | 557 } |
558 |