Skip to content

Commit

Permalink
Add DescriptionRow (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored May 29, 2024
1 parent a8ddfe5 commit 9509f1b
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 111 deletions.
70 changes: 25 additions & 45 deletions src/Views/DriversView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,23 @@
};
description_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);

var warning_image = new Gtk.Image.from_icon_name ("security-low-symbolic", LARGE_TOOLBAR);
warning_image.get_style_context ().add_class ("accent");
warning_image.get_style_context ().add_class ("yellow");

var warning_label = new Gtk.Label (_("Proprietary drivers contain private code that can't be reviewed. Security and other updates are dependent on the driver vendor.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var internet_image = new Gtk.Image.from_icon_name ("network-wireless-symbolic", LARGE_TOOLBAR);
internet_image.get_style_context ().add_class ("accent");
internet_image.get_style_context ().add_class ("blue");

var internet_label = new Gtk.Label (_("An Internet connection is required to install NVIDIA® graphics drivers.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var install_later_image = new Gtk.Image.from_icon_name ("system-software-install-symbolic", LARGE_TOOLBAR);
install_later_image.get_style_context ().add_class ("accent");
install_later_image.get_style_context ().add_class ("purple");

var install_later_label = new Gtk.Label (_("Proprietary drivers can be installed later through AppCenter, but an Internet connection will be required for all drivers.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};
var warning_row = new DescriptionRow (
_("Proprietary drivers contain private code that can't be reviewed. Security and other updates are dependent on the driver vendor."),
"security-low-symbolic",
"yellow"
);

var internet_row = new DescriptionRow (
_("An Internet connection is required to install NVIDIA® graphics drivers."),
"network-wireless-symbolic",
"blue"
);

var install_later_row = new DescriptionRow (
_("Proprietary drivers can be installed later through AppCenter, but an Internet connection will be required for all drivers."),
"system-software-install-symbolic",
"purple"
);

var checkbutton_label = new Gtk.Label (_("Include third-party proprietary drivers when installing. I agree to their respective licenses and terms of use.")) {
wrap = true
Expand All @@ -77,26 +62,21 @@
child = checkbutton_label
};

var message_grid = new Gtk.Grid () {
valign = CENTER,
row_spacing = 32,
column_spacing = 12
var message_box = new Gtk.Box (VERTICAL, 32) {
valign = CENTER
};
message_grid.attach (description_label, 0, 0, 2, 1);
message_grid.attach (warning_image, 0, 1);
message_grid.attach (warning_label, 1, 1);
message_grid.attach (internet_image, 0, 2);
message_grid.attach (internet_label, 1, 2);
message_grid.attach (install_later_image, 0, 3);
message_grid.attach (install_later_label, 1, 3);
message_grid.attach (drivers_check, 0, 4, 2);
message_box.add (description_label);
message_box.add (warning_row);
message_box.add (internet_row);
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_grid, 1, 0, 1, 2);
content_area.attach (message_box, 1, 0, 1, 2);

var back_button = new Gtk.Button.with_label (_("Back"));
back_button.clicked.connect (() => ((Hdy.Deck) get_parent ()).navigate (BACK));
Expand Down
73 changes: 30 additions & 43 deletions src/Views/EncryptView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,44 +61,31 @@ public class EncryptView : AbstractInstallerView {
};
details_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);

var protect_image = new Gtk.Image.from_icon_name ("security-high-symbolic", Gtk.IconSize.LARGE_TOOLBAR);

var protect_label = new Gtk.Label (_("Data will only be protected from others with physical access to this device when it is shut down.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var restart_image = new Gtk.Image.from_icon_name ("system-reboot-symbolic", Gtk.IconSize.LARGE_TOOLBAR);

var restart_label = new Gtk.Label (_("The encryption password will be required each time this device is turned on. Store it somewhere safe.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
var protect_row = new DescriptionRow (
_("Data will only be protected from others with physical access to this device when it is shut down."),
"security-high-symbolic",
"green"
);

var restart_row = new DescriptionRow (
_("The encryption password will be required each time this device is turned on. Store it somewhere safe."),
"system-reboot-symbolic",
"blue"
);

var keyboard_row = new DescriptionRow (
_("A built-in or USB keyboard will be required to type the encryption password each time this device is turned on."),
"input-keyboard-symbolic",
"slate"
);

var description_box = new Gtk.Box (VERTICAL, 32) {
valign = CENTER
};

var keyboard_image = new Gtk.Image.from_icon_name ("input-keyboard-symbolic", Gtk.IconSize.LARGE_TOOLBAR);

var keyboard_label = new Gtk.Label (_("A built-in or USB keyboard will be required to type the encryption password each time this device is turned on.")) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
wrap = true,
xalign = 0
};

var choice_grid = new Gtk.Grid () {
column_spacing = 12,
row_spacing = 32
};
choice_grid.attach (details_label, 0, 0, 2);
choice_grid.attach (protect_image, 0, 1);
choice_grid.attach (protect_label, 1, 1);
choice_grid.attach (restart_image, 0, 2);
choice_grid.attach (restart_label, 1, 2);
choice_grid.attach (keyboard_image, 0, 3);
choice_grid.attach (keyboard_label, 1, 3);
description_box.add (details_label);
description_box.add (protect_row);
description_box.add (restart_row);
description_box.add (keyboard_row);

var description = new Gtk.Label (
_("If you forget the encryption password, <b>you will not be able to recover data.</b> This is a unique password for this device, not the password for your user account.")
Expand Down Expand Up @@ -135,7 +122,9 @@ public class EncryptView : AbstractInstallerView {
confirm_entry_revealer = new ErrorRevealer (".");
confirm_entry_revealer.label_widget.get_style_context ().add_class (Gtk.STYLE_CLASS_ERROR);

var password_box = new Gtk.Box (VERTICAL, 3);
var password_box = new Gtk.Box (VERTICAL, 3) {
valign = CENTER
};
password_box.add (description);
password_box.add (pw_label);
password_box.add (pw_entry);
Expand All @@ -146,12 +135,10 @@ public class EncryptView : AbstractInstallerView {
password_box.add (confirm_entry_revealer);

var stack = new Gtk.Stack () {
vhomogeneous = false,
transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT,
valign = Gtk.Align.CENTER,
transition_type = SLIDE_LEFT_RIGHT,
vexpand = true
};
stack.add (choice_grid);
stack.add (description_box);
stack.add (password_box);

content_area.column_homogeneous = true;
Expand All @@ -177,7 +164,7 @@ public class EncryptView : AbstractInstallerView {
next_button.grab_focus ();

back_button.clicked.connect (() => {
stack.visible_child = choice_grid;
stack.visible_child = description_box;
next_button.label = _(SKIP_STRING);
next_button.sensitive = true;
back_button.hide ();
Expand Down
24 changes: 1 addition & 23 deletions src/Views/PartitioningView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class Installer.PartitioningView : AbstractInstallerView {

var recommended_row = new DescriptionRow (
_("It is also recommended to select a <b>Swap</b> partition."),
"dialog-information-symbolic",
"media-memory-symbolic",
"blue"
);

Expand Down Expand Up @@ -340,26 +340,4 @@ public class Installer.PartitioningView : AbstractInstallerView {
array[index] = array[array.size - 1];
return array.remove_at (array.size - 1);
}

private class DescriptionRow : Gtk.Box {
public DescriptionRow (string description, string icon_name, string color) {
var image = new Gtk.Image.from_icon_name (icon_name, MENU) {
valign = Gtk.Align.START
};
image.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT);
image.get_style_context ().add_class (color);

var description_label = new Gtk.Label (description) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
use_markup = true,
wrap = true,
xalign = 0
};

spacing = 12;
add (image);
add (description_label);
}
}
}
39 changes: 39 additions & 0 deletions src/Widgets/DescriptionRow.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
*/

public class DescriptionRow : Gtk.Box {
public string description { get; construct; }
public string icon_name { get; construct; }
public string color { get; construct; }

public DescriptionRow (string description, string icon_name, string color) {
Object (
color: color,
description: description,
icon_name: icon_name
);
}

construct {
var image = new Gtk.Image.from_icon_name (icon_name, LARGE_TOOLBAR) {
pixel_size = 24,
valign = START
};
image.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT);
image.get_style_context ().add_class (color);

var description_label = new Gtk.Label (description) {
hexpand = true,
max_width_chars = 1, // Make Gtk wrap, but not expand the window
use_markup = true,
wrap = true,
xalign = 0
};

spacing = 12;
add (image);
add (description_label);
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ vala_files = [
'Views/TryInstallView.vala',
'Views/SuccessView.vala',
'Widgets/DecryptMenu.vala',
'Widgets/DescriptionRow.vala',
'Widgets/DiskBar.vala',
'Widgets/DiskGrid.vala',
'Widgets/InstallTypeGrid.vala',
Expand Down

0 comments on commit 9509f1b

Please sign in to comment.