Skip to content

Commit

Permalink
Don't get ancestor, use action
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 25, 2024
1 parent 0795559 commit f09b5cb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
9 changes: 8 additions & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface UPower : GLib.Object {
public abstract bool on_battery { owned get; set; }
}

public class Installer.MainWindow : Gtk.Window {
public class Installer.MainWindow : Gtk.ApplicationWindow {
// We have to do it step by step because the vala compiler has overflows with big numbers.
private const uint64 ONE_GB = 1000 * 1000 * 1000;
// Minimum 15 GB
Expand Down Expand Up @@ -67,6 +67,13 @@ public class Installer.MainWindow : Gtk.Window {
child = overlay;
titlebar = new Gtk.Grid () { visible = false };

var back_action = new SimpleAction ("back", null);
back_action.activate.connect (() => {
navigation_view.pop ();
});

add_action (back_action);

language_view.next_step.connect (() => {
// Don't prompt for screen reader if we're able to navigate without it
if (orca_timeout_id != 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/Views/DriversView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@

content_area.append (message_box);

var back_button = new Gtk.Button.with_label (_("Back"));
back_button.clicked.connect (() => ((Adw.NavigationView) get_parent ()).pop ());
var back_button = new Gtk.Button.with_label (_("Back")) {
action_name = "win.back"
};

var next_button = new Gtk.Button.with_label (_("Erase and Install"));
next_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION);
Expand Down
6 changes: 3 additions & 3 deletions src/Views/KeyboardLayoutView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class KeyboardLayoutView : AbstractInstallerView {

content_area.append (stack_box);

var back_button = new Gtk.Button.with_label (_("Back"));
var back_button = new Gtk.Button.with_label (_("Back")) {
action_name = "win.back"
};

var next_button = new Gtk.Button.with_label (_("Select")) {
sensitive = false
Expand All @@ -66,8 +68,6 @@ public class KeyboardLayoutView : AbstractInstallerView {
next_button.activate ();
});

back_button.clicked.connect (() => ((Adw.NavigationView) get_parent ()).pop ());

next_button.clicked.connect (() => {
unowned Gtk.ListBoxRow row = input_variant_widget.main_listbox.get_selected_row ();
if (row != null) {
Expand Down
5 changes: 3 additions & 2 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ public class Installer.PartitioningView : AbstractInstallerView {
modify_partitions_button = new Gtk.Button.with_label (_("Modify Partitions…"));
modify_partitions_button.clicked.connect (() => open_partition_editor ());

var back_button = new Gtk.Button.with_label (_("Back"));
var back_button = new Gtk.Button.with_label (_("Back")) {
action_name = "win.back"
};

next_button = new Gtk.Button.with_label (_("Next"));
next_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);
Expand All @@ -148,7 +150,6 @@ public class Installer.PartitioningView : AbstractInstallerView {
action_box_end.append (back_button);
action_box_end.append (next_button);

back_button.clicked.connect (() => ((Adw.NavigationView) get_parent ()).pop ());
next_button.clicked.connect (() => next_step ());
}

Expand Down
6 changes: 3 additions & 3 deletions src/Views/TryInstallView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public class Installer.TryInstallView : AbstractInstallerView {

content_area.append (type_scrolled);

var back_button = new Gtk.Button.with_label (_("Back"));
var back_button = new Gtk.Button.with_label (_("Back")) {
action_name = "win.back"
};

var next_button = new Gtk.Button.with_label (_("Next")) {
sensitive = false
Expand All @@ -86,8 +88,6 @@ public class Installer.TryInstallView : AbstractInstallerView {
action_box_end.append (back_button);
action_box_end.append (next_button);

back_button.clicked.connect (() => ((Adw.NavigationView) get_parent ()).pop ());

demo_button.toggled.connect (() => {
if (demo_button.active) {
next_button.label = demo_button.title;
Expand Down

0 comments on commit f09b5cb

Please sign in to comment.