Skip to content
API Documentation
BastionGuard™
BootOptionsBox Class Reference
Inheritance diagram for BootOptionsBox:

Public Member Functions

 BootOptionsBox (Gtk.Window _parent_window)

Private Member Functions

void add_bootloader_options ()
void add_chk_reinstall_grub ()
void add_chk_update_initramfs (Gtk.Box hbox)
void add_chk_update_grub (Gtk.Box hbox)
void save_grub_device_selection ()
void refresh_options ()
void refresh_cmb_grub_dev ()
void cmb_grub_dev_select_default ()

Private Attributes

Gtk.Box option_box
Gtk.ComboBoxText cmb_grub_dev
Gee.ArrayList< Device?> grub_devices = new Gee.ArrayList<Device?>()
Gtk.CheckButton chk_reinstall_grub
Gtk.CheckButton chk_update_initramfs
Gtk.CheckButton chk_update_grub
Gtk.Window parent_window

Detailed Description

Definition at line 16 of file BootOptionsBox.vala.

Constructor & Destructor Documentation

◆ BootOptionsBox()

BootOptionsBox.BootOptionsBox ( Gtk.Window _parent_window)
inline

Definition at line 27 of file BootOptionsBox.vala.

27 {
28
29 log_debug("BootOptionsBox: BootOptionsBox()");
30
31 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
32 parent_window = _parent_window;
33 margin_top = 12;
34 margin_bottom = 12;
35 margin_start = 12;
36 margin_end = 12;
37
38 option_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 6);
39 append(option_box);
40
43
44 log_debug("BootOptionsBox: BootOptionsBox(): exit");
45 }
void add_bootloader_options()
Gtk.Window parent_window
void log_debug(string message)

References add_bootloader_options(), TeeJee.Logging.log_debug(), option_box, parent_window, and refresh_options().

Referenced by BootOptionsWindow.BootOptionsWindow().

Member Function Documentation

◆ add_bootloader_options()

void BootOptionsBox.add_bootloader_options ( )
inlineprivate

Definition at line 47 of file BootOptionsBox.vala.

47 {
49
50 var hbox = new Gtk.Box(Orientation.HORIZONTAL, 6);
51 hbox.margin_start = 12;
52 append (hbox);
53
54 cmb_grub_dev = new Gtk.ComboBoxText();
55 cmb_grub_dev.hexpand = true;
56 hbox.append(cmb_grub_dev);
57
58 cmb_grub_dev.changed.connect(()=>{
60 });
61
62 hbox = new Gtk.Box(Orientation.HORIZONTAL, 6);
63 append (hbox);
66 }
void add_chk_update_initramfs(Gtk.Box hbox)
Gtk.ComboBoxText cmb_grub_dev
void add_chk_update_grub(Gtk.Box hbox)
void save_grub_device_selection()
void add_chk_reinstall_grub()

References add_chk_reinstall_grub(), add_chk_update_grub(), add_chk_update_initramfs(), cmb_grub_dev, and save_grub_device_selection().

Referenced by BootOptionsBox().

◆ add_chk_reinstall_grub()

void BootOptionsBox.add_chk_reinstall_grub ( )
inlineprivate

Definition at line 68 of file BootOptionsBox.vala.

68 {
69 var chk = new CheckButton.with_label(_("(Re)install GRUB2 on:"));
70 chk.active = false;
71 chk.set_tooltip_markup(_("Re-installs the GRUB2 bootloader on the selected device."));
72 append (chk);
74
75 chk.toggled.connect(()=>{
76 cmb_grub_dev.sensitive = chk_reinstall_grub.active;
77 App.reinstall_grub2 = chk_reinstall_grub.active;
79 });
80 }
#define _(s)
Gtk.CheckButton chk_reinstall_grub

References _, chk_reinstall_grub, and save_grub_device_selection().

Referenced by add_bootloader_options().

◆ add_chk_update_grub()

void BootOptionsBox.add_chk_update_grub ( Gtk.Box hbox)
inlineprivate

Definition at line 94 of file BootOptionsBox.vala.

94 {
95 var chk = new CheckButton.with_label(_("Update GRUB menu"));
96 chk.active = false;
97 chk.set_tooltip_markup(_("Updates the GRUB menu entries (recommended). This is safe to run and should be left selected."));
98 hbox.append (chk);
99 chk_update_grub = chk;
100
101 chk.toggled.connect(()=>{
102 App.update_grub = chk_update_grub.active;
103 });
104 }
Gtk.CheckButton chk_update_grub

References _, and chk_update_grub.

Referenced by add_bootloader_options().

◆ add_chk_update_initramfs()

void BootOptionsBox.add_chk_update_initramfs ( Gtk.Box hbox)
inlineprivate

Definition at line 82 of file BootOptionsBox.vala.

82 {
83 var chk = new CheckButton.with_label(_("Update initramfs"));
84 chk.active = false;
85 chk.set_tooltip_markup(_("Re-generates initramfs for all installed kernels. This is generally not needed. Select this only if the restored system fails to boot."));
86 hbox.append (chk);
88
89 chk.toggled.connect(()=>{
90 App.update_initramfs = chk_update_initramfs.active;
91 });
92 }
Gtk.CheckButton chk_update_initramfs

References _, and chk_update_initramfs.

Referenced by add_bootloader_options().

◆ cmb_grub_dev_select_default()

void BootOptionsBox.cmb_grub_dev_select_default ( )
inlineprivate

Definition at line 170 of file BootOptionsBox.vala.

170 {
171 if (cmb_grub_dev == null){
172 return;
173 }
174
175 log_debug("BootOptionsBox: cmb_grub_dev_select_default()");
176
177 if (App.grub_device.length == 0){
178 cmb_grub_dev.active = -1;
179 return;
180 }
181
182 int active = -1;
183 for (int i = 0; i < grub_devices.size; i++){
184 Device? dev_iter = grub_devices[i];
185 if ((dev_iter != null) && (dev_iter.device == App.grub_device)){
186 active = i;
187 break;
188 }
189 }
190
191 cmb_grub_dev.active = active;
192 log_debug("BootOptionsBox: cmb_grub_dev_select_default(): exit");
193 }
Main App
Gee.ArrayList< Device?> grub_devices
string device
Definition Device.vala:44
string grub_device
Definition Main.vala:141

References App, cmb_grub_dev, Device.device, Main.grub_device, grub_devices, TeeJee.Logging.log_debug(), and Device.size.

Referenced by refresh_cmb_grub_dev().

◆ refresh_cmb_grub_dev()

void BootOptionsBox.refresh_cmb_grub_dev ( )
inlineprivate

Definition at line 145 of file BootOptionsBox.vala.

145 {
146 grub_devices.clear();
147 cmb_grub_dev.remove_all();
148
149 foreach(Device dev in Device.get_block_devices_using_lsblk()) {
150 if ((dev.type != "disk") && (dev.type != "part")){
151 continue;
152 }
153 if ((dev.fstype == "luks")||(dev.fstype == "lvm2")){
154 continue;
155 }
156 if (dev.size_bytes < 10 * KB){
157 continue;
158 }
159
160 grub_devices.add(dev);
161 string text = (dev.type == "disk")
162 ? _("%s (MBR)").printf(dev.description())
163 : dev.description();
164 cmb_grub_dev.append_text(text);
165 }
166
168 }
void cmb_grub_dev_select_default()
string type
Definition Device.vala:64
uint64 size_bytes
Definition Device.vala:77
string description()
Definition Device.vala:1825
string fstype
Definition Device.vala:65

References _, cmb_grub_dev, cmb_grub_dev_select_default(), Device.description(), Device.fstype, Device.get_block_devices_using_lsblk(), grub_devices, Device.size_bytes, and Device.type.

Referenced by refresh_options().

◆ refresh_options()

void BootOptionsBox.refresh_options ( )
inlineprivate

Definition at line 123 of file BootOptionsBox.vala.

123 {
125
126 chk_reinstall_grub.active = App.reinstall_grub2;
127 cmb_grub_dev.sensitive = chk_reinstall_grub.active;
128 chk_update_initramfs.active = App.update_initramfs;
129 chk_update_grub.active = App.update_grub;
130
131 chk_reinstall_grub.sensitive = true;
132 chk_update_initramfs.sensitive = true;
133 chk_update_grub.sensitive = true;
134
135 if (App.mirror_system){
136 chk_reinstall_grub.sensitive = false;
137 chk_update_initramfs.sensitive = false;
138 chk_update_grub.sensitive = false;
139 }
140 else if (App.snapshot_to_restore.distro.dist_id == "fedora"){
141 chk_reinstall_grub.sensitive = false;
142 }
143 }
bool update_initramfs
Definition Main.vala:139
Snapshot snapshot_to_restore
Definition Main.vala:136
bool update_grub
Definition Main.vala:140
bool mirror_system
Definition Main.vala:85
bool reinstall_grub2
Definition Main.vala:138
LinuxDistro distro
Definition Snapshot.vala:52

References App, chk_reinstall_grub, LinuxDistro.dist_id, Snapshot.distro, Main.mirror_system, refresh_cmb_grub_dev(), Main.reinstall_grub2, Main.snapshot_to_restore, Main.update_grub, and Main.update_initramfs.

Referenced by BootOptionsBox().

◆ save_grub_device_selection()

void BootOptionsBox.save_grub_device_selection ( )
inlineprivate

Definition at line 106 of file BootOptionsBox.vala.

106 {
107 App.grub_device = "";
108 if (!App.reinstall_grub2){
109 return;
110 }
111
112 int index = cmb_grub_dev.get_active();
113 if ((index < 0) || (index >= grub_devices.size)){
114 return;
115 }
116
117 Device? entry = grub_devices[index];
118 if (entry != null){
119 App.grub_device = entry.device;
120 }
121 }

References App, cmb_grub_dev, Device.device, grub_devices, Main.reinstall_grub2, and Device.size.

Referenced by add_bootloader_options(), and add_chk_reinstall_grub().

Member Data Documentation

◆ chk_reinstall_grub

Gtk.CheckButton BootOptionsBox.chk_reinstall_grub
private

Definition at line 22 of file BootOptionsBox.vala.

Referenced by add_chk_reinstall_grub(), and refresh_options().

◆ chk_update_grub

Gtk.CheckButton BootOptionsBox.chk_update_grub
private

Definition at line 24 of file BootOptionsBox.vala.

Referenced by add_chk_update_grub().

◆ chk_update_initramfs

Gtk.CheckButton BootOptionsBox.chk_update_initramfs
private

Definition at line 23 of file BootOptionsBox.vala.

Referenced by add_chk_update_initramfs().

◆ cmb_grub_dev

Gtk.ComboBoxText BootOptionsBox.cmb_grub_dev
private

◆ grub_devices

Gee.ArrayList<Device?> BootOptionsBox.grub_devices = new Gee.ArrayList<Device?>()
private

◆ option_box

Gtk.Box BootOptionsBox.option_box
private

Definition at line 18 of file BootOptionsBox.vala.

Referenced by BootOptionsBox().

◆ parent_window

Gtk.Window BootOptionsBox.parent_window
private

Definition at line 25 of file BootOptionsBox.vala.

Referenced by BootOptionsBox().


The documentation for this class was generated from the following file: