aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sword.cc24
-rw-r--r--sword.h2
2 files changed, 17 insertions, 9 deletions
diff --git a/sword.cc b/sword.cc
index 1487cd1..ada3d6e 100644
--- a/sword.cc
+++ b/sword.cc
@@ -10,11 +10,18 @@ bool isNoMods;
Sword::Sword() {
auto mods = libbible::getModules();
isNoMods = mods.empty();
- defaultMod = libbible::settingsRead("module");
- if(mods.find(defaultMod) == mods.end()) {
- defaultMod = string();
+ string defaultMod = libbible::settingsRead("module");
+ currMod = libbible::settingsRead("biblereader::currMod");
+ if(mods.find(currMod) == mods.end()) {
+ currMod = defaultMod;
+ }
+ if(mods.find(currMod) == mods.end()) {
+ currMod = string();
if(! mods.empty()) {
+ // New default mod (previous was deleted)
defaultMod = mods.begin()->first;
+ libbible::settingsWrite("module", defaultMod);
+ currMod = defaultMod;
}
}
}
@@ -31,7 +38,8 @@ vector<string> Sword::getModules() {
}
void Sword::setModule(string version) {
- defaultMod = version;
+ currMod = version;
+ libbible::settingsWrite("biblereader::currMod", currMod);
}
void Sword::fillBuffer(string ref, Glib::RefPtr<Gtk::TextBuffer> buf) {
@@ -46,7 +54,7 @@ void Sword::fillBuffer(string ref, Glib::RefPtr<Gtk::TextBuffer> buf) {
return;
}
- auto texts = libbible::getText(libbible::getPassage(defaultMod, ref));
+ auto texts = libbible::getText(libbible::getPassage(currMod, ref));
auto iter = buf->get_iter_at_offset(0);
@@ -128,12 +136,12 @@ void Sword::getConfig(string book, int chapter, struct config *conf) {
conf->maxChapter = 0;
conf->version = "";
} else {
- auto passages = libbible::getPassages(defaultMod, book);
+ auto passages = libbible::getPassages(currMod, book);
conf->chapter = chapter;
conf->book = passages[0].bookShort;
conf->bookFull = passages[0].book;
conf->maxChapter = passages.back().chapterStart;
- conf->version = defaultMod;
+ conf->version = currMod;
}
}
@@ -141,5 +149,5 @@ vector<string> Sword::getBooks() {
if(isNoMods) {
return vector<string>();
}
- return libbible::getModules()[defaultMod];
+ return libbible::getModules()[currMod];
}
diff --git a/sword.h b/sword.h
index aa52c13..1cd7f61 100644
--- a/sword.h
+++ b/sword.h
@@ -16,7 +16,7 @@ public:
void getConfig(std::string book, int chapter, struct config *conf);
protected:
- std::string defaultMod;
+ std::string currMod;
};