aboutsummaryrefslogtreecommitdiff
path: root/src/mods.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mods.cc')
-rw-r--r--src/mods.cc78
1 files changed, 32 insertions, 46 deletions
diff --git a/src/mods.cc b/src/mods.cc
index 0f6f498..2123220 100644
--- a/src/mods.cc
+++ b/src/mods.cc
@@ -99,9 +99,12 @@ void Mods::displayMain() {
auto *button = Gtk::manage(new Gtk::Button("Download"));
network->pack_start(*button, false, false);
button->signal_clicked().connect([this]() {
- updateInstallable();
- displayDownload();
- });
+ if(! modsAvailable.empty()) {
+ return;
+ }
+ modsAvailable = libbible::downloadModsAvailable();
+ displayDownload();
+ });
auto *local = Gtk::manage(new Gtk::VBox);
hbox->add(*local);
label = Gtk::manage(new Gtk::Label);
@@ -113,12 +116,14 @@ void Mods::displayMain() {
filter->add_mime_type("application/zip");
add->set_filter(filter);
add->signal_file_set().connect([this, add]() {
- installMods(add->get_filenames());
- this->header->reader->refresh();
- this->header->updateMenus();
- this->header->updateButtons();
- this->header->showText();
- });
+ for(auto filename : add->get_filenames()) {
+ libbible::installModFromZip(filename);
+ }
+ this->header->reader->refresh();
+ this->header->updateMenus();
+ this->header->updateButtons();
+ this->header->showText();
+ });
window->show_all_children();
}
@@ -133,8 +138,8 @@ void Mods::displayDownload() {
auto *button = Gtk::manage(new Gtk::Button("Back"));
vbox->pack_start(*button, false, false);
button->signal_clicked().connect([this]() {
- displayMain();
- });
+ displayMain();
+ });
auto *label = Gtk::manage(new Gtk::Label);
label->set_text("Language Selection:");
vbox->pack_start(*label, false, false);
@@ -166,48 +171,29 @@ void Mods::displayDownload() {
auto *langButton = Gtk::manage(new Gtk::Button(fullLanguage));
langButton->set_relief(Gtk::ReliefStyle::RELIEF_NONE);
langButton->signal_clicked().connect([language, fullLanguage, langMenuButton, langMenu, modsSelection, this]() {
- langMenu->popdown();
- langMenuButton->set_label(fullLanguage);
- for(auto child : modsSelection->get_children()) {
+ langMenu->popdown();
+ langMenuButton->set_label(fullLanguage);
+ for(auto child : modsSelection->get_children()) {
modsSelection->remove(*child);
- }
- for(string name : modsAvailable[language]) {
+ }
+ for(string name : modsAvailable[language]) {
auto *installButton = Gtk::manage(new Gtk::Button(name));
installButton->signal_clicked().connect([language, name, this]() {
- worker = new std::thread([language, name, this] {
- complete = false;
- libbible::installModFromInternet(language, name);
- complete = true;
- dispatcher.emit();
- header->showText();
- });
- });
+ worker = new std::thread([language, name, this] {
+ complete = false;
+ libbible::installModFromInternet(language, name);
+ complete = true;
+ dispatcher.emit();
+ header->showText();
+ });
+ });
modsSelection->pack_start(*installButton, false, false);
- }
- modsSelection->show_all_children();
- });
+ }
+ modsSelection->show_all_children();
+ });
langBox->add(*langButton);
}
langMenuButton->set_popover(*langMenu);
langMenu->show_all_children();
window->show_all_children();
}
-
-void Mods::installMods(std::vector<std::string> filenames) {
- for(auto filename : filenames) {
- libbible::installModFromZip(filename);
- }
-}
-
-void Mods::uninstallMods(std::vector<std::string> modnames) {
- for(auto mod : modnames) {
- libbible::uninstallMod(mod);
- }
-}
-
-void Mods::updateInstallable() {
- if(! modsAvailable.empty()) {
- return;
- }
- modsAvailable = libbible::downloadModsAvailable();
-}