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

Public Member Functions

signal void delete_selected ()
signal void mark_selected ()
signal void browse_selected ()
signal void view_snapshot_log (bool show_restore_log)
 SnapshotListBox (Gtk.Window _parent_window)
void hide_context_menu ()
void refresh ()
Gee.ArrayList< Snapshot > selected_snapshots ()

Public Attributes

Gtk.ListBox treeview

Private Member Functions

void build_ui ()
void add_sort_button (string label, int column, bool default_desc)
void clear_rows ()

Private Attributes

Gtk.Window parent_window
Gtk.ListBox listbox
Gtk.ScrolledWindow scrolled
Gtk.Box header_actions
int sort_column_index = 0
bool sort_desc = true

Detailed Description

Definition at line 114 of file SnapshotListBox.vala.

Constructor & Destructor Documentation

◆ SnapshotListBox()

SnapshotListBox.SnapshotListBox ( Gtk.Window _parent_window)
inline

Definition at line 128 of file SnapshotListBox.vala.

128 {
129 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
130 parent_window = _parent_window;
131 margin_top = 6;
132 margin_bottom = 6;
133 margin_start = 6;
134 margin_end = 6;
135 build_ui();
136 refresh();
137 }

References build_ui(), parent_window, and refresh().

Referenced by DeleteWindow.DeleteWindow(), and MainWindow.init_snapshots_page().

Member Function Documentation

◆ add_sort_button()

void SnapshotListBox.add_sort_button ( string label,
int column,
bool default_desc )
inlineprivate

Definition at line 200 of file SnapshotListBox.vala.

200 {
201 var btn = new Gtk.Button.with_label(label);
202 btn.clicked.connect(() => {
203 if (sort_column_index == column) {
205 } else {
206 sort_column_index = column;
207 sort_desc = default_desc;
208 }
209 refresh();
210 });
211 header_actions.append(btn);
212 }

References header_actions, refresh(), sort_column_index, and sort_desc.

Referenced by build_ui().

◆ browse_selected()

signal void SnapshotListBox.browse_selected ( )

◆ build_ui()

void SnapshotListBox.build_ui ( )
inlineprivate

Definition at line 139 of file SnapshotListBox.vala.

139 {
140 header_actions = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
141 header_actions.halign = Gtk.Align.END;
142 append(header_actions);
143
144 add_sort_button(_("Newest"), 0, true);
145 add_sort_button(_("System"), 1, false);
146 add_sort_button(_("Tags"), 2, false);
147
148 listbox = new Gtk.ListBox();
149 listbox.selection_mode = Gtk.SelectionMode.NONE;
150 listbox.add_css_class("boxed-list");
151 listbox.row_activated.connect((row) => {
152 var snap_row = row as SnapshotRow;
153 if (snap_row != null) {
154 snap_row.check.active = !snap_row.check.active;
155 }
156 });
158
159 scrolled = new Gtk.ScrolledWindow();
160 scrolled.set_child(listbox);
161 scrolled.vexpand = false;
162 scrolled.hexpand = true;
163 scrolled.set_min_content_height(100);
164 scrolled.set_max_content_height(160);
165 scrolled.set_propagate_natural_height(true);
166 append(scrolled);
167
168 var footer = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
169 footer.halign = Gtk.Align.END;
170 append(footer);
171
172 var btn_browse = new Gtk.Button.with_label(_("Browse Files"));
173 btn_browse.add_css_class("btn-info");
174 btn_browse.clicked.connect(() => { browse_selected(); });
175 footer.append(btn_browse);
176
177 var btn_log_create = new Gtk.Button.with_label(_("Rsync Log (Create)"));
178 btn_log_create.sensitive = !App.btrfs_mode;
179 btn_log_create.add_css_class("btn-primary");
180 btn_log_create.clicked.connect(() => { view_snapshot_log(false); });
181 footer.append(btn_log_create);
182
183 var btn_log_restore = new Gtk.Button.with_label(_("Rsync Log (Restore)"));
184 btn_log_restore.sensitive = !App.btrfs_mode;
185 btn_log_restore.add_css_class("btn-primary");
186 btn_log_restore.clicked.connect(() => { view_snapshot_log(true); });
187 footer.append(btn_log_restore);
188
189 var btn_mark = new Gtk.Button.with_label(_("Mark/Unmark"));
190 btn_mark.add_css_class("btn-warning");
191 btn_mark.clicked.connect(() => { mark_selected(); });
192 footer.append(btn_mark);
193
194 var btn_delete = new Gtk.Button.with_label(_("Delete"));
195 btn_delete.add_css_class("btn-danger");
196 btn_delete.clicked.connect(() => { delete_selected(); });
197 footer.append(btn_delete);
198 }
Main App
#define _(s)
bool btrfs_mode
Definition Main.vala:52
Gtk.ScrolledWindow scrolled
signal void browse_selected()
void add_sort_button(string label, int column, bool default_desc)
signal void view_snapshot_log(bool show_restore_log)
signal void mark_selected()
signal void delete_selected()

References _, add_sort_button(), App, browse_selected(), Main.btrfs_mode, delete_selected(), header_actions, listbox, mark_selected(), scrolled, treeview, and view_snapshot_log().

Referenced by SnapshotListBox().

◆ clear_rows()

void SnapshotListBox.clear_rows ( )
inlineprivate

Definition at line 218 of file SnapshotListBox.vala.

218 {
219 Gtk.Widget? child = listbox.get_first_child();
220 while (child != null) {
221 Gtk.Widget? next = child.get_next_sibling();
222 listbox.remove(child);
223 child = next;
224 }
225 }

References listbox.

Referenced by refresh().

◆ delete_selected()

signal void SnapshotListBox.delete_selected ( )

◆ hide_context_menu()

void SnapshotListBox.hide_context_menu ( )
inline

Definition at line 214 of file SnapshotListBox.vala.

214 {
215 // no-op in GTK4 list implementation
216 }

Referenced by DeleteWindow.DeleteWindow().

◆ mark_selected()

signal void SnapshotListBox.mark_selected ( )

◆ refresh()

void SnapshotListBox.refresh ( )
inline

Definition at line 227 of file SnapshotListBox.vala.

227 {
228 clear_rows();
229 if ((App.repo == null) || !App.repo.available()) {
230 return;
231 }
232
234 var list = App.repo.snapshots;
235
236 if (sort_column_index == 0) {
237 if (sort_desc) {
238 list.sort((a,b) => ((Snapshot)a).date.compare(((Snapshot)b).date));
239 } else {
240 list.sort((a,b) => -1 * (((Snapshot)a).date.compare(((Snapshot)b).date)));
241 }
242 } else if (sort_column_index == 1) {
243 if (sort_desc) {
244 list.sort((a,b) => strcmp(((Snapshot)b).sys_distro, ((Snapshot)a).sys_distro));
245 } else {
246 list.sort((a,b) => strcmp(((Snapshot)a).sys_distro, ((Snapshot)b).sys_distro));
247 }
248 } else {
249 if (sort_desc) {
250 list.sort((a,b) => strcmp(((Snapshot)b).taglist, ((Snapshot)a).taglist));
251 } else {
252 list.sort((a,b) => strcmp(((Snapshot)a).taglist, ((Snapshot)b).taglist));
253 }
254 }
255
256 foreach (Snapshot bak in list) {
257 listbox.append(new SnapshotRow(bak));
258 }
259 }
SnapshotRepo repo
Definition Main.vala:70
Gee.ArrayList< Snapshot?> snapshots
bool load_snapshots()
SnapshotRow(Snapshot bak)

References App, SnapshotRepo.available(), clear_rows(), listbox, SnapshotRepo.load_snapshots(), Main.repo, SnapshotRow.SnapshotRow(), SnapshotRepo.snapshots, sort_column_index, and sort_desc.

Referenced by add_sort_button(), DeleteWindow.initialize_tab(), MainWindow.mark_selected(), MainWindow.refresh_all(), and SnapshotListBox().

◆ selected_snapshots()

Gee.ArrayList< Snapshot > SnapshotListBox.selected_snapshots ( )
inline

Definition at line 261 of file SnapshotListBox.vala.

261 {
262 var list = new Gee.ArrayList<Snapshot>();
263 Gtk.Widget? child = listbox.get_first_child();
264 while (child != null) {
265 var row = child as SnapshotRow;
266 if ((row != null) && row.check.active) {
267 list.add(row.snapshot);
268 }
269 child = child.get_next_sibling();
270 }
271 return list;
272 }

References listbox.

Referenced by MainWindow.browse_selected(), MainWindow.delete_selected(), DeleteWindow.go_next(), MainWindow.mark_selected(), MainWindow.restore(), DeleteWindow.validate_current_tab(), and MainWindow.view_snapshot_log().

◆ view_snapshot_log()

signal void SnapshotListBox.view_snapshot_log ( bool show_restore_log)

Member Data Documentation

◆ header_actions

Gtk.Box SnapshotListBox.header_actions
private

Definition at line 119 of file SnapshotListBox.vala.

Referenced by add_sort_button(), and build_ui().

◆ listbox

Gtk.ListBox SnapshotListBox.listbox
private

Definition at line 117 of file SnapshotListBox.vala.

Referenced by build_ui(), clear_rows(), refresh(), and selected_snapshots().

◆ parent_window

Gtk.Window SnapshotListBox.parent_window
private

Definition at line 116 of file SnapshotListBox.vala.

Referenced by SnapshotListBox().

◆ scrolled

Gtk.ScrolledWindow SnapshotListBox.scrolled
private

Definition at line 118 of file SnapshotListBox.vala.

Referenced by build_ui().

◆ sort_column_index

int SnapshotListBox.sort_column_index = 0
private

Definition at line 120 of file SnapshotListBox.vala.

Referenced by add_sort_button(), and refresh().

◆ sort_desc

bool SnapshotListBox.sort_desc = true
private

Definition at line 121 of file SnapshotListBox.vala.

Referenced by add_sort_button(), and refresh().

◆ treeview

Gtk.ListBox SnapshotListBox.treeview

Definition at line 115 of file SnapshotListBox.vala.

Referenced by build_ui().


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