[Gtkmm] Add another predicate for the string_option of GncBook.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21487 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2011-10-24 20:41:28 +00:00
parent 905e478531
commit 3743ed74db
3 changed files with 18 additions and 7 deletions

View File

@ -115,12 +115,12 @@ GType Book::get_base_type()
}
void Book::set_string_option (const Glib::ustring& opt_name, const Glib::ustring& opt_val)
void Book::string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val)
{
qof_book_set_string_option(gobj(), opt_name.c_str(), opt_val.c_str());
}
Glib::ustring Book::get_string_option (const Glib::ustring& opt_name) const
Glib::ustring Book::string_option_get (const Glib::ustring& opt_name) const
{
const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
if (r)
@ -128,6 +128,14 @@ Glib::ustring Book::get_string_option (const Glib::ustring& opt_name) const
else
return "";
}
bool Book::string_option_exists (const Glib::ustring& opt_name) const
{
const char* r = qof_book_get_string_option(gobj(), opt_name.c_str());
if (r)
return true;
else
return false;
}
// Account Book::get_root_account()
// {

View File

@ -106,8 +106,9 @@ public:
{
qof_book_mark_readonly(gobj());
}
void set_string_option (const Glib::ustring& opt_name, const Glib::ustring& opt_val);
Glib::ustring get_string_option (const Glib::ustring& opt_name) const;
void string_option_set (const Glib::ustring& opt_name, const Glib::ustring& opt_val);
Glib::ustring string_option_get (const Glib::ustring& opt_name) const;
bool string_option_exists (const Glib::ustring& opt_name) const;
};
} // END namespace gnc

View File

@ -160,9 +160,11 @@ test_book_get_string_option( Fixture *fixture, gconstpointer pData )
Glib::ustring opt_name_notset("Not Set");
Glib::RefPtr<gnc::Book> book = Glib::wrap(fixture->book, true); // "true" is important!
g_assert( book );
book->set_string_option( opt_name, opt_value);
g_assert_cmpstr( book->get_string_option( opt_name ).c_str(), == , opt_value.c_str());
g_assert( book->get_string_option( opt_name_notset ).empty());
book->string_option_set( opt_name, opt_value);
g_assert_cmpstr( book->string_option_get( opt_name ).c_str(), == , opt_value.c_str());
g_assert( book->string_option_exists(opt_name) == true);
g_assert( book->string_option_get( opt_name_notset ).empty());
g_assert( book->string_option_exists( opt_name_notset ) == false);
}
void test_suite_gtkmm_book()