Skip to content

Commit

Permalink
Put the default value in the defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Zijung Chueh committed Jul 13, 2018
1 parent 7a22fa0 commit 88175b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ settings_t defaults = {
.code = 0,.sym = NoSymbol,.is_valid = false
}, /* ignore this */

.mouse_left_click = MOUSE_CLOSE_CURRENT,

.mouse_middle_click = MOUSE_DO_ACTION,

.mouse_right_click = MOUSE_CLOSE_ALL,

};

rule_t default_rules[] = {
Expand Down
27 changes: 21 additions & 6 deletions src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,33 +537,48 @@ void load_settings(char *cmdline_config_path)
{
char *c = option_get_string(
"global",
"mouse_left_click", "-left_click", "close_current",
"mouse_left_click", "-left_click", NULL,
"Action of Left click event"
);

settings.mouse_left_click = parse_mouse_action(c);
if (c) {
settings.mouse_left_click = parse_mouse_action(c);
} else {
settings.mouse_left_click = defaults.mouse_left_click;
}

g_free(c);
}

{
char *c = option_get_string(
"global",
"mouse_middle_click", "-mouse_middle_click", "do_action",
"mouse_middle_click", "-mouse_middle_click", NULL,
"Action of middle click event"
);

settings.mouse_middle_click = parse_mouse_action(c);
if (c) {
settings.mouse_middle_click = parse_mouse_action(c);
} else {
settings.mouse_middle_click = defaults.mouse_middle_click;
}

g_free(c);
}

{
char *c = option_get_string(
"global",
"mouse_right_click", "-mouse_right_click", "close_all",
"mouse_right_click", "-mouse_right_click", NULL,
"Action of right click event"
);

settings.mouse_right_click = parse_mouse_action(c);
if (c) {
settings.mouse_right_click = parse_mouse_action(c);
} else {
settings.mouse_right_click = defaults.mouse_right_click;
}

g_free(c);
}

Expand Down

0 comments on commit 88175b2

Please sign in to comment.