Bug 345924 - Report options 'Reset Button' always flags changes

If a report is loaded with default settings and the 'Reset button' is
pressed the 'OK/Apply' buttons will be enabled which should not happen
as there are no changes to be made.

Fixed by resetting the changed flag on options load and then comparing
the current value to the default one when the 'Reset button' pressed.
This commit is contained in:
Robert Fewell 2020-10-22 14:26:50 +01:00
parent 8e5e3480ad
commit c11f4db96e
3 changed files with 35 additions and 17 deletions

View File

@ -225,7 +225,7 @@ void
gnc_option_changed_widget_cb(GtkWidget *widget, GNCOption *option)
{
gnc_option_set_changed (option, TRUE);
gnc_option_call_option_widget_changed_proc(option);
gnc_option_call_option_widget_changed_proc(option, FALSE);
gnc_options_dialog_changed_internal (widget, TRUE);
}
@ -369,7 +369,18 @@ gnc_option_set_ui_value_internal (GNCOption *option, gboolean use_default)
type = gnc_option_type(option);
if (use_default)
{
SCM opt_getter = gnc_option_getter(option);
SCM opt_value = scm_call_0(opt_getter);
SCM def_value;
getter = gnc_option_default_getter(option);
def_value = scm_call_0(getter);
// only set changed if the values have changed
if (!scm_is_true(scm_equal_p(opt_value, def_value)))
gnc_option_set_changed (option, TRUE);
}
else
getter = gnc_option_getter(option);
@ -1983,8 +1994,9 @@ gnc_options_dialog_build_contents_full (GNCOptionWin *propertybox,
for (j = 0; j < gnc_option_section_num_options(section); j++)
{
// setting TRUE will clear the changed flag after proc
gnc_option_call_option_widget_changed_proc(
gnc_get_option_section_option(section, j) );
gnc_get_option_section_option(section, j), TRUE);
}
}
@ -2106,13 +2118,16 @@ gnc_options_dialog_reset_cb(GtkWidget * w, gpointer data)
GNCOptionSection *section;
gpointer val;
val = g_object_get_data(G_OBJECT(w), "section");
val = g_object_get_data (G_OBJECT(w), "section");
g_return_if_fail (val);
g_return_if_fail (win);
section = (GNCOptionSection*)val;
gnc_option_db_section_reset_widgets (section);
gnc_options_dialog_changed_internal (win->window, TRUE);
if (gnc_option_db_get_changed (win->option_db))
gnc_options_dialog_changed_internal (win->window, TRUE);
}
void

View File

@ -790,17 +790,19 @@ gnc_option_widget_changed_proc_getter(GNCOption *option)
}
/********************************************************************\
* gnc_option_call_option_widget_changed_proc *
* If there is an option_widget_changed_cb for this option, call *
* it with the SCM value of the option that is passed in. If *
* there is no such callback function or value, do nothing. *
* *
* Args: option - the GNCOption *
* Returns: void *
\********************************************************************/
/**********************************************************************\
* gnc_option_call_option_widget_changed_proc *
* If there is an option_widget_changed_cb for this option, call *
* it with the SCM value of the option that is passed in. If *
* there is no such callback function or value, do nothing. *
* *
* Args: option - the GNCOption *
* reset_changed - whether to reset the changed flag afterwards *
* Returns: void *
\**********************************************************************/
void
gnc_option_call_option_widget_changed_proc(GNCOption *option)
gnc_option_call_option_widget_changed_proc (GNCOption *option,
gboolean reset_changed)
{
SCM cb, value;
@ -815,6 +817,8 @@ gnc_option_call_option_widget_changed_proc(GNCOption *option)
scm_call_1(cb, value);
}
}
if (reset_changed)
option->changed = FALSE;
}
@ -1847,9 +1851,7 @@ gnc_option_db_section_reset_widgets (GNCOptionSection *section)
option_node = option_node->next)
{
option = option_node->data;
gnc_option_set_ui_value (option, TRUE);
gnc_option_set_changed (option, TRUE);
}
}

View File

@ -130,7 +130,8 @@ gboolean gnc_option_get_color_info(GNCOption *option,
gdouble *blue,
gdouble *alpha);
void gnc_option_call_option_widget_changed_proc (GNCOption *option);
void gnc_option_call_option_widget_changed_proc (GNCOption *option,
gboolean reset_changed);
void gnc_option_set_default(GNCOption *option);