Revert "page-wrapper: Use AdwNavigationView backward button"

AdwNavigationView requires a bad style hack to align the button to the
top and also causes issues when pushing new pages onto the stack via
gestures.

This reverts commit 4d2fdd4920.
This commit is contained in:
Peter Eisenmann
2024-08-02 14:48:01 +02:00
parent 0521b1af21
commit 928ae01f6c
4 changed files with 28 additions and 7 deletions

View File

@@ -7,8 +7,3 @@
background: none;
box-shadow:none;
}
/* Super hacky libadwaita button alignment workaround */
headerbar .back {
margin-bottom: 123px;
}

View File

@@ -7,6 +7,7 @@ template $PageWrapper : Adw.NavigationPage {
Adw.HeaderBar {
show-start-title-buttons: false;
show-end-title-buttons: false;
show-back-button: false;
styles ["flat"]
[start]
@@ -19,6 +20,16 @@ template $PageWrapper : Adw.NavigationPage {
visible: bind win_controls_start.empty inverted;
}
Revealer previous_revealer {
transition-type: crossfade;
child: Button {
action-name: "win.previous-page";
focusable: true;
focus-on-click: false;
icon-name: "go-previous-symbolic";
};
}
Revealer next_revealer {
transition-type: crossfade;
child: Button {

View File

@@ -126,6 +126,7 @@ class PageWrapper(Adw.NavigationPage):
__gtype_name__ = __qualname__
next_revealer = Gtk.Template.Child()
previous_revealer = Gtk.Template.Child()
title_image = Gtk.Template.Child()
title_label = Gtk.Template.Child()
reload_revealer = Gtk.Template.Child()
@@ -188,7 +189,8 @@ class PageWrapper(Adw.NavigationPage):
del self.page
self._set_new_page(self.page_name)
def update_navigation_buttons(self, is_last: bool):
def update_navigation_buttons(self, is_first: bool, is_last: bool):
self.previous_revealer.set_reveal_child(not is_first)
self.next_revealer.set_reveal_child(not is_last)
self.reload_revealer.set_reveal_child(
self.page_name in reloadable_pages)

View File

@@ -84,6 +84,7 @@ class OsInstallerWindow(Adw.ApplicationWindow):
self.shortcut_controller.set_scope(Gtk.ShortcutScope(1))
self._add_action('next-page', self._navigate_forward, '<Alt>Right')
self._add_action('previous-page', self._navigate_backward, '<Alt>Left')
self._add_action('reload-page', self._reload_page, 'F5')
self._add_action('about-page', self._show_about_page, '<Alt>Return')
self._add_action('quit', self._show_confirm_dialog, '<Ctl>q')
@@ -187,7 +188,8 @@ class OsInstallerWindow(Adw.ApplicationWindow):
def _update_page(self):
current_page = self.navigation_view.get_visible_page()
current_page.update_navigation_buttons(self._current_is_last())
is_first, is_last = self._current_is_first(), self._current_is_last()
current_page.update_navigation_buttons(is_first, is_last)
def _load_next_page(self, offset: int = forward):
page_name = self._get_next_page_name(offset)
@@ -203,12 +205,23 @@ class OsInstallerWindow(Adw.ApplicationWindow):
previous_page_name = self.previous_pages.pop()
self._load_page(previous_page_name, offset=backwards)
def _current_is_first(self):
page = self.navigation_view.get_visible_page()
return page.get_tag() == self.pages[0]
def _current_is_last(self):
page_name = self.navigation_view.get_visible_page().get_tag()
return page_name == self.pages[-1]
### callbacks ###
def _navigate_backward(self, _, __):
with self.navigation_lock:
if self.previous_pages:
self._load_previous_page()
elif not self._current_is_first():
self._load_next_page(backwards)
def _navigate_forward(self, _, __):
with self.navigation_lock:
if not self._current_is_last():