From 3d181a5f62de219a8e9742471d111962d6d1dc25 Mon Sep 17 00:00:00 2001 From: Siddhartha Das Date: Wed, 10 May 2017 23:37:04 +0100 Subject: [PATCH] Added margin control to reading preference pop up --- data/icons/24/bookworm-profile-day.png | Bin 173 -> 2454 bytes data/icons/24/bookworm-profile-night.png | Bin 173 -> 2454 bytes po/bookworm.pot | 10 ++-- .../com.github.babluboy.bookworm.gschema.xml | 4 ++ src/constants.vala | 1 + src/contentHandler.vala | 8 +-- src/prefpopover.vala | 46 +++++++++++++++++- src/settings.vala | 1 + 8 files changed, 60 insertions(+), 10 deletions(-) diff --git a/data/icons/24/bookworm-profile-day.png b/data/icons/24/bookworm-profile-day.png index d672d5774e59321b7b48f2b40e1ce144b31fb04b..ce9a8a5a03e7abe489586eb3f03377edf32beea4 100644 GIT binary patch literal 2454 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE8a>06_(#sfb_@ k!RusL9ZFCKi3(^Q2Z;+fHH6g?Z9(qxboFyt=akR{0CFQEga7~l delta 139 zcmbOxyq0l-R{ehlAY8C_`D6wL2F?PH$YKTt-s>RD=%g{b0w~B{;_2(k{*Z;2S5(mX zx2HZ($jZ~jF~s9|@}8QXpX%A9nAF&$niu9Xa_?&B>*I4}i`!Y0YQpEHE3q}dmdKI;Vst06Ewvi~s-t delta 98 zcmV-o0GA!~g&Q diff --git a/po/bookworm.pot b/po/bookworm.pot index dc715134..b17fc5d3 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-09 22:53+0100\n" +"POT-Creation-Date: 2017-05-10 23:20+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,11 +17,11 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/constants.vala:76 +#: src/constants.vala:77 msgid "About" msgstr "" -#: src/constants.vala:102 +#: src/constants.vala:103 msgid "All Files" msgstr "" @@ -103,7 +103,7 @@ msgstr "" msgid "Not Available" msgstr "" -#: src/constants.vala:65 src/constants.vala:77 +#: src/constants.vala:65 src/constants.vala:78 msgid "Preferences" msgstr "" @@ -137,7 +137,7 @@ msgstr "" msgid "Turn on Night Mode" msgstr "" -#: src/constants.vala:75 +#: src/constants.vala:76 msgid "Unknown Book" msgstr "" diff --git a/schemas/com.github.babluboy.bookworm.gschema.xml b/schemas/com.github.babluboy.bookworm.gschema.xml index b26101d8..b6eae9b4 100644 --- a/schemas/com.github.babluboy.bookworm.gschema.xml +++ b/schemas/com.github.babluboy.bookworm.gschema.xml @@ -36,5 +36,9 @@ true Local storage for extracted contents of books + + "1" + Save the page width for reading + diff --git a/src/constants.vala b/src/constants.vala index c3b333fc..83a6fe73 100644 --- a/src/constants.vala +++ b/src/constants.vala @@ -69,6 +69,7 @@ namespace BookwormApp.Constants { public const int SPACING_WIDGETS = 12; public const int SPACING_BUTTONS = 6; public const double ZOOM_CHANGE_VALUE = 0.1; + public const int MARGIN_CHANGE_VALUE = 2; public const string RGBA_HEX_WHITE = "#ffffff"; public const string RGBA_HEX_BLACK = "#002B36"; diff --git a/src/contentHandler.vala b/src/contentHandler.vala index 5759d04b..c78a419d 100644 --- a/src/contentHandler.vala +++ b/src/contentHandler.vala @@ -30,14 +30,16 @@ public class BookwormApp.contentHandler { }else{ onloadJavaScript.append("document.getElementsByTagName('BODY')[0].style.color='black';"); } + //Adjust page margin + string cssMargin = ""; //add onload javascript to body tag if(pageContent.index_of("" + pageContent + ""; + pageContent = cssMargin + "" + pageContent + ""; } return pageContent; } diff --git a/src/prefpopover.vala b/src/prefpopover.vala index 5fc920e7..e96c4703 100644 --- a/src/prefpopover.vala +++ b/src/prefpopover.vala @@ -40,28 +40,48 @@ public class BookwormApp.PreferencesMenu { Gtk.Box textSizeBox = new Gtk.Box(Orientation.HORIZONTAL, BookwormApp.Constants.SPACING_BUTTONS); textSizeBox.pack_start(textSmallerButton, false, false); - textSizeBox.pack_start(textLargerButton, false, false); + textSizeBox.pack_end(textLargerButton, false, false); Gtk.Image day_profile_image = new Gtk.Image (); day_profile_image.set_from_file (Constants.DAY_PROFILE_IMAGE_LOCATION); Gtk.Button dayProfileButton = new Gtk.Button(); dayProfileButton.set_image (day_profile_image); + dayProfileButton.set_halign(Gtk.Align.START); dayProfileButton.set_relief (ReliefStyle.NONE); Gtk.Image night_profile_image = new Gtk.Image (); night_profile_image.set_from_file (Constants.NIGHT_PROFILE_IMAGE_LOCATION); Gtk.Button nightProfileButton = new Gtk.Button(); nightProfileButton.set_image (night_profile_image); + nightProfileButton.set_halign(Gtk.Align.END); nightProfileButton.set_relief (ReliefStyle.NONE); Gtk.Box profileBox = new Gtk.Box(Orientation.HORIZONTAL, BookwormApp.Constants.SPACING_BUTTONS); profileBox.pack_start(dayProfileButton, false, false); - profileBox.pack_start(nightProfileButton, 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.Button marginDecreaseButton = new Gtk.Button(); + marginDecreaseButton.set_image (icon_margin_indent_less); + marginDecreaseButton.set_halign(Gtk.Align.END); + marginDecreaseButton.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.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(profileBox, false, false); prefPopover.add(prefBox); @@ -95,6 +115,28 @@ public class BookwormApp.PreferencesMenu { } }); + marginIncreaseButton.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); + currentBookForMarginIncrease = BookwormApp.Bookworm.renderPage(BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead), ""); + BookwormApp.Bookworm.libraryViewMap.set(BookwormApp.Bookworm.locationOfEBookCurrentlyRead, currentBookForMarginIncrease); + } + } + }); + + marginDecreaseButton.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); + currentBookForMarginDecrease = BookwormApp.Bookworm.renderPage(BookwormApp.Bookworm.libraryViewMap.get(BookwormApp.Bookworm.locationOfEBookCurrentlyRead), ""); + BookwormApp.Bookworm.libraryViewMap.set(BookwormApp.Bookworm.locationOfEBookCurrentlyRead, currentBookForMarginDecrease); + } + } + }); + return prefPopover; } } diff --git a/src/settings.vala b/src/settings.vala index 668a0b60..b67c3800 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -28,6 +28,7 @@ public class BookwormApp.Settings : Granite.Services.Settings { public double zoom_level { get; set; } public string reading_profile { get; set; } public bool is_local_storage_enabled { get; set; } + public string reading_width { get; set; } public static Settings get_instance () { if (instance == null) {