Skip to content

Commit

Permalink
Final release for v0.9 with .mobi support
Browse files Browse the repository at this point in the history
  • Loading branch information
babluboy committed Jul 23, 2017
1 parent 877c2c7 commit 8a57a5d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
13 changes: 7 additions & 6 deletions data/com.github.babluboy.bookworm.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
<p>This version supports EPUB, MOBI, PRC, PDF and Comics (CBR and CBZ) formats with support for more formats to follow soon.</p>
<p>New features for Bookworm v0.9 include:</p>
<ul>
​ <li>Added support for .mobi and .prc formats</li>
​ <li>xxx</li>
<li>xxx</li>
<li>xxx</li>
<li>xxx</li>
​ <li>Added support for .mobi (Kindle) format</li>
​ <li>Added prefference to control library view on start</li>
<li>Automatically scroll to exact last read page position</li>
<li>Added a progress bar on hover of the book cover</li>
<li>Keyboard shortcut (Ctrl+D) for bookmarking</li>
<li>Squashed some bugs</li>
​ </ul>
</description>
<screenshots>
Expand All @@ -34,7 +35,7 @@
<binary>bookworm</binary>
</provides>
<releases>
<release version="0.9" date="2017-07-31">
<release version="0.9" date="2017-07-23">
​<description>
​ <p>Support mobi format and UX improvements</p>
​</description>
Expand Down
3 changes: 2 additions & 1 deletion src/contentHandler.vala
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ public class BookwormApp.contentHandler {
}
}else{
//pick the book from the BookwormApp.Bookworm.libraryViewMap as it would have been added
//as part of the code above to create a new book and add it to the BookwormApp.Bookworm.libraryViewMap
//as part of the code above to create a new book
requestedBook = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.commandLineArgs[1].strip());
}
debug("Bookworm opened for single book["+requestedBook.getBookLocation()+"] - proceed to reading view...");
if(requestedBook != null){
//set the name of the book being currently read
BookwormApp.Bookworm.locationOfEBookCurrentlyRead = BookwormApp.Bookworm.commandLineArgs[1].strip();
Expand Down
4 changes: 4 additions & 0 deletions src/dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,10 @@ public class BookwormApp.AppDialog : Gtk.Dialog {
localStorageSwitch.set_active (true);
BookwormApp.Bookworm.settings.is_local_storage_enabled = (bool) bookwormSettings.get_default_value ("is-local-storage-enabled");

//Reset Library at start option
showLibraryAtStartSwitch.set_active (false);
BookwormApp.Bookworm.settings.is_show_library_on_start = (bool) bookwormSettings.get_default_value ("is-show-library-on-start");;

//Reset Dark Theme
nightModeSwitch.set_active (false);
BookwormApp.Bookworm.settings.is_dark_theme_enabled = (bool) bookwormSettings.get_default_value ("is-dark-theme-enabled");
Expand Down
25 changes: 20 additions & 5 deletions src/library.vala
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public class BookwormApp.Library {

public static void removeSelectedBooksFromLibrary(){
ArrayList<string> listOfBooksToBeRemoved = new ArrayList<string> ();
//loop through the Library View Hashmap and remove the selected books
//loop through the Library View Hashmap and remove the selected books from the Library View Model
foreach (BookwormApp.Book book in BookwormApp.Bookworm.libraryViewMap.values){
//check if the book selection flag to true and add it to removal list
if(book.getIsBookSelected()){
Expand All @@ -461,6 +461,9 @@ public class BookwormApp.Library {
if(book.getBookCoverLocation().index_of(BookwormApp.Constants.DEFAULT_COVER_IMAGE_LOCATION.replace("-cover-N.png","")) == -1){
BookwormApp.Utils.execute_sync_command("rm \""+book.getBookCoverLocation()+"\"");
}
//update the onloadBookList - this is to enable re-adding the book within the same session
BookwormApp.Bookworm.pathsOfBooksInLibraryOnLoadStr.assign(BookwormApp.Bookworm.pathsOfBooksInLibraryOnLoadStr.str.replace(book.getBookLocation(), ""));
BookwormApp.Library.listOfBooksInLibraryOnLoad.remove(book);
}
}

Expand Down Expand Up @@ -520,18 +523,27 @@ public class BookwormApp.Library {
}

public static async void addBooksToLibrary (){
debug("Starting to add books....");
debug("Starting to add "+BookwormApp.Bookworm.pathsOfBooksToBeAdded.length.to_string()+" books....");
double progress = 0d;
//loop through the command line and add books to library
foreach(string pathToSelectedBook in BookwormApp.Bookworm.pathsOfBooksToBeAdded){
Idle.add (addBooksToLibrary.callback);
//Set async callback only if multiple books are being added
//If only one book is being added, complete parsing and adding the book,
//so that it will be added to the BookwormApp.Bookworm.libraryViewMap and opened on the BookwormApp.contentHandler.performStartUpActions method
if(BookwormApp.Bookworm.pathsOfBooksToBeAdded.length > 2){
Idle.add (addBooksToLibrary.callback);
}
//set progress for the UI Book addition progress bar
BookwormApp.Bookworm.noOfBooksAddedFromCommand++;
progress = ((double) BookwormApp.Bookworm.noOfBooksAddedFromCommand)/BookwormApp.Bookworm.pathsOfBooksToBeAdded.length;
BookwormApp.AppWindow.bookAdditionBar.set_text (_("Added ") + ((int)(BookwormApp.AppWindow.bookAdditionBar.get_fraction()*100)).to_string() + "% : " + File.new_for_path(BookwormApp.Bookworm.locationOfEBookCurrentlyRead).get_basename());
BookwormApp.AppWindow.bookAdditionBar.set_fraction (progress);
//Return control back for any further actions
yield;
//Return control back for any further actions only if multiple books are being added
//If only one book is being added, complete parsing and adding the book,
//so that it will be added to the BookwormApp.Bookworm.libraryViewMap and opened on the BookwormApp.contentHandler.performStartUpActions method
if(BookwormApp.Bookworm.pathsOfBooksToBeAdded.length > 2){
yield;
}
if("bookworm" != pathToSelectedBook.strip()){ //ignore the first command which is the application name
//check if book already exists in the library
if(BookwormApp.Bookworm.pathsOfBooksInLibraryOnLoadStr.str.index_of(pathToSelectedBook.strip()) != -1){
Expand All @@ -546,6 +558,9 @@ public class BookwormApp.Library {
//the book will be updated to the libraryViewMap within the addBookToLibrary function
//however the libraryViewMap will only be fully populated when all books are added to it
addBookToLibrary(aBookBeingAdded);
//update the onloadBookList - this is to prevent re-adding the book within the same session
BookwormApp.Bookworm.pathsOfBooksInLibraryOnLoadStr.append(aBookBeingAdded.getBookLocation());
BookwormApp.Library.listOfBooksInLibraryOnLoad.add(aBookBeingAdded);
}
}
}
Expand Down

0 comments on commit 8a57a5d

Please sign in to comment.