diff --git a/cozy/app_controller.py b/cozy/app_controller.py index 3e17195b..1d9d13cb 100644 --- a/cozy/app_controller.py +++ b/cozy/app_controller.py @@ -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 @@ -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) diff --git a/cozy/ui/book_detail_view.py b/cozy/ui/book_detail_view.py index 115b77a1..79dedb07 100644 --- a/cozy/ui/book_detail_view.py +++ b/cozy/ui/book_detail_view.py @@ -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() @@ -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 diff --git a/cozy/ui/main_view.py b/cozy/ui/main_view.py index 1710a201..b1f0f431 100644 --- a/cozy/ui/main_view.py +++ b/cozy/ui/main_view.py @@ -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 @@ -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): diff --git a/data/ui/book_detail.blp b/data/ui/book_detail.blp index c65c8105..6c4d5b21 100644 --- a/data/ui/book_detail.blp +++ b/data/ui/book_detail.blp @@ -1,276 +1,286 @@ using Gtk 4.0; using Adw 1; -template $BookDetail: Adw.BreakpointBin { - width-request: 350; - height-request: 52; - - Adw.Breakpoint { - condition ("max-width: 550sp") - - setters { - top_box.orientation: vertical; - top_box.spacing: 6; - top_box.halign: center; - book_label.halign: center; - author_label.halign: center; - play_button.halign: center; - } - } - - child: Box { - orientation: vertical; - - Adw.Banner unavailable_banner { - title: _("Some or all files of this book cannot be found."); - } - - ScrolledWindow { - focusable: true; - vexpand: true; - hscrollbar-policy: never; - propagate-natural-width: true; - propagate-natural-height: true; +template $BookDetail: Adw.NavigationPage { + tag: 'book_overview'; + title: bind template.book-title; + + Adw.ToolbarView { + [top] + Adw.HeaderBar {} + + content: Adw.BreakpointBin { + width-request: 350; + height-request: 52; + + Adw.Breakpoint { + condition ("max-width: 550sp") + + setters { + top_box.orientation: vertical; + top_box.spacing: 6; + top_box.halign: center; + book_label.halign: center; + author_label.halign: center; + play_button.halign: center; + } + } child: Box { orientation: vertical; - Adw.Clamp { - maximum-size: 800; - - Box top_box { - orientation: horizontal; - spacing: 30; - margin-start: 18; - margin-end: 18; - margin-top: 12; - margin-bottom: 18; - halign: start; - - Box album_art_container { - halign: center; - width-request: 200; - height-request: 200; - - Picture album_art { - styles [ - "book_detail_art", - ] - } - - styles [ - "card", - ] - } - - Box { - orientation: vertical; - margin-top: 12; - margin-bottom: 12; - spacing: 6; - vexpand: false; + Adw.Banner unavailable_banner { + title: _("Some or all files of this book cannot be found."); + } - Label book_label { + ScrolledWindow { + focusable: true; + vexpand: true; + hscrollbar-policy: never; + propagate-natural-width: true; + propagate-natural-height: true; + + child: Box { + orientation: vertical; + + Adw.Clamp { + maximum-size: 800; + + Box top_box { + orientation: horizontal; + spacing: 30; + margin-start: 18; + margin-end: 18; + margin-top: 12; + margin-bottom: 18; halign: start; - label: bind template.book_title; - ellipsize: end; - max-width-chars: 35; - lines: 1; - - styles [ - "title-1", - "bold", - ] - } - Label author_label { - halign: start; - label: _("Book author"); - ellipsize: end; - max-width-chars: 50; - lines: 1; - - styles [ - "title-3", - "dim-label", - ] - } + Box album_art_container { + halign: center; + width-request: 200; + height-request: 200; - Button play_button { - focusable: true; - receives-default: true; - margin-top: 18; - halign: start; - valign: end; - vexpand: true; - tooltip-text: _("Start/Stop playback"); - accessibility { - label: _("Start or pause the playback"); - } - - styles [ - "suggested-action", - "pill", - ] + Picture album_art { + styles [ + "book_detail_art", + ] + } - Adw.ButtonContent play_icon { - label: _("Start"); - icon-name: 'media-playback-start-symbolic'; + styles [ + "card", + ] } - } - } - Box { - halign: center; - valign: center; - margin-bottom: 12; - spacing: 5; - - Box download_box { - halign: end; - valign: center; - - Image download_image { - icon-name: 'download-symbolic'; + Box { + orientation: vertical; + margin-top: 12; + margin-bottom: 12; + spacing: 6; + vexpand: false; + + Label book_label { + halign: start; + label: bind template.book_title; + ellipsize: end; + max-width-chars: 35; + lines: 1; + + styles [ + "title-1", + "bold", + ] + } + + Label author_label { + halign: start; + label: _("Book author"); + ellipsize: end; + max-width-chars: 50; + lines: 1; + + styles [ + "title-3", + "dim-label", + ] + } + + Button play_button { + focusable: true; + receives-default: true; + margin-top: 18; + halign: start; + valign: end; + vexpand: true; + tooltip-text: _("Start/Stop playback"); + accessibility { + label: _("Start or pause the playback"); + } + + styles [ + "suggested-action", + "pill", + ] + + Adw.ButtonContent play_icon { + label: _("Start"); + icon-name: 'media-playback-start-symbolic'; + } + } } - Label download_label { - margin-start: 5; - margin-end: 4; - label: _("Download"); + Box { + halign: center; + valign: center; + margin-bottom: 12; + spacing: 5; + + Box download_box { + halign: end; + valign: center; + + Image download_image { + icon-name: 'download-symbolic'; + } + + Label download_label { + margin-start: 5; + margin-end: 4; + label: _("Download"); + } + } + + Switch download_switch { + focusable: true; + halign: start; + valign: center; + } } - } - - Switch download_switch { - focusable: true; - halign: start; - valign: center; - } - } - - ProgressBar book_progress_bar { - width-request: 250; - halign: center; - valign: start; - show-text: true; - margin-bottom: 18; - } - - Grid { - margin-bottom: 18; - hexpand: true; - row-spacing: 4; - column-spacing: 20; - Label remaining_text { - halign: start; - hexpand: true; - label: _("Remaining"); - - styles [ - "dim-label", - ] - - layout { - column: '0'; - row: '3'; - } - } - - Label remaining_label { - hexpand: true; - label: 'label'; - xalign: 0; - - layout { - column: '1'; - row: '3'; + ProgressBar book_progress_bar { + width-request: 250; + halign: center; + valign: start; + show-text: true; + margin-bottom: 18; } - } - - Label total_label { - hexpand: true; - label: 'label'; - xalign: 0; - layout { - column: '1'; - row: '2'; + Grid { + margin-bottom: 18; + hexpand: true; + row-spacing: 4; + column-spacing: 20; + + Label remaining_text { + halign: start; + hexpand: true; + label: _("Remaining"); + + styles [ + "dim-label", + ] + + layout { + column: '0'; + row: '3'; + } + } + + Label remaining_label { + hexpand: true; + label: 'label'; + xalign: 0; + + layout { + column: '1'; + row: '3'; + } + } + + Label total_label { + hexpand: true; + label: 'label'; + xalign: 0; + + layout { + column: '1'; + row: '2'; + } + } + + Label last_played_label { + hexpand: true; + label: 'label'; + xalign: 0; + + layout { + column: '1'; + row: '1'; + } + } + + Label { + halign: start; + label: _("Total"); + + styles [ + "dim-label", + ] + + layout { + column: '0'; + row: '2'; + } + } + + Label { + halign: start; + label: _("Last played"); + + styles [ + "dim-label", + ] + + layout { + column: '0'; + row: '1'; + } + } } } + } - Label last_played_label { - hexpand: true; - label: 'label'; - xalign: 0; + Adw.Clamp { + maximum-size: 800; + vexpand: true; - layout { - column: '1'; - row: '1'; - } - } - - Label { - halign: start; - label: _("Total"); + Stack chapters_stack { + margin-start: 18; + margin-end: 18; + margin-top: 12; + margin-bottom: 24; - styles [ - "dim-label", - ] + StackPage { + name: 'chapters_wrapper'; - layout { - column: '0'; - row: '2'; + child: Box chapter_list_container { + orientation: vertical; + spacing: 18; + }; } - } - - Label { - halign: start; - label: _("Last played"); - styles [ - "dim-label", - ] + StackPage { + name: 'chapters_loader'; - layout { - column: '0'; - row: '1'; + child: Spinner spinner { + halign: center; + spinning: true; + }; } } } - } - } - - Adw.Clamp { - maximum-size: 800; - vexpand: true; - - Stack chapters_stack { - margin-start: 18; - margin-end: 18; - margin-top: 12; - margin-bottom: 24; - - StackPage { - name: 'chapters_wrapper'; - - child: Box chapter_list_container { - orientation: vertical; - spacing: 18; - }; - } - - StackPage { - name: 'chapters_loader'; - - child: Spinner spinner { - halign: center; - spinning: true; - }; - } - } + }; } }; - } - }; + }; + } } diff --git a/data/ui/main_window.blp b/data/ui/main_window.blp index 45ab8af8..00decdb6 100644 --- a/data/ui/main_window.blp +++ b/data/ui/main_window.blp @@ -191,15 +191,6 @@ Adw.ApplicationWindow app_window { }; } } - - Adw.NavigationPage book_overview_page { - tag: 'book_overview'; - - child: Adw.ToolbarView book_overview { - [top] - Adw.HeaderBar {} - }; - } }; [bottom]