[options] Implement widget-changed callbacks.

Enables full functionality for complex-boolean and multichoice-callback
options.

Note that setter-function callback isn't used in any GnuCash code so it
is not implemented and is not present in the register-callback functions.
This commit is contained in:
John Ralls
2022-07-26 14:54:10 -07:00
parent 552aa438ff
commit da0eff2cac
6 changed files with 108 additions and 42 deletions

View File

@@ -197,11 +197,14 @@ public:
*/
std::istream& in_stream(std::istream& iss);
friend GncOptionVariant& swig_get_option(GncOption*);
void set_widget_changed (void* cb) { m_widget_changed = cb; }
void* get_widget_changed () { return m_widget_changed; }
private:
inline static const std::string c_empty_string{""};
GncOptionVariantPtr m_option;
GncOptionUIItemPtr m_ui_item{nullptr};
/* This is a hack to reserve space for a Guile callback pointer. */
void* m_widget_changed{};
};
inline bool

View File

@@ -643,17 +643,6 @@ gnc_register_simple_boolean_option(GncOptionDB* db,
db->register_option(section, std::move(option));
}
void
gnc_register_complex_boolean_option(GncOptionDB* db,
const char* section, const char* name,
const char* key, const char* doc_string,
bool value)
{
GncOption option{section, name, key, doc_string, value,
GncOptionUIType::BOOLEAN};
db->register_option(section, std::move(option));
}
void
gnc_register_pixmap_option(GncOptionDB* db, const char* section,
const char* name, const char* key,

View File

@@ -232,35 +232,6 @@ inline void gnc_register_simple_boolean_option(const GncOptionDBPtr& db,
doc_string, value);
}
/**
* Create a new complex boolean option and register it in the options database.
*
* @param db A GncOptionDB* for calling from C. Caller retains ownership.
* @param section The database section for the option.
* @param name The option name.
* @param doc_string A description of the option. This will be used in tooltips and should be marked for translation.
* @param value The initial and default value for the option.
*/
void gnc_register_complex_boolean_option(GncOptionDB* db,
const char* section, const char* name,
const char* key,
const char* doc_string,
bool value);
/**
* As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
*/
inline void gnc_register_complex_boolean_option(const GncOptionDBPtr& db,
const char* section,
const char* name,
const char* key,
const char* doc_string,
bool value)
{
gnc_register_complex_boolean_option(db.get(), section, name, key,
doc_string, value);
}
/**
* Create a new pixmap option and register it in the options database.
*