Mercurial > mplayer.hg
annotate gui/app/cfg.c @ 36429:28ea255e40ce
Add support for TV/DVB to the GUI.
Support is limited to a single (resp. the first) card.
At the same time, add the new GUI option 'gui_tv_digital',
the new GUI message 'evPlayTV' and the new GUI font symbol 'b'.
Additionally, update the documentation.
author | ib |
---|---|
date | Fri, 29 Nov 2013 12:41:32 +0000 |
parents | c667e34fb941 |
children | cc8102c4ca83 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
34562 | 19 #include <stdio.h> |
23077 | 20 #include <stdlib.h> |
21 #include <string.h> | |
22 | |
33179 | 23 #include "cfg.h" |
35493 | 24 #include "gui.h" |
35525 | 25 #include "gui/interface.h" |
26 #include "gui/util/list.h" | |
27 #include "gui/util/string.h" | |
33179 | 28 |
23077 | 29 #include "config.h" |
30 #include "help_mp.h" | |
33179 | 31 #include "mixer.h" |
33768 | 32 #include "mp_core.h" |
33179 | 33 #include "mp_msg.h" |
34 #include "mpcommon.h" | |
35 #include "mplayer.h" | |
36 #include "parser-cfg.h" | |
37 #include "path.h" | |
36032 | 38 #include "libavutil/common.h" |
39 #include "libmpcodecs/vd.h" | |
40 #include "libmpdemux/demuxer.h" | |
41 #include "libvo/video_out.h" | |
42 #include "libvo/x11_common.h" | |
34562 | 43 #include "stream/stream.h" |
44 #include "sub/ass_mp.h" | |
32981 | 45 #include "sub/font_load.h" |
33179 | 46 #include "sub/sub.h" |
23077 | 47 |
36429 | 48 guiTV_t guiTV[2] = { |
49 { STREAMTYPE_TV, "tv" }, | |
50 { STREAMTYPE_DVB, "dvb" } | |
51 }; | |
52 | |
33265 | 53 m_config_t *gui_conf; |
54 | |
33220 | 55 int gtkCacheOn; |
33180 | 56 int gtkCacheSize = 2048; |
57 | |
33220 | 58 int gtkVfPP; |
23077 | 59 |
33249 | 60 int gtkVfLAVC; |
33180 | 61 char *gtkDXR3Device; |
62 | |
33220 | 63 int gtkAutoSyncOn; |
64 int gtkAutoSync; | |
23077 | 65 |
33220 | 66 int gtkAONorm; |
67 int gtkAOSurround; | |
68 int gtkAOExtraStereo; | |
33221 | 69 float gtkAOExtraStereoMul = 1.0f; |
33180 | 70 |
33179 | 71 char *gtkAOALSAMixer; |
72 char *gtkAOALSAMixerChannel; | |
73 char *gtkAOALSADevice; | |
33180 | 74 |
75 char *gtkAOOSSMixer; | |
76 char *gtkAOOSSMixerChannel; | |
77 char *gtkAOOSSDevice; | |
78 | |
33179 | 79 char *gtkAOESDDevice; |
23077 | 80 |
33180 | 81 char *gtkAOSDLDriver; |
23077 | 82 |
33220 | 83 int gtkEnableAudioEqualizer; |
33747 | 84 float gtkEquChannels[6][10]; |
23077 | 85 |
33220 | 86 int gtkSubDumpMPSub; |
87 int gtkSubDumpSrt; | |
23077 | 88 |
33180 | 89 gtkASS_t gtkASS; |
90 | |
35493 | 91 int gtkEnablePlayBar = True; |
33220 | 92 int gtkLoadFullscreen; |
35493 | 93 int gtkShowVideoWindow = True; |
23077 | 94 |
35493 | 95 int gui_save_pos = True; |
34698 | 96 int gui_main_pos_x = -3; |
97 int gui_main_pos_y = -3; | |
34697 | 98 int gui_video_pos_x = -3; |
99 int gui_video_pos_y = -3; | |
23077 | 100 |
36429 | 101 int gui_tv_digital = True; |
102 | |
33747 | 103 int guiWinID = -1; |
104 | |
105 char *skinName; | |
106 | |
33751
c28c967e40e9
Replace numeric constant fsPersistant_MaxPos for fsHistory array size.
ib
parents:
33750
diff
changeset
|
107 char *fsHistory[5]; |
33750
8b5898908212
Remove variable holding history of selected files from interface.[ch].
ib
parents:
33748
diff
changeset
|
108 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
109 static const char gui_configuration[] = "gui.conf"; |
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
110 static const char gui_history[] = "gui.history"; |
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
111 static const char gui_playlist[] = "gui.pl"; |
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
112 static const char gui_urllist[] = "gui.url"; |
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
113 |
33179 | 114 static const m_option_t gui_opts[] = { |
34708 | 115 { "cache", >kCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
34707 | 116 { "cache_size", >kCacheSize, CONF_TYPE_INT, CONF_RANGE, 32, 0x7fffffff, NULL }, |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
117 |
34708 | 118 { "vf_pp", >kVfPP, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
33223 | 119 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27359
diff
changeset
|
120 #ifdef CONFIG_DXR3 |
34708 | 121 { "vf_lavc", >kVfLAVC, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
122 { "vo_dxr3_device", >kDXR3Device, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
23077 | 123 #endif |
124 | |
34708 | 125 { "autosync", >kAutoSyncOn, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
126 { "autosync_size", >kAutoSync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL }, | |
23077 | 127 |
34708 | 128 { "ao_volnorm", >kAONorm, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
129 { "ao_surround", >kAOSurround, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
130 { "ao_extra_stereo", >kAOExtraStereo, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
131 { "ao_extra_stereo_coefficient", >kAOExtraStereoMul, CONF_TYPE_FLOAT, CONF_RANGE, -10.0, 10.0, NULL }, | |
33223 | 132 |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27387
diff
changeset
|
133 #ifdef CONFIG_ALSA |
34708 | 134 { "ao_alsa_mixer", >kAOALSAMixer, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
135 { "ao_alsa_mixer_channel", >kAOALSAMixerChannel, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
136 { "ao_alsa_device", >kAOALSADevice, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
23077 | 137 #endif |
33223 | 138 |
139 #ifdef CONFIG_OSS_AUDIO | |
34708 | 140 { "ao_oss_mixer", >kAOOSSMixer, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
141 { "ao_oss_mixer_channel", >kAOOSSMixerChannel, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
142 { "ao_oss_device", >kAOOSSDevice, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
23077 | 143 #endif |
33223 | 144 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
145 #ifdef CONFIG_ESD |
34708 | 146 { "ao_esd_device", >kAOESDDevice, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
23077 | 147 #endif |
148 | |
33223 | 149 #ifdef CONFIG_SDL |
34708 | 150 { "ao_sdl_subdriver", >kAOSDLDriver, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
23077 | 151 #endif |
152 | |
34708 | 153 { "enable_audio_equ", >kEnableAudioEqualizer, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
23077 | 154 |
34708 | 155 { "equ_channel_1", >kEquChannel1, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
156 { "equ_channel_2", >kEquChannel2, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
157 { "equ_channel_3", >kEquChannel3, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
158 { "equ_channel_4", >kEquChannel4, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
159 { "equ_channel_5", >kEquChannel5, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
160 { "equ_channel_6", >kEquChannel6, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
161 |
33223 | 162 #define audio_equ_row(i, j) \ |
34708 | 163 { "equ_band_" # i # j, >kEquChannels[i][j], CONF_TYPE_FLOAT, CONF_RANGE, -15.0, 15.0, NULL } |
33289 | 164 audio_equ_row(0, 0), audio_equ_row(0, 1), audio_equ_row(0, 2), audio_equ_row(0, 3), audio_equ_row(0, 4), audio_equ_row(0, 5), audio_equ_row(0, 6), audio_equ_row(0, 7), audio_equ_row(0, 8), audio_equ_row(0, 9), |
165 audio_equ_row(1, 0), audio_equ_row(1, 1), audio_equ_row(1, 2), audio_equ_row(1, 3), audio_equ_row(1, 4), audio_equ_row(1, 5), audio_equ_row(1, 6), audio_equ_row(1, 7), audio_equ_row(1, 8), audio_equ_row(1, 9), | |
166 audio_equ_row(2, 0), audio_equ_row(2, 1), audio_equ_row(2, 2), audio_equ_row(2, 3), audio_equ_row(2, 4), audio_equ_row(2, 5), audio_equ_row(2, 6), audio_equ_row(2, 7), audio_equ_row(2, 8), audio_equ_row(2, 9), | |
167 audio_equ_row(3, 0), audio_equ_row(3, 1), audio_equ_row(3, 2), audio_equ_row(3, 3), audio_equ_row(3, 4), audio_equ_row(3, 5), audio_equ_row(3, 6), audio_equ_row(3, 7), audio_equ_row(3, 8), audio_equ_row(3, 9), | |
168 audio_equ_row(4, 0), audio_equ_row(4, 1), audio_equ_row(4, 2), audio_equ_row(4, 3), audio_equ_row(4, 4), audio_equ_row(4, 5), audio_equ_row(4, 6), audio_equ_row(4, 7), audio_equ_row(4, 8), audio_equ_row(4, 9), | |
169 audio_equ_row(5, 0), audio_equ_row(5, 1), audio_equ_row(5, 2), audio_equ_row(5, 3), audio_equ_row(5, 4), audio_equ_row(5, 5), audio_equ_row(5, 6), audio_equ_row(5, 7), audio_equ_row(5, 8), audio_equ_row(5, 9), | |
23077 | 170 #undef audio_equ_row |
171 | |
34708 | 172 { "playbar", >kEnablePlayBar, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
173 { "load_fullscreen", >kLoadFullscreen, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
174 { "show_videowin", >kShowVideoWindow, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
33223 | 175 |
34708 | 176 { "gui_save_pos", &gui_save_pos, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
177 { "gui_main_pos_x", &gui_main_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
178 { "gui_main_pos_y", &gui_main_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
179 { "gui_video_out_pos_x", &gui_video_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
180 { "gui_video_out_pos_y", &gui_video_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL }, | |
33223 | 181 |
34708 | 182 { "idle", &player_idle_mode, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL }, |
33477 | 183 |
36429 | 184 #ifdef CONFIG_TV |
185 { "gui_tv_digital", &gui_tv_digital, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
186 #endif | |
187 | |
33223 | 188 // NOTE TO MYSELF: Do we really need all/any non-gtkOptions, i.e. override mplayer options? |
189 | |
34708 | 190 { "gui_skin", &skinName, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
33223 | 191 |
34708 | 192 { "stopxscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
33223 | 193 |
34708 | 194 { "cdrom_device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
195 { "dvd_device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
33223 | 196 |
34708 | 197 { "osd_level", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL }, |
33223 | 198 |
34708 | 199 { "vo_driver", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL }, |
200 { "v_vfm", &video_fm_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL }, | |
33223 | 201 |
34708 | 202 { "vf_autoq", &auto_quality, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL }, |
203 { "vo_direct_render", &vo_directrendering, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
204 { "vo_doublebuffering", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
205 { "vo_panscan", &vo_panscan, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 1.0, NULL }, | |
33223 | 206 |
34708 | 207 { "v_flip", &flip, CONF_TYPE_INT, CONF_RANGE, -1, 1, NULL }, |
208 { "v_framedrop", &frame_dropping, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL }, | |
209 { "v_idx", &index_mode, CONF_TYPE_INT, CONF_RANGE, -1, 2, NULL }, | |
210 { "v_ni", &force_ni, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
33223 | 211 |
34708 | 212 { "ao_driver", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL }, |
213 { "a_afm", &audio_fm_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL }, | |
33223 | 214 |
34708 | 215 { "softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
33223 | 216 |
34708 | 217 { "sub_auto_load", &sub_auto, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
33223 | 218 #ifdef CONFIG_ICONV |
34708 | 219 { "sub_cp", &sub_cp, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
33223 | 220 #endif |
34708 | 221 { "sub_overlap", &suboverlap_enabled, CONF_TYPE_FLAG, 0, 0, 0, NULL }, |
222 { "sub_pos", &sub_pos, CONF_TYPE_INT, CONF_RANGE, 0, 200, NULL }, | |
223 { "sub_unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
33223 | 224 |
34708 | 225 { "font_factor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0, NULL }, |
226 { "font_name", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL }, | |
33223 | 227 |
228 #ifdef CONFIG_FREETYPE | |
34708 | 229 { "font_encoding", &subtitle_font_encoding, CONF_TYPE_STRING, 0, 0, 0, NULL }, |
230 { "font_text_scale", &text_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 100.0, NULL }, | |
231 { "font_osd_scale", &osd_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 100.0, NULL }, | |
232 { "font_blur", &subtitle_font_radius, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 8.0, NULL }, | |
233 { "font_outline", &subtitle_font_thickness, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 8.0, NULL }, | |
234 { "font_autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL }, | |
33223 | 235 #endif |
236 | |
237 #ifdef CONFIG_ASS | |
34708 | 238 { "ass_enabled", &ass_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
239 { "ass_use_margins", &ass_use_margins, CONF_TYPE_FLAG, 0, 0, 1, NULL }, | |
240 { "ass_top_margin", &ass_top_margin, CONF_TYPE_INT, CONF_RANGE, 0, 512, NULL }, | |
241 { "ass_bottom_margin", &ass_bottom_margin, CONF_TYPE_INT, CONF_RANGE, 0, 512, NULL }, | |
33223 | 242 #endif |
243 | |
34708 | 244 { NULL, NULL, 0, 0, 0, 0, NULL } |
23077 | 245 }; |
246 | |
35521 | 247 int cfg_gui_include(m_option_t *conf, const char *file) |
33470 | 248 { |
249 (void)conf; | |
250 | |
35521 | 251 return m_config_parse_config_file(gui_conf, file, 0); |
33470 | 252 } |
253 | |
34561 | 254 void cfg_read(void) |
23077 | 255 { |
34580 | 256 char *fname, line[512]; |
34578 | 257 FILE *file; |
33179 | 258 |
35493 | 259 player_idle_mode = True; // GUI is in idle mode by default |
33476 | 260 |
34684 | 261 /* configuration */ |
33179 | 262 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
263 fname = get_path(gui_configuration); |
33179 | 264 |
34578 | 265 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[cfg] file: %s\n", fname); |
33179 | 266 |
267 gui_conf = m_config_new(); | |
33480 | 268 |
269 if (!gui_conf) { | |
270 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_MemAllocFailed); | |
33768 | 271 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
33480 | 272 } |
273 | |
33179 | 274 m_config_register_options(gui_conf, gui_opts); |
275 | |
34578 | 276 if (!disable_gui_conf && (m_config_parse_config_file(gui_conf, fname, 1) < 0)) { |
34577
22887c794c02
In case of a GUI config error, exit MPlayer with error.
ib
parents:
34576
diff
changeset
|
277 gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_ConfigFileError "\n"); |
22887c794c02
In case of a GUI config error, exit MPlayer with error.
ib
parents:
34576
diff
changeset
|
278 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
33179 | 279 } |
280 | |
34578 | 281 free(fname); |
23077 | 282 |
34684 | 283 /* playlist */ |
33179 | 284 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
285 fname = get_path(gui_playlist); |
34578 | 286 file = fopen(fname, "rt"); |
33179 | 287 |
34578 | 288 if (file) { |
34581 | 289 while (fgetstr(line, sizeof(line), file)) { |
33179 | 290 plItem *item; |
23077 | 291 |
34588 | 292 if (!*line) |
293 continue; | |
294 | |
34583 | 295 item = calloc(1, sizeof(plItem)); |
34582 | 296 |
297 if (!item) { | |
298 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_MemAllocFailed); | |
299 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); | |
300 } | |
301 | |
34580 | 302 item->path = strdup(line); |
34584 | 303 |
34588 | 304 if (fgetstr(line, sizeof(line), file) && *line) { |
34585 | 305 item->name = strdup(line); |
34681 | 306 listMgr(PLAYLIST_ITEM_APPEND, item); |
34584 | 307 } else { |
308 free(item->path); | |
309 free(item); | |
310 } | |
33179 | 311 } |
312 | |
34578 | 313 fclose(file); |
23077 | 314 } |
33179 | 315 |
34578 | 316 free(fname); |
33179 | 317 |
34684 | 318 /* URL list */ |
33179 | 319 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
320 fname = get_path(gui_urllist); |
34578 | 321 file = fopen(fname, "rt"); |
23077 | 322 |
34578 | 323 if (file) { |
34581 | 324 while (fgetstr(line, sizeof(line), file)) { |
33555 | 325 urlItem *item; |
33179 | 326 |
34588 | 327 if (!*line) |
328 continue; | |
329 | |
34583 | 330 item = calloc(1, sizeof(urlItem)); |
34582 | 331 |
332 if (!item) { | |
333 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_MemAllocFailed); | |
334 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); | |
335 } | |
336 | |
34580 | 337 item->url = strdup(line); |
34663 | 338 listMgr(URLLIST_ITEM_ADD, item); |
33179 | 339 } |
340 | |
34578 | 341 fclose(file); |
23077 | 342 } |
33179 | 343 |
34578 | 344 free(fname); |
33179 | 345 |
34684 | 346 /* directory history */ |
33179 | 347 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
348 fname = get_path(gui_history); |
34579 | 349 file = fopen(fname, "rt"); |
33179 | 350 |
34578 | 351 if (file) { |
34586 | 352 unsigned int i = 0; |
23077 | 353 |
34581 | 354 while (fgetstr(line, sizeof(line), file)) |
34588 | 355 if (*line && (i < FF_ARRAY_ELEMS(fsHistory))) |
34589 | 356 fsHistory[i++] = strdup(line); |
33179 | 357 |
34578 | 358 fclose(file); |
23077 | 359 } |
360 | |
34578 | 361 free(fname); |
23077 | 362 } |
363 | |
34561 | 364 void cfg_write(void) |
23077 | 365 { |
34578 | 366 char *fname; |
367 FILE *file; | |
33179 | 368 |
34684 | 369 /* configuration */ |
33179 | 370 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
371 fname = get_path(gui_configuration); |
34578 | 372 file = fopen(fname, "wt+"); |
33179 | 373 |
34578 | 374 if (file) { |
34621
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
375 const m_option_t *opts = gui_opts; |
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
376 |
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
377 while (opts->name) { |
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
378 char *val = m_option_print(opts, opts->p); |
33179 | 379 |
34578 | 380 if (val == (char *)-1) { |
34621
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
381 gmp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, opts->name); |
34578 | 382 val = NULL; |
33179 | 383 } |
23077 | 384 |
34578 | 385 if (val) { |
34595 | 386 char delim[] = "\""; |
34593
83f7a2f8af3b
Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents:
34592
diff
changeset
|
387 |
83f7a2f8af3b
Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents:
34592
diff
changeset
|
388 if (!strchr(val, ' ')) |
83f7a2f8af3b
Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents:
34592
diff
changeset
|
389 *delim = 0; |
83f7a2f8af3b
Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents:
34592
diff
changeset
|
390 |
34621
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
391 fprintf(file, "%s=%s%s%s\n", opts->name, delim, val, delim); |
34578 | 392 free(val); |
33179 | 393 } |
34621
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
394 |
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
395 opts++; |
33179 | 396 } |
397 | |
34578 | 398 fclose(file); |
23077 | 399 } |
33179 | 400 |
34578 | 401 free(fname); |
33179 | 402 |
34684 | 403 /* playlist */ |
33179 | 404 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
405 fname = get_path(gui_playlist); |
34578 | 406 file = fopen(fname, "wt+"); |
33179 | 407 |
34578 | 408 if (file) { |
34667 | 409 plItem *item = listMgr(PLAYLIST_GET, 0); |
33179 | 410 |
34594 | 411 while (item) { |
412 if (item->path && item->name) { | |
413 fprintf(file, "%s\n", item->path); | |
414 fprintf(file, "%s\n", item->name); | |
33179 | 415 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
416 |
34594 | 417 item = item->next; |
33179 | 418 } |
419 | |
34578 | 420 fclose(file); |
23077 | 421 } |
33179 | 422 |
34578 | 423 free(fname); |
33179 | 424 |
34684 | 425 /* URL list */ |
33179 | 426 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
427 fname = get_path(gui_urllist); |
34578 | 428 file = fopen(fname, "wt+"); |
33179 | 429 |
34578 | 430 if (file) { |
34668 | 431 urlItem *item = listMgr(URLLIST_GET, 0); |
33179 | 432 |
34594 | 433 while (item) { |
434 if (item->url) | |
435 fprintf(file, "%s\n", item->url); | |
436 | |
437 item = item->next; | |
33179 | 438 } |
23077 | 439 |
34578 | 440 fclose(file); |
23077 | 441 } |
33179 | 442 |
34578 | 443 free(fname); |
33179 | 444 |
34684 | 445 /* directory history */ |
33179 | 446 |
34596
04feb00f91be
Prefer static const char arrays for string constants to #defines.
ib
parents:
34595
diff
changeset
|
447 fname = get_path(gui_history); |
34578 | 448 file = fopen(fname, "wt+"); |
33179 | 449 |
34578 | 450 if (file) { |
34621
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
451 unsigned int i; |
97148652b0c6
Replace for loop with index by while loop with pointer.
ib
parents:
34610
diff
changeset
|
452 |
35870
26ad65a4e47d
Free memory allocated for fsHistory[] elements when GUI ends.
ib
parents:
35525
diff
changeset
|
453 for (i = 0; i < FF_ARRAY_ELEMS(fsHistory); i++) { |
26ad65a4e47d
Free memory allocated for fsHistory[] elements when GUI ends.
ib
parents:
35525
diff
changeset
|
454 if (fsHistory[i]) { |
34578 | 455 fprintf(file, "%s\n", fsHistory[i]); |
35870
26ad65a4e47d
Free memory allocated for fsHistory[] elements when GUI ends.
ib
parents:
35525
diff
changeset
|
456 free(fsHistory[i]); |
26ad65a4e47d
Free memory allocated for fsHistory[] elements when GUI ends.
ib
parents:
35525
diff
changeset
|
457 } |
26ad65a4e47d
Free memory allocated for fsHistory[] elements when GUI ends.
ib
parents:
35525
diff
changeset
|
458 } |
23077 | 459 |
34578 | 460 fclose(file); |
33179 | 461 } |
462 | |
34578 | 463 free(fname); |
23077 | 464 } |