wmix: moved the initialisation of the config to the related file

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS 2014-06-07 21:21:47 +02:00 committed by Carlos R. Mafra
parent eb8be92aa8
commit b394e0bdba
4 changed files with 29 additions and 21 deletions

View file

@ -45,6 +45,31 @@
struct _Config config; struct _Config config;
/*
* Sets the default values in configuration
*/
void config_init(void)
{
char *home;
memset(&config, 0, sizeof(config));
/* we can theoretically live without a config file */
home = getenv("HOME");
if (home) {
config.file = calloc(1, strlen(home) + 9);
sprintf(config.file, "%s/.wmixrc", home);
}
config.mousewheel = 1;
config.scrolltext = 1;
config.wheel_button_up = 4;
config.wheel_button_down = 5;
config.scrollstep = 0.03;
config.osd = 1;
config.osd_color = strdup("green");
}
/* /*
* Parse Command-Line options * Parse Command-Line options
* *

View file

@ -33,5 +33,3 @@ typedef unsigned int bool;
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#define MAX_DOUBLE_CLICK_TIME 0.5 #define MAX_DOUBLE_CLICK_TIME 0.5
#define BUTTON_WHEEL_UP 4
#define BUTTON_WHEEL_DOWN 5

View file

@ -47,6 +47,9 @@ extern struct _Config {
/* Current version of WMixer */ /* Current version of WMixer */
#define VERSION "3.0" #define VERSION "3.0"
/* Sets the default values in the config */
void config_init(void);
/* Sets configuration from command line */ /* Sets configuration from command line */
void parse_cli_options(int argc, char **argv); void parse_cli_options(int argc, char **argv);

View file

@ -61,26 +61,8 @@ static void motion_event(XMotionEvent *event);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
XEvent event; XEvent event;
char *home;
memset(&config, 0, sizeof(config));
/* we can theoretically live without a config file */
home = getenv("HOME");
if (home) {
config.file = calloc(1, strlen(home) + 9);
sprintf(config.file, "%s/.wmixrc", home);
}
/* default values */
config.mousewheel = 1;
config.scrolltext = 1;
config.wheel_button_up = 4;
config.wheel_button_down = 5;
config.scrollstep = 0.03;
config.osd = 1;
config.osd_color = strdup("green");
config_init();
parse_cli_options(argc, argv); parse_cli_options(argc, argv);
config_read(); config_read();