From bde8785a865faefd408c19ba36b4871923debfc8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 22 Jan 2022 11:32:36 -0500 Subject: Displays download language as full names rather than codes --- mods.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'mods.cc') diff --git a/mods.cc b/mods.cc index 99985b6..405b316 100644 --- a/mods.cc +++ b/mods.cc @@ -5,6 +5,7 @@ #include #include #include +#include // We want: https://developer.gnome.org/gtkmm-tutorial/stable/sec-multithread-example.html.en void Mods::update(unsigned long totalBytes, unsigned long completedBytes, std::string mess) @@ -157,13 +158,19 @@ void Mods::displayDownload() { sw->add(*langBox); sw->set_propagate_natural_width(true); sw->set_min_content_height(300); - for(auto item : modsAvailable) { - string language = item.first; - auto *langButton = Gtk::manage(new Gtk::Button(language)); + auto langAbbrevsToFull = libbible::getLanguageNames(); + std::map langFullToAbbrevs; + for(const auto& [abbrev, full] : langAbbrevsToFull) langFullToAbbrevs.emplace(full, abbrev); + std::vector langsSorted; + for(auto const& pair : modsAvailable) langsSorted.push_back(langAbbrevsToFull[pair.first]); + std::sort(langsSorted.begin(), langsSorted.end()); + for(string fullLanguage : langsSorted) { + string language = langFullToAbbrevs[fullLanguage]; + auto *langButton = Gtk::manage(new Gtk::Button(fullLanguage)); langButton->set_relief(Gtk::ReliefStyle::RELIEF_NONE); - langButton->signal_clicked().connect([language, langMenuButton, langMenu, modsSelection, this]() { + langButton->signal_clicked().connect([language, fullLanguage, langMenuButton, langMenu, modsSelection, this]() { langMenu->popdown(); - langMenuButton->set_label(language); + langMenuButton->set_label(fullLanguage); for(auto child : modsSelection->get_children()) { modsSelection->remove(*child); } -- cgit v1.2.3