@ -163,25 +163,11 @@ function PageBrowserWidget:init()
self.max_nb_cols = 6
-- Get some info that shouldn't change across calls to update() and updateLayout()
self.ui . toc : fillToc ( )
self.max_toc_depth = self.ui . toc.toc_depth
self.nb_pages = self.ui . document : getPageCount ( )
self.cur_page = self.ui . toc.pageno
-- Get bookmarks and highlights from ReaderBookmark
self.bookmarked_pages = self.ui . bookmark : getBookmarkedPages ( )
-- Get read page from the statistics plugin if enabled
self.read_pages = self.ui . statistics and self.ui . statistics : getCurrentBookReadPages ( )
self.current_session_duration = self.ui . statistics and ( os.time ( ) - self.ui . statistics.start_current_period )
-- Hidden flows, for first page display, and to draw them gray
self.has_hidden_flows = self.ui . document : hasHiddenFlows ( )
if self.has_hidden_flows and # self.ui . document.flows > 0 then
self.hidden_flows = { }
-- Pick into credocument internal data to build a table
-- of {first_page_number, last_page_number) for each flow
for flow , tab in ipairs ( self.ui . document.flows ) do
table.insert ( self.hidden_flows , { tab [ 1 ] , tab [ 1 ] + tab [ 2 ] - 1 } )
end
end
-- Reference page numbers, for first row page display
self.page_labels = nil
if self.ui . pagemap and self.ui . pagemap : wantsPageLabels ( ) then
@ -190,11 +176,43 @@ function PageBrowserWidget:init()
-- Location stack
self.previous_locations = self.ui . link : getPreviousLocationPages ( )
-- Update stuff that may be updated by the user while in PageBrowser
self : updateEditableStuff ( )
self.editable_stuff_edited = false -- reset this
-- Compute settings-dependant sizes and options, and build the inner widgets
-- (this will call self:update())
self : updateLayout ( )
end
function PageBrowserWidget : updateEditableStuff ( update_view )
-- Toc, bookmarks and hidden flows may be edited
-- Note: we update everything to keep things simpler, but we could provide flags to
-- let us know what stuff has been updated and only do their related work.
self.ui . toc : fillToc ( )
self.max_toc_depth = self.ui . toc.toc_depth
-- Get bookmarks and highlights from ReaderBookmark
self.bookmarked_pages = self.ui . bookmark : getBookmarkedPages ( )
-- Hidden flows, for first page display, and to draw them gray
self.hidden_flows = nil
self.has_hidden_flows = self.ui . document : hasHiddenFlows ( )
if self.has_hidden_flows and # self.ui . document.flows > 0 then
self.hidden_flows = { }
-- Pick into credocument internal data to build a table
-- of {first_page_number, last_page_number) for each flow
for flow , tab in ipairs ( self.ui . document.flows ) do
table.insert ( self.hidden_flows , { tab [ 1 ] , tab [ 1 ] + tab [ 2 ] - 1 } )
end
end
-- Keep a flag so we can propagate the fact that editable stuff
-- has been updated to our parent/launcher when we will close,
-- so they can update themselves too.
self.editable_stuff_edited = true
if update_view then
self : updateLayout ( )
end
end
function PageBrowserWidget : updateLayout ( )
-- We start with showing all toc levels (we could use book_map_toc_depth,
-- but we might want to have it different here).
@ -1053,6 +1071,9 @@ function PageBrowserWidget:onClose(close_all_parents)
-- will do the cleanup below.
self.launcher : onClose ( true )
else
if self.editable_stuff_edited then
self.launcher : updateEditableStuff ( true )
end
UIManager : setDirty ( self.launcher , " ui " )
end
else
@ -1068,8 +1089,9 @@ function PageBrowserWidget:onClose(close_all_parents)
collectgarbage ( )
collectgarbage ( )
end )
-- As we're getting back to Reader, do a full flashing refresh to remove
-- any ghost trace of thumbnails or black page slots
-- As we're getting back to Reader, update the footer and do a full flashing
-- refresh to remove any ghost trace of thumbnails or black page slots
UIManager : broadcastEvent ( Event : new ( " UpdateFooter " ) )
UIManager : setDirty ( self.ui . dialog , " full " )
end
return true
@ -1468,9 +1490,7 @@ function PageBrowserWidget:onHold(arg, ges)
-- we may get (and cache) a thumbnail showing the wrong
-- bookmark state...
self.ui . bookmark : toggleBookmark ( page )
-- Update our cached bookmarks info and ensure the bottom ribbon is redrawn
self.bookmarked_pages = self.ui . bookmark : getBookmarkedPages ( )
self : updateLayout ( )
self : updateEditableStuff ( true )
return true
end
break