Skip to content

Commit

Permalink
AbstractInstallerView: replace ButtonBox with Boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed May 7, 2024
1 parent 93df033 commit ea9d0d7
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 37 deletions.
40 changes: 25 additions & 15 deletions src/Views/AbstractInstallerView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public abstract class AbstractInstallerView : Gtk.Box {
public signal void cancel ();

protected Gtk.Grid content_area;
protected Gtk.ButtonBox action_area;
protected Gtk.Box action_box_start;
protected Gtk.Box action_box_end;

protected AbstractInstallerView (bool cancellable = false) {
Object (cancellable: cancellable);
Expand All @@ -36,29 +37,38 @@ public abstract class AbstractInstallerView : Gtk.Box {
orientation = Gtk.Orientation.VERTICAL
};

action_area = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL) {
layout_style = Gtk.ButtonBoxStyle.END,
margin_end = 10,
margin_start = 10,
spacing = 6
action_box_end = new Gtk.Box (HORIZONTAL, 6) {
halign = END,
hexpand = true,
homogeneous = true
};

if (cancellable) {
var cancel_button = new Gtk.Button.with_label (_("Cancel Installation"));
cancel_button.clicked.connect (() => {
cancel ();
});
action_box_start = new Gtk.Box (HORIZONTAL, 6) {
homogeneous = true
};

action_area.add (cancel_button);
}
var action_area = new Gtk.Box (HORIZONTAL, 12) {
margin_start = 10,
margin_end = 10
};
action_area.add (action_box_start);

if (Installer.App.test_mode) {
var test_label = new Gtk.Label (_("Test Mode"));
test_label.get_style_context ().add_class (Gtk.STYLE_CLASS_ERROR);

action_area.add (test_label);
action_area.set_child_non_homogeneous (test_label, true);
action_area.set_child_secondary (test_label, true);
}

action_area.add (action_box_end);

if (cancellable) {
var cancel_button = new Gtk.Button.with_label (_("Cancel Installation"));
cancel_button.clicked.connect (() => {
cancel ();
});

action_box_end.add (cancel_button);
}

orientation = VERTICAL;
Expand Down
2 changes: 1 addition & 1 deletion src/Views/CheckView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class Installer.CheckView : AbstractInstallerView {
ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
ignore_button.clicked.connect (() => next_step ());

action_area.add (ignore_button);
action_box_end.add (ignore_button);

bool minimum_specs = true;

Expand Down
2 changes: 1 addition & 1 deletion src/Views/DiskView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class Installer.DiskView : AbstractInstallerView {
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
next_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (FORWARD));

action_area.add (next_button);
action_box_end.add (next_button);

show_all ();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Views/DriversView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
next_button.clicked.connect (() => next_step ());

action_area.add (back_button);
action_area.add (next_button);
action_box_end.add (back_button);
action_box_end.add (next_button);

drivers_check.toggled.connect (() => {
unowned var configuration = Configuration.get_default ();
Expand Down
6 changes: 3 additions & 3 deletions src/Views/EncryptView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ public class EncryptView : AbstractInstallerView {
};
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (back_button);
action_area.add (encrypt_button);
action_area.add (next_button);
action_box_end.add (back_button);
action_box_end.add (encrypt_button);
action_box_end.add (next_button);

next_button.grab_focus ();

Expand Down
6 changes: 3 additions & 3 deletions src/Views/ErrorView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public class ErrorView : AbstractInstallerView {
var install_button = new Gtk.Button.with_label (_("Try Installing Again"));
install_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (restart_button);
action_area.add (demo_button);
action_area.add (install_button);
action_box_end.add (restart_button);
action_box_end.add (demo_button);
action_box_end.add (install_button);

restart_button.clicked.connect (Utils.restart);

Expand Down
4 changes: 2 additions & 2 deletions src/Views/KeyboardLayoutView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public class KeyboardLayoutView : AbstractInstallerView {
};
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (back_button);
action_area.add (next_button);
action_box_end.add (back_button);
action_box_end.add (next_button);

input_variant_widget.main_listbox.set_sort_func ((row1, row2) => {
return ((LayoutRow) row1).layout.description.collate (((LayoutRow) row2).layout.description);
Expand Down
2 changes: 1 addition & 1 deletion src/Views/LanguageView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public class Installer.LanguageView : AbstractInstallerView {
next_button.sensitive = false;
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (next_button);
action_box_end.add (next_button);

lang_variant_widget.main_listbox.row_selected.connect (row_selected);
lang_variant_widget.main_listbox.select_row (lang_variant_widget.main_listbox.get_row_at_index (0));
Expand Down
8 changes: 3 additions & 5 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ public class Installer.PartitioningView : AbstractInstallerView {
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
next_button.sensitive = false;

action_area.add (modify_partitions_button);
action_area.set_child_secondary (modify_partitions_button, true);
action_area.set_child_non_homogeneous (modify_partitions_button, true);
action_area.add (back_button);
action_area.add (next_button);
action_box_start.add (modify_partitions_button);
action_box_end.add (back_button);
action_box_end.add (next_button);

back_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (Hdy.NavigationDirection.BACK));
next_button.clicked.connect (() => next_step ());
Expand Down
4 changes: 2 additions & 2 deletions src/Views/SuccessView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public class SuccessView : AbstractInstallerView {
restart_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
restart_button.clicked.connect (Utils.restart);

action_area.add (shutdown_button);
action_area.add (restart_button);
action_box_end.add (shutdown_button);
action_box_end.add (restart_button);

update_secondary_label ();

Expand Down
4 changes: 2 additions & 2 deletions src/Views/TryInstallView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public class Installer.TryInstallView : AbstractInstallerView {
};
next_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

action_area.add (back_button);
action_area.add (next_button);
action_box_end.add (back_button);
action_box_end.add (next_button);

back_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (Hdy.NavigationDirection.BACK));

Expand Down

0 comments on commit ea9d0d7

Please sign in to comment.