Skip to content

Commit

Permalink
Simplify adding the book overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Jun 1, 2024
1 parent 797dbbf commit fe055a7
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 260 deletions.
2 changes: 0 additions & 2 deletions cozy/app_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from cozy.power_manager import PowerManager
from cozy.report import reporter
from cozy.ui.app_view import AppView
from cozy.ui.book_detail_view import BookDetailView
from cozy.ui.headerbar import Headerbar
from cozy.ui.library_view import LibraryView
from cozy.ui.main_view import CozyUI
Expand Down Expand Up @@ -51,7 +50,6 @@ def __init__(self, gtk_app, main_window_builder, main_window):
self.library_view: LibraryView = LibraryView(main_window_builder)
self.app_view: AppView = AppView(main_window_builder)
self.headerbar: Headerbar = Headerbar(main_window_builder)
self.book_detail_view: BookDetailView = BookDetailView(main_window_builder)
self.media_controller: MediaController = MediaController(main_window_builder)
self.search_view: SearchView = SearchView(main_window_builder, self.headerbar)

Expand Down
10 changes: 2 additions & 8 deletions cozy/ui/book_detail_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def add_chapter(self, chapter: Chapter, callback: Callable[[None], None]):


@Gtk.Template.from_resource("/com/github/geigi/cozy/ui/book_detail.ui")
class BookDetailView(Adw.BreakpointBin):
class BookDetailView(Adw.NavigationPage):
__gtype_name__ = "BookDetail"

play_button: Gtk.Button = Gtk.Template.Child()
Expand Down Expand Up @@ -70,15 +70,9 @@ class BookDetailView(Adw.BreakpointBin):

_current_selected_chapter: ChapterElement | None = None

def __init__(self, main_window_builder: Gtk.Builder):
def __init__(self):
super().__init__()

overview: Adw.ToolbarView = main_window_builder.get_object("book_overview")
overview.set_content(self)

book_overview_page: Adw.NavigationPage = main_window_builder.get_object("book_overview_page")
self.bind_property("book-title", book_overview_page, "title", GObject.BindingFlags.SYNC_CREATE)

self._chapters_event = Event()
self._chapters_thread: Thread | None = None
self._chapters_job_locked = False
Expand Down
3 changes: 3 additions & 0 deletions cozy/ui/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from cozy.media.player import Player
from cozy.model.settings import Settings as SettingsModel
from cozy.ui.about_window import AboutWindow
from cozy.ui.book_detail_view import BookDetailView
from cozy.ui.library_view import LibraryView
from cozy.ui.preferences_window import PreferencesWindow
from cozy.ui.widgets.first_import_button import FirstImportButton
Expand Down Expand Up @@ -82,6 +83,8 @@ def __init_window(self):
self.navigation_view: Adw.NavigationView = self.window_builder.get_object("navigation_view")
self.drop_revealer: Gtk.Revealer = self.window_builder.get_object("drop_revealer")

self.navigation_view.add(BookDetailView())

self.window.present()

def __init_actions(self):
Expand Down
Loading

0 comments on commit fe055a7

Please sign in to comment.