diff --git a/data/com.github.babluboy.bookworm.appdata.xml b/data/com.github.babluboy.bookworm.appdata.xml index 62932a57..c808a655 100644 --- a/data/com.github.babluboy.bookworm.appdata.xml +++ b/data/com.github.babluboy.bookworm.appdata.xml @@ -9,8 +9,14 @@ A simple, focused eBook reader

Read the books you love without having to worry about the different format complexities like epub, pdf, mobi, cbr, etc.

-

Manage your library with access to update book metadata and quickly find books with tag based filtering and metadata searching.

+

Manage your library with access to update book metadata and quickly find books with tag based filtering and metadata searching.

This version supports EPUB, PDF and Comics (CBR and CBZ) formats with support for more formats to follow soon.

+

Key features for Bookworm v0.7:

+
diff --git a/data/com.github.babluboy.bookworm.desktop b/data/com.github.babluboy.bookworm.desktop index 2f6fbfab..d3cd4dc3 100755 --- a/data/com.github.babluboy.bookworm.desktop +++ b/data/com.github.babluboy.bookworm.desktop @@ -3,7 +3,7 @@ Name=Bookworm GenericName=eBook Reader Comment=A simple ebook reader for Elementary OS Categories=Office; -MimeType=application/epub+zip;application/pdf;application/x-pdf; +MimeType=application/epub+zip;application/pdf;application/x-pdf;application/cbr;application/x-cbz; Exec=bookworm %F Icon=bookworm Terminal=false diff --git a/po/bookworm.pot b/po/bookworm.pot index e6131b04..c16f2c4a 100644 --- a/po/bookworm.pot +++ b/po/bookworm.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-05-17 20:54+0100\n" +"POT-Creation-Date: 2017-05-18 18:22+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,15 +17,15 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/constants.vala:103 +#: src/constants.vala:106 msgid "About" msgstr "" -#: src/constants.vala:69 +#: src/constants.vala:72 msgid "Add books to library" msgstr "" -#: src/constants.vala:134 +#: src/constants.vala:70 msgid "All Files" msgstr "" @@ -41,6 +41,10 @@ msgstr "" msgid "Bookmarks" msgstr "" +#: src/constants.vala:68 +msgid "Books" +msgstr "" + #: src/constants.vala:47 msgid "Bookworm does not support the format of the file found at location : " msgstr "" @@ -57,11 +61,11 @@ msgstr "" msgid "Click on a link to jump to bookmarked section" msgstr "" -#: src/constants.vala:74 +#: src/constants.vala:77 msgid "Click to bookmark this page" msgstr "" -#: src/constants.vala:75 +#: src/constants.vala:78 msgid "Click to remove this bookmark" msgstr "" @@ -73,19 +77,19 @@ msgstr "" msgid "Contents" msgstr "" -#: src/constants.vala:84 +#: src/constants.vala:87 msgid "Dark theme" msgstr "" -#: src/constants.vala:77 +#: src/constants.vala:80 msgid "Decrease font size" msgstr "" -#: src/constants.vala:81 +#: src/constants.vala:84 msgid "Decrease line spacing" msgstr "" -#: src/constants.vala:79 +#: src/constants.vala:82 msgid "Decrease line width" msgstr "" @@ -93,7 +97,7 @@ msgstr "" msgid "Edit Info for" msgstr "" -#: src/constants.vala:92 +#: src/constants.vala:95 msgid "Enable cache (opens books faster)" msgstr "" @@ -101,7 +105,7 @@ msgstr "" msgid "Enter full screen view" msgstr "" -#: src/constants.vala:86 src/constants.vala:87 +#: src/constants.vala:89 src/constants.vala:90 msgid "Enter full screen view and Esc key to exit" msgstr "" @@ -113,15 +117,19 @@ msgstr "" msgid "Found the following matches for '$$$' in &&&:" msgstr "" -#: src/constants.vala:76 +#: src/constants.vala:69 +msgid "Images" +msgstr "" + +#: src/constants.vala:79 msgid "Increase font size" msgstr "" -#: src/constants.vala:80 +#: src/constants.vala:83 msgid "Increase line spacing" msgstr "" -#: src/constants.vala:78 +#: src/constants.vala:81 msgid "Increase line width" msgstr "" @@ -141,7 +149,7 @@ msgstr "" msgid "Library" msgstr "" -#: src/constants.vala:83 +#: src/constants.vala:86 msgid "Light theme" msgstr "" @@ -163,7 +171,7 @@ msgstr "" msgid "Not Available" msgstr "" -#: src/constants.vala:90 src/constants.vala:104 +#: src/constants.vala:93 src/constants.vala:107 msgid "Preferences" msgstr "" @@ -173,7 +181,7 @@ msgid "" "location : " msgstr "" -#: src/constants.vala:70 +#: src/constants.vala:73 msgid "Remove selected books from library (eBook file will not be deleted)" msgstr "" @@ -193,7 +201,7 @@ msgstr "" msgid "Search this book..." msgstr "" -#: src/constants.vala:72 +#: src/constants.vala:75 msgid "See Table of Contents, Bookmarks and Search Results" msgstr "" @@ -201,23 +209,23 @@ msgstr "" msgid "Select an eBook to read" msgstr "" -#: src/constants.vala:71 +#: src/constants.vala:74 msgid "Select one or more books in library" msgstr "" -#: src/constants.vala:85 +#: src/constants.vala:88 msgid "Sepia theme" msgstr "" -#: src/constants.vala:73 +#: src/constants.vala:76 msgid "Set reading preferences" msgstr "" -#: src/constants.vala:91 +#: src/constants.vala:94 msgid "Turn on Night Mode" msgstr "" -#: src/constants.vala:102 +#: src/constants.vala:105 msgid "Unknown Book" msgstr "" @@ -237,7 +245,7 @@ msgstr "" msgid "Update Title" msgstr "" -#: src/constants.vala:82 +#: src/constants.vala:85 msgid "Update cover image" msgstr "" diff --git a/screenshots/BookwormLibraryView.jpeg b/screenshots/BookwormLibraryView.jpeg index 6e6d3181..4732aab4 100644 Binary files a/screenshots/BookwormLibraryView.jpeg and b/screenshots/BookwormLibraryView.jpeg differ diff --git a/src/constants.vala b/src/constants.vala index 3f5f0aac..f949e5c8 100644 --- a/src/constants.vala +++ b/src/constants.vala @@ -65,6 +65,9 @@ namespace BookwormApp.Constants { public const string TEXT_FOR_PAGE_CONTEXTMENU_FULL_SCREEN_ENTRY = _("Enter full screen view"); public const string TEXT_FOR_PAGE_CONTEXTMENU_FULL_SCREEN_EXIT = _("Exit full screen view"); public const string TEXT_FOR_PAGE_CONTEXTMENU_WORD_MEANING = _("Check Word Meaning"); + public const string TEXT_FOR_FILE_CHOOSER_FILTER_BOOKS = _("Books"); + public const string TEXT_FOR_FILE_CHOOSER_FILTER_IMAGES = _("Images"); + public const string TEXT_FOR_FILE_CHOOSER_FILTER_ALL_FILES = _("All Files"); public const string TOOLTIP_TEXT_FOR_ADD_BOOK = _("Add books to library"); public const string TOOLTIP_TEXT_FOR_REMOVE_BOOK = _("Remove selected books from library (eBook file will not be deleted)"); @@ -131,7 +134,9 @@ namespace BookwormApp.Constants { public static const int MAX_BOOK_COVER_PER_ROW = 6; public static const int MAX_NUMBER_OF_LINES_PER_PAGE = 30; public static const int MAX_NUMBER_OF_CHARS_PER_LINE = 80; - public static const string FILE_CHOOSER_FILTER_ALL_FILES = _("All Files"); + public static const string FILE_CHOOSER_FILTER_EBOOKS[] = {"*.epub", "*.pdf", "*.cbr", "*.cbz"}; + public static const string FILE_CHOOSER_FILTER_IMAGES[] = {"*.jpg", "*.jpeg", "*.gif", "*.png", "*.svg"}; + public static const string BOOKWORM_READING_MODE[] = {"DAY MODE", "SEPIA MODE", diff --git a/src/dialog.vala b/src/dialog.vala index 04ce08be..15ac92d1 100644 --- a/src/dialog.vala +++ b/src/dialog.vala @@ -52,7 +52,7 @@ public class BookwormApp.AppDialog : Gtk.Dialog { updateCoverImageBox.pack_start(updateCoverImageButton,false, true, 0); //Add action for setting cover image updateCoverImageButton.clicked.connect (() => { - ArrayList selectedFiles = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select Image"), BookwormApp.Bookworm.window, false, BookwormApp.Utils.getFileTypeMapping("IMAGES"), "JPG"); + ArrayList selectedFiles = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select Image"), BookwormApp.Bookworm.window, false, "IMAGES"); if(selectedFiles != null && selectedFiles.size > 0){ string selectedCoverImagePath = selectedFiles.get(0); //copy cover image to bookworm cover image cache @@ -87,7 +87,7 @@ public class BookwormApp.AppDialog : Gtk.Dialog { updateTitleBox.pack_end(updateTitleEntry,false, true, 0); //Add action for setting Book Title updateTitleEntry.focus_out_event.connect (() => { - if(updateTitleEntry.get_text() != null && updateTitleEntry.get_text().length > 0){ + if(!aBook.getIsBookCoverImagePresent() && updateTitleEntry.get_text() != null && updateTitleEntry.get_text().length > 0){ aBook.setBookTitle(updateTitleEntry.get_text()); aBook.setWasBookOpened(true); //refresh the library view diff --git a/src/library.vala b/src/library.vala index 9c8a5444..8321a1f4 100644 --- a/src/library.vala +++ b/src/library.vala @@ -27,7 +27,7 @@ public class BookwormApp.Library{ Gtk.Image bookSelectionImage; Gtk.Image bookSelectedImage; string bookCoverLocation; - + Gdk.Pixbuf aBookCover; Gdk.Pixbuf bookPlaceholderCoverPix = new Gdk.Pixbuf.from_file_at_scale(BookwormApp.Constants.PLACEHOLDER_COVER_IMAGE_LOCATION, 150, 200, false); Gtk.Image bookPlaceholderCoverImage = new Gtk.Image.from_pixbuf(bookPlaceholderCoverPix); @@ -37,8 +37,20 @@ public class BookwormApp.Library{ bookCoverLocation = BookwormApp.Constants.DEFAULT_COVER_IMAGE_LOCATION.replace("N", GLib.Random.int_range(1, 6).to_string()); aBook.setBookCoverLocation(bookCoverLocation); } - Gdk.Pixbuf aBookCover = new Gdk.Pixbuf.from_file_at_scale(aBook.getBookCoverLocation(), 150, 200, false); - aCoverImage = new Gtk.Image.from_pixbuf(aBookCover); + try{ + aBookCover = new Gdk.Pixbuf.from_file_at_scale(aBook.getBookCoverLocation(), 150, 200, false); + aCoverImage = new Gtk.Image.from_pixbuf(aBookCover); + }catch(GLib.Error e){ + //Sometimes the path to the image selected by the parser is not a image + //This catch block assigns a default cover selected at random to cover this issue + bookCoverLocation = BookwormApp.Constants.DEFAULT_COVER_IMAGE_LOCATION.replace("N", GLib.Random.int_range(1, 6).to_string()); + aBook.setBookCoverLocation(bookCoverLocation); + aBookCover = new Gdk.Pixbuf.from_file_at_scale(aBook.getBookCoverLocation(), 150, 200, false); + aCoverImage = new Gtk.Image.from_pixbuf(aBookCover); + //set cover image present flag to false - this will add title text to the default cover + aBook.setIsBookCoverImagePresent(false); + } + aCoverImage.set_halign(Align.START); aCoverImage.set_valign(Align.START); diff --git a/src/utils.vala b/src/utils.vala index 7cceb958..f7468490 100644 --- a/src/utils.vala +++ b/src/utils.vala @@ -513,33 +513,10 @@ namespace BookwormApp.Utils { debug("Completed creating Table Of Contents...."); return tocHTML.str; } - //Utility function to provide a filter list of file types. This is used for file chooser dialog filter - public static Gee.HashMap getFileTypeMapping(string fileType){ - Gee.HashMap filterMap = new Gee.HashMap(); - switch(fileType){ - case "EBOOKS": - filterMap.set("*.epub", "EPUB"); - filterMap.set("*.pdf", "PDF"); - filterMap.set("*", BookwormApp.Constants.FILE_CHOOSER_FILTER_ALL_FILES); - break; - case "IMAGES": - filterMap.set("*.jpg", "JPG"); - filterMap.set("*.jpeg", "JPEG"); - filterMap.set("*.gif", "GIF"); - filterMap.set("*.png", "PNG"); - filterMap.set("*", BookwormApp.Constants.FILE_CHOOSER_FILTER_ALL_FILES); - break; - default: - filterMap.set("*", BookwormApp.Constants.FILE_CHOOSER_FILTER_ALL_FILES); - break; - } - return filterMap; - } - + // Create a GtkFileChooserDialog to perform the action desired //The filterMap should be in the format: key=*.epub, value=ePUB, key=*.jpg, value=Images - public Gtk.FileChooserDialog new_file_chooser_dialog (Gtk.FileChooserAction action, string title, Gtk.Window? parent, bool select_multiple, Gee.HashMap filterMap, string defaultFilterName) { - bool isFilterSet = false; + public Gtk.FileChooserDialog new_file_chooser_dialog (Gtk.FileChooserAction action, string title, Gtk.Window? parent, bool select_multiple, string filterType) { Gtk.FileChooserDialog aFileChooserDialog = new Gtk.FileChooserDialog (title, parent, action); aFileChooserDialog.set_select_multiple (select_multiple); aFileChooserDialog.add_button (_("Cancel"), Gtk.ResponseType.CANCEL); @@ -550,10 +527,9 @@ namespace BookwormApp.Utils { aFileChooserDialog.set_current_name(""); } aFileChooserDialog.set_default_response (Gtk.ResponseType.ACCEPT); - debug("Setting File chooser to open on folder:"+BookwormApp.Utils.last_file_chooser_path); if(BookwormApp.Utils.last_file_chooser_path != null && BookwormApp.Utils.last_file_chooser_path.length != 0){ bool aFileChooserDialogOpeningstatus = aFileChooserDialog.set_current_folder_file (GLib.File.new_for_path(BookwormApp.Utils.last_file_chooser_path)); - debug("Opening FileChooserDialog with path:"+BookwormApp.Utils.last_file_chooser_path+" returned status:"+aFileChooserDialogOpeningstatus.to_string()); + debug("Opening FileChooserDialog with last used path:"+BookwormApp.Utils.last_file_chooser_path+" returned status:"+aFileChooserDialogOpeningstatus.to_string()); }else{ aFileChooserDialog.set_current_folder (GLib.Environment.get_home_dir ()); } @@ -563,25 +539,43 @@ namespace BookwormApp.Utils { return false; }); - foreach (var entry in filterMap.entries) { - Gtk.FileFilter files_filter = new Gtk.FileFilter (); - files_filter.set_filter_name (entry.value); - files_filter.add_pattern (entry.key); - aFileChooserDialog.add_filter (files_filter); - if((!isFilterSet) && defaultFilterName == entry.value){ - aFileChooserDialog.set_filter (files_filter); - isFilterSet = true; - } + //Set File filters based on the required Filter Type + switch(filterType){ + case "EBOOKS": + Gtk.FileFilter ebook_files_filter = new Gtk.FileFilter (); + //Add filter for supported eBook formats + ebook_files_filter.set_filter_name (BookwormApp.Constants.TEXT_FOR_FILE_CHOOSER_FILTER_BOOKS); + foreach (string pattern in BookwormApp.Constants.FILE_CHOOSER_FILTER_EBOOKS) { + ebook_files_filter.add_pattern (pattern); + } + aFileChooserDialog.add_filter (ebook_files_filter); + break; + case "IMAGES": + Gtk.FileFilter image_files_filter = new Gtk.FileFilter (); + //Add filter for supported eBook formats + image_files_filter.set_filter_name (BookwormApp.Constants.TEXT_FOR_FILE_CHOOSER_FILTER_IMAGES); + foreach (string pattern in BookwormApp.Constants.FILE_CHOOSER_FILTER_IMAGES) { + image_files_filter.add_pattern (pattern); + } + aFileChooserDialog.add_filter (image_files_filter); + break; + default: + break; } + //Set the All Files filter + Gtk.FileFilter all_files_filter = new Gtk.FileFilter (); + all_files_filter.set_filter_name (BookwormApp.Constants.TEXT_FOR_FILE_CHOOSER_FILTER_ALL_FILES); + all_files_filter.add_pattern ("*"); + aFileChooserDialog.add_filter (all_files_filter); return aFileChooserDialog; } - public static ArrayList selectFileChooser(Gtk.FileChooserAction action, string title, Gtk.Window? parent, bool select_multiple, Gee.HashMap filterMap, string defaultFilterName){ + public static ArrayList selectFileChooser(Gtk.FileChooserAction action, string title, Gtk.Window? parent, bool select_multiple, string filterType){ ArrayList eBookLocationList = new ArrayList(); //create a hashmap to hold details for the book Gee.HashMap bookDetailsMap = new Gee.HashMap(); //choose eBook using a File chooser dialog - Gtk.FileChooserDialog aFileChooserDialog = BookwormApp.Utils.new_file_chooser_dialog (action, title, parent, select_multiple, filterMap, defaultFilterName); + Gtk.FileChooserDialog aFileChooserDialog = BookwormApp.Utils.new_file_chooser_dialog (action, title, parent, select_multiple, filterType); aFileChooserDialog.show_all (); if (aFileChooserDialog.run () == Gtk.ResponseType.ACCEPT) { SList uris = aFileChooserDialog.get_uris (); diff --git a/src/window.vala b/src/window.vala index af79028f..1d81a48c 100644 --- a/src/window.vala +++ b/src/window.vala @@ -192,7 +192,7 @@ public class BookwormApp.AppWindow { }); //Add action for adding a book on the library view add_book_button.clicked.connect (() => { - ArrayList selectedEBooks = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select eBook"), BookwormApp.Bookworm.window, true, BookwormApp.Utils.getFileTypeMapping("EBOOKS"), "EPUB"); + ArrayList selectedEBooks = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select eBook"), BookwormApp.Bookworm.window, true, "EBOOKS"); BookwormApp.Bookworm.pathsOfBooksToBeAdded = new string[selectedEBooks.size]; int countOfBooksToBeAdded = 0; foreach(string pathToSelectedBook in selectedEBooks){ @@ -345,7 +345,7 @@ public class BookwormApp.AppWindow { BookwormApp.Bookworm.bookWormUIBox.show_all(); BookwormApp.Bookworm.toggleUIState(); - ArrayList selectedEBooks = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select eBook"), BookwormApp.Bookworm.window, true, BookwormApp.Utils.getFileTypeMapping("EBOOKS"), "EPUB"); + ArrayList selectedEBooks = BookwormApp.Utils.selectFileChooser(Gtk.FileChooserAction.OPEN, _("Select eBook"), BookwormApp.Bookworm.window, true, "EBOOKS"); BookwormApp.Bookworm.pathsOfBooksToBeAdded = new string[selectedEBooks.size]; int countOfBooksToBeAdded = 0; foreach(string pathToSelectedBook in selectedEBooks){