annotate gui/win32/wincfg.c @ 36948:a5537f70df8e

Change assignment of stream in Win32 GUI. Adjust the code to the X11/GTK GUI.
author ib
date Sun, 23 Mar 2014 11:52:09 +0000
parents 7d8f27be5796
children
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 *
26457
9ba6d4487292 Use standard GPL header.
diego
parents: 26372
diff changeset
19 * You should have received a copy of the GNU General Public License along
9ba6d4487292 Use standard GPL header.
diego
parents: 26372
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
9ba6d4487292 Use standard GPL header.
diego
parents: 26372
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23079
8e9b11648f40 Use proper GPL header.
diego
parents: 23078
diff changeset
22 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23
26193
609236ad27f4 more header / declaration cleanups; fixes a lot of warnings as well as a preempt to removal of redundant wincfg.h.
vayne
parents: 25713
diff changeset
24 #include <windows.h>
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26 #include <string.h>
30901
76a13038105e Rename get_path.[ch] --> path.[ch].
diego
parents: 30558
diff changeset
27 #include "path.h"
23123
21e29d5932c5 header / declarations cleanup, also fixes broken compilation.
vayne
parents: 23091
diff changeset
28 #include "mplayer.h"
23091
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
29 #include "mp_msg.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
30 #include "help_mp.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
31 #include "m_config.h"
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
32 #include "m_option.h"
32020
6c48f42a9c75 Replace m_config_parse_config_file() forward declaration by proper #include.
diego
parents: 31327
diff changeset
33 #include "parser-cfg.h"
23091
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
34 #include "libvo/video_out.h"
32068
ab6ac5b156ca Replace proc_priority extern declaration by osdep/priority.h #include.
diego
parents: 32020
diff changeset
35 #include "osdep/priority.h"
23091
52488bb09d90 Consistently use quotes instead of angled brackets in #include
diego
parents: 23079
diff changeset
36 #include "mixer.h"
35528
ab07b17fddfb Rebuild GUI directory structure.
ib
parents: 35501
diff changeset
37 #include "gui/ui/ui.h"
26372
76413880bfad Update include paths to account for build system changes.
diego
parents: 26193
diff changeset
38 #include "gui/interface.h"
26193
609236ad27f4 more header / declaration cleanups; fixes a lot of warnings as well as a preempt to removal of redundant wincfg.h.
vayne
parents: 25713
diff changeset
39 #include "gui.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34595
diff changeset
41 static const char gui_configuration[] = "gui.conf";
34576
7596714e9e76 Replace string constants by symbolic constants.
ib
parents: 34561
diff changeset
42
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43 /* params */
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
44 int gtkAONorm = FALSE;
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
45 int gtkAOExtraStereo = FALSE;
36906
7d8f27be5796 Make value explicitly type float.
ib
parents: 36694
diff changeset
46 float gtkAOExtraStereoMul = 1.0f;
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
47 int gtkCacheOn = FALSE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 int gtkCacheSize = 2048;
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
49 int gtkAutoSyncOn = FALSE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 int gtkAutoSync = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
52 int video_window = TRUE;
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
53 int console = FALSE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
55 int gui_save_pos = TRUE;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 int gui_main_pos_x = -2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 int gui_main_pos_y = -2;
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34626
diff changeset
58 int gui_video_pos_x = -1;
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34626
diff changeset
59 int gui_video_pos_y = -1;
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60
33297
9a7b0dab3d95 Fix compilation error with Win32 GUI.
ib
parents: 32068
diff changeset
61 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
62 static const m_option_t gui_opts[] =
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 { "priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 { "vo_driver", &video_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 { "v_framedrop", &frame_dropping, CONF_TYPE_INT, CONF_RANGE, 0, 2, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 { "vo_doublebuffering", &vo_doublebuffering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 { "vo_direct_render", &vo_directrendering, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 { "ao_driver", &audio_driver_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 { "ao_volnorm", &gtkAONorm, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 { "softvol", &soft_vol, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 { "ao_extra_stereo", &gtkAOExtraStereo, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 { "ao_extra_stereo_coefficient", &gtkAOExtraStereoMul, CONF_TYPE_FLOAT, CONF_RANGE, -10, 10, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 { "delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 { "osd_level", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 { "cache", &gtkCacheOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
34707
0a4b7681a408 Update GUI code after r34792.
ib
parents: 34697
diff changeset
77 { "cache_size", &gtkCacheSize, CONF_TYPE_INT, CONF_RANGE, 32, 0x7fffffff, NULL },
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 { "autosync", &gtkAutoSyncOn, CONF_TYPE_FLAG, 0, 0, 1, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 { "autosync_size", &gtkAutoSync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 { "gui_skin", &skinName, CONF_TYPE_STRING, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 { "gui_main_pos_x", &gui_main_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 { "gui_main_pos_y", &gui_main_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
34697
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34626
diff changeset
83 { "gui_sub_pos_x", &gui_video_pos_x, CONF_TYPE_INT, 0, 0, 0, NULL },
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34626
diff changeset
84 { "gui_sub_pos_y", &gui_video_pos_y, CONF_TYPE_INT, 0, 0, 0, NULL },
ac6b38cd0d45 Rename sub window video window.
ib
parents: 34626
diff changeset
85 { "sub_window", &video_window, CONF_TYPE_FLAG, 0, 0, 1, NULL},
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86 { "console", &console, CONF_TYPE_FLAG, 0, 0, 1, NULL},
34085
cc1808245016 Make idle mode default in Win32 GUI.
ib
parents: 33566
diff changeset
87 { "idle", &player_idle_mode, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
23077
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
33566
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
91 int cfg_gui_include(m_option_t *conf, const char *filename)
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
92 {
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
93 (void)conf;
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
94
34193
95f91c9bcc9f Add missing parameter to Win32 GUI's call to m_config_parse_config_file().
ib
parents: 34085
diff changeset
95 return m_config_parse_config_file(gui_conf, filename, 0);
33566
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
96 }
b2dad0a365ea Add cfg_gui_include also for win32 GUI.
reimar
parents: 33557
diff changeset
97
34561
f744357e94bd Make cfg_read() and cfg_write() void functions.
ib
parents: 34390
diff changeset
98 void cfg_read(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99 {
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34595
diff changeset
100 char *cfg = get_path(gui_configuration);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101
35501
7bb176fac55c Use boolean symbolic constants in Win32 GUI.
ib
parents: 34707
diff changeset
102 player_idle_mode = TRUE; // GUI is in idle mode by default
34085
cc1808245016 Make idle mode default in Win32 GUI.
ib
parents: 33566
diff changeset
103
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104 /* read configuration */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] [cfg] reading config file: %s\n", cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 gui_conf = m_config_new();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107 m_config_register_options(gui_conf, gui_opts);
34194
280b461a6676 Add missing parameter to Win32 GUI's call to m_config_parse_config_file().
ib
parents: 34193
diff changeset
108 if (m_config_parse_config_file(gui_conf, cfg, 1) < 0)
34577
22887c794c02 In case of a GUI config error, exit MPlayer with error.
ib
parents: 34576
diff changeset
109 mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_ConfigFileError "\n");
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 free(cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112
34561
f744357e94bd Make cfg_read() and cfg_write() void functions.
ib
parents: 34390
diff changeset
113 void cfg_write(void)
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 {
34596
04feb00f91be Prefer static const char arrays for string constants to #defines.
ib
parents: 34595
diff changeset
115 char *cfg = get_path(gui_configuration);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 FILE *f;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 /* save configuration */
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 if ((f = fopen(cfg, "wt+")))
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 for (i=0; gui_opts[i].name; i++)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 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
125 if(v == (char *)-1) {
36694
eed2fb870f43 Rename symbolic constants of GUI help message texts.
ib
parents: 35528
diff changeset
126 mp_msg(MSGT_GPLAYER, MSGL_WARN, MSGTR_GUI_MSG_UnableToSaveOption, gui_opts[i].name);
25712
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
127 v = NULL;
363e217ce9fd Win32 gui has the same m_option_print error handling bug
reimar
parents: 23123
diff changeset
128 }
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129 if(v)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 {
34595
97bf974e7623 Simplify character array definition.
ib
parents: 34593
diff changeset
131 char delim[] = "\"";
34593
83f7a2f8af3b Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents: 34577
diff changeset
132
34626
fb13b4e8eeb4 Fix two copy-and-paste errors in the Win32 GUI.
ib
parents: 34596
diff changeset
133 if (!strchr(v, ' ')) *delim = 0;
34593
83f7a2f8af3b Adjust content of GUI configuration file to MPlayer configuration files.
ib
parents: 34577
diff changeset
134
34626
fb13b4e8eeb4 Fix two copy-and-paste errors in the Win32 GUI.
ib
parents: 34596
diff changeset
135 fprintf(f, "%s=%s%s%s\n", gui_opts[i].name, delim, v, delim);
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136 free(v);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 fclose(f);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 free(cfg);
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 }