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

Public Member Functions

 RsyncLogBox (Gtk.Window _window)
void open_log (string _rsync_log_file)
bool init_delayed ()

Public Attributes

Gtk.Label lbl_header
Gtk.Label lbl_header_progress
Gtk.Label lbl_msg
Gtk.Label lbl_status
Gtk.Label lbl_remaining
Gtk.ProgressBar progressbar

Properties

bool is_restore_log [get]
bool is_running [get]

Private Member Functions

void parse_log_file ()
void parse_log_file_thread ()
void create_progressbar ()
void create_filters ()
void add_search_entry (Gtk.Box hbox)
void add_combo (Gtk.Box hbox)
void create_listview ()
string display_status (FileItem item)
string relpath_for (FileItem item)
bool item_matches (FileItem item)
Gtk.Widget create_log_row (FileItem item)
void clear_rows ()
void refresh_rows ()
void apply_filters ()

Private Attributes

Gtk.Box vbox_progress
Gtk.Box vbox_list
Gtk.ComboBoxText cmb_filter
Gtk.Box hbox_filter
Gtk.Entry txt_pattern
Gtk.ListBox listbox
string name_filter = ""
string status_filter = ""
Gtk.Spinner spinner
uint tmr_init = 0
bool thread_is_running = false
string rsync_log_file
Gee.ArrayList< FileItem > loglist
Gtk.Window window

Detailed Description

Definition at line 16 of file RsyncLogBox.vala.

Constructor & Destructor Documentation

◆ RsyncLogBox()

RsyncLogBox.RsyncLogBox ( Gtk.Window _window)
inline

Definition at line 42 of file RsyncLogBox.vala.

42 {
43 GLib.Object(orientation: Gtk.Orientation.VERTICAL, spacing: 6);
44 this.margin_start = 6;
45 this.margin_end = 6;
46 this.margin_top = 6;
47 this.margin_bottom = 6;
48 window = _window;
49 log_debug("RsyncLogBox: RsyncLogBox()");
50 }
Gtk.Window window
void log_debug(string message)

References TeeJee.Logging.log_debug(), and window.

Referenced by RestoreWindow.build_pages(), and RsyncLogWindow.RsyncLogWindow().

Member Function Documentation

◆ add_combo()

void RsyncLogBox.add_combo ( Gtk.Box hbox)
inlineprivate

Definition at line 171 of file RsyncLogBox.vala.

171 {
172 cmb_filter = new Gtk.ComboBoxText();
173 hbox.append(cmb_filter);
174 cmb_filter.append("", _("All Files"));
175 cmb_filter.append("created", "%s".printf(App.dry_run ? _("Create") : _("Created")));
176 if (is_restore_log){
177 cmb_filter.append("deleted", "%s".printf(App.dry_run ? _("Delete") : _("Deleted")));
178 }
179 cmb_filter.append("changed", "%s".printf(App.dry_run ? _("Restore") : _("Changed")));
180 if (!App.dry_run){
181 cmb_filter.append("checksum", " └ %s".printf(_("Checksum")));
182 cmb_filter.append("size", " └ %s".printf(_("Size")));
183 cmb_filter.append("timestamp", " └ %s".printf(_("Timestamp")));
184 cmb_filter.append("permissions", " └ %s".printf(_("Permissions")));
185 cmb_filter.append("owner", " └ %s".printf(_("Owner")));
186 cmb_filter.append("group", " └ %s".printf(_("Group")));
187 }
188 cmb_filter.set_active_id("");
189 }
Main App
#define _(s)
bool dry_run
Definition Main.vala:100
Gtk.ComboBoxText cmb_filter
bool is_restore_log

References _, App, cmb_filter, Main.dry_run, and is_restore_log.

Referenced by create_filters().

◆ add_search_entry()

void RsyncLogBox.add_search_entry ( Gtk.Box hbox)
inlineprivate

Definition at line 162 of file RsyncLogBox.vala.

162 {
163 var txt = new Gtk.Entry();
164 txt.hexpand = true;
165 txt.placeholder_text = _("Filter by name or path");
166 hbox.append(txt);
167 txt_pattern = txt;
168 txt.changed.connect(()=>{ name_filter = txt.text.down(); apply_filters(); });
169 }
string name_filter
void apply_filters()
Gtk.Entry txt_pattern

References _, apply_filters(), name_filter, and txt_pattern.

Referenced by create_filters().

◆ apply_filters()

void RsyncLogBox.apply_filters ( )
inlineprivate

Definition at line 326 of file RsyncLogBox.vala.

326 {
327 status_filter = cmb_filter.get_active_id() ?? "";
328 name_filter = txt_pattern.text.down();
329 refresh_rows();
330 }
string status_filter
void refresh_rows()

References cmb_filter, name_filter, refresh_rows(), status_filter, and txt_pattern.

Referenced by add_search_entry(), and open_log().

◆ clear_rows()

void RsyncLogBox.clear_rows ( )
inlineprivate

Definition at line 303 of file RsyncLogBox.vala.

303 {
304 Gtk.Widget? child = listbox.get_first_child();
305 while (child != null){
306 Gtk.Widget? next = child.get_next_sibling();
307 listbox.remove(child);
308 child = next;
309 }
310 }
Gtk.ListBox listbox

References listbox.

Referenced by refresh_rows().

◆ create_filters()

void RsyncLogBox.create_filters ( )
inlineprivate

Definition at line 144 of file RsyncLogBox.vala.

144 {
145 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
146 hbox.visible = false;
147 append(hbox);
148 hbox_filter = hbox;
149 add_search_entry(hbox);
150 add_combo(hbox);
151
152 if (!App.dry_run){
153 var label = add_label(hbox, "");
154 label.hexpand = true;
155 var button = new Gtk.Button.with_label(_("Close"));
156 button.get_style_context().add_class("btn-cancel");
157 hbox.append(button);
158 button.clicked.connect(()=>{ window.destroy(); });
159 }
160 }
Gtk.Box hbox_filter
void add_search_entry(Gtk.Box hbox)
void add_combo(Gtk.Box hbox)
Gtk.Label add_label(Gtk.Box box, string text, bool bold=false, bool italic=false, bool large=false)

References _, add_combo(), TeeJee.GtkHelper.add_label(), add_search_entry(), App, Main.dry_run, hbox_filter, and window.

Referenced by open_log().

◆ create_listview()

void RsyncLogBox.create_listview ( )
inlineprivate

Definition at line 191 of file RsyncLogBox.vala.

191 {
192 vbox_list = new Gtk.Box(Orientation.VERTICAL, 6);
193 vbox_list.visible = false;
194 append(vbox_list);
195 listbox = new Gtk.ListBox();
196 listbox.selection_mode = Gtk.SelectionMode.NONE;
197 listbox.add_css_class("boxed-list");
198 var scrolled = new Gtk.ScrolledWindow();
199 scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
200 scrolled.vexpand = true;
201 scrolled.set_child(listbox);
202 vbox_list.append(scrolled);
203 }
Gtk.Box vbox_list

References listbox, and vbox_list.

Referenced by open_log().

◆ create_log_row()

Gtk.Widget RsyncLogBox.create_log_row ( FileItem item)
inlineprivate

Definition at line 273 of file RsyncLogBox.vala.

273 {
274 var row = new Gtk.ListBoxRow();
275 var outer = new Gtk.Box(Gtk.Orientation.VERTICAL, 4);
276 outer.margin_start = 8;
277 outer.margin_end = 8;
278 outer.margin_top = 8;
279 outer.margin_bottom = 8;
280 row.set_child(outer);
281
282 var top = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
283 outer.append(top);
284
285 var image = new Gtk.Image.from_pixbuf(item.get_icon(16, false, false));
286 top.append(image);
287
288 var status = new Gtk.Label(display_status(item));
289 status.xalign = 0.0f;
290 status.add_css_class("accent");
291 status.width_chars = 12;
292 top.append(status);
293
294 var path = new Gtk.Label(relpath_for(item));
295 path.xalign = 0.0f;
296 path.hexpand = true;
297 path.wrap = true;
298 top.append(path);
299
300 return row;
301 }
Gdk.? Pixbuf get_icon(int icon_size, bool add_transparency, bool add_emblems)
string display_status(FileItem item)
string relpath_for(FileItem item)

References display_status(), FileItem.get_icon(), and relpath_for().

Referenced by refresh_rows().

◆ create_progressbar()

void RsyncLogBox.create_progressbar ( )
inlineprivate

Definition at line 127 of file RsyncLogBox.vala.

127 {
128 vbox_progress = new Gtk.Box(Orientation.VERTICAL, 6);
129 append(vbox_progress);
130 lbl_header_progress = add_label_header(vbox_progress, _("Parsing log file..."), true);
131 var hbox_status = new Gtk.Box(Orientation.HORIZONTAL, 6);
132 vbox_progress.append(hbox_status);
133 spinner = new Gtk.Spinner();
134 spinner.spinning = true;
135 hbox_status.append(spinner);
136 lbl_msg = add_label(hbox_status, _("Preparing..."));
137 lbl_msg.hexpand = true;
138 lbl_msg.ellipsize = Pango.EllipsizeMode.END;
139 lbl_msg.max_width_chars = 50;
140 progressbar = new Gtk.ProgressBar();
142 }
Gtk.Label lbl_header_progress
Gtk.Box vbox_progress
Gtk.ProgressBar progressbar
Gtk.Spinner spinner
Gtk.Label lbl_msg

References _, TeeJee.GtkHelper.add_label(), lbl_header_progress, lbl_msg, progressbar, spinner, and vbox_progress.

Referenced by open_log().

◆ display_status()

string RsyncLogBox.display_status ( FileItem item)
inlineprivate

Definition at line 205 of file RsyncLogBox.vala.

205 {
206 if (is_restore_log){
207 switch(item.file_status){
208 case "checksum":
209 case "size":
210 case "timestamp":
211 case "permissions":
212 case "owner":
213 case "group":
214 return App.dry_run ? _("Restore") : _("Changed");
215 case "created":
216 return App.dry_run ? _("Create") : _("Created");
217 case "deleted":
218 return App.dry_run ? _("Delete") : _("Deleted");
219 default:
220 return item.file_status;
221 }
222 }
223 switch(item.file_status){
224 case "checksum":
225 case "size":
226 case "timestamp":
227 case "permissions":
228 case "owner":
229 case "group":
230 return _("Changed");
231 case "created":
232 return _("Created");
233 case "deleted":
234 return _("Deleted");
235 default:
236 return item.file_status;
237 }
238 }
string file_status
Definition FileItem.vala:49

References _, FileItem.file_status, and is_restore_log.

Referenced by create_log_row().

◆ init_delayed()

bool RsyncLogBox.init_delayed ( )
inline

Definition at line 78 of file RsyncLogBox.vala.

78 {
79 if (tmr_init > 0){
80 Source.remove(tmr_init);
81 tmr_init = 0;
82 }
84 if (App.dry_run && (lbl_header != null)){
85 lbl_header.visible = true;
86 }
87 return false;
88 }
void parse_log_file()
Gtk.Label lbl_header

References App, Main.dry_run, lbl_header, parse_log_file(), and tmr_init.

Referenced by open_log().

◆ item_matches()

bool RsyncLogBox.item_matches ( FileItem item)
inlineprivate

Definition at line 249 of file RsyncLogBox.vala.

249 {
250 string relpath = relpath_for(item).down();
251 if ((name_filter.length > 0) && !relpath.contains(name_filter)){
252 return false;
253 }
254 if (status_filter.length == 0){
255 return true;
256 }
257 if (status_filter == "changed"){
258 switch(item.file_status){
259 case "checksum":
260 case "size":
261 case "timestamp":
262 case "permissions":
263 case "owner":
264 case "group":
265 return true;
266 default:
267 return false;
268 }
269 }
270 return item.file_status == status_filter;
271 }

References FileItem.file_status, name_filter, relpath_for(), and status_filter.

Referenced by refresh_rows().

◆ open_log()

void RsyncLogBox.open_log ( string _rsync_log_file)
inline

Definition at line 52 of file RsyncLogBox.vala.

52 {
53 rsync_log_file = _rsync_log_file;
54 if (App.dry_run){
55 lbl_header = add_label_header(this, _("Confirm Actions"), true);
56 lbl_header.visible = false;
57 }
61
62 cmb_filter.changed.connect(() => {
63 status_filter = cmb_filter.get_active_id() ?? "";
65 });
66
67 show();
68 tmr_init = Timeout.add(100, init_delayed);
69 log_debug("RsyncLogWindow: open_log(): exit");
70 }
string rsync_log_file
void create_listview()
void create_progressbar()
bool init_delayed()
void create_filters()

References _, App, apply_filters(), cmb_filter, create_filters(), create_listview(), create_progressbar(), Main.dry_run, init_delayed(), lbl_header, TeeJee.Logging.log_debug(), rsync_log_file, status_filter, and tmr_init.

Referenced by RestoreWindow.initialize_tab(), and RsyncLogWindow.RsyncLogWindow().

◆ parse_log_file()

void RsyncLogBox.parse_log_file ( )
inlineprivate

Definition at line 90 of file RsyncLogBox.vala.

90 {
91 try {
92 thread_is_running = true;
93 new Thread<void>.try ("log-file-parser", () => {parse_log_file_thread();});
94 }
95 catch (Error e) {
96 log_error (e.message);
97 }
98
99 while (thread_is_running){
100 double fraction = (App.task.prg_count_total > 0) ? ((App.task.prg_count * 1.0) / App.task.prg_count_total) : 0.0;
101 if (fraction < 0.99){
102 progressbar.fraction = fraction;
103 }
104 lbl_msg.label = _("Read %'d of %'d lines...").printf(App.task.prg_count, App.task.prg_count_total);
105 sleep(500);
107 }
108
109 lbl_msg.label = _("Populating list...");
111 refresh_rows();
112 vbox_progress.visible = false;
113 vbox_list.visible = true;
114 hbox_filter.visible = true;
115 }
int64 prg_count
int64 prg_count_total
RsyncTask task
Definition Main.vala:160
bool thread_is_running
void parse_log_file_thread()
void log_error(string message, bool highlight=false, bool is_warning=false)
void sleep(int milliseconds)

References _, App, Error, TeeJee.GtkHelper.gtk_do_events(), TeeJee.Logging.log_error(), parse_log_file_thread(), AsyncTask.prg_count, AsyncTask.prg_count_total, refresh_rows(), TeeJee.System.sleep(), Main.task, and thread_is_running.

Referenced by init_delayed().

◆ parse_log_file_thread()

void RsyncLogBox.parse_log_file_thread ( )
inlineprivate

Definition at line 117 of file RsyncLogBox.vala.

117 {
118 App.task = new RsyncTask();
120 thread_is_running = false;
121 }
Gee.ArrayList< FileItem > loglist
Gee.ArrayList< FileItem > parse_log(string log_file_path)

References App, loglist, RsyncTask.parse_log(), rsync_log_file, RsyncTask.RsyncTask(), Main.task, and thread_is_running.

Referenced by parse_log_file().

◆ refresh_rows()

void RsyncLogBox.refresh_rows ( )
inlineprivate

Definition at line 312 of file RsyncLogBox.vala.

312 {
313 clear_rows();
314 if (loglist == null){ return; }
315 foreach(var item in loglist) {
316 if (App.dry_run && (item.file_type == FileType.DIRECTORY)){
317 continue;
318 }
319 if (!item_matches(item)){
320 continue;
321 }
322 listbox.append(create_log_row(item));
323 }
324 }
Gtk.Widget create_log_row(FileItem item)
bool item_matches(FileItem item)
void clear_rows()

References App, clear_rows(), create_log_row(), Main.dry_run, item_matches(), listbox, and loglist.

Referenced by apply_filters(), and parse_log_file().

◆ relpath_for()

string RsyncLogBox.relpath_for ( FileItem item)
inlineprivate

Definition at line 240 of file RsyncLogBox.vala.

240 {
241 var spath = "%s/localhost".printf(file_parent(rsync_log_file));
242 var relpath = item.file_path[spath.length:item.file_path.length];
243 if (!is_restore_log){
244 relpath = relpath[1:relpath.length];
245 }
246 return relpath;
247 }
string file_path
Definition FileItem.vala:41
string file_parent(string file_path)

References TeeJee.FileSystem.file_parent(), FileItem.file_path, is_restore_log, and rsync_log_file.

Referenced by create_log_row(), and item_matches().

Member Data Documentation

◆ cmb_filter

Gtk.ComboBoxText RsyncLogBox.cmb_filter
private

Definition at line 19 of file RsyncLogBox.vala.

Referenced by add_combo(), apply_filters(), and open_log().

◆ hbox_filter

Gtk.Box RsyncLogBox.hbox_filter
private

Definition at line 20 of file RsyncLogBox.vala.

Referenced by create_filters().

◆ lbl_header

Gtk.Label RsyncLogBox.lbl_header

Definition at line 27 of file RsyncLogBox.vala.

Referenced by init_delayed(), and open_log().

◆ lbl_header_progress

Gtk.Label RsyncLogBox.lbl_header_progress

Definition at line 28 of file RsyncLogBox.vala.

Referenced by create_progressbar().

◆ lbl_msg

Gtk.Label RsyncLogBox.lbl_msg

Definition at line 30 of file RsyncLogBox.vala.

Referenced by create_progressbar().

◆ lbl_remaining

Gtk.Label RsyncLogBox.lbl_remaining

Definition at line 32 of file RsyncLogBox.vala.

◆ lbl_status

Gtk.Label RsyncLogBox.lbl_status

Definition at line 31 of file RsyncLogBox.vala.

◆ listbox

Gtk.ListBox RsyncLogBox.listbox
private

Definition at line 22 of file RsyncLogBox.vala.

Referenced by clear_rows(), create_listview(), and refresh_rows().

◆ loglist

Gee.ArrayList<FileItem> RsyncLogBox.loglist
private

Definition at line 39 of file RsyncLogBox.vala.

Referenced by parse_log_file_thread(), and refresh_rows().

◆ name_filter

string RsyncLogBox.name_filter = ""
private

Definition at line 24 of file RsyncLogBox.vala.

Referenced by add_search_entry(), apply_filters(), and item_matches().

◆ progressbar

Gtk.ProgressBar RsyncLogBox.progressbar

Definition at line 33 of file RsyncLogBox.vala.

Referenced by create_progressbar().

◆ rsync_log_file

string RsyncLogBox.rsync_log_file
private

Definition at line 38 of file RsyncLogBox.vala.

Referenced by open_log(), parse_log_file_thread(), and relpath_for().

◆ spinner

Gtk.Spinner RsyncLogBox.spinner
private

Definition at line 29 of file RsyncLogBox.vala.

Referenced by create_progressbar().

◆ status_filter

string RsyncLogBox.status_filter = ""
private

Definition at line 25 of file RsyncLogBox.vala.

Referenced by apply_filters(), item_matches(), and open_log().

◆ thread_is_running

bool RsyncLogBox.thread_is_running = false
private

Definition at line 36 of file RsyncLogBox.vala.

Referenced by parse_log_file(), and parse_log_file_thread().

◆ tmr_init

uint RsyncLogBox.tmr_init = 0
private

Definition at line 35 of file RsyncLogBox.vala.

Referenced by init_delayed(), and open_log().

◆ txt_pattern

Gtk.Entry RsyncLogBox.txt_pattern
private

Definition at line 21 of file RsyncLogBox.vala.

Referenced by add_search_entry(), and apply_filters().

◆ vbox_list

Gtk.Box RsyncLogBox.vbox_list
private

Definition at line 18 of file RsyncLogBox.vala.

Referenced by create_listview().

◆ vbox_progress

Gtk.Box RsyncLogBox.vbox_progress
private

Definition at line 17 of file RsyncLogBox.vala.

Referenced by create_progressbar().

◆ window

Gtk.Window RsyncLogBox.window
private

Definition at line 40 of file RsyncLogBox.vala.

Referenced by create_filters(), and RsyncLogBox().

Property Documentation

◆ is_restore_log

bool RsyncLogBox.is_restore_log
getprivate

Definition at line 72 of file RsyncLogBox.vala.

72 {
73 get {
74 return file_basename(rsync_log_file).contains("restore");
75 }
76 }
string file_basename(string file_path)

Referenced by add_combo(), display_status(), and relpath_for().

◆ is_running

bool RsyncLogBox.is_running
get

Definition at line 123 of file RsyncLogBox.vala.

123 {
124 get { return thread_is_running; }
125 }

Referenced by RsyncLogWindow.on_close_request().


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