aboutsummaryrefslogtreecommitdiff
path: root/mods.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-01-22 11:32:36 -0500
committerYour Name <you@example.com>2022-01-22 11:32:36 -0500
commitbde8785a865faefd408c19ba36b4871923debfc8 (patch)
treef57013939b907c62f05d86b9b2d107e937941d18 /mods.cc
parent74ee5578e251d4f9c748d5dbf160d89974c31814 (diff)
downloadbiblereader-bde8785a865faefd408c19ba36b4871923debfc8.tar.gz
biblereader-bde8785a865faefd408c19ba36b4871923debfc8.tar.bz2
biblereader-bde8785a865faefd408c19ba36b4871923debfc8.zip
Displays download language as full names rather than codes
Diffstat (limited to 'mods.cc')
-rw-r--r--mods.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/mods.cc b/mods.cc
index 99985b6..405b316 100644
--- a/mods.cc
+++ b/mods.cc
@@ -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);
}