diff options
author | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-17 19:41:40 +0200 |
---|---|---|
committer | Stefano Facchini <stefano.facchini@gmail.com> | 2020-06-30 16:01:22 +0200 |
commit | bca7df84d19c1803da2025668fe62f31f25e3772 (patch) | |
tree | 24b2cf850b5bcfd90228ff6d99ba1eee4e4d7f89 | |
parent | c7c204fc486619d337ca54c90419413841a76c28 (diff) | |
download | baobab-bca7df84d19c1803da2025668fe62f31f25e3772.tar.gz |
Split out a long anonymous function
-rw-r--r-- | src/baobab-window.vala | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/src/baobab-window.vala b/src/baobab-window.vala index a2a3f60..69b0c45 100644 --- a/src/baobab-window.vala +++ b/src/baobab-window.vala @@ -596,48 +596,52 @@ namespace Baobab { treemap_chart.location = location; } - void scan_active_location (bool force) { + void scanner_completed () { var scanner = active_location.scanner; - scan_completed_handler = scanner.completed.connect(() => { - if (scan_completed_handler > 0) { - scanner.disconnect (scan_completed_handler); - scan_completed_handler = 0; - } + if (scan_completed_handler > 0) { + scanner.disconnect (scan_completed_handler); + scan_completed_handler = 0; + } - try { - scanner.finish(); - } catch (IOError.CANCELLED e) { - // Handle cancellation silently - return; - } catch (Error e) { - Gtk.TreeIter iter; - Scanner.State state; - scanner.get_iter_first (out iter); - scanner.get (iter, Scanner.Columns.STATE, out state); - if (state == Scanner.State.ERROR) { - var primary = _("Could not scan folder “%s”").printf (scanner.directory.get_parse_name ()); - message (primary, e.message, Gtk.MessageType.ERROR); - } else { - var primary = _("Could not scan some of the folders contained in “%s”").printf (scanner.directory.get_parse_name ()); - message (primary, e.message, Gtk.MessageType.WARNING); - } + try { + scanner.finish(); + } catch (IOError.CANCELLED e) { + // Handle cancellation silently + return; + } catch (Error e) { + Gtk.TreeIter iter; + Scanner.State state; + scanner.get_iter_first (out iter); + scanner.get (iter, Scanner.Columns.STATE, out state); + if (state == Scanner.State.ERROR) { + var primary = _("Could not scan folder “%s”").printf (scanner.directory.get_parse_name ()); + message (primary, e.message, Gtk.MessageType.ERROR); + } else { + var primary = _("Could not scan some of the folders contained in “%s”").printf (scanner.directory.get_parse_name ()); + message (primary, e.message, Gtk.MessageType.WARNING); } + } - set_chart_location (active_location); + set_chart_location (active_location); - set_ui_state (result_page, false); + set_ui_state (result_page, false); - if (!scanner.show_allocated_size) { - message (_("Could not always detect occupied disk sizes."), _("Apparent sizes may be shown instead."), Gtk.MessageType.INFO); - } + if (!scanner.show_allocated_size) { + message (_("Could not always detect occupied disk sizes."), _("Apparent sizes may be shown instead."), Gtk.MessageType.INFO); + } - if (!is_active) { - var notification = new Notification(_("Scan completed")); - notification.set_body (_("Completed scan of “%s”").printf (scanner.directory.get_parse_name ())); - get_application ().send_notification ("scan-completed", notification); - } - }); + if (!is_active) { + var notification = new Notification(_("Scan completed")); + notification.set_body (_("Completed scan of “%s”").printf (scanner.directory.get_parse_name ())); + get_application ().send_notification ("scan-completed", notification); + } + } + + void scan_active_location (bool force) { + var scanner = active_location.scanner; + + scan_completed_handler = scanner.completed.connect (scanner_completed); clear_message (); set_ui_state (result_page, true); |