Navigation improvements - closes #80

This commit is contained in:
kramo
2023-05-13 21:49:37 +02:00
parent f7c363f118
commit c113ebb750
3 changed files with 27 additions and 10 deletions

View File

@@ -114,12 +114,12 @@ template DetailsWindow : Adw.Window {
description: _("File to open or command to run when launching the game");
[header-suffix]
Gtk.MenuButton exec-info-button {
Gtk.MenuButton exec_info_button {
valign: center;
icon-name: "help-about-symbolic";
popover: Popover {
visible: bind exec-info-button.active bidirectional;
visible: bind exec_info_button.active bidirectional;
Label exec_info_label {
use-markup: true;

View File

@@ -9,6 +9,14 @@ Adw.StatusPage notice_no_results {
valign: center;
}
Adw.StatusPage hidden_notice_no_results {
icon-name: "system-search-symbolic";
title: _("No Games Found");
description: _("Try a different search.");
vexpand: true;
valign: center;
}
Adw.StatusPage notice_empty {
icon-name: "applications-games-symbolic";
title: _("No Games");
@@ -250,6 +258,8 @@ template CartridgesWindow : Adw.ApplicationWindow {
}
SearchBar search_bar {
search-mode-enabled: bind search_button.active bidirectional;
key-capture-widget: library_view;
Adw.Clamp {
maximum-size: 500;
tightening-threshold: 500;
@@ -298,7 +308,7 @@ template CartridgesWindow : Adw.ApplicationWindow {
}
[end]
MenuButton {
MenuButton hidden_primary_menu_button {
tooltip-text: _("Main Menu");
icon-name: "open-menu-symbolic";
menu-model: primary_menu;
@@ -313,6 +323,8 @@ template CartridgesWindow : Adw.ApplicationWindow {
}
SearchBar hidden_search_bar {
search-mode-enabled: bind hidden_search_button.active bidirectional;
key-capture-widget: hidden_library_view;
Adw.Clamp {
maximum-size: 500;
tightening-threshold: 500;

View File

@@ -56,11 +56,13 @@ class CartridgesWindow(Adw.ApplicationWindow):
details_view_last_played = Gtk.Template.Child()
details_view_hide_button = Gtk.Template.Child()
hidden_primary_menu_button = Gtk.Template.Child()
hidden_library = Gtk.Template.Child()
hidden_library_view = Gtk.Template.Child()
hidden_scrolledwindow = Gtk.Template.Child()
hidden_library_bin = Gtk.Template.Child()
hidden_notice_empty = Gtk.Template.Child()
hidden_notice_no_results = Gtk.Template.Child()
hidden_search_bar = Gtk.Template.Child()
hidden_search_entry = Gtk.Template.Child()
hidden_search_button = Gtk.Template.Child()
@@ -134,6 +136,10 @@ class CartridgesWindow(Adw.ApplicationWindow):
else:
Game(self, game).update()
# Connect search entries
self.search_bar.connect_entry(self.search_entry)
self.hidden_search_bar.connect_entry(self.hidden_search_entry)
# Connect signals
self.search_entry.connect("search-changed", self.search_changed, False)
self.hidden_search_entry.connect("search-changed", self.search_changed, True)
@@ -158,7 +164,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
continue
if game.hidden:
if game.filtered and hidden_child != self.hidden_scrolledwindow:
hidden_child = self.notice_no_results
hidden_child = self.hidden_notice_no_results
continue
hidden_child = self.hidden_scrolledwindow
else:
@@ -301,7 +307,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
else Gtk.StackTransitionType.OVER_LEFT
)
if next_page == self.library_view or self.hidden_library_view:
if next_page in (self.library_view, self.hidden_library_view):
self.previous_page = next_page
self.lookup_action("show_hidden").set_enabled(
next_page == self.library_view
@@ -342,16 +348,13 @@ class CartridgesWindow(Adw.ApplicationWindow):
if self.stack.get_visible_child() == self.library_view:
search_bar = self.search_bar
search_entry = self.search_entry
search_button = self.search_button
elif self.stack.get_visible_child() == self.hidden_library_view:
search_bar = self.hidden_search_bar
search_entry = self.hidden_search_entry
search_button = self.hidden_search_button
else:
return
search_bar.set_search_mode(not (search_mode := search_bar.get_search_mode()))
search_button.set_active(not search_button.get_active())
if not search_mode:
self.set_focus(search_entry)
@@ -386,5 +389,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
self.toasts.pop((game, undo))
def on_open_menu_action(self, *_args):
if self.stack.get_visible_child() != self.details_view:
self.primary_menu_button.set_active(True)
if self.stack.get_visible_child() == self.library_view:
self.primary_menu_button.popup()
elif self.stack.get_visible_child() == self.hidden_library_view:
self.hidden_primary_menu_button.popup()