aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2022-04-20 12:07:48 -0400
committerYour Name <you@example.com>2022-04-20 12:07:48 -0400
commit534088c3c721654fef662a2d2051d1ff3bbb1c20 (patch)
tree91f0bfdd26164435906fbcd66d3a9753ed36a0c5
parent7fc9d0c19efb22cb02af7f34c8473c960ec2d02e (diff)
downloadbiblereader-534088c3c721654fef662a2d2051d1ff3bbb1c20.tar.gz
biblereader-534088c3c721654fef662a2d2051d1ff3bbb1c20.tar.bz2
biblereader-534088c3c721654fef662a2d2051d1ff3bbb1c20.zip
Code simplifications
-rw-r--r--src/header.cc3
-rw-r--r--src/mods.cc78
-rw-r--r--src/mods.h3
3 files changed, 33 insertions, 51 deletions
diff --git a/src/header.cc b/src/header.cc
index 69e0742..58d1700 100644
--- a/src/header.cc
+++ b/src/header.cc
@@ -170,7 +170,7 @@ void Header::updateMenus() {
delVersion->signal_clicked().connect([version, this]() {
menuMenu.popdown();
std::vector<std::string> toDel {version};
- this->mods->uninstallMods(toDel);
+ libbible::uninstallMod(version);
reader->refresh();
updateButtons();
updateMenus();
@@ -199,7 +199,6 @@ void Header::updateMenus() {
void Header::showMods() {
window->remove();
window->add(*this->mods);
- //this->mods->displayMain();
window->show_all_children();
}
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();
-}
diff --git a/src/mods.h b/src/mods.h
index 7373961..dab5a15 100644
--- a/src/mods.h
+++ b/src/mods.h
@@ -22,9 +22,6 @@ public:
Mods(Header *header, Gtk::Window *window);
virtual ~Mods();
- void installMods(std::vector<std::string> filenames);
- void uninstallMods(std::vector<std::string> modnames);
- void updateInstallable();
void displayMain();
void displayDownload();