From 65de43dc325dace3cd985a7b92fb655e94f3df15 Mon Sep 17 00:00:00 2001 From: Siddhartha Das Date: Sun, 11 Feb 2018 21:02:54 +0000 Subject: [PATCH] Fixes for loading a book from right click in Files --- data/com.github.babluboy.bookworm.appdata.xml | 22 ++++-- po/com.github.babluboy.bookworm.pot | 50 +++++++------ .../com.github.babluboy.bookworm.gschema.xml | 5 +- src/bookinfo.vala | 7 +- src/bookworm.vala | 13 ++-- src/constants.vala | 29 +++++--- src/constants.vala.in | 29 +++++--- src/contentHandler.vala | 19 ++++- src/dialog.vala | 14 +++- src/ePubReader.vala | 74 +++++++++---------- src/prefpopover.vala | 8 +- src/xmlHandler.vala | 9 ++- 12 files changed, 171 insertions(+), 108 deletions(-) diff --git a/data/com.github.babluboy.bookworm.appdata.xml b/data/com.github.babluboy.bookworm.appdata.xml index 27bdb0dc..5ca0353d 100644 --- a/data/com.github.babluboy.bookworm.appdata.xml +++ b/data/com.github.babluboy.bookworm.appdata.xml @@ -6,7 +6,7 @@ bookworm GPL-3.0+ Bookworm - A simple, focused eBook reader + A 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 by tagging and updating metadata on books, to quickly find books using metadata searching and tag based filtering.

@@ -26,16 +26,21 @@ com.github.babluboy.bookworm - + -

Annotations and Two Page Views

+

Right to Left Reading

    -
  • Support for creating Annotations with searchable tags
  • -
  • Two page reading
  • -
  • New shortcuts (See Bookworm Homepage for details)
  • +
  • Support for Right to Left Reading
  • +
  • A shiny new icon and new cover images
  • +
  • Better support for EPUB Table of Contents
+ + +

Annotations and Two Page Views

+
+

Support mobi format and UX improvements

@@ -67,4 +72,9 @@ https://github.com/babluboy/bookworm/issues https://github.com/babluboy/bookworm/wiki bablu.boy_AT_gmail.com + + #e29ffc + #260063 + 2 + diff --git a/po/com.github.babluboy.bookworm.pot b/po/com.github.babluboy.bookworm.pot index 253e2f5a..0f98926a 100644 --- a/po/com.github.babluboy.bookworm.pot +++ b/po/com.github.babluboy.bookworm.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-10 16:45+0000\n" +"POT-Creation-Date: 2018-02-11 16:20+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -21,7 +21,7 @@ msgstr "" msgid "Select Image" msgstr "" -#: ../src/dialog.vala:504 +#: ../src/dialog.vala:510 msgid "Select folder" msgstr "" @@ -330,82 +330,90 @@ msgid "Decrease line spacing" msgstr "" #: ../src/constants.vala:106 -msgid "Update cover image" +msgid "Align left" msgstr "" #: ../src/constants.vala:107 +msgid "Align right" +msgstr "" + +#: ../src/constants.vala:108 +msgid "Update cover image" +msgstr "" + +#: ../src/constants.vala:109 msgid "Apply theme for this colour profile" msgstr "" -#: ../src/constants.vala:108 ../src/constants.vala:109 +#: ../src/constants.vala:110 ../src/constants.vala:111 msgid "Enter full screen view and Esc key to undo" msgstr "" -#: ../src/constants.vala:110 +#: ../src/constants.vala:112 msgid "Add folder to scan for books" msgstr "" -#: ../src/constants.vala:111 +#: ../src/constants.vala:113 msgid "Remove displayed folder from book scan" msgstr "" -#: ../src/constants.vala:112 +#: ../src/constants.vala:114 msgid "Add annotation to selected text" msgstr "" -#: ../src/constants.vala:114 ../src/constants.vala:139 +#: ../src/constants.vala:116 ../src/constants.vala:141 msgid "Preferences" msgstr "" -#: ../src/constants.vala:115 +#: ../src/constants.vala:117 msgid "Turn on Dark Mode" msgstr "" -#: ../src/constants.vala:116 +#: ../src/constants.vala:118 msgid "Enable cache (opens books faster)" msgstr "" -#: ../src/constants.vala:117 +#: ../src/constants.vala:119 msgid "Always show library on startup" msgstr "" -#: ../src/constants.vala:118 +#: ../src/constants.vala:120 msgid "Enable two page reading" msgstr "" -#: ../src/constants.vala:119 +#: ../src/constants.vala:121 msgid "Select Font" msgstr "" -#: ../src/constants.vala:120 +#: ../src/constants.vala:122 msgid "Customize reading profile" msgstr "" -#: ../src/constants.vala:121 +#: ../src/constants.vala:123 msgid "Text" msgstr "" -#: ../src/constants.vala:122 +#: ../src/constants.vala:124 msgid "Background" msgstr "" -#: ../src/constants.vala:123 +#: ../src/constants.vala:125 msgid "Add folders to scan for books" msgstr "" -#: ../src/constants.vala:124 +#: ../src/constants.vala:126 msgid "Profile" msgstr "" -#: ../src/constants.vala:125 +#: ../src/constants.vala:127 msgid "Reset to default values" msgstr "" -#: ../src/constants.vala:137 +#: ../src/constants.vala:139 msgid "Unknown Book" msgstr "" -#: ../src/constants.vala:138 +#: ../src/constants.vala:140 msgid "About" msgstr "" diff --git a/schemas/com.github.babluboy.bookworm.gschema.xml b/schemas/com.github.babluboy.bookworm.gschema.xml index 5aadc6c7..d4d7baf4 100644 --- a/schemas/com.github.babluboy.bookworm.gschema.xml +++ b/schemas/com.github.babluboy.bookworm.gschema.xml @@ -82,7 +82,10 @@ "#000000,#fbfbfb,#586e75,#fdf6e3,#93a1a1,#002b36" - List of profile colours. Three profiles with two colors each. First color is text color and second one is bgcolor + + List of profile colours. Each profiles has two colors - First color is text color and second one is bgcolor. + The first three sets are customizable and the last two sets are the default light and dark profiles + "" diff --git a/src/bookinfo.vala b/src/bookinfo.vala index d4683072..1dd30202 100644 --- a/src/bookinfo.vala +++ b/src/bookinfo.vala @@ -148,9 +148,10 @@ public class BookwormApp.Info:Gtk.Window { int bookmarkNumber = 1; foreach (string bookmarkedPage in bookmarkList) { if(bookmarkedPage != null && bookmarkedPage.length > 0){ - LinkButton bookmarkLinkButton = new LinkButton.with_label (bookmarkedPage, BookwormApp.Constants.TEXT_FOR_BOOKMARKS - .replace("NNN", bookmarkNumber.to_string()) - .replace("PPP", (int.parse(bookmarkedPage)+1).to_string())); + LinkButton bookmarkLinkButton = new LinkButton.with_label (bookmarkedPage, + BookwormApp.Constants.TEXT_FOR_BOOKMARKS + .replace("NNN", bookmarkNumber.to_string()) + .replace("PPP", (int.parse(bookmarkedPage)+1).to_string())); bookmarkNumber++; bookmarkLinkButton.halign = Align.START; bookmarks_box.pack_start(bookmarkLinkButton,false,false,0); diff --git a/src/bookworm.vala b/src/bookworm.vala index 10f763c6..92cc9d56 100644 --- a/src/bookworm.vala +++ b/src/bookworm.vala @@ -96,7 +96,7 @@ public class BookwormApp.Bookworm : Granite.Application { flags |= ApplicationFlags.HANDLES_COMMAND_LINE; program_name = BookwormApp.Constants.program_name; exec_name = "com.github.babluboy.bookworm"; - + options = new OptionEntry[4]; options[0] = { "version", 0, 0, OptionArg.NONE, ref command_line_option_version, _("Display version number"), null }; options[1] = { "debug", 0, 0, OptionArg.NONE, ref command_line_option_debug, _("Run Bookworm in debug mode"), null }; @@ -135,6 +135,9 @@ public class BookwormApp.Bookworm : Granite.Application { opt_context.add_main_entries (options, null); unowned string[] tmpArgs = args; opt_context.parse (ref tmpArgs); + if("--version" in args){ + command_line_option_version = true; + } } catch (OptionError e) { info ("Run '%s --help' to see a full list of available command line options.\n", args[0]); info ("error: %s\n", e.message); @@ -148,7 +151,7 @@ public class BookwormApp.Bookworm : Granite.Application { debug ("Bookworm running in info mode..."); } if(command_line_option_version){ - print("\nbookworm version "+Constants.bookworm_version+"\n"); + print("\nBookworm Version "+BookwormApp.Constants.bookworm_version+"\n"); return 0; }else if(command_line_option_discover){ BookwormApp.BackgroundTasks.performTasks(); @@ -397,9 +400,9 @@ public class BookwormApp.Bookworm : Granite.Application { //Update the library view BookwormApp.Library.updateLibraryViewFromDB(); //load scripts data - bookwormScripts = BookwormApp.Utils.fileOperations("READ_FILE", - BookwormApp.Constants.HTML_SCRIPT_LOCATION, - "", + bookwormScripts = BookwormApp.Utils.fileOperations("READ_FILE", + BookwormApp.Constants.HTML_SCRIPT_LOCATION, + "", ""); } diff --git a/src/constants.vala b/src/constants.vala index df03da79..bc3e4529 100644 --- a/src/constants.vala +++ b/src/constants.vala @@ -103,6 +103,8 @@ namespace BookwormApp.Constants { public const string TOOLTIP_TEXT_FOR_LINE_WIDTH_DECREASE = _("Decrease line width"); public const string TOOLTIP_TEXT_FOR_LINE_HEIGHT_INCREASE = _("Increase line spacing"); public const string TOOLTIP_TEXT_FOR_LINE_HEIGHT_DECREASE = _("Decrease line spacing"); + public const string TOOLTIP_TEXT_FOR_READING_LEFT_ALIGN = _("Align left"); + public const string TOOLTIP_TEXT_FOR_READING_RIGHT_ALIGN = _("Align right"); public const string TOOLTIP_TEXT_FOR_UPDATING_COVER_IMAGE = _("Update cover image"); public const string TOOLTIP_TEXT_FOR_PROFILE = _("Apply theme for this colour profile"); public const string TOOLTIP_TEXT_FOR_PAGE_CONTEXTMENU_FULL_SCREEN_ENTRY = _("Enter full screen view and Esc key to undo"); @@ -182,16 +184,23 @@ namespace BookwormApp.Constants { public const string FILE_CHOOSER_FILTER_IMAGES[] = {"*.jpg", "*.jpeg", "*.gif", "*.png", "*.svg"}; - public const string BOOKWORM_READING_MODE[] = {"PROFILE1","PROFILE2","PROFILE3"}; - public const string BOOKWORM_UI_STATES[] = {"LIBRARY_MODE_GRID", - "READING_MODE", - "GRID_SELECTION_MODE", - "GRID_SELECTED_MODE", - "CONTENT_MODE", - "LIBRARY_MODE_LIST", - "LIST_SELECTION_MODE", - "LIST_SELECTED_MODE" - }; + public const string BOOKWORM_READING_MODE[] = { + "PROFILE1", + "PROFILE2", + "PROFILE3", + "PROFILE_LIGHT_DEFAULT", + "PROFILE_DARK_DEFAULT" + }; + public const string BOOKWORM_UI_STATES[] = { + "LIBRARY_MODE_GRID", + "READING_MODE", + "GRID_SELECTION_MODE", + "GRID_SELECTED_MODE", + "CONTENT_MODE", + "LIBRARY_MODE_LIST", + "LIST_SELECTION_MODE", + "LIST_SELECTED_MODE" + }; public const string IDENTIFIER_FOR_PROPERTY_VALUE = "=="; public const string IDENTIFIER_FOR_PROPERTY_START = "~~"; public const string IDENTIFIER_FOR_PROPERTY_END = "##\n"; diff --git a/src/constants.vala.in b/src/constants.vala.in index deaa5cc6..445faba6 100644 --- a/src/constants.vala.in +++ b/src/constants.vala.in @@ -103,6 +103,8 @@ namespace BookwormApp.Constants { public const string TOOLTIP_TEXT_FOR_LINE_WIDTH_DECREASE = _("Decrease line width"); public const string TOOLTIP_TEXT_FOR_LINE_HEIGHT_INCREASE = _("Increase line spacing"); public const string TOOLTIP_TEXT_FOR_LINE_HEIGHT_DECREASE = _("Decrease line spacing"); + public const string TOOLTIP_TEXT_FOR_READING_LEFT_ALIGN = _("Align left"); + public const string TOOLTIP_TEXT_FOR_READING_RIGHT_ALIGN = _("Align right"); public const string TOOLTIP_TEXT_FOR_UPDATING_COVER_IMAGE = _("Update cover image"); public const string TOOLTIP_TEXT_FOR_PROFILE = _("Apply theme for this colour profile"); public const string TOOLTIP_TEXT_FOR_PAGE_CONTEXTMENU_FULL_SCREEN_ENTRY = _("Enter full screen view and Esc key to undo"); @@ -182,16 +184,23 @@ namespace BookwormApp.Constants { public const string FILE_CHOOSER_FILTER_IMAGES[] = {"*.jpg", "*.jpeg", "*.gif", "*.png", "*.svg"}; - public const string BOOKWORM_READING_MODE[] = {"PROFILE1","PROFILE2","PROFILE3"}; - public const string BOOKWORM_UI_STATES[] = {"LIBRARY_MODE_GRID", - "READING_MODE", - "GRID_SELECTION_MODE", - "GRID_SELECTED_MODE", - "CONTENT_MODE", - "LIBRARY_MODE_LIST", - "LIST_SELECTION_MODE", - "LIST_SELECTED_MODE" - }; + public const string BOOKWORM_READING_MODE[] = { + "PROFILE1", + "PROFILE2", + "PROFILE3", + "PROFILE_LIGHT_DEFAULT", + "PROFILE_DARK_DEFAULT" + }; + public const string BOOKWORM_UI_STATES[] = { + "LIBRARY_MODE_GRID", + "READING_MODE", + "GRID_SELECTION_MODE", + "GRID_SELECTED_MODE", + "CONTENT_MODE", + "LIBRARY_MODE_LIST", + "LIST_SELECTION_MODE", + "LIST_SELECTED_MODE" + }; public const string IDENTIFIER_FOR_PROPERTY_VALUE = "=="; public const string IDENTIFIER_FOR_PROPERTY_START = "~~"; public const string IDENTIFIER_FOR_PROPERTY_END = "##\n"; diff --git a/src/contentHandler.vala b/src/contentHandler.vala index f7a65fa9..4fb01a57 100644 --- a/src/contentHandler.vala +++ b/src/contentHandler.vala @@ -137,7 +137,20 @@ public class BookwormApp.contentHandler { } //Set background and font colour based on profile string[] profileColorList = settings.list_of_profile_colors.split (","); - if(BookwormApp.Constants.BOOKWORM_READING_MODE[2] == BookwormApp.Bookworm.settings.reading_profile){ + + if(BookwormApp.Constants.BOOKWORM_READING_MODE[4] == BookwormApp.Bookworm.settings.reading_profile){ + //default dark profile + cssForTextAndBackgroundColor = " background-color: #002b36"+ + " !important; color: #93a1a1"+ + " !important;"; + currentBookwormScripts = currentBookwormScripts.replace("$SCROLLBAR_BACKGROUND", "#002b36"); + } else if(BookwormApp.Constants.BOOKWORM_READING_MODE[3] == BookwormApp.Bookworm.settings.reading_profile){ + //default light profile + cssForTextAndBackgroundColor = " background-color: #fbfbfb"+ + " !important; color: #000000"+ + " !important;"; + currentBookwormScripts = currentBookwormScripts.replace("$SCROLLBAR_BACKGROUND", "#fbfbfb"); + } else if(BookwormApp.Constants.BOOKWORM_READING_MODE[2] == BookwormApp.Bookworm.settings.reading_profile){ cssForTextAndBackgroundColor = " background-color: "+ profileColorList[5] + " !important; color: "+ profileColorList[4] + " !important;"; @@ -147,7 +160,7 @@ public class BookwormApp.contentHandler { " !important; color: "+ profileColorList[2] + " !important;"; currentBookwormScripts = currentBookwormScripts.replace("$SCROLLBAR_BACKGROUND", profileColorList[3]); - }else{ + } else{ cssForTextAndBackgroundColor = " background-color: "+ profileColorList[1] + " !important; color: "+ profileColorList[0] + " !important;"; @@ -299,7 +312,7 @@ public class BookwormApp.contentHandler { //open the book added, if only one book path is present on command line //if this book was not in the library, then the library view will be shown if(BookwormApp.Bookworm.pathsOfBooksToBeAdded.length == 2 && - "bookworm" == BookwormApp.Bookworm.pathsOfBooksToBeAdded[0]) + BookwormApp.Constants.bookworm_id == BookwormApp.Bookworm.pathsOfBooksToBeAdded[0]) { BookwormApp.Book requestedBook = null; //Check if the requested book is available in the library diff --git a/src/dialog.vala b/src/dialog.vala index 0f771387..ddf64506 100644 --- a/src/dialog.vala +++ b/src/dialog.vala @@ -329,14 +329,10 @@ public class BookwormApp.AppDialog : Gtk.Dialog { //set the value for the first profile profileCombobox.active = 0; - //Gdk.Color.parse (profileColorList[0], out txtcolor); - //textColourButton.set_color (txtcolor); var aRGBATextColor = Gdk.RGBA(); aRGBATextColor.parse(profileColorList[0]); textColourButton.rgba = aRGBATextColor; - //Gdk.Color.parse (profileColorList[1], out bgcolor); - //backgroundColourButton.set_color (bgcolor); var aRGBABackgroundColor = Gdk.RGBA(); aRGBABackgroundColor.parse(profileColorList[1]); backgroundColourButton.rgba = aRGBABackgroundColor; @@ -437,11 +433,21 @@ public class BookwormApp.AppDialog : Gtk.Dialog { nightModeSwitch.notify["active"].connect (() => { if (nightModeSwitch.active) { + //Set the dark theme BookwormApp.Bookworm.settings.is_dark_theme_enabled = true; Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true; + //Set the default dark theme for webkit + BookwormApp.Bookworm.settings.reading_profile = BookwormApp.Constants.BOOKWORM_READING_MODE[4]; + //Refresh the page if it is open + BookwormApp.contentHandler.refreshCurrentPage(); }else{ + //Set the light theme BookwormApp.Bookworm.settings.is_dark_theme_enabled = false; Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = false; + //Set the default light theme for webkit + BookwormApp.Bookworm.settings.reading_profile = BookwormApp.Constants.BOOKWORM_READING_MODE[3]; + //Refresh the page if it is open + BookwormApp.contentHandler.refreshCurrentPage(); } }); //Set text entry for text/background color based on selected profile diff --git a/src/ePubReader.vala b/src/ePubReader.vala index 4851b956..17553813 100644 --- a/src/ePubReader.vala +++ b/src/ePubReader.vala @@ -148,40 +148,6 @@ public class BookwormApp.ePubReader { debug ("Sucessfully determined absolute path to OPF File as : "+locationOfOPFFile); return locationOfOPFFile; } - - public static ArrayList parseOPFData (string locationOfOPFFile) { - //Parse OPF xml file to read the MANIFEST data (id, href, media-type) - ArrayList inputDataList = new ArrayList(); - inputDataList.add(new XMLData() { - containerTagName = "manifest", - inputTagName = "item", - inputAttributeName = "id"} - ); - inputDataList.add(new XMLData() { - containerTagName = "manifest", - inputTagName = "item", - inputAttributeName ="href"} - ); - inputDataList.add(new XMLData() { - containerTagName = "manifest", - inputTagName = "item", - inputAttributeName ="media-type"} - ); - inputDataList.add(new XMLData() { - containerTagName = "spine", - inputTagName = "itemref", - inputAttributeName ="idref"} - ); - inputDataList.add(new XMLData() { - containerTagName = "", - inputTagName = "spine", - inputAttributeName ="toc"} - ); - XmlParser thisParser = new XmlParser(); - ArrayList opfItemsList = new ArrayList(); - opfItemsList = thisParser.extractDataFromXML(locationOfOPFFile, inputDataList); - return opfItemsList; - } public static BookwormApp.Book determineToC (owned BookwormApp.Book aBook, string locationOfOPFFile) { //Parse OPF xml file to read the MANIFEST data (id, href, media-type) @@ -294,7 +260,7 @@ public class BookwormApp.ePubReader { public static BookwormApp.Book setCoverImage (owned BookwormApp.Book aBook, string locationOfOPFFile){ debug("Initiated process for cover image extraction of eBook located at:"+aBook.getBookExtractionLocation()); string bookCoverLocation = ""; - //Parse OPF xml file to read the MANIFEST data (id, href, media-type) + //Parse OPF xml file to read the MANIFEST data ArrayList inputDataList = new ArrayList(); inputDataList.add(new XMLData() { containerTagName = "manifest", @@ -304,6 +270,7 @@ public class BookwormApp.ePubReader { inputDataList.add(new XMLData() { containerTagName = "manifest", inputTagName = "item", + enforceAttributeData = true, inputAttributeName = "media-type"} ); inputDataList.add(new XMLData() { @@ -311,18 +278,24 @@ public class BookwormApp.ePubReader { inputTagName = "item", inputAttributeName = "href"} ); + inputDataList.add(new XMLData() { + containerTagName = "manifest", + inputTagName = "item", + enforceAttributeData = true, + inputAttributeName = "properties"} + ); XmlParser thisParser = new XmlParser(); ArrayList opfItemsList = new ArrayList(); opfItemsList = thisParser.extractDataFromXML(locationOfOPFFile, inputDataList); - //Check for a MANIFEST item for cover int count = 0; - foreach(string id in opfItemsList[0].extractedTagAttributes){ - if( id.contains("cover") ){ + //epub3.1 : Check for a MANIFEST item with "properties" attribute contaning the word "cover-image" + foreach(string properties in opfItemsList[3].extractedTagAttributes){ + if( properties.contains("cover-image") ){ //Get media type for the cover items string coverMediaType = opfItemsList[1].extractedTagAttributes.get(count); //get cover location if media type matches "image" - if(coverMediaType.contains("image")){ + if(coverMediaType.index_of("image") != -1){ bookCoverLocation = opfItemsList[2].extractedTagAttributes.get(count); bookCoverLocation = aBook.getBaseLocationOfContents() + bookCoverLocation; break; @@ -331,7 +304,28 @@ public class BookwormApp.ePubReader { count++; } - //check if cover was not found and assign flag for default cover to be used + //If cover could not be located in properties="cover-image" : + //Check for a MANIFEST item with "id" attribute contaning the word "cover" + if( bookCoverLocation.length < 1 && + "true" == BookwormApp.Utils.fileOperations ("EXISTS", "", bookCoverLocation, "") ) + { + count = 0; + foreach(string id in opfItemsList[0].extractedTagAttributes){ + if( id.contains("cover") ){ + //Get media type for the cover items + string coverMediaType = opfItemsList[1].extractedTagAttributes.get(count); + //get cover location if media type matches "image" + if(coverMediaType.index_of("image") != -1){ + bookCoverLocation = opfItemsList[2].extractedTagAttributes.get(count); + bookCoverLocation = aBook.getBaseLocationOfContents() + bookCoverLocation; + break; + } + } + count++; + } + } + + //check if cover was still not found and assign flag for default cover to be used if( bookCoverLocation.length < 1 && "true" == BookwormApp.Utils.fileOperations ("EXISTS", "", bookCoverLocation, "") ) { diff --git a/src/prefpopover.vala b/src/prefpopover.vala index ade2456c..0a1fb27d 100644 --- a/src/prefpopover.vala +++ b/src/prefpopover.vala @@ -49,13 +49,13 @@ public class BookwormApp.PreferencesMenu { alignLeftButton.set_image (BookwormApp.Bookworm.pref_menu_icon_align_left); alignLeftButton.set_halign(Gtk.Align.START); alignLeftButton.set_relief (ReliefStyle.NONE); - alignLeftButton.set_tooltip_markup (BookwormApp.Constants.TOOLTIP_TEXT_FOR_FONT_SIZE_INCREASE); + alignLeftButton.set_tooltip_markup (BookwormApp.Constants.TOOLTIP_TEXT_FOR_READING_LEFT_ALIGN); Gtk.Button alignRightButton = new Gtk.Button(); alignRightButton.set_image (BookwormApp.Bookworm.pref_menu_icon_align_right); alignRightButton.set_halign(Gtk.Align.END); alignRightButton.set_relief (ReliefStyle.NONE); - alignRightButton.set_tooltip_markup (BookwormApp.Constants.TOOLTIP_TEXT_FOR_FONT_SIZE_DECREASE); + alignRightButton.set_tooltip_markup (BookwormApp.Constants.TOOLTIP_TEXT_FOR_READING_RIGHT_ALIGN); Gtk.Box textAlignBox = new Gtk.Box(Orientation.HORIZONTAL, BookwormApp.Constants.SPACING_BUTTONS); textAlignBox.pack_start(alignLeftButton, false, false); @@ -175,8 +175,8 @@ public class BookwormApp.PreferencesMenu { profileButton3.clicked.connect (() => { BookwormApp.Bookworm.settings.reading_profile = BookwormApp.Constants.BOOKWORM_READING_MODE[2]; - //Refresh the page if it is open - BookwormApp.contentHandler.refreshCurrentPage(); + //Refresh the page if it is open + BookwormApp.contentHandler.refreshCurrentPage(); }); marginDecreaseButton.clicked.connect (() => { diff --git a/src/xmlHandler.vala b/src/xmlHandler.vala index 02d6ce65..71b73b86 100644 --- a/src/xmlHandler.vala +++ b/src/xmlHandler.vala @@ -29,6 +29,7 @@ public class BookwormApp.XMLData { public string containerTagName; public string inputTagName; public string inputAttributeName; + public bool enforceAttributeData = false; public ArrayList extractedTagValues = new ArrayList(); public ArrayList extractedTagAttributes = new ArrayList(); } @@ -167,16 +168,22 @@ public class BookwormApp.XmlParser { //If Extraction criteria is met and attribute extraction is required, extract required attribute if(thisXMLData.shouldExtractionStart && thisXMLData.inputAttributeName.length > 0) { //check whether attributes are expected int count = 0; - foreach (string attribute in attributeList){ + bool wasAttributeExtracted = false; + foreach (string attribute in attributeList) { if(attributeList.length >= count+1){ if(thisXMLData.inputAttributeName == attributeList[count]) { //extract the odd attribute data as the even attribute is the name of the attribute thisXMLData.extractedTagAttributes.add(attributeList[count+1]); + wasAttributeExtracted = true; break; } count = count + 2; } } + //Check if attribute was not extracted and the attribute value is forced, add an empty value + if(!wasAttributeExtracted && thisXMLData.enforceAttributeData){ + thisXMLData.extractedTagAttributes.add(""); + } } }