Skip to content

Commit

Permalink
Fix progress calculation, don't display progress for documents
Browse files Browse the repository at this point in the history
under five pages long.

Current page is 0-based so progress was being displayed off by
one - a document was never fully read/last page.

Either way, progress display can be confusing for short documents,
but it's not really necessary either, so only show progress for
longer documents (5 pages or more).
  • Loading branch information
mtwebster committed Jun 11, 2023
1 parent cfba1e3 commit 6acae8d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions usr/lib/thingy/thingy.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,16 @@ def add_document_to_library(self, uri, app_id, mark_as_favorite):
progress_tracked = False
if num_pages is not None and current_page is not None:
num_pages = int(num_pages)
current_page = int(current_page)
if current_page > 0:
progress = float(current_page) / float(num_pages)
bar = Gtk.ProgressBar()
bar.set_fraction(progress)
bar.set_margin_start(50)
bar.set_margin_end(50)
box.pack_end(bar, False, False, 0)
progress_tracked = True
if num_pages > 4:
current_page = int(current_page)
if current_page > 0:
progress = float(current_page) / float(num_pages - 1)
bar = Gtk.ProgressBar()
bar.set_fraction(progress)
bar.set_margin_start(50)
bar.set_margin_end(50)
box.pack_end(bar, False, False, 0)
progress_tracked = True

if not progress_tracked:
box.pack_end(Gtk.Label(), False, False, 0)
Expand Down

0 comments on commit 6acae8d

Please sign in to comment.