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

Public Member Functions

 BackupBox (Gtk.Window _parent_window)
void pause ()
void resume ()
bool take_snapshot ()

Public Attributes

Gtk.Label lbl_msg
Gtk.Label lbl_status
Gtk.Label lbl_remaining
Gtk.ProgressBar progressbar
Gtk.Label lbl_unchanged
Gtk.Label lbl_created
Gtk.Label lbl_deleted
Gtk.Label lbl_modified
Gtk.Label lbl_checksum
Gtk.Label lbl_size
Gtk.Label lbl_timestamp
Gtk.Label lbl_permissions
Gtk.Label lbl_owner
Gtk.Label lbl_group

Private Member Functions

void add_progress_area ()
Gtk.Label add_count_label (Gtk.Box box, string text, ref Gtk.SizeGroup? sg_label, ref Gtk.SizeGroup? sg_value, int add_margin_bottom=0)
void take_snapshot_thread ()

Private Attributes

Gtk.Box details_box
Gtk.Spinner spinner
Gtk.Window parent_window
bool thread_is_running = false
bool thread_status_success = false

Detailed Description

Definition at line 39 of file BackupBox.vala.

Constructor & Destructor Documentation

◆ BackupBox()

BackupBox.BackupBox ( Gtk.Window _parent_window)
inline

Definition at line 62 of file BackupBox.vala.

62 {
63
64 log_debug("BackupBox: BackupBox()");
65
66 //base(Gtk.Orientation.VERTICAL, 6); // issue with vala
67 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6); // work-around
68 parent_window = _parent_window;
69 margin_top = 12;
70 margin_bottom = 12;
71 margin_start = 12;
72 margin_end = 12;
73
74 add_label_header(this, _("Creating Snapshot..."), true);
75
77
78 // add count labels ---------------------------------
79
80 Gtk.SizeGroup sg_label = null;
81 Gtk.SizeGroup sg_value = null;
82
83 details_box = new Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6);
84 append(details_box);
85
86 var label = add_label(details_box, _("File and directory counts:"), true);
87 label.margin_bottom = 6;
88 label.margin_top = 12;
89
90 lbl_unchanged = add_count_label(details_box, _("No Change"), ref sg_label, ref sg_value);
91 lbl_created = add_count_label(details_box, _("Created"), ref sg_label, ref sg_value);
92 lbl_deleted = add_count_label(details_box, _("Deleted"), ref sg_label, ref sg_value);
93 lbl_modified = add_count_label(details_box, _("Changed"), ref sg_label, ref sg_value, 12);
94
95 label = add_label(details_box, _("Changed items:"), true);
96 label.margin_bottom = 6;
97
98 lbl_checksum = add_count_label(details_box, _("Checksum"), ref sg_label, ref sg_value);
99 lbl_size = add_count_label(details_box, _("Size"), ref sg_label, ref sg_value);
100 lbl_timestamp = add_count_label(details_box, _("Timestamp"), ref sg_label, ref sg_value);
101 lbl_permissions = add_count_label(details_box, _("Permissions"), ref sg_label, ref sg_value);
102 lbl_owner = add_count_label(details_box, _("Owner"), ref sg_label, ref sg_value);
103 lbl_group = add_count_label(details_box, _("Group"), ref sg_label, ref sg_value, 24);
104
105 lbl_deleted.sensitive = false;
106
107 log_debug("BackupBox: BackupBox(): exit");
108 }
#define _(s)
Gtk.Label lbl_unchanged
Gtk.Label lbl_size
Gtk.Window parent_window
Gtk.Label lbl_deleted
void add_progress_area()
Gtk.Label lbl_checksum
Gtk.Box details_box
Gtk.Label lbl_modified
Gtk.Label lbl_created
Gtk.Label add_count_label(Gtk.Box box, string text, ref Gtk.SizeGroup? sg_label, ref Gtk.SizeGroup? sg_value, int add_margin_bottom=0)
Gtk.Label lbl_owner
Gtk.Label lbl_permissions
Gtk.Label lbl_group
Gtk.Label lbl_timestamp
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)
void log_debug(string message)

References _, add_count_label(), TeeJee.GtkHelper.add_label(), add_progress_area(), details_box, lbl_checksum, lbl_created, lbl_deleted, lbl_group, lbl_modified, lbl_owner, lbl_permissions, lbl_size, lbl_timestamp, lbl_unchanged, TeeJee.Logging.log_debug(), and parent_window.

Referenced by BackupWindow.build_pages().

Member Function Documentation

◆ add_count_label()

Gtk.Label BackupBox.add_count_label ( Gtk.Box box,
string text,
ref Gtk.SizeGroup? sg_label,
ref Gtk.SizeGroup? sg_value,
int add_margin_bottom = 0 )
inlineprivate

Definition at line 148 of file BackupBox.vala.

150 {
151
152 var hbox = new Gtk.Box(Orientation.HORIZONTAL, 6);
153 box.append(hbox);
154
155 var label = add_label(hbox, text + ":");
156 label.xalign = (float) 1.0;
157 label.margin_start = 12;
158 label.margin_end = 6;
159 var text_label = label;
160
161 if (add_margin_bottom > 0){
162 label.margin_bottom = add_margin_bottom;
163 }
164
165 // add to size group
166 if (sg_label == null){
167 sg_label = new Gtk.SizeGroup(SizeGroupMode.HORIZONTAL);
168 }
169 sg_label.add_widget(label);
170
171 label = add_label(hbox, "");
172 label.xalign = (float) 0.0;
173
174 if (add_margin_bottom > 0){
175 label.margin_bottom = add_margin_bottom;
176 }
177
178 // add to size group
179 if (sg_value == null){
180 sg_value = new Gtk.SizeGroup(SizeGroupMode.HORIZONTAL);
181 }
182 sg_value.add_widget(label);
183
184 label.notify["sensitive"].connect(()=>{
185 text_label.sensitive = label.sensitive;
186 });
187
188 return label;
189 }

References TeeJee.GtkHelper.add_label().

Referenced by BackupBox().

◆ add_progress_area()

void BackupBox.add_progress_area ( )
inlineprivate

Definition at line 110 of file BackupBox.vala.

110 {
111
112 var hbox_status = new Gtk.Box(Orientation.HORIZONTAL, 6);
113 append(hbox_status);
114
115 spinner = new Gtk.Spinner();
116 spinner.start();
117 hbox_status.append(spinner);
118
119 //lbl_msg
120 lbl_msg = add_label(hbox_status, _("Preparing..."));
121 lbl_msg.hexpand = true;
122 lbl_msg.ellipsize = Pango.EllipsizeMode.END;
123 lbl_msg.max_width_chars = 50;
124
125 lbl_remaining = add_label(hbox_status, "");
126
127 //progressbar
128 progressbar = new Gtk.ProgressBar();
129 append(progressbar);
130
131 //lbl_status
132 lbl_status = add_label(this, "");
133 lbl_status.ellipsize = Pango.EllipsizeMode.MIDDLE;
134 lbl_status.max_width_chars = 45;
135 lbl_status.margin_bottom = 6;
136 }
Gtk.Label lbl_remaining
Gtk.Label lbl_status
Gtk.Spinner spinner
Gtk.Label lbl_msg
Gtk.ProgressBar progressbar

References _, TeeJee.GtkHelper.add_label(), lbl_msg, lbl_remaining, lbl_status, progressbar, and spinner.

Referenced by BackupBox().

◆ pause()

void BackupBox.pause ( )
inline

Definition at line 138 of file BackupBox.vala.

138 {
139 this.spinner.stop();
140 this.lbl_msg.set_label(_("Paused"));
141 }

References _.

Referenced by BackupWindow.create_actions().

◆ resume()

void BackupBox.resume ( )
inline

Definition at line 143 of file BackupBox.vala.

143 {
144 this.spinner.start();
145 this.lbl_msg.set_label("");
146 }

Referenced by BackupWindow.create_actions().

◆ take_snapshot()

bool BackupBox.take_snapshot ( )
inline

Definition at line 191 of file BackupBox.vala.

191 {
192
193 try {
194 thread_is_running = true;
195 new Thread<void>.try ("snapshot-taker", () => {take_snapshot_thread();});
196 }
197 catch (Error e) {
198 log_error (e.message);
199 return false;
200 }
201
202 if (App.btrfs_mode){
203
204 while (thread_is_running){
205
207 sleep(200);
208
209 #if XAPP
210 XApp.set_window_progress_pulse(parent_window, true);
211 #endif
212 }
213
214 #if XAPP
215 XApp.set_window_progress_pulse(parent_window, false);
216 #endif
217 }
218 else{
219
220 //string last_message = "";
221 int wait_interval_millis = 100;
222 int status_line_counter = 0;
223 int status_line_counter_default = 1000 / wait_interval_millis;
224 string status_line = "";
225 string last_status_line = "";
226 int remaining_counter = 10;
227
228 while (thread_is_running){
229 string task_status_line;
230 double fraction;
231 string task_stat_time_remaining;
232
233 bool checking = App.space_check_task != null;
234
235 details_box.visible = !checking;
236
237 if (checking)
238 {
239 task_status_line = App.space_check_task.status_line;
240 fraction = App.space_check_task.progress;
241 task_stat_time_remaining = App.space_check_task.stat_time_remaining;
242 }
243 else
244 {
245 task_status_line = App.task.status_line;
246 fraction = App.task.progress;
247 task_stat_time_remaining = App.task.stat_time_remaining;
248 }
249
250 status_line = escape_html(task_status_line);
251 if (status_line != last_status_line){
252 lbl_status.label = status_line;
253 last_status_line = status_line;
254 status_line_counter = status_line_counter_default;
255 }
256 else{
257 status_line_counter--;
258 if (status_line_counter < 0){
259 status_line_counter = status_line_counter_default;
260 lbl_status.label = "";
261 }
262 }
263
264 // time remaining
265 remaining_counter--;
266 if (remaining_counter == 0){
267 lbl_remaining.label =
268 task_stat_time_remaining + " " + _("remaining");
269
270 remaining_counter = 10;
271 }
272
273 if (fraction < 0.99){
274 progressbar.fraction = fraction;
275 #if XAPP
276 XApp.set_window_progress(parent_window, (int)(fraction * 100.0));
277 #endif
278 }
279
280 if(App.task.status == AppStatus.PAUSED) {
281 lbl_msg.label = _("Paused");
282 } else {
283 lbl_msg.label = escape_html(App.progress_text);
284 }
285
286 if (!checking)
287 {
288 lbl_unchanged.label = "%'d".printf(App.task.count_unchanged);
289 lbl_created.label = "%'d".printf(App.task.count_created);
290 lbl_deleted.label = "%'d".printf(App.task.count_deleted);
291 lbl_modified.label = "%'d".printf(App.task.count_modified);
292 lbl_checksum.label = "%'d".printf(App.task.count_checksum);
293 lbl_size.label = "%'d".printf(App.task.count_size);
294 lbl_timestamp.label = "%'d".printf(App.task.count_timestamp);
295 lbl_permissions.label = "%'d".printf(App.task.count_permissions);
296 lbl_owner.label = "%'d".printf(App.task.count_owner);
297 lbl_group.label = "%'d".printf(App.task.count_group);
298 }
299
301
302 sleep(100);
303 //gtk_do_events();
304 }
305
306 #if XAPP
307 XApp.set_window_progress(parent_window, 0);
308 #endif
309 }
310
312
313 //TODO: low: check if snapshot was created successfully.
314 }
Main App
AppStatus
string??? stat_time_remaining
AppStatus status
double progress
string status_line
bool thread_is_running
void take_snapshot_thread()
bool thread_status_success
string progress_text
Definition Main.vala:156
RsyncTask task
Definition Main.vala:160
bool btrfs_mode
Definition Main.vala:52
RsyncSpaceCheckTask space_check_task
Definition Main.vala:162
int64 count_group
int64 count_deleted
int64 count_owner
int64 count_modified
int64 count_permissions
int64 count_size
int64 count_created
int64 count_timestamp
int64 count_unchanged
int64 count_checksum
void log_error(string message, bool highlight=false, bool is_warning=false)
string escape_html(string html)
void sleep(int milliseconds)

References _, App, Main.btrfs_mode, RsyncTask.count_checksum, RsyncTask.count_created, RsyncTask.count_deleted, RsyncTask.count_group, RsyncTask.count_modified, RsyncTask.count_owner, RsyncTask.count_permissions, RsyncTask.count_size, RsyncTask.count_timestamp, RsyncTask.count_unchanged, Error, TeeJee.Misc.escape_html(), TeeJee.GtkHelper.gtk_do_events(), TeeJee.Logging.log_error(), parent_window, AsyncTask.progress, Main.progress_text, TeeJee.System.sleep(), Main.space_check_task, AsyncTask.stat_time_remaining, AsyncTask.status, AsyncTask.status_line, take_snapshot_thread(), Main.task, thread_is_running, and thread_status_success.

Referenced by BackupWindow.initialize_tab().

◆ take_snapshot_thread()

void BackupBox.take_snapshot_thread ( )
inlineprivate

Definition at line 316 of file BackupBox.vala.

316 {
317
319 thread_is_running = false;
320 }
bool create_snapshot(bool is_ondemand, Gtk.Window? parent_win)
Definition Main.vala:1082

References App, Main.create_snapshot(), parent_window, thread_is_running, and thread_status_success.

Referenced by take_snapshot().

Member Data Documentation

◆ details_box

Gtk.Box BackupBox.details_box
private

Definition at line 40 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_checksum

Gtk.Label BackupBox.lbl_checksum

Definition at line 50 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_created

Gtk.Label BackupBox.lbl_created

Definition at line 47 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_deleted

Gtk.Label BackupBox.lbl_deleted

Definition at line 48 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_group

Gtk.Label BackupBox.lbl_group

Definition at line 55 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_modified

Gtk.Label BackupBox.lbl_modified

Definition at line 49 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_msg

Gtk.Label BackupBox.lbl_msg

Definition at line 42 of file BackupBox.vala.

Referenced by add_progress_area().

◆ lbl_owner

Gtk.Label BackupBox.lbl_owner

Definition at line 54 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_permissions

Gtk.Label BackupBox.lbl_permissions

Definition at line 53 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_remaining

Gtk.Label BackupBox.lbl_remaining

Definition at line 44 of file BackupBox.vala.

Referenced by add_progress_area().

◆ lbl_size

Gtk.Label BackupBox.lbl_size

Definition at line 51 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_status

Gtk.Label BackupBox.lbl_status

Definition at line 43 of file BackupBox.vala.

Referenced by add_progress_area().

◆ lbl_timestamp

Gtk.Label BackupBox.lbl_timestamp

Definition at line 52 of file BackupBox.vala.

Referenced by BackupBox().

◆ lbl_unchanged

Gtk.Label BackupBox.lbl_unchanged

Definition at line 46 of file BackupBox.vala.

Referenced by BackupBox().

◆ parent_window

Gtk.Window BackupBox.parent_window
private

Definition at line 57 of file BackupBox.vala.

Referenced by BackupBox(), take_snapshot(), and take_snapshot_thread().

◆ progressbar

Gtk.ProgressBar BackupBox.progressbar

Definition at line 45 of file BackupBox.vala.

Referenced by add_progress_area().

◆ spinner

Gtk.Spinner BackupBox.spinner
private

Definition at line 41 of file BackupBox.vala.

Referenced by add_progress_area().

◆ thread_is_running

bool BackupBox.thread_is_running = false
private

Definition at line 59 of file BackupBox.vala.

Referenced by take_snapshot(), and take_snapshot_thread().

◆ thread_status_success

bool BackupBox.thread_status_success = false
private

Definition at line 60 of file BackupBox.vala.

Referenced by take_snapshot(), and take_snapshot_thread().


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