From d34fe568cdd7441493466a6758542ef73e459225 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 12 Oct 2005 09:49:40 +0200 Subject: [PATCH] Introduce option_changed() for marking the options as modified This just bundles the touching and calling change hooks. --- src/config/dialogs.c | 6 ++---- src/config/options.c | 8 ++++++++ src/config/options.h | 5 +++++ src/dialogs/options.c | 2 ++ src/session/session.c | 5 +++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 9bacd457..7b1233d7 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -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); diff --git a/src/config/options.c b/src/config/options.c index 8af22753..fe5e943b 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -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) diff --git a/src/config/options.h b/src/config/options.h index d0948d49..88a0f130 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -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); diff --git a/src/dialogs/options.c b/src/dialogs/options.c index 1d54e2fd..ebe51516 100644 --- a/src/dialogs/options.c +++ b/src/dialogs/options.c @@ -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; } diff --git a/src/session/session.c b/src/session/session.c index 0c600497..49699a9b 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -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, -- 2.11.4.GIT