Skip to content

Commit

Permalink
Add option to remove books from recents screen (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haaruun-I authored Aug 9, 2024
1 parent 6389282 commit 98e034d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cozy/ui/library_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ def populate_reader(self):
self._reader_box.populate(self._view_model.readers)

def _on_library_view_mode_changed(self):
self.refresh_filters()
self._navigation_view.pop_to_tag("main")

def refresh_filters(self):
visible_child_name = None
active_filter_box: Gtk.ListBox = None

Expand All @@ -130,7 +134,6 @@ def _on_library_view_mode_changed(self):
self._main_stack.props.visible_child_name = main_view_page
self._filter_stack.set_visible_child_name(visible_child_name)
self._book_stack.set_visible_child_name(books_view_page)
self._navigation_view.pop_to_tag("main")

if active_filter_box:
self._apply_selected_filter(active_filter_box.get_selected_row())
Expand Down
9 changes: 9 additions & 0 deletions cozy/ui/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init_actions(self):
Init all app actions.
"""
self.create_action("about", self.show_about_window, ["F1"])
self.create_action("reset_book", self.reset_book)
self.create_action("remove_book", self.remove_book)
self.create_action("mark_book_as_read", self.mark_book_as_read)
self.create_action("jump_to_book_folder", self.jump_to_book_folder)
Expand Down Expand Up @@ -130,6 +131,14 @@ def create_action(

return action

def refresh_library_filters(self):
self._library_view.refresh_filters()

def reset_book(self, *_) -> None:
if self.app.selected_book is not None:
self.app.selected_book.reset()
self.refresh_library_filters()

def remove_book(self, *_) -> None:
if self.app.selected_book is not None:
self.app.selected_book.remove()
Expand Down
3 changes: 3 additions & 0 deletions cozy/ui/widgets/book_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def set_playing(self, is_playing):
def update_progress(self):
self.play_button.progress = self.book.progress / self.book.duration

def reset(self) -> None:
self.book.last_played = 0

def remove(self) -> None:
self.emit("remove-book", self.book)

Expand Down
9 changes: 7 additions & 2 deletions data/ui/book_card.blp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ template $BookCard: FlowBoxChild {
valign: end;
halign: end;

$BookElementPlayButton play_button {
$BookCardPlayButton play_button {
width-request: 54;
height-request: 54;
margin-end: 18;
margin-bottom: 18;
focusable: true;
focus-on-click: false;
icon_name: "media-playback-start-symbolic";
icon-name: "media-playback-start-symbolic";
tooltip-text: _("Start/Stop playback");

clicked => $_play_pause();
Expand Down Expand Up @@ -128,6 +128,11 @@ menu book_menu {
label: _("Mark as Read");
}

item {
action: 'app.reset_book';
label: _("Remove from Recents");
}

item {
action: 'app.jump_to_book_folder';
label: _("Open in Files");
Expand Down

0 comments on commit 98e034d

Please sign in to comment.