From 11fea2320cd1eed76d301582c156994f510d4c98 Mon Sep 17 00:00:00 2001 From: Dzheremi-belpois Date: Sun, 22 Dec 2024 16:21:35 +0300 Subject: [PATCH] fix: incorrect SongCards selection and search button and hotkey unavailability --- chronograph/ui/SongCard.py | 4 ++-- chronograph/utils/file.py | 2 +- chronograph/window.py | 12 +++++++++--- data/gtk/window.blp | 26 ++++++++++++-------------- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/chronograph/ui/SongCard.py b/chronograph/ui/SongCard.py index bd03de8..f474fc2 100644 --- a/chronograph/ui/SongCard.py +++ b/chronograph/ui/SongCard.py @@ -21,13 +21,13 @@ class SongCard(Gtk.Box): def __init__(self, file: Union[FileID3, FileVorbis]) -> None: super().__init__() - self._file: FileID3 = file + self._file: Union[FileID3, FileVorbis] = file self.title_label.set_text(self._file._title) self.artist_label.set_text(self._file._artist) self.event_controller_motion = Gtk.EventControllerMotion.new() self.add_controller(self.event_controller_motion) self.event_controller_motion.connect("enter", self.toggle_buttons) - self.event_controller_motion.connect("leave", self.toggle_buttons, None, None) + self.event_controller_motion.connect("leave", self.toggle_buttons) if (_texture := self._file.get_cover_texture()) == "icon": self.cover.set_from_icon_name("note-placeholder") diff --git a/chronograph/utils/file.py b/chronograph/utils/file.py index 3953539..2a70b0c 100644 --- a/chronograph/utils/file.py +++ b/chronograph/utils/file.py @@ -142,7 +142,7 @@ def cover(self, data: bytes) -> None: def load_str_data(self) -> None: """Should be implemenmted in file specific child classes""" raise NotImplementedError - + def load_cover(self) -> None: """Should be implemenmted in file specific child classes""" raise NotImplementedError diff --git a/chronograph/window.py b/chronograph/window.py index 11520f4..2b603ef 100644 --- a/chronograph/window.py +++ b/chronograph/window.py @@ -21,6 +21,7 @@ class ChronographWindow(Adw.ApplicationWindow): overlay_split_view: Adw.OverlaySplitView = Gtk.Template.Child() search_bar: Gtk.SearchBar = Gtk.Template.Child() search_entry: Gtk.SearchEntry = Gtk.Template.Child() + library_overlay: Gtk.Overlay = Gtk.Template.Child() library_scrolled_window: Gtk.ScrolledWindow = Gtk.Template.Child() library: Gtk.FlowBox = Gtk.Template.Child() @@ -34,12 +35,17 @@ def __init__(self, **kwargs) -> None: ) ) + # TODO: This should be implemented in ALL parsers functions + for child in self.library: + child.set_focusable(False) + if self.library.get_child_at_index(0) is None: self.library_scrolled_window.set_child(self.no_source_opened) def on_toggle_sidebar_action(self, *_args) -> None: - value = not self.overlay_split_view.get_show_sidebar() - self.overlay_split_view.set_show_sidebar(value) + self.overlay_split_view.set_show_sidebar( + not self.overlay_split_view.get_show_sidebar() + ) def on_toggle_search_action(self, *_args) -> None: if self.navigation_view.get_visible_page() == self.library_nav_page: @@ -48,7 +54,7 @@ def on_toggle_search_action(self, *_args) -> None: else: return - search_bar.set_search_mode(not (search_mode := search_bar.get_search_mode)) + search_bar.set_search_mode(not (search_mode := search_bar.get_search_mode())) if not search_mode: self.set_focus(search_entry) diff --git a/data/gtk/window.blp b/data/gtk/window.blp index 9bfd738..e625b04 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -83,20 +83,23 @@ template $ChronographWindow : Adw.ApplicationWindow { valign: start; halign: start; - MenuButton open_source_button { - icon-name: "open-source-symbolic"; - tooltip-text: _("Select a directory or open a file"); - menu-model: open_source_menu; - } + Box { + MenuButton open_source_button { + icon-name: "open-source-symbolic"; + tooltip-text: _("Select a directory or open a file"); + menu-model: open_source_menu; + } - ToggleButton toggle_search_button { - icon-name: "search-symbolic"; - tooltip-text: _("Toggle search"); - action-name: "win.toggle_search"; + ToggleButton toggle_search_button { + icon-name: "search-symbolic"; + tooltip-text: _("Toggle search"); + action-name: "win.toggle_search"; + } } } } + [top] SearchBar search_bar { search-mode-enabled: bind toggle_search_button.active bidirectional; key-capture-widget: navigation_view; @@ -121,16 +124,11 @@ template $ChronographWindow : Adw.ApplicationWindow { Overlay library_overlay { ScrolledWindow library_scrolled_window { - hexpand: true; - vexpand: true; - FlowBox library { homogeneous: true; halign: center; max-children-per-line: 100; valign: start; - hexpand: true; - vexpand: true; column-spacing: 12; row-spacing: 12; margin-top: 12;