diff options
Diffstat (limited to 'mods.cc')
-rw-r--r-- | mods.cc | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -5,6 +5,7 @@ #include <thread> #include <sys/types.h> #include <sys/stat.h> +#include <algorithm> // 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<std::string, std::string> langFullToAbbrevs; + for(const auto& [abbrev, full] : langAbbrevsToFull) langFullToAbbrevs.emplace(full, abbrev); + std::vector<std::string> 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); } |