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

Public Member Functions

 SnapshotRow (Snapshot bak)

Public Attributes

Snapshot snapshot
Gtk.CheckButton check

Private Member Functions

void build_ui ()
string build_meta_text ()

Private Attributes

Gtk.Entry desc_entry

Detailed Description

Definition at line 12 of file SnapshotListBox.vala.

Constructor & Destructor Documentation

◆ SnapshotRow()

SnapshotRow.SnapshotRow ( Snapshot bak)
inline

Definition at line 17 of file SnapshotListBox.vala.

17 {
18 snapshot = bak;
19 build_ui();
20 }

References build_ui(), and snapshot.

Referenced by SnapshotListBox.refresh().

Member Function Documentation

◆ build_meta_text()

string SnapshotRow.build_meta_text ( )
inlineprivate

Definition at line 86 of file SnapshotListBox.vala.

86 {
87 var parts = new Gee.ArrayList<string>();
88 if ((snapshot.sys_distro ?? "").length > 0) {
89 parts.add(snapshot.sys_distro.replace("LinuxMint", "Linux Mint"));
90 }
91 if ((snapshot.taglist_short ?? "").length > 0) {
92 parts.add(_("Tags") + ": " + snapshot.taglist_short);
93 }
94 if (snapshot.btrfs_mode) {
95 int64 size = 0;
96 int64 unshared = 0;
97 if (snapshot.subvolumes.has_key("@")) {
98 size += snapshot.subvolumes["@"].total_bytes;
99 unshared += snapshot.subvolumes["@"].unshared_bytes;
100 }
101 if (snapshot.subvolumes.has_key("@home")) {
102 size += snapshot.subvolumes["@home"].total_bytes;
103 unshared += snapshot.subvolumes["@home"].unshared_bytes;
104 }
105 parts.add(_("Size") + ": " + format_file_size(size));
107 parts.add(_("Unshared") + ": " + format_file_size(unshared));
108 }
109 }
110 return string.joinv(" • ", parts.to_array());
111 }
Main App
#define _(s)
bool btrfs_qgroups_enabled
Definition Main.vala:182
string sys_distro
Definition Snapshot.vala:40
Gee.HashMap< string, Subvolume > subvolumes
Definition Snapshot.vala:46
bool btrfs_mode
Definition Snapshot.vala:56
string taglist_short
string format_file_size(uint64 size, bool binary_units=false, string unit="", bool show_units=true, int decimals=1)

References _, App, Snapshot.btrfs_mode, Main.btrfs_qgroups_enabled, TeeJee.FileSystem.format_file_size(), snapshot, Snapshot.subvolumes, Snapshot.sys_distro, and Snapshot.taglist_short.

Referenced by build_ui().

◆ build_ui()

void SnapshotRow.build_ui ( )
inlineprivate

Definition at line 22 of file SnapshotListBox.vala.

22 {
23 var outer = new Gtk.Box(Gtk.Orientation.VERTICAL, 2);
24 outer.margin_top = 5;
25 outer.margin_bottom = 5;
26 outer.margin_start = 8;
27 outer.margin_end = 8;
28 set_child(outer);
29
30 var top = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
31 outer.append(top);
32
33 check = new Gtk.CheckButton();
34 check.valign = Gtk.Align.START;
35 top.append(check);
36
37 var info = new Gtk.Box(Gtk.Orientation.VERTICAL, 2);
38 info.hexpand = true;
39 top.append(info);
40
41 var title = new Gtk.Label(null);
42 title.use_markup = true;
43 title.wrap = true;
44 title.xalign = 0.0f;
45 string line1 = GLib.Markup.escape_text(snapshot.date_formatted);
46 if (snapshot.live) {
47 line1 = "<b>%s</b>".printf(line1);
48 }
49 title.label = line1;
50 info.append(title);
51
52 var meta = new Gtk.Label(build_meta_text());
53 meta.wrap = true;
54 meta.xalign = 0.0f;
55 meta.add_css_class("dim-label");
56 info.append(meta);
57
58 desc_entry = new Gtk.Entry();
59 desc_entry.placeholder_text = _("Comments");
60 desc_entry.text = snapshot.description ?? "";
61 desc_entry.sensitive = !snapshot.marked_for_deletion;
62 // Mostra il campo commento solo se ha contenuto o se esplicitamente visibile
63 desc_entry.visible = (snapshot.description != null && snapshot.description.length > 0);
64 desc_entry.changed.connect(() => {
65 if (snapshot.description != desc_entry.text) {
66 snapshot.description = desc_entry.text;
68 }
69 });
70 info.append(desc_entry);
71
72 // Mostra campo commento al click del checkbox
73 check.toggled.connect(() => {
74 if (check.active) {
75 desc_entry.visible = true;
76 } else if (snapshot.description == null || snapshot.description.length == 0) {
77 desc_entry.visible = false;
78 }
79 });
80
82 add_css_class("error");
83 }
84 }
string build_meta_text()
Gtk.Entry desc_entry
Gtk.CheckButton check
string description
Definition Snapshot.vala:42
bool live
Definition Snapshot.vala:50
void update_control_file()
string date_formatted
Definition Snapshot.vala:95
bool marked_for_deletion
Definition Snapshot.vala:51

References _, build_meta_text(), check, Snapshot.date_formatted, desc_entry, Snapshot.description, Snapshot.live, Snapshot.marked_for_deletion, snapshot, and Snapshot.update_control_file().

Referenced by SnapshotRow().

Member Data Documentation

◆ check

Gtk.CheckButton SnapshotRow.check

Definition at line 14 of file SnapshotListBox.vala.

Referenced by build_ui().

◆ desc_entry

Gtk.Entry SnapshotRow.desc_entry
private

Definition at line 15 of file SnapshotListBox.vala.

Referenced by build_ui().

◆ snapshot

Snapshot SnapshotRow.snapshot

Definition at line 13 of file SnapshotListBox.vala.

Referenced by build_meta_text(), build_ui(), and SnapshotRow().


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