Skip to content

Commit

Permalink
AbstractInstallerView: replace ButtonBox with Boxes (#766)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Kornheisl <ryan@skarva.tech>
  • Loading branch information
danirabbit and zeebok committed May 24, 2024
1 parent 4794720 commit 8dd639d
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 37 deletions.
3 changes: 3 additions & 0 deletions data/Application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.button-box button {
min-width: 86px; /* https://github.com/elementary/granite/issues/577#issuecomment-1318979272 */
}
1 change: 1 addition & 0 deletions data/io.elementary.installer.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/io/elementary/installer">
<file compressed="true">Application.css</file>
<file alias="disk-bar-fallback.css" compressed="true">disk-bar-fallback.css</file>
<file alias="ProgressView.css" compressed="true">ProgressView.css</file>
<file compressed="true">wallpaper.jpg</file>
Expand Down
13 changes: 13 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ public class Installer.App : Gtk.Application {
add_main_option_entries (INSTALLER_OPTIONS);
}

public override void startup () {
base.startup ();

var css_provider = new Gtk.CssProvider ();
css_provider.load_from_resource ("io/elementary/installer/Application.css");

Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);
}

public override void activate () {
var window = new MainWindow () {
deletable = false,
Expand Down
41 changes: 26 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,39 @@ 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);
action_area.get_style_context ().add_class ("button-box");

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 @@ -143,11 +143,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 8dd639d

Please sign in to comment.