gamepad: Implement return button action for sidebar
This commit is contained in:
@@ -136,7 +136,22 @@ class Gamepad(GObject.Object):
|
||||
open_menu.grab_focus()
|
||||
return
|
||||
|
||||
self.window.grid.grab_focus()
|
||||
grid_visible = self.window.view_stack.props.visible_child_name == "grid"
|
||||
if self._is_focused_on_top_bar():
|
||||
focus_widget = self.window.grid if grid_visible else self.window.sidebar
|
||||
|
||||
# If the grid is not visible (i.e no search results or imports)
|
||||
# the searchbar is focused as a fallback.
|
||||
elif self._is_focused_on_sidebar():
|
||||
focus_widget = (
|
||||
self.window.grid if grid_visible else self.window.search_entry
|
||||
)
|
||||
else:
|
||||
focus_widget = (
|
||||
self.window.sidebar if grid_visible else self.window.search_entry
|
||||
)
|
||||
|
||||
focus_widget.grab_focus()
|
||||
self.window.props.focus_visible = True
|
||||
|
||||
def _navigate_to_game_position(self, new_pos: int):
|
||||
|
||||
@@ -208,7 +208,7 @@ template $Window: Adw.ApplicationWindow {
|
||||
}
|
||||
|
||||
content: Adw.ToastOverlay toast_overlay {
|
||||
child: Adw.ViewStack {
|
||||
child: Adw.ViewStack view_stack {
|
||||
visible-child-name: bind $_if_else(
|
||||
grid.model as <NoSelection>.n-items,
|
||||
"grid",
|
||||
|
||||
@@ -56,6 +56,7 @@ class Window(Adw.ApplicationWindow):
|
||||
sort_button: Gtk.MenuButton = Gtk.Template.Child()
|
||||
main_menu_button: Gtk.MenuButton = Gtk.Template.Child()
|
||||
toast_overlay: Adw.ToastOverlay = Gtk.Template.Child()
|
||||
view_stack: Adw.ViewStack = Gtk.Template.Child()
|
||||
grid: Gtk.GridView = Gtk.Template.Child()
|
||||
sorter: GameSorter = Gtk.Template.Child()
|
||||
collection_filter: CollectionFilter = Gtk.Template.Child()
|
||||
|
||||
Reference in New Issue
Block a user