Add support for setting a string option.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7826 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2003-01-13 07:33:53 +00:00
parent f6423ddd09
commit d15db59c42
4 changed files with 69 additions and 1 deletions

View File

@ -440,6 +440,23 @@ gnc_set_boolean_option(const char *section, const char *name, gboolean value)
}
/********************************************************************\
* gnc_set_string_option *
* sets the string option to the given value. If successful *
* returns TRUE, otherwise FALSE. *
* *
* Args: section - section name of option *
* name - name of option *
* value - value to set to *
* Return: success indicator *
\********************************************************************/
gboolean
gnc_set_string_option(const char *section, const char *name, const char *value)
{
return gnc_option_db_set_string_option(global_options, section, name, value);
}
/********************************************************************\
* _gnc_option_refresh_ui *
* sets the GUI representation of an option with its *

View File

@ -87,6 +87,9 @@ gboolean gnc_set_number_option(const char *section, const char *name,
gboolean gnc_set_boolean_option(const char *section, const char *name,
gboolean value);
gboolean gnc_set_string_option(const char *section, const char *name,
const char *value);
void gnc_option_refresh_ui_by_name(const char *section_name,
const char *name);

View File

@ -2334,7 +2334,7 @@ gnc_option_db_set_option_default(GNCOptionDB *odb,
/********************************************************************\
* gnc_option_db_set_number_option *
* gnc_option_db_set_option *
* sets the option to the given value. If successful *
* returns TRUE, otherwise FALSE. *
* *
@ -2451,6 +2451,49 @@ gnc_option_db_set_boolean_option(GNCOptionDB *odb,
return TRUE;
}
/********************************************************************\
* gnc_option_db_set_string_option *
* sets the string option to the given value. If successful *
* returns TRUE, otherwise FALSE. *
* *
* Args: odb - option database to search in *
* section - section name of option *
* name - name of option *
* value - value to set to *
* Return: success indicator *
\********************************************************************/
gboolean
gnc_option_db_set_string_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *value)
{
GNCOption *option;
SCM scm_value;
SCM setter;
option = gnc_option_db_get_option_by_name(odb, section, name);
if (option == NULL)
return FALSE;
if (value)
scm_value = gh_str2scm(value, strlen(value));
else
scm_value = SCM_BOOL_F;
scm_value = gnc_option_valid_value(option, scm_value);
if (scm_value == SCM_UNDEFINED)
return FALSE;
setter = gnc_option_setter(option);
if (setter == SCM_UNDEFINED)
return FALSE;
gh_call1(setter, scm_value);
return TRUE;
}
/*******************************************************************\
* gnc_option_date_option_get_subtype *
* find out whether a date option is a relative or absolute date *

View File

@ -224,6 +224,11 @@ gboolean gnc_option_db_set_boolean_option(GNCOptionDB *odb,
const char *name,
gboolean value);
gboolean gnc_option_db_set_string_option(GNCOptionDB *odb,
const char *section,
const char *name,
const char *value);
char * gnc_option_date_option_get_subtype(GNCOption *option);
char * gnc_date_option_value_get_type (SCM option_value);