25 log_debug(
"BackupDeviceBox: BackupDeviceBox()");
26 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
33 var hbox =
new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
35 add_label_header(hbox,
_(
"Select Snapshot Location"),
true);
39 spacer.hexpand =
true;
44 var toolbar =
new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
45 toolbar.halign = Gtk.Align.END;
46 toolbar.valign = Gtk.Align.CENTER;
52 var btn_smb = add_button(toolbar,
_(
"Add Network Share…"),
53 _(
"Mount a Samba/CIFS share (NAS, shared folder) and use it as a snapshot location"),
55 btn_smb.add_css_class(
"btn-toolbar");
56 btn_smb.hexpand =
false;
57 var lbl = btn_smb.get_child();
58 if (lbl is Gtk.Label){
59 ((Gtk.Label) lbl).wrap =
false;
60 ((Gtk.Label) lbl).ellipsize = Pango.EllipsizeMode.NONE;
62 btn_smb.clicked.connect(() => {
67 var btn_refresh = add_button(toolbar,
_(
"Refresh"),
"",
null,
null);
68 btn_refresh.add_css_class(
"btn-toolbar");
69 btn_refresh.hexpand =
false;
71 var lbl = btn_refresh.get_child();
72 if (lbl is Gtk.Label){
73 ((Gtk.Label) lbl).wrap =
false;
74 ((Gtk.Label) lbl).ellipsize = Pango.EllipsizeMode.NONE;
77 btn_refresh.clicked.connect(()=>{
84 log_debug(
"BackupDeviceBox: BackupDeviceBox(): exit");
92 lbl_common.label =
"<i>• %s\n• %s\n• %s</i>".printf(
93 _(
"Devices displayed above have BTRFS file systems."),
94 _(
"BTRFS snapshots are saved on system partition. Other partitions are not supported."),
95 _(
"Snapshots are saved to /bastionguard-backup-btrfs on selected partition. Other locations are not supported.")
99 lbl_common.label =
"<i>• %s\n• %s\n• %s\n• %s</i>".printf(
100 _(
"Devices displayed above have Linux file systems."),
101 _(
"Devices with Windows file systems are not supported (NTFS, FAT, etc)."),
102 _(
"Network shares (SMB / NAS / shared folders) can be added with the button above."),
103 _(
"On a local device snapshots are saved to /bastionguard-backup; on a network share they are saved to a bastionguard-backup folder inside the share.")
110 device_list.selection_mode = Gtk.SelectionMode.SINGLE;
111 device_list.activate_on_single_click =
true;
130 var scrolled =
new Gtk.ScrolledWindow();
131 scrolled.hexpand =
true;
132 scrolled.vexpand =
true;
133 scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
139 var row =
new Gtk.ListBoxRow();
140 row.set_data<
Device>(
"device", dev);
142 var outer =
new Gtk.Box(Gtk.Orientation.HORIZONTAL, 12);
143 outer.margin_top = 6;
144 outer.margin_bottom = 6;
145 outer.margin_start = 6;
146 outer.margin_end = 6;
151 var primary =
new Gtk.Box(Gtk.Orientation.VERTICAL, 2);
152 primary.hexpand =
true;
153 string title = (dev.type ==
"disk") ?
"%s %s".printf(dev.
model, dev.
vendor).strip() : dev.
kname;
154 if (title.length == 0){
157 var title_label =
new Gtk.Label(title);
158 title_label.xalign = 0.0f;
159 title_label.add_css_class(
"heading");
160 primary.append(title_label);
169 var subtitle =
new Gtk.Label(details);
170 subtitle.xalign = 0.0f;
171 subtitle.wrap =
true;
172 primary.append(subtitle);
173 outer.append(primary);
175 var status =
new Gtk.Label(
"");
176 status.xalign = 1.0f;
177 status.set_data<
string>(
"uuid", dev.
uuid);
178 outer.append(status);
180 row.set_child(outer);
186 while (child !=
null){
187 var next = child.get_next_sibling();
188 if (child is Gtk.ListBoxRow){
189 var row = (Gtk.ListBoxRow) child;
190 Gtk.Widget? boxw = row.get_child();
191 if (boxw is Gtk.Box){
192 Gtk.Widget? last = ((Gtk.Box) boxw).get_last_child();
193 if (last is Gtk.Label){
194 bool selected =
false;
200 selected = (App.repo !=
null)
202 && (App.repo.mount_path == smb.mount_point + (smb.subpath.length > 0 ?
"/" + smb.subpath :
""));
211 ((Gtk.Label) last).label = selected ?
"✓" :
"";
220 var infobar =
new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
221 infobar.visible =
false;
225 var content = infobar;
229 var scrolled =
new Gtk.ScrolledWindow();
230 scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER);
231 scrolled.set_size_request(-1, 100);
234 label =
new Gtk.Label(
"");
235 label.set_use_markup(
true);
238 label.wrap_mode = Pango.WrapMode.WORD;
239 label.margin_top = 6;
240 label.margin_bottom = 6;
241 label.margin_start = 6;
242 label.margin_end = 6;
243 scrolled.set_child(label);
249 if (dev.
type ==
"disk"){
250 bool found_child =
false;
256 foreach (var child
in dev.
children){
265 string msg = App.btrfs_mode ?
_(
"Selected device does not have BTRFS partition") :
_(
"Selected device does not have Linux partition");
266 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(msg);
277 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(
_(
"Select a partition on this disk"));
292 if (dev.has_children() && dev.children[0].has_linux_filesystem()){
311 switch (status_code){
313 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(details);
320 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(message);
325 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(details);
331 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(
_(
"There are no snapshots on this device"));
341 switch (status_code){
343 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(details);
350 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(message.replace(
"<",
"<"));
356 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(message);
361 lbl_infobar_location.label =
"<span weight=\"bold\">%s</span>".printf(details);
381 if (disk.type !=
"disk") {
continue; }
390 foreach (var s
in smb_mounts){
400 if (!part.has_linux_filesystem()){
continue; }
403 if (part.is_encrypted_partition() && (!part.has_children() || (part.children[0].fstype ==
"btrfs"))){
405 else if (part.is_lvm_partition() && (!part.has_children() || (part.children[0].fstype ==
"btrfs"))){
407 else if (part.fstype ==
"btrfs"){
414 if (part.pkname == parent.kname) {
418 else if ((part.kname == parent.kname) && (part.type ==
"disk") && part.has_linux_filesystem() && !part.has_children()){
420 part2.copy_fields_from(part);
422 part2.pkname = part.device.replace(
"/dev/",
"");
432 var row =
new Gtk.ListBoxRow();
433 row.set_data<
SmbShare>(
"smb_share", share);
435 var outer =
new Gtk.Box(Gtk.Orientation.HORIZONTAL, 12);
436 outer.margin_top = 6;
437 outer.margin_bottom = 6;
438 outer.margin_start = 6;
439 outer.margin_end = 6;
447 var primary =
new Gtk.Box(Gtk.Orientation.VERTICAL, 2);
448 primary.hexpand =
true;
451 title_label.xalign = 0.0f;
452 title_label.add_css_class(
"heading");
453 primary.append(title_label);
456 string details =
_(
"Network share (SMB / CIFS)");
459 if (df.size > 0 && df[0].size_bytes > 0){
461 if (df[0].free_bytes > 0){
462 details +=
" • " +
_(
"Free") +
": "
470 var subtitle =
new Gtk.Label(details);
471 subtitle.xalign = 0.0f;
472 subtitle.wrap =
true;
473 primary.append(subtitle);
474 outer.append(primary);
476 var status =
new Gtk.Label(
"");
477 status.xalign = 1.0f;
478 outer.append(status);
480 row.set_child(outer);
487 gtk_messagebox(
_(
"Network shares not available"), err,
parent_window,
true);
bool check_backup_location()
void device_list_refresh()
void add_device_row(Device dev, string kind)
void try_change_smb_share(SmbShare share)
void append_child_volumes(Device parent)
void change_backup_device(Device pi)
void init_infobar_location()
Gtk.Label lbl_infobar_location
void update_selected_rows()
void on_add_smb_share_clicked()
void add_smb_row(SmbShare share)
void try_change_device(Device dev)
BackupDeviceBox(Gtk.Window _parent_window)
static Gee.ArrayList< Device > get_disk_space_using_df(string dev_name_or_mount_point="")
bool has_linux_filesystem()
static ? Device find_device_in_list(Gee.ArrayList< Device > list, string _dev_alias)
Gee.ArrayList< Device > children
const string ICON_HARDDRIVE
static Gtk.Image lookup_image(string icon_name, int icon_size, bool symbolic=false, bool use_hardcoded=false)
Gee.ArrayList< Device > partitions
static bool is_available(out string error_message)
static Gee.ArrayList< SmbShare > list_active_mounts()
static ? SmbShare run_dialog(Gtk.Window? parent, SmbShare? prefill=null)
SnapshotRepo. from_device(Device dev, Gtk.Window? parent_win, bool btrfs_repo)
SnapshotRepo. from_path(string path, Gtk.Window? parent_win, bool _btrfs_mode)
SnapshotLocationStatus status_code
string path_combine(string path1, string path2)
string format_file_size(uint64 size, bool binary_units=false, string unit="", bool show_units=true, int decimals=1)
bool dir_create(string dir_path, bool show_message=false)
void gtk_set_busy(bool busy, Gtk.Window win)
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
void log_debug(string message)
void log_msg(string message, bool highlight=false)
string escape_html(string html)