1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

Introduce option_changed() for marking the options as modified

This just bundles the touching and calling change hooks.
This commit is contained in:
Petr Baudis 2005-10-12 09:49:40 +02:00 committed by Petr Baudis
parent dea63f3103
commit d34fe568cd
5 changed files with 20 additions and 6 deletions

View File

@ -35,6 +35,7 @@
static void
toggle_success_msgbox(void *dummy)
{
/* TODO: option_changed() */
get_opt_bool("ui.success_msgbox") = !get_opt_bool("ui.success_msgbox");
get_opt_rec(config_options, "ui.success_msgbox")->flags |= OPT_TOUCHED;
}
@ -306,10 +307,7 @@ check_valid_option(struct dialog_data *dlg_data, struct widget_data *widget_data
option_types[option->type].set(option, chinon)) {
struct option *current = option;
option->flags |= OPT_TOUCHED;
/* Notify everyone out there! */
call_change_hooks(ses, current, option);
option_changed(ses, current, option);
commandline = 0;
mem_free(chinon);

View File

@ -1009,6 +1009,14 @@ call_change_hooks(struct session *ses, struct option *current, struct option *op
}
}
void
option_changed(struct session *ses, struct option *current, struct option *option)
{
option->flags |= OPT_TOUCHED;
/* Notify everyone out there! */
call_change_hooks(ses, current, option);
}
int
commit_option_values(struct option_resolver *resolvers,
struct option *root, union option_value *values, int size)

View File

@ -180,6 +180,11 @@ void toggle_option(struct session *ses, struct option *option);
void call_change_hooks(struct session *ses, struct option *current,
struct option *option);
/* Do proper bookkeeping after an option has changed - call this every time
* you change an option value. */
void option_changed(struct session *ses, struct option *current,
struct option *option);
extern int commit_option_values(struct option_resolver *resolvers,
struct option *root,
union option_value *values, int size);

View File

@ -38,6 +38,8 @@ display_codepage(struct terminal *term, void *name_, void *xxx)
if (opt->value.number != index) {
opt->value.number = index;
/* TODO: option_changed() (we need to review the hooks
* to handle NULL ses or properly document that stuff). */
opt->flags |= OPT_TOUCHED;
}

View File

@ -760,8 +760,9 @@ setup_first_session(struct session *ses, struct uri *uri)
}
if (!get_opt_bool("config.saving_style_w")) {
get_opt_bool("config.saving_style_w") = 1;
get_opt_rec(config_options, "config.saving_style_w")->flags |= OPT_TOUCHED;
struct option *opt = get_opt_rec(config_options, "config.saving_style_w");
opt->value.number = 1;
option_changed(ses, opt, opt);
if (get_opt_int("config.saving_style") != 3) {
info_box(term, 0,
N_("Warning"), ALIGN_CENTER,