annotate gui/win32/wincfg.c @ 26131:83c95bd31aab

Add necessary #includes to pass 'make checkheaders'.
author diego
date Tue, 04 Mar 2008 23:35:24 +0000
parents 0fe20154a883
children 609236ad27f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
1 /*
23079
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
2 * MPlayer GUI for Win32
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de>
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com>
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
6 *
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
7 * This file is part of MPlayer.
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
8 *
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
10 * it under the terms of the GNU General Public License as published by
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
12 * (at your option) any later version.
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
13 *
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
17 * GNU General Public License for more details.
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
18 *
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
19 * You should have received a copy of the GNU General Public License
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
20 * along with MPlayer; if not, write to the Free Software
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
22 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26
23123
21e29d5932c5 header / declarations cleanup, also fixes broken compilation.
vayne
parents: 23091
diff changeset
27 #include "mplayer.h"
23091
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
28 #include "mp_msg.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
29 #include "help_mp.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
30 #include "m_config.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
31 #include "m_option.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
32 #include "libvo/video_out.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
33 #include "mixer.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
34 #include "wincfg.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
35 #include "interface.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
37 /* params */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38 int gtkAONorm = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
39 int gtkAOExtraStereo = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40 float gtkAOExtraStereoMul = 1.0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 int gtkCacheOn = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42 int gtkCacheSize = 2048;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43 int gtkAutoSyncOn = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
44 int gtkAutoSync = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 int sub_window = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 int console = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 int gui_save_pos = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 int gui_main_pos_x = -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51 int gui_main_pos_y = -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 int gui_sub_pos_x = -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53 int gui_sub_pos_y = -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 /* External functions */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 extern int frame_dropping;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 extern char *proc_priority;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 extern int m_config_parse_config_file(m_config_t *config, char *conffile);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 static m_config_t *gui_conf;
25713
0fe20154a883 gui_opts should be const for win32 gui as well (why, oh why, was all
reimar
parents: 25712
diff changeset
61 static const m_option_t gui_opts[] =
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 { "priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 { "vo_driver", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 { "v_framedrop", &frame_dropping, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 { "vo_doublebuffering", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 { "vo_direct_render", &vo_directrendering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 { "ao_driver", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 { "ao_volnorm", &gtkAONorm, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 { "softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 { "ao_extra_stereo", &gtkAOExtraStereo, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 { "ao_extra_stereo_coefficient", &gtkAOExtraStereoMul, CONF_TYPE_FLOAT, CONF_RANGE, -10, 10, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 { "delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 { "dvd_device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 { "cdrom_device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 { "osd_level", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 { "cache", &gtkCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 { "cache_size", &gtkCacheSize, CONF_TYPE_INT, CONF_RANGE, -1, 65535, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 { "autosync", &gtkAutoSyncOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 { "autosync_size", &gtkAutoSync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 { "gui_skin", &skinName, CONF_TYPE_STRING, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 { "gui_main_pos_x", &gui_main_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 { "gui_main_pos_y", &gui_main_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 { "gui_sub_pos_x", &gui_sub_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85 { "gui_sub_pos_y", &gui_sub_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 { "sub_window", &sub_window, CONF_TYPE_FLAG, 0, 0, 1, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 { "console", &console, CONF_TYPE_FLAG, 0, 0, 1, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 { NULL, NULL, 0, 0, 0, 0, NULL }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 char *gfgets(char *str, int size, FILE *f)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 char *s = fgets(str, size, f);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 char c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 if(s)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 c = s[strlen(s) - 1];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98 if ((c == '\n') || (c == '\r'))
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 s[strlen(s) - 1]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 c = s[strlen(s) - 1];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 if ((c == '\n') || (c == '\r'))
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 s[strlen(s) - 1]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 return s;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 int cfg_read(void)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 char *cfg = get_path("gui.conf");
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 /* read configuration */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] [cfg] reading config file: %s\n", cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113 gui_conf = m_config_new();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 m_config_register_options(gui_conf, gui_opts);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 if (m_config_parse_config_file(gui_conf, cfg) < 0)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 mp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_ConfigFileError);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 free(cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 int cfg_write(void)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 char *cfg = get_path("gui.conf");
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 FILE *f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 /* save configuration */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 if ((f = fopen(cfg, "wt+")))
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 for (i=0; gui_opts[i].name; i++)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 char *v = m_option_print(&gui_opts[i], gui_opts[i].p);
25712
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
133 if(v == (char *)-1) {
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
134 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_UnableToSaveOption, gui_opts[i].name);
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
135 v = NULL;
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
136 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 if(v)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 fprintf(f, "%s = \"%s\"\n", gui_opts[i].name, v);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 free(v);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 fclose(f);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 free(cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 }