From e02771c1b3c7b2abb7b416381ad9a06d352c2698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 29 May 2024 10:04:38 -0700 Subject: [PATCH 1/2] AbstractInstallerView: do more layout --- src/Views/AbstractInstallerView.vala | 39 +++++++++++++++++----------- src/Views/CheckView.vala | 16 +++++------- src/Views/DiskView.vala | 27 ++++++------------- src/Views/DriversView.vala | 14 +++++----- src/Views/EncryptView.vala | 11 +++----- src/Views/ErrorView.vala | 10 +++---- src/Views/KeyboardLayoutView.vala | 11 +++----- src/Views/LanguageView.vala | 11 +++----- src/Views/PartitioningView.vala | 12 +++++---- src/Views/ProgressView.vala | 13 +++++++--- src/Views/SuccessView.vala | 14 +++++----- src/Views/TryInstallView.vala | 15 +++++------ 12 files changed, 90 insertions(+), 103 deletions(-) diff --git a/src/Views/AbstractInstallerView.vala b/src/Views/AbstractInstallerView.vala index cfd02a9ef..4476bae58 100644 --- a/src/Views/AbstractInstallerView.vala +++ b/src/Views/AbstractInstallerView.vala @@ -20,7 +20,8 @@ public abstract class AbstractInstallerView : Gtk.Box { public signal void cancel (); - protected Gtk.Grid content_area; + protected Gtk.Box title_area; + protected Gtk.Box content_area; protected Gtk.Box action_box_start; protected Gtk.Box action_box_end; @@ -29,13 +30,20 @@ public abstract class AbstractInstallerView : Gtk.Box { } construct { - content_area = new Gtk.Grid () { - column_spacing = 12, - row_spacing = 12, + title_area = new Gtk.Box (VERTICAL, 12) { + valign = CENTER + }; + title_area.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + + content_area = new Gtk.Box (VERTICAL, 24); + + var box = new Gtk.Box (HORIZONTAL, 12) { + homogeneous = true, hexpand = true, vexpand = true, - orientation = Gtk.Orientation.VERTICAL }; + box.add (title_area); + box.add (content_area); action_box_end = new Gtk.Box (HORIZONTAL, 6) { halign = END, @@ -47,10 +55,7 @@ public abstract class AbstractInstallerView : Gtk.Box { homogeneous = true }; - var action_area = new Gtk.Box (HORIZONTAL, 12) { - margin_start = 10, - margin_end = 10 - }; + var action_area = new Gtk.Box (HORIZONTAL, 12); action_area.add (action_box_start); action_area.get_style_context ().add_class ("button-box"); @@ -72,11 +77,15 @@ public abstract class AbstractInstallerView : Gtk.Box { action_box_end.add (cancel_button); } - orientation = VERTICAL; - spacing = 24; - margin_top = 12; - margin_bottom = 12; - add (content_area); - add (action_area); + var main_box = new Gtk.Box (VERTICAL, 24) { + margin_top = 12, + margin_end = 12, + margin_bottom = 12, + margin_start = 12 + }; + main_box.add (box); + main_box.add (action_area); + + add (main_box); } } diff --git a/src/Views/CheckView.vala b/src/Views/CheckView.vala index 4fd4b03c3..40fc661ca 100644 --- a/src/Views/CheckView.vala +++ b/src/Views/CheckView.vala @@ -50,7 +50,6 @@ public class Installer.CheckView : AbstractInstallerView { var title_label = new Gtk.Label (_("Before Installing")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var beta_view = new CheckView ( _("Pre-Release Version"), @@ -71,16 +70,15 @@ public class Installer.CheckView : AbstractInstallerView { ); specs_view.attach (get_comparison_grid (), 1, 2); - message_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 32) { - valign = Gtk.Align.CENTER + message_box = new Gtk.Box (VERTICAL, 32) { + valign = CENTER, + vexpand = true }; - content_area.column_homogeneous = true; - content_area.margin_start = content_area.margin_end = 12; - content_area.valign = Gtk.Align.CENTER; - content_area.attach (image, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (message_box, 1, 0, 1, 2); + title_area.add (image); + title_area.add (title_label); + + content_area.add (message_box); var ignore_button = new Gtk.Button.with_label (_("Install Anyway")); ignore_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); diff --git a/src/Views/DiskView.vala b/src/Views/DiskView.vala index f0bad0b15..a84f09f75 100644 --- a/src/Views/DiskView.vala +++ b/src/Views/DiskView.vala @@ -39,14 +39,11 @@ public class Installer.DiskView : AbstractInstallerView { var image_overlay = new Gtk.Overlay () { child = install_image, - valign = END + halign = CENTER }; image_overlay.add_overlay (install_badge); - var install_label = new Gtk.Label (_("Select a Drive")) { - valign = Gtk.Align.START - }; - install_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + var install_label = new Gtk.Label (_("Select a Drive")); var install_desc_label = new Gtk.Label ( _("This will erase all data on the selected drive. If you have not backed your data up, you can cancel the installation and use Demo Mode.") @@ -89,20 +86,12 @@ public class Installer.DiskView : AbstractInstallerView { load_stack.add (load_box); load_stack.add_named (disk_scrolled, "disk"); - var title_grid = new Gtk.Grid () { - halign = Gtk.Align.CENTER, - valign = Gtk.Align.CENTER, - row_spacing = 12 - }; - title_grid.attach (image_overlay, 0, 0); - title_grid.attach (install_label, 0, 1); - - content_area.margin_start = content_area.margin_end = 12; - content_area.column_homogeneous = true; - content_area.valign = Gtk.Align.CENTER; - content_area.attach (title_grid, 0, 0, 1, 2); - content_area.attach (install_desc_label, 1, 0); - content_area.attach (load_stack, 1, 1); + title_area.add (image_overlay); + title_area.add (install_label); + + content_area.valign = CENTER; + content_area.add (install_desc_label); + content_area.add (load_stack); next_button = new Gtk.Button.with_label (_("Next")) { // Make sure we can skip this view in Test Mode diff --git a/src/Views/DriversView.vala b/src/Views/DriversView.vala index 4de3b39fb..204cc44c0 100644 --- a/src/Views/DriversView.vala +++ b/src/Views/DriversView.vala @@ -27,7 +27,6 @@ var title_label = new Gtk.Label (_("Additional Drivers")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var description_label = new Gtk.Label (_("Broadcom® Wi-Fi adapters, NVIDIA® graphics, and some virtual machines may not function properly without additional drivers. Most devices do not require additional drivers.")) { max_width_chars = 1, // Make Gtk wrap, but not expand the window @@ -63,7 +62,8 @@ }; var message_box = new Gtk.Box (VERTICAL, 32) { - valign = CENTER + valign = CENTER, + vexpand = true }; message_box.add (description_label); message_box.add (warning_row); @@ -71,12 +71,10 @@ message_box.add (install_later_row); message_box.add (drivers_check); - content_area.column_homogeneous = true; - content_area.margin_start = content_area.margin_end = 12; - content_area.valign = Gtk.Align.CENTER; - content_area.attach (image, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (message_box, 1, 0, 1, 2); + title_area.add (image); + title_area.add (title_label); + + content_area.add (message_box); var back_button = new Gtk.Button.with_label (_("Back")); back_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (BACK)); diff --git a/src/Views/EncryptView.vala b/src/Views/EncryptView.vala index 55f471344..37bec5c5e 100644 --- a/src/Views/EncryptView.vala +++ b/src/Views/EncryptView.vala @@ -51,7 +51,6 @@ public class EncryptView : AbstractInstallerView { var title_label = new Gtk.Label (_("Enable Drive Encryption")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var details_label = new Gtk.Label (_("Encrypt this device's drive if required for added protection, but be sure you understand:")) { hexpand = true, @@ -141,12 +140,10 @@ public class EncryptView : AbstractInstallerView { stack.add (description_box); stack.add (password_box); - content_area.column_homogeneous = true; - content_area.margin_end = 12; - content_area.margin_start = 12; - content_area.attach (overlay, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (stack, 1, 0, 1, 2); + title_area.add (overlay); + title_area.add (title_label); + + content_area.add (stack); var back_button = new Gtk.Button.with_label (_("Back")); diff --git a/src/Views/ErrorView.vala b/src/Views/ErrorView.vala index 0a230510e..7fec10514 100644 --- a/src/Views/ErrorView.vala +++ b/src/Views/ErrorView.vala @@ -32,7 +32,6 @@ public class ErrorView : AbstractInstallerView { var title_label = new Gtk.Label (_("Could Not Install")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var description_label = new Gtk.Label (_("Installing %s failed, possibly due to a hardware error. The device may not restart properly. You can try the following:").printf (Utils.get_pretty_name ())) { margin_bottom = 12, @@ -112,11 +111,10 @@ public class ErrorView : AbstractInstallerView { grid.attach (terminal_button, 0, 4, 2); grid.attach (terminal_revealer, 0, 5, 2); - content_area.column_homogeneous = true; - content_area.margin_start = content_area.margin_end = 12; - content_area.attach (image, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (grid, 1, 0, 1, 2); + title_area.add (image); + title_area.add (title_label); + + content_area.add (grid); var restart_button = new Gtk.Button.with_label (_("Restart Device")); diff --git a/src/Views/KeyboardLayoutView.vala b/src/Views/KeyboardLayoutView.vala index da6be7973..94126fc0e 100644 --- a/src/Views/KeyboardLayoutView.vala +++ b/src/Views/KeyboardLayoutView.vala @@ -30,7 +30,6 @@ public class KeyboardLayoutView : AbstractInstallerView { var title_label = new Gtk.Label (_("Select Keyboard Layout")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); input_variant_widget = new VariantWidget (); @@ -45,12 +44,10 @@ public class KeyboardLayoutView : AbstractInstallerView { stack_box.add (input_variant_widget); stack_box.add (keyboard_test_entry); - content_area.column_homogeneous = true; - content_area.margin_end = 12; - content_area.margin_start = 12; - content_area.attach (image, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (stack_box, 1, 0, 1, 2); + title_area.add (image); + title_area.add (title_label); + + content_area.add (stack_box); var back_button = new Gtk.Button.with_label (_("Back")); diff --git a/src/Views/LanguageView.vala b/src/Views/LanguageView.vala index d91aba7d3..0d2eb2702 100644 --- a/src/Views/LanguageView.vala +++ b/src/Views/LanguageView.vala @@ -49,7 +49,6 @@ public class Installer.LanguageView : AbstractInstallerView { select_stack = new Gtk.Stack (); select_stack.valign = Gtk.Align.START; - select_stack.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); select_stack.transition_type = Gtk.StackTransitionType.CROSSFADE; select_stack.add (select_label); @@ -165,12 +164,10 @@ public class Installer.LanguageView : AbstractInstallerView { lang_variant_widget.main_listbox.row_selected.disconnect (row_selected); }); - content_area.column_homogeneous = true; - content_area.margin_end = 10; - content_area.margin_start = 10; - content_area.attach (image, 0, 0, 1, 1); - content_area.attach (select_stack, 0, 1, 1, 1); - content_area.attach (lang_variant_widget, 1, 0, 1, 2); + title_area.add (image); + title_area.add (select_stack); + + content_area.add (lang_variant_widget); timeout (); } diff --git a/src/Views/PartitioningView.vala b/src/Views/PartitioningView.vala index 0b736004a..9372f04a1 100644 --- a/src/Views/PartitioningView.vala +++ b/src/Views/PartitioningView.vala @@ -50,7 +50,6 @@ public class Installer.PartitioningView : AbstractInstallerView { luks = new Gee.ArrayList (); var title_label = new Gtk.Label (_("Select Partitions")); - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var format_row = new DescriptionRow ( _("Selecting “Format” will erase all data on the selected partition."), @@ -101,7 +100,8 @@ public class Installer.PartitioningView : AbstractInstallerView { var disk_scroller = new Gtk.ScrolledWindow (null, null) { child = disk_list, hexpand = true, - hscrollbar_policy = NEVER + hscrollbar_policy = NEVER, + propagate_natural_height = true }; var load_spinner = new Gtk.Spinner () { @@ -128,9 +128,11 @@ public class Installer.PartitioningView : AbstractInstallerView { load_stack.add_named (load_box, "loading"); load_stack.add_named (disk_scroller, "disk"); - content_area.attach (title_label, 0, 0); - content_area.attach (description_box, 0, 1); - content_area.attach (load_stack, 0, 2); + title_area.add (title_label); + + content_area.valign = CENTER; + content_area.add (description_box); + content_area.add (load_stack); load_disks.begin (); diff --git a/src/Views/ProgressView.vala b/src/Views/ProgressView.vala index 313f07909..830027aad 100644 --- a/src/Views/ProgressView.vala +++ b/src/Views/ProgressView.vala @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -public class ProgressView : AbstractInstallerView { +public class ProgressView : Gtk.Box { public signal void on_success (); public signal void on_error (); @@ -87,13 +87,20 @@ public class ProgressView : AbstractInstallerView { hexpand = true }; - content_area.margin_end = 12; - content_area.margin_start = 12; + var content_area = new Gtk.Grid () { + margin_top = 12, + margin_end = 12, + margin_bottom = 12, + margin_start = 12, + row_spacing = 12 + }; content_area.attach (logo_stack, 0, 0, 2); content_area.attach (progressbar_label, 0, 1); content_area.attach (terminal_button, 1, 1); content_area.attach (progressbar, 0, 2, 2); + add (content_area); + terminal_button.toggled.connect (() => { if (terminal_button.active) { terminal_button.tooltip_text = _("Hide log"); diff --git a/src/Views/SuccessView.vala b/src/Views/SuccessView.vala index 2eedea4b0..287b6c769 100644 --- a/src/Views/SuccessView.vala +++ b/src/Views/SuccessView.vala @@ -29,7 +29,6 @@ public class SuccessView : AbstractInstallerView { var title_label = new Gtk.Label (_("Continue Setting Up")) { valign = Gtk.Align.START }; - title_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); var primary_label = new Gtk.Label (_("%s has been installed").printf (Utils.get_pretty_name ())) { hexpand = true, @@ -48,17 +47,16 @@ public class SuccessView : AbstractInstallerView { var message_grid = new Gtk.Grid () { row_spacing = 6, - valign = Gtk.Align.CENTER + valign = CENTER, + vexpand = true }; message_grid.attach (primary_label, 0, 0); message_grid.attach (secondary_label, 0, 1); - content_area.column_homogeneous = true; - content_area.margin_start = content_area.margin_end = 12; - content_area.valign = Gtk.Align.CENTER; - content_area.attach (image, 0, 0); - content_area.attach (title_label, 0, 1); - content_area.attach (message_grid, 1, 0, 1, 2); + title_area.add (image); + title_area.add (title_label); + + content_area.add (message_grid); var shutdown_button = new Gtk.Button.with_label (_("Shut Down")); shutdown_button.clicked.connect (Utils.shutdown); diff --git a/src/Views/TryInstallView.vala b/src/Views/TryInstallView.vala index f20ec8728..5b4af3c81 100644 --- a/src/Views/TryInstallView.vala +++ b/src/Views/TryInstallView.vala @@ -28,7 +28,6 @@ public class Installer.TryInstallView : AbstractInstallerView { var type_label = new Gtk.Label (_("Try or Install")) { valign = Gtk.Align.START }; - type_label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); // Force the user to make a conscious selection, not spam "Next" var no_selection = new Gtk.RadioButton (null) { @@ -60,7 +59,8 @@ public class Installer.TryInstallView : AbstractInstallerView { }; var type_box = new Gtk.Box (VERTICAL, 6) { - valign = CENTER + valign = CENTER, + vexpand = true }; type_box.add (demo_button); type_box.add (clean_install_button); @@ -73,13 +73,10 @@ public class Installer.TryInstallView : AbstractInstallerView { propagate_natural_height = true }; - content_area.column_homogeneous = true; - content_area.margin_end = 12; - content_area.margin_start = 12; - content_area.valign = Gtk.Align.CENTER; - content_area.attach (type_image, 0, 0); - content_area.attach (type_label, 0, 1); - content_area.attach (type_scrolled, 1, 0, 1, 2); + title_area.add (type_image); + title_area.add (type_label); + + content_area.add (type_scrolled); var back_button = new Gtk.Button.with_label (_("Back")); From c3236a5317765722854985ded1c6a78245605fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 29 May 2024 10:07:16 -0700 Subject: [PATCH 2/2] remove some unnecessary properties --- src/Views/DriversView.vala | 7 ++----- src/Views/EncryptView.vala | 5 +---- src/Views/ErrorView.vala | 7 ++----- src/Views/SuccessView.vala | 7 ++----- src/Views/TryInstallView.vala | 7 ++----- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/Views/DriversView.vala b/src/Views/DriversView.vala index 204cc44c0..a071694b6 100644 --- a/src/Views/DriversView.vala +++ b/src/Views/DriversView.vala @@ -20,13 +20,10 @@ construct { var image = new Gtk.Image.from_icon_name ("application-x-firmware", Gtk.IconSize.INVALID) { - pixel_size = 128, - valign = Gtk.Align.END + pixel_size = 128 }; - var title_label = new Gtk.Label (_("Additional Drivers")) { - valign = Gtk.Align.START - }; + var title_label = new Gtk.Label (_("Additional Drivers")); var description_label = new Gtk.Label (_("Broadcom® Wi-Fi adapters, NVIDIA® graphics, and some virtual machines may not function properly without additional drivers. Most devices do not require additional drivers.")) { max_width_chars = 1, // Make Gtk wrap, but not expand the window diff --git a/src/Views/EncryptView.vala b/src/Views/EncryptView.vala index 37bec5c5e..b03f2de71 100644 --- a/src/Views/EncryptView.vala +++ b/src/Views/EncryptView.vala @@ -43,14 +43,11 @@ public class EncryptView : AbstractInstallerView { var overlay = new Gtk.Overlay () { child = image, halign = CENTER, - valign = END, width_request = 60 }; overlay.add_overlay (overlay_image); - var title_label = new Gtk.Label (_("Enable Drive Encryption")) { - valign = Gtk.Align.START - }; + var title_label = new Gtk.Label (_("Enable Drive Encryption")); var details_label = new Gtk.Label (_("Encrypt this device's drive if required for added protection, but be sure you understand:")) { hexpand = true, diff --git a/src/Views/ErrorView.vala b/src/Views/ErrorView.vala index 7fec10514..6607373e7 100644 --- a/src/Views/ErrorView.vala +++ b/src/Views/ErrorView.vala @@ -25,13 +25,10 @@ public class ErrorView : AbstractInstallerView { construct { var image = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG) { - pixel_size = 128, - valign = Gtk.Align.END + pixel_size = 128 }; - var title_label = new Gtk.Label (_("Could Not Install")) { - valign = Gtk.Align.START - }; + var title_label = new Gtk.Label (_("Could Not Install")); var description_label = new Gtk.Label (_("Installing %s failed, possibly due to a hardware error. The device may not restart properly. You can try the following:").printf (Utils.get_pretty_name ())) { margin_bottom = 12, diff --git a/src/Views/SuccessView.vala b/src/Views/SuccessView.vala index 287b6c769..e72558035 100644 --- a/src/Views/SuccessView.vala +++ b/src/Views/SuccessView.vala @@ -22,13 +22,10 @@ public class SuccessView : AbstractInstallerView { construct { var image = new Gtk.Image.from_icon_name ("process-completed", Gtk.IconSize.DIALOG) { - pixel_size = 128, - valign = Gtk.Align.END + pixel_size = 128 }; - var title_label = new Gtk.Label (_("Continue Setting Up")) { - valign = Gtk.Align.START - }; + var title_label = new Gtk.Label (_("Continue Setting Up")); var primary_label = new Gtk.Label (_("%s has been installed").printf (Utils.get_pretty_name ())) { hexpand = true, diff --git a/src/Views/TryInstallView.vala b/src/Views/TryInstallView.vala index 5b4af3c81..7e1d0c53e 100644 --- a/src/Views/TryInstallView.vala +++ b/src/Views/TryInstallView.vala @@ -21,13 +21,10 @@ public class Installer.TryInstallView : AbstractInstallerView { construct { var type_image = new Gtk.Image.from_icon_name (Application.get_default ().application_id, Gtk.IconSize.DIALOG) { - pixel_size = 128, - valign = Gtk.Align.END + pixel_size = 128 }; - var type_label = new Gtk.Label (_("Try or Install")) { - valign = Gtk.Align.START - }; + var type_label = new Gtk.Label (_("Try or Install")); // Force the user to make a conscious selection, not spam "Next" var no_selection = new Gtk.RadioButton (null) {