Skip to content

Commit

Permalink
fix: incorrect SongCards selection and search button and hotkey unava…
Browse files Browse the repository at this point in the history
…ilability
  • Loading branch information
Dzheremi2 committed Dec 22, 2024
1 parent 5ec0528 commit 11fea23
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions chronograph/ui/SongCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion chronograph/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 9 additions & 3 deletions chronograph/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand All @@ -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)
Expand Down
26 changes: 12 additions & 14 deletions data/gtk/window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 11fea23

Please sign in to comment.