Skip to content

Commit

Permalink
Added control for line height in reading mode
Browse files Browse the repository at this point in the history
  • Loading branch information
babluboy committed May 11, 2017
1 parent 3d181a5 commit 773e504
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 35 deletions.
32 changes: 18 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,24 @@ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/48/bookworm.png DESTINATIO
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/64/bookworm.png DESTINATION share/icons/hicolor/64x64/apps)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/128/bookworm.png DESTINATION share/icons/hicolor/128x128/apps)
#install bookworm specific icons in application specific folder - /usr/share/bookworm
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-go-next.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-go-previous.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-list-add.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-list-remove.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-view-grid-symbolic.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-view-list-symbolic.png DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-bookmark-inactive.png DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-bookmark-active.png DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection-checked.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection-option.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-open-menu.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-profile-day.png DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-profile-night.png DESTINATION share/bookworm/icons/hicolor/24x24/actions)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-go-next.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-go-previous.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-list-add.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-list-remove.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-view-grid-symbolic.svg DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-line-height-more.png DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-line-height-less.png DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-width-more.png DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/bookworm-width-less.png DESTINATION share/bookworm/icons/hicolor/16x16/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-view-list-symbolic.png DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-bookmark-inactive.png DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-bookmark-active.png DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection-checked.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection-option.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-selection.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-open-menu.svg DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-profile-day.png DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/bookworm-profile-night.png DESTINATION share/bookworm/icons/hicolor/24x24/actions/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/256/bookworm-placeholder-cover.png DESTINATION share/bookworm/icons/hicolor/256x256/apps/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/256/bookworm-default-cover-1.png DESTINATION share/bookworm/icons/hicolor/256x256/apps/)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/256/bookworm-default-cover-2.png DESTINATION share/bookworm/icons/hicolor/256x256/apps/)
Expand Down
Binary file added data/icons/16/bookworm-line-height-less.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/16/bookworm-line-height-more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/16/bookworm-width-less.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/icons/16/bookworm-width-more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions po/bookworm.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-10 23:20+0100\n"
"POT-Creation-Date: 2017-05-11 18:23+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -17,11 +17,11 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: src/constants.vala:77
#: src/constants.vala:78
msgid "About"
msgstr ""

#: src/constants.vala:103
#: src/constants.vala:108
msgid "All Files"
msgstr ""

Expand Down Expand Up @@ -103,7 +103,7 @@ msgstr ""
msgid "Not Available"
msgstr ""

#: src/constants.vala:65 src/constants.vala:78
#: src/constants.vala:65 src/constants.vala:79
msgid "Preferences"
msgstr ""

Expand Down Expand Up @@ -137,7 +137,7 @@ msgstr ""
msgid "Turn on Night Mode"
msgstr ""

#: src/constants.vala:76
#: src/constants.vala:77
msgid "Unknown Book"
msgstr ""

Expand Down
4 changes: 4 additions & 0 deletions schemas/com.github.babluboy.bookworm.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@
<default>"1"</default>
<summary>Save the page width for reading</summary>
</key>
<key name="reading-line-height" type="s">
<default>"100"</default>
<summary>Save the page line height for reading</summary>
</key>
</schema>
</schemalist>
Binary file modified screenshots/BookwormReadingView.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/BookwormReadingViewNightView.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace BookwormApp.Constants {
public const int SPACING_BUTTONS = 6;
public const double ZOOM_CHANGE_VALUE = 0.1;
public const int MARGIN_CHANGE_VALUE = 2;
public const int LINE_HEIGHT_CHANGE_VALUE = 10;
public const string RGBA_HEX_WHITE = "#ffffff";
public const string RGBA_HEX_BLACK = "#002B36";

Expand All @@ -83,6 +84,10 @@ namespace BookwormApp.Constants {
public static const string ADD_BOOK_ICON_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-list-add.svg";
public static const string REMOVE_BOOK_ICON_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-list-remove.svg";
public static const string LIBRARY_VIEW_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-view-grid-symbolic.svg";
public static const string MORE_LINE_HEIGHT_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-line-height-more.png";
public static const string LESS_LINE_HEIGHT_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-line-height-less.png";
public static const string MORE_LINE_WIDTH_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-width-more.png";
public static const string LESS_LINE_WIDTH_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/16x16/actions/bookworm-width-less.png";
public static const string CONTENTS_VIEW_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/24x24/actions/bookworm-view-list-symbolic.png";
public static const string BOOKMARK_INACTIVE_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/24x24/actions/bookworm-bookmark-inactive.png";
public static const string BOOKMARK_ACTIVE_IMAGE_LOCATION = "/usr/share/bookworm/icons/hicolor/24x24/actions/bookworm-bookmark-active.png";
Expand Down
2 changes: 1 addition & 1 deletion src/contentHandler.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class BookwormApp.contentHandler {
onloadJavaScript.append("document.getElementsByTagName('BODY')[0].style.color='black';");
}
//Adjust page margin
string cssMargin = "<style>body{margin-right: "+BookwormApp.Bookworm.settings.reading_width+"%;margin-left: "+BookwormApp.Bookworm.settings.reading_width+"%;}</style>";
string cssMargin = "<style>body{line-height: "+BookwormApp.Bookworm.settings.reading_line_height+"%;margin-right: "+BookwormApp.Bookworm.settings.reading_width+"%;margin-left: "+BookwormApp.Bookworm.settings.reading_width+"%;}</style>";

//add onload javascript to body tag
if(pageContent.index_of("<BODY") != -1){
Expand Down
70 changes: 57 additions & 13 deletions src/prefpopover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,50 @@ public class BookwormApp.PreferencesMenu {
profileBox.pack_start(dayProfileButton, false, false);
profileBox.pack_end(nightProfileButton, false, false);

Gtk.Image icon_margin_indent_more = new Gtk.Image.from_icon_name ("format-indent-more-symbolic", IconSize.MENU);
Gtk.Button marginIncreaseButton = new Gtk.Button();
marginIncreaseButton.set_image (icon_margin_indent_more);
marginIncreaseButton.set_halign(Gtk.Align.START);
marginIncreaseButton.set_relief (ReliefStyle.NONE);

Gtk.Image icon_margin_indent_less = new Gtk.Image.from_icon_name ("format-indent-less-symbolic", IconSize.MENU);
Gtk.Image icon_width_indent_less = new Gtk.Image ();
icon_width_indent_less.set_from_file (Constants.LESS_LINE_WIDTH_IMAGE_LOCATION);
Gtk.Button marginDecreaseButton = new Gtk.Button();
marginDecreaseButton.set_image (icon_margin_indent_less);
marginDecreaseButton.set_halign(Gtk.Align.END);
marginDecreaseButton.set_image (icon_width_indent_less);
marginDecreaseButton.set_halign(Gtk.Align.START);
marginDecreaseButton.set_relief (ReliefStyle.NONE);

Gtk.Image icon_width_indent_more = new Gtk.Image ();
icon_width_indent_more.set_from_file (Constants.MORE_LINE_WIDTH_IMAGE_LOCATION);
Gtk.Button marginIncreaseButton = new Gtk.Button();
marginIncreaseButton.set_image (icon_width_indent_more);
marginIncreaseButton.set_halign(Gtk.Align.END);
marginIncreaseButton.set_relief (ReliefStyle.NONE);

Gtk.Box marginBox = new Gtk.Box(Orientation.HORIZONTAL, BookwormApp.Constants.SPACING_BUTTONS);
marginBox.pack_start(marginIncreaseButton, false, false);
marginBox.pack_end(marginDecreaseButton, false, false);

Gtk.Image icon_line_height_less = new Gtk.Image ();
icon_line_height_less.set_from_file (Constants.LESS_LINE_HEIGHT_IMAGE_LOCATION);
Gtk.Button heightDecreaseButton = new Gtk.Button();
heightDecreaseButton.set_image (icon_line_height_less);
heightDecreaseButton.set_halign(Gtk.Align.START);
heightDecreaseButton.set_relief (ReliefStyle.NONE);

Gtk.Image icon_line_height_more = new Gtk.Image ();
icon_line_height_more.set_from_file (Constants.MORE_LINE_HEIGHT_IMAGE_LOCATION);
Gtk.Button heightIncreaseButton = new Gtk.Button();
heightIncreaseButton.set_image (icon_line_height_more);
heightIncreaseButton.set_halign(Gtk.Align.START);
heightIncreaseButton.set_relief (ReliefStyle.NONE);

Gtk.Box lineHeightBox = new Gtk.Box(Orientation.HORIZONTAL, BookwormApp.Constants.SPACING_BUTTONS);
lineHeightBox.pack_start(heightIncreaseButton, false, false);
lineHeightBox.pack_end(heightDecreaseButton, false, false);

Gtk.Box prefBox = new Gtk.Box(Orientation.VERTICAL, BookwormApp.Constants.SPACING_BUTTONS);
prefBox.set_border_width(BookwormApp.Constants.SPACING_WIDGETS);
prefBox.pack_start(textSizeBox, false, false);
prefBox.pack_start(new Gtk.HSeparator() , true, true, 0);
prefBox.pack_start(marginBox, false, false);
prefBox.pack_start(new Gtk.HSeparator() , true, true, 0);
prefBox.pack_start(lineHeightBox, false, false);
prefBox.pack_start(new Gtk.HSeparator() , true, true, 0);
prefBox.pack_start(profileBox, false, false);

prefPopover.add(prefBox);
Expand Down Expand Up @@ -115,8 +137,8 @@ public class BookwormApp.PreferencesMenu {
}
});

marginIncreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_width.to_int() < 40){
marginDecreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_width.to_int() <= 40){
BookwormApp.Bookworm.settings.reading_width = (BookwormApp.Bookworm.settings.reading_width.to_int() + BookwormApp.Constants.MARGIN_CHANGE_VALUE).to_string();
if(BookwormApp.Bookworm.BOOKWORM_CURRENT_STATE == BookwormApp.Constants.BOOKWORM_UI_STATES[1]){
BookwormApp.Book currentBookForMarginIncrease = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
Expand All @@ -126,8 +148,8 @@ public class BookwormApp.PreferencesMenu {
}
});

marginDecreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_width.to_int() > 1){
marginIncreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_width.to_int() >= 1){
BookwormApp.Bookworm.settings.reading_width = (BookwormApp.Bookworm.settings.reading_width.to_int() - BookwormApp.Constants.MARGIN_CHANGE_VALUE).to_string();
if(BookwormApp.Bookworm.BOOKWORM_CURRENT_STATE == BookwormApp.Constants.BOOKWORM_UI_STATES[1]){
BookwormApp.Book currentBookForMarginDecrease = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
Expand All @@ -137,6 +159,28 @@ public class BookwormApp.PreferencesMenu {
}
});

heightDecreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_line_height.to_int() >= 100){
BookwormApp.Bookworm.settings.reading_line_height = (BookwormApp.Bookworm.settings.reading_line_height.to_int() - BookwormApp.Constants.LINE_HEIGHT_CHANGE_VALUE).to_string();
if(BookwormApp.Bookworm.BOOKWORM_CURRENT_STATE == BookwormApp.Constants.BOOKWORM_UI_STATES[1]){
BookwormApp.Book currentBookForLineHeightDecrease = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
currentBookForLineHeightDecrease = BookwormApp.Bookworm.renderPage(BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead), "");
BookwormApp.Bookworm.libraryViewMap.set(BookwormApp.Bookworm.locationOfEBookCurrentlyRead, currentBookForLineHeightDecrease);
}
}
});

heightIncreaseButton.clicked.connect (() => {
if(BookwormApp.Bookworm.settings.reading_line_height.to_int() <= 500){
BookwormApp.Bookworm.settings.reading_line_height = (BookwormApp.Bookworm.settings.reading_line_height.to_int() + BookwormApp.Constants.LINE_HEIGHT_CHANGE_VALUE).to_string();
if(BookwormApp.Bookworm.BOOKWORM_CURRENT_STATE == BookwormApp.Constants.BOOKWORM_UI_STATES[1]){
BookwormApp.Book currentBookForLineHeightIncrease = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
currentBookForLineHeightIncrease = BookwormApp.Bookworm.renderPage(BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead), "");
BookwormApp.Bookworm.libraryViewMap.set(BookwormApp.Bookworm.locationOfEBookCurrentlyRead, currentBookForLineHeightIncrease);
}
}
});

return prefPopover;
}
}
1 change: 1 addition & 0 deletions src/settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class BookwormApp.Settings : Granite.Services.Settings {
public string reading_profile { get; set; }
public bool is_local_storage_enabled { get; set; }
public string reading_width { get; set; }
public string reading_line_height { get; set; }

public static Settings get_instance () {
if (instance == null) {
Expand Down
7 changes: 5 additions & 2 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,17 @@ public class BookwormApp.AppWindow {
BookwormApp.Bookworm.locationOfEBookCurrentlyRead = currentBookForReverse.getBookLocation();
});
//Add action for moving the pages for the page slider
pageSlider.value_changed.connect (() => {
pageSlider.change_value.connect ((scroll, new_value) => {
debug("Page Slider value change Initiated for book at location:"+BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
BookwormApp.Book currentBookForSlider = new BookwormApp.Book();
currentBookForSlider = BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead);
currentBookForSlider.setBookPageNumber(pageSlider.get_value ().to_string().to_int()-1);
currentBookForSlider.setBookPageNumber(new_value.to_string().to_int()-1);
//update book details to libraryView Map
currentBookForSlider = BookwormApp.Bookworm.renderPage(currentBookForSlider, "");
BookwormApp.Bookworm.libraryViewMap.set(currentBookForSlider.getBookLocation(), currentBookForSlider);
BookwormApp.Bookworm.locationOfEBookCurrentlyRead = currentBookForSlider.getBookLocation();
debug("Page Slider value change action completed for book at location:"+BookwormApp.Bookworm.locationOfEBookCurrentlyRead+" and rendering completed for page number:"+currentBookForSlider.getBookPageNumber().to_string());
return true;
});
//Add action for adding a book on the library view
add_book_button.clicked.connect (() => {
Expand Down

0 comments on commit 773e504

Please sign in to comment.