diff --git a/gnucash/gnome-utils/dialog-options.cpp b/gnucash/gnome-utils/dialog-options.cpp index 87c2f2b714..7e2720679b 100644 --- a/gnucash/gnome-utils/dialog-options.cpp +++ b/gnucash/gnome-utils/dialog-options.cpp @@ -46,7 +46,6 @@ extern "C" #include "glib-guile.h" #include "gnc-account-sel.h" #include "gnc-tree-view-account.h" -#include "gnc-combott.h" #include "gnc-commodity-edit.h" #include "gnc-component-manager.h" #include "gnc-general-select.h" @@ -1180,15 +1179,12 @@ create_multichoice_widget(GncOption& option) { GtkTreeIter iter; auto itemstring = option.permissible_value_name(i); - auto description = option.permissible_value_description(i); gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, - (itemstring && *itemstring) ? _(itemstring) : "", 1, - (description && *description) ? _(description) : "", -1); + gtk_list_store_set(store, &iter, 0, + (itemstring && *itemstring) ? _(itemstring) : "", 1); } /* Create the new Combo with tooltip and add the store */ - auto widget = GTK_WIDGET(gnc_combott_new()); - g_object_set( G_OBJECT( widget ), "model", GTK_TREE_MODEL(store), NULL ); + auto widget{GTK_WIDGET(gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)))}; g_object_unref(store); g_signal_connect(G_OBJECT(widget), "changed", @@ -1204,13 +1200,13 @@ public: GncOptionGtkUIItem{widget, GncOptionUIType::MULTICHOICE} {} void set_ui_item_from_option(GncOption& option) noexcept override { - auto widget{GNC_COMBOTT(get_widget())}; - gnc_combott_set_active(widget, option.get_value()); + auto widget{GTK_COMBO_BOX(get_widget())}; + gtk_combo_box_set_active(widget, option.get_value()); } void set_option_from_ui_item(GncOption& option) noexcept override { - auto widget{GNC_COMBOTT(get_widget())}; - option.set_value(gnc_combott_get_active(widget)); + auto widget{GTK_COMBO_BOX(get_widget())}; + option.set_value(gtk_combo_box_get_active(widget)); } }; @@ -1300,9 +1296,7 @@ private: }; -RelativeDateEntry::RelativeDateEntry(GncOption& option) : - m_entry{GTK_WIDGET(gnc_combott_new())} - +RelativeDateEntry::RelativeDateEntry(GncOption& option) { /* GtkComboBox still does not support per-item tooltips, so have @@ -1319,12 +1313,11 @@ RelativeDateEntry::RelativeDateEntry(GncOption& option) : GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, - option.permissible_value_name(index), 1, - option.permissible_value_description(index), -1); + option.permissible_value_name(index), 1); } /* Create the new Combo with tooltip and add the store */ - g_object_set( G_OBJECT(m_entry), "model", GTK_TREE_MODEL(store), nullptr); + m_entry = GTK_WIDGET(gtk_combo_box_new_with_model(GTK_TREE_MODEL(store))); g_object_unref(store); g_signal_connect(G_OBJECT(m_entry), "changed", @@ -1334,13 +1327,13 @@ RelativeDateEntry::RelativeDateEntry(GncOption& option) : void RelativeDateEntry::set_entry_from_option(GncOption& option) { - gnc_combott_set_active(GNC_COMBOTT(m_entry), option.get_value()); + gtk_combo_box_set_active(GTK_COMBO_BOX(m_entry), option.get_value()); } void RelativeDateEntry::set_option_from_entry(GncOption& option) { - option.set_value(gnc_combott_get_active(GNC_COMBOTT(m_entry))); + option.set_value(gtk_combo_box_get_active(GTK_COMBO_BOX(m_entry))); } using AbsoluteDateEntryPtr = std::unique_ptr; @@ -2465,7 +2458,6 @@ create_radiobutton_widget(char *name, GncOption& option) for (decltype(num_values) i = 0; i < num_values; i++) { auto label = option.permissible_value_name(i); - auto tip = option.permissible_value_description(i); widget = gtk_radio_button_new_with_label_from_widget (widget ? @@ -2474,7 +2466,6 @@ create_radiobutton_widget(char *name, GncOption& option) label && *label ? _(label) : ""); g_object_set_data (G_OBJECT (widget), "gnc_radiobutton_index", GINT_TO_POINTER (i)); - gtk_widget_set_tooltip_text(widget, tip && *tip ? _(tip) : ""); g_signal_connect(G_OBJECT(widget), "toggled", G_CALLBACK(radiobutton_set_cb), &option); gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0); diff --git a/libgnucash/app-utils/gnc-option-impl.hpp b/libgnucash/app-utils/gnc-option-impl.hpp index bcd0cc3654..38c9c0b675 100644 --- a/libgnucash/app-utils/gnc-option-impl.hpp +++ b/libgnucash/app-utils/gnc-option-impl.hpp @@ -526,7 +526,6 @@ operator>> (std::istream& iss, OptType& opt) } using GncMultichoiceOptionEntry = std::tuple; using GncMultichoiceOptionIndexVec = std::vector; @@ -535,9 +534,8 @@ using GncMultichoiceOptionChoices = std::vector; /** Multichoice options have a vector of valid options * (GncMultichoiceOptionChoices) and validate the selection as being one of * those values. The value is the index of the selected item in the vector. The - * tuple contains three strings, a key, a display - * name and a brief description for the tooltip. Both name and description - * should be localized at the point of use. + * tuple contains three strings, a key, and a display + * name, which * should be localized at the point of use. * * */ @@ -726,15 +724,11 @@ public: { return std::get<1>(m_choices.at(index)).c_str(); } - const char* permissible_value_description(std::size_t index) const - { - return std::get<2>(m_choices.at(index)).c_str(); - } void reset_default_value() { m_value = m_default_value; } bool is_changed() const noexcept { return m_value != m_default_value; } GncOptionUIType get_ui_type() const noexcept { return m_ui_type; } void make_internal() { m_ui_type = GncOptionUIType::INTERNAL; } - GncOptionMultichoiceKeyType get_keytype(unsigned i) const { return std::get<3>(m_choices.at(i)); } + GncOptionMultichoiceKeyType get_keytype(unsigned i) const { return std::get<2>(m_choices.at(i)); } private: std::size_t find_key (const std::string& key) const noexcept { @@ -1144,10 +1138,6 @@ public: { return gnc_relative_date_display_string(m_period_set.at(index)); } - const char* permissible_value_description(std::size_t index) const - { - return gnc_relative_date_description(m_period_set.at(index)); - } void reset_default_value() { m_period = m_default_period; m_date = m_default_date; diff --git a/libgnucash/app-utils/gnc-option.cpp b/libgnucash/app-utils/gnc-option.cpp index 6f708681bf..4ab4a1ddb4 100644 --- a/libgnucash/app-utils/gnc-option.cpp +++ b/libgnucash/app-utils/gnc-option.cpp @@ -361,20 +361,6 @@ GncOption::permissible_value_name(std::size_t index) const }, *m_option); } -const char* -GncOption::permissible_value_description(std::size_t index) const -{ - return std::visit([index] (const auto& option) -> const char* { - if constexpr (std::is_same_v, - GncOptionMultichoiceValue> || - std::is_same_v, - GncOptionDateValue>) - return option.permissible_value_description(index); - else - return ""; - }, *m_option); -} - GList* GncOption::account_type_list() const noexcept { diff --git a/libgnucash/app-utils/gnc-option.hpp b/libgnucash/app-utils/gnc-option.hpp index 5edbc9404c..dfc875befb 100644 --- a/libgnucash/app-utils/gnc-option.hpp +++ b/libgnucash/app-utils/gnc-option.hpp @@ -117,7 +117,6 @@ public: std::size_t permissible_value_index(const char* value) const; const char* permissible_value(std::size_t index) const; const char* permissible_value_name(std::size_t index) const; - const char* permissible_value_description(std::size_t index) const; GList* account_type_list() const noexcept; bool is_alternate() const noexcept; void set_alternate(bool) noexcept; diff --git a/libgnucash/app-utils/gnc-optiondb.hpp b/libgnucash/app-utils/gnc-optiondb.hpp index a5b6c427b9..92e04cf5e5 100644 --- a/libgnucash/app-utils/gnc-optiondb.hpp +++ b/libgnucash/app-utils/gnc-optiondb.hpp @@ -49,7 +49,6 @@ using GncOptionAccountList = std::vector; using GncOptionAccountTypeList = std::vector; using GncMultichoiceOptionEntry = std::tuple; using GncMultichoiceOptionChoices = std::vector; diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 95c1456966..52be11160e 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -419,8 +419,7 @@ gnc_option_test_book_destroy(QofBook* book) throw std::invalid_argument("Unsupported key type in multichoice option."); std::string key{scm_to_utf8_string(keyval)}; std::string name{scm_to_utf8_string(SCM_SIMPLE_VECTOR_REF(vec, 1))}; - std::string desc{scm_to_utf8_string(SCM_SIMPLE_VECTOR_REF(vec, 2))}; - choices.push_back({std::move(key), std::move(name), std::move(desc), keytype}); + choices.push_back({std::move(key), std::move(name), keytype}); } $1 = &choices; } diff --git a/libgnucash/app-utils/options.scm b/libgnucash/app-utils/options.scm index 4acf907baa..849a06e473 100644 --- a/libgnucash/app-utils/options.scm +++ b/libgnucash/app-utils/options.scm @@ -90,9 +90,8 @@ (retval '())) (do ((i 0 (1+ i))) ((>= i num-values)) (let ((value (GncOption-permissible-value option i)) - (name (GncOption-permissible-value-name option i)) - (desc (GncOption-permissible-value-description option i))) - (set! retval (cons retval (vector value name desc))))) + (name (GncOption-permissible-value-name option i))) + (set! retval (cons retval (vector value name))))) retval)) (define-public (gnc:new-options) diff --git a/libgnucash/app-utils/test/gtest-gnc-option.cpp b/libgnucash/app-utils/test/gtest-gnc-option.cpp index d715c268ee..379617e13b 100644 --- a/libgnucash/app-utils/test/gtest-gnc-option.cpp +++ b/libgnucash/app-utils/test/gtest-gnc-option.cpp @@ -959,10 +959,10 @@ protected: {"foo", "bar", "baz", "Phony Option", "plugh", { - {"plugh", "xyzzy", "thud", KT::STRING}, - {"waldo", "pepper", "salt", KT::STRING}, - {"pork", "sausage", "links", KT::STRING}, - {"corge", "grault", "garply", KT::STRING} + {"plugh", "xyzzy", KT::STRING}, + {"waldo", "pepper", KT::STRING}, + {"pork", "sausage", KT::STRING}, + {"corge", "grault", KT::STRING} }}} {} GncOption m_option; }; @@ -1003,15 +1003,11 @@ TEST_F(GncMultichoiceOption, test_permissible_value_stuff) EXPECT_EQ(3U, m_option.permissible_value_index("corge")); EXPECT_STREQ("waldo", m_option.permissible_value(1)); EXPECT_STREQ("sausage", m_option.permissible_value_name(2)); - EXPECT_STREQ("thud", - m_option.permissible_value_description(0)); }); EXPECT_THROW({ auto result = m_option.permissible_value(7); }, std::out_of_range); EXPECT_THROW({ auto result = m_option.permissible_value_name(9); }, std::out_of_range); - EXPECT_THROW({ auto result = m_option.permissible_value_description(4); }, - std::out_of_range); EXPECT_EQ(std::numeric_limits::max(), m_option.permissible_value_index("xyzzy")); } @@ -1059,10 +1055,10 @@ protected: "foo", "bar", "baz", "Phony Option", GncMultichoiceOptionIndexVec{0, 2}, { - {"plugh", "xyzzy", "thud", KT::STRING}, - {"waldo", "pepper", "salt", KT::STRING}, - {"pork", "sausage", "links", KT::STRING}, - {"corge", "grault", "garply", KT::STRING} + {"plugh", "xyzzy", KT::STRING}, + {"waldo", "pepper", KT::STRING}, + {"pork", "sausage", KT::STRING}, + {"corge", "grault", KT::STRING} }}} {} GncOption m_option; }; diff --git a/libgnucash/app-utils/test/gtest-gnc-optiondb.cpp b/libgnucash/app-utils/test/gtest-gnc-optiondb.cpp index bae79b04ad..ce0017646d 100644 --- a/libgnucash/app-utils/test/gtest-gnc-optiondb.cpp +++ b/libgnucash/app-utils/test/gtest-gnc-optiondb.cpp @@ -178,10 +178,10 @@ using KT = GncOptionMultichoiceKeyType; TEST_F(GncOptionDBTest, test_register_multichoice_option) { GncMultichoiceOptionChoices choices{ - { "plugh", "xyzzy", "thud", KT::STRING}, - { "waldo", "pepper", "salt", KT::STRING}, - { "pork", "sausage", "links", KT::STRING}, - { "corge", "grault", "garply", KT::STRING}}; + { "plugh", "xyzzy", KT::STRING}, + { "waldo", "pepper", KT::STRING}, + { "pork", "sausage", KT::STRING}, + { "corge", "grault", KT::STRING}}; gnc_register_multichoice_option(m_db, "foo", "bar", "baz", "Phony Option", "waldo", std::move(choices));