mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Create routines qof_book_get_string_option() and qof_book_set_string_option() to get/set a kvp string, respectively.
qof_book_set_string_option() also handles saving the book so that the kvp is updated in the db. In the future, qof_book_set_<type>_option() and qof_book_get_<type>_option() should be created, where type is boolean, int, double, ... In addition, other places which handle options in the book should use these routines. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18594 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ef5a742bf1
commit
6ed568ab77
@ -200,36 +200,31 @@ gnc_get_current_book (void)
|
|||||||
return qof_session_get_book (gnc_get_current_session ());
|
return qof_session_get_book (gnc_get_current_session ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OPTION_TAXUS_NAME "book/tax_US/name"
|
||||||
|
#define OPTION_TAXUS_TYPE "book/tax_US/type"
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_set_current_book_tax_name (const gchar *tax_name)
|
gnc_set_current_book_tax_name (const gchar *tax_name)
|
||||||
{
|
{
|
||||||
QofBook* current_book = gnc_get_current_book();
|
qof_book_set_string_option(gnc_get_current_book(), OPTION_TAXUS_NAME, tax_name);
|
||||||
|
|
||||||
qof_book_begin_edit(current_book);
|
|
||||||
kvp_frame_set_string (qof_book_get_slots (current_book),
|
|
||||||
"book/tax_US/name", tax_name);
|
|
||||||
qof_book_commit_edit(current_book);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gnc_get_current_book_tax_name (void)
|
gnc_get_current_book_tax_name (void)
|
||||||
{
|
{
|
||||||
return kvp_frame_get_string (qof_book_get_slots (gnc_get_current_book()),
|
return qof_book_get_string_option(gnc_get_current_book(), OPTION_TAXUS_NAME);
|
||||||
"book/tax_US/name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_set_current_book_tax_type (const gchar *tax_type)
|
gnc_set_current_book_tax_type (const gchar *tax_type)
|
||||||
{
|
{
|
||||||
kvp_frame_set_string(qof_book_get_slots(gnc_get_current_book()),
|
qof_book_set_string_option(gnc_get_current_book(), OPTION_TAXUS_TYPE, tax_type);
|
||||||
"book/tax_US/type", tax_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
gnc_get_current_book_tax_type (void)
|
gnc_get_current_book_tax_type (void)
|
||||||
{
|
{
|
||||||
return kvp_frame_get_string(qof_book_get_slots(gnc_get_current_book()),
|
return qof_book_get_string_option(gnc_get_current_book(), OPTION_TAXUS_TYPE);
|
||||||
"book/tax_US/type");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Account *
|
Account *
|
||||||
|
@ -203,11 +203,17 @@ create_book_tables( GncSqlBackend* be )
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_sql_save_book( GncSqlBackend* be, QofInstance* inst)
|
gnc_sql_save_book( GncSqlBackend* be, QofInstance* inst)
|
||||||
{
|
{
|
||||||
|
gboolean status;
|
||||||
|
|
||||||
g_return_val_if_fail( be != NULL, FALSE );
|
g_return_val_if_fail( be != NULL, FALSE );
|
||||||
g_return_val_if_fail( inst != NULL, FALSE );
|
g_return_val_if_fail( inst != NULL, FALSE );
|
||||||
g_return_val_if_fail( QOF_IS_BOOK(inst), FALSE );
|
g_return_val_if_fail( QOF_IS_BOOK(inst), FALSE );
|
||||||
|
|
||||||
return gnc_sql_commit_standard_item( be, inst, BOOK_TABLE, GNC_ID_BOOK, col_table );
|
status = gnc_sql_commit_standard_item( be, inst, BOOK_TABLE, GNC_ID_BOOK, col_table );
|
||||||
|
|
||||||
|
qof_book_mark_saved( QOF_BOOK(inst) );
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================= */
|
/* ================================================================= */
|
||||||
|
@ -1012,7 +1012,6 @@ identity_edit_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
|||||||
{
|
{
|
||||||
ti_dialog->tax_type_changed = TRUE;
|
ti_dialog->tax_type_changed = TRUE;
|
||||||
gnc_set_current_book_tax_type (entry_type);
|
gnc_set_current_book_tax_type (entry_type);
|
||||||
qof_book_kvp_changed(ti_dialog->this_book);
|
|
||||||
ti_dialog->tax_type = g_strdup (entry_type);
|
ti_dialog->tax_type = g_strdup (entry_type);
|
||||||
if (entry_type != NULL)
|
if (entry_type != NULL)
|
||||||
{
|
{
|
||||||
@ -1041,7 +1040,6 @@ identity_edit_response_cb (GtkDialog *dialog, gint response, gpointer data)
|
|||||||
if (!(safe_strcmp (ti_dialog->tax_name, entry_name) == 0))
|
if (!(safe_strcmp (ti_dialog->tax_name, entry_name) == 0))
|
||||||
{
|
{
|
||||||
gnc_set_current_book_tax_name (entry_name);
|
gnc_set_current_book_tax_name (entry_name);
|
||||||
qof_book_kvp_changed(ti_dialog->this_book);
|
|
||||||
ti_dialog->tax_name = g_strdup (entry_name);
|
ti_dialog->tax_name = g_strdup (entry_name);
|
||||||
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_name_display),
|
gtk_label_set_text (GTK_LABEL (ti_dialog->entity_name_display),
|
||||||
entry_name);
|
entry_name);
|
||||||
|
@ -262,7 +262,9 @@ qof_book_set_backend (QofBook *book, QofBackend *be)
|
|||||||
|
|
||||||
void qof_book_kvp_changed (QofBook *book)
|
void qof_book_kvp_changed (QofBook *book)
|
||||||
{
|
{
|
||||||
|
qof_book_begin_edit(book);
|
||||||
qof_book_mark_dirty(book);
|
qof_book_mark_dirty(book);
|
||||||
|
qof_book_commit_edit(book);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
@ -441,7 +443,8 @@ qof_book_get_counter (const QofBook *book, const char *counter_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Determine whether this book uses trading accounts */
|
/* Determine whether this book uses trading accounts */
|
||||||
gboolean qof_book_use_trading_accounts (const QofBook *book)
|
gboolean
|
||||||
|
qof_book_use_trading_accounts (const QofBook *book)
|
||||||
{
|
{
|
||||||
const char *opt;
|
const char *opt;
|
||||||
kvp_value *kvp_val;
|
kvp_value *kvp_val;
|
||||||
@ -461,6 +464,21 @@ gboolean qof_book_use_trading_accounts (const QofBook *book)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char*
|
||||||
|
qof_book_get_string_option(const QofBook* book, const char* opt_name)
|
||||||
|
{
|
||||||
|
return kvp_frame_get_string(qof_book_get_slots(book), opt_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val)
|
||||||
|
{
|
||||||
|
qof_book_begin_edit(book);
|
||||||
|
kvp_frame_set_string(qof_book_get_slots(book), opt_name, opt_val);
|
||||||
|
qof_book_mark_dirty(book);
|
||||||
|
qof_book_commit_edit(book);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
qof_book_begin_edit (QofBook *book)
|
qof_book_begin_edit (QofBook *book)
|
||||||
{
|
{
|
||||||
|
@ -278,6 +278,9 @@ gboolean qof_book_equal (const QofBook *book_1, const QofBook *book_2);
|
|||||||
*/
|
*/
|
||||||
gint64 qof_book_get_counter (const QofBook *book, const char *counter_name);
|
gint64 qof_book_get_counter (const QofBook *book, const char *counter_name);
|
||||||
|
|
||||||
|
const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
|
||||||
|
void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
|
||||||
|
|
||||||
void qof_book_begin_edit(QofBook *book);
|
void qof_book_begin_edit(QofBook *book);
|
||||||
void qof_book_commit_edit(QofBook *book);
|
void qof_book_commit_edit(QofBook *book);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user