From c2df644c9fb525017ed1f2ffadff43128c925f41 Mon Sep 17 00:00:00 2001 From: Nikolay Brovko Date: Tue, 28 Jan 2020 04:39:53 +0300 Subject: [PATCH] remove tabs, empty whitespaced lines, unnecessary this keyword --- src/app-window.vala | 16 +++---- src/application.vala | 70 +++++++++++++++--------------- src/yggdrasil-service-openrc.vala | 38 ++++++++-------- src/yggdrasil-service-systemd.vala | 38 ++++++++-------- src/yggdrasil-service.vala | 2 +- 5 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/app-window.vala b/src/app-window.vala index 20a6358..fc1a48a 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -29,20 +29,20 @@ namespace Yggtk { [GtkChild] private Gtk.Button save_config_button; - [GtkCallback] - private bool on_service_state_switch_state_set (bool state) { - this.application.activate_action ("set-service-state", new Variant.boolean (state)); - return true; - } + [GtkCallback] + private bool on_service_state_switch_state_set (bool state) { + application.activate_action ("set-service-state", new Variant.boolean (state)); + return true; + } [GtkCallback] private void on_peer_ip_entry_changed () { save_config_button.visible = peer_ip_entry.text.length > 0; } - public void set_service_state (bool state) { - service_state_switch.set_state (state); - } + public void set_service_state (bool state) { + service_state_switch.set_state (state); + } public AppWindow (Gtk.Application application) { diff --git a/src/application.vala b/src/application.vala index bb156b2..f37c552 100644 --- a/src/application.vala +++ b/src/application.vala @@ -19,9 +19,9 @@ namespace Yggtk { public class Application : Gtk.Application { - private YggdrasilService yggdrasil_service = null; + private YggdrasilService yggdrasil_service = null; - private AppWindow window = null; + private AppWindow window = null; public Application () { Object ( @@ -54,44 +54,44 @@ namespace Yggtk { update_yggdrasil_action.activate.connect (update_yggdrasil); add_action (update_yggdrasil_action); - SimpleAction set_service_state_action = new SimpleAction ("set-service-state", VariantType.BOOLEAN); - set_service_state_action.activate.connect (set_service_state); - add_action (set_service_state_action); + SimpleAction set_service_state_action = new SimpleAction ("set-service-state", VariantType.BOOLEAN); + set_service_state_action.activate.connect (set_service_state); + add_action (set_service_state_action); SimpleAction browse_peers_action = new SimpleAction ("browse-peers", null); browse_peers_action.activate.connect (browse_peers); add_action (browse_peers_action); } - private void set_service_state (SimpleAction action, Variant? state) { - try { - if (yggdrasil_service.get_status () == state.get_boolean ()) { - return; - } + private void set_service_state (SimpleAction action, Variant? state) { + try { + if (yggdrasil_service.get_status () == state.get_boolean ()) { + return; + } - if (state.get_boolean ()) { - yggdrasil_service.start (); - } else { - yggdrasil_service.stop (); - } + if (state.get_boolean ()) { + yggdrasil_service.start (); + } else { + yggdrasil_service.stop (); + } - display_current_service_state (); - } catch (SpawnError e) { - stderr.printf ("Unable to change service state: %s\n", e.message); - } - } + display_current_service_state (); + } catch (SpawnError e) { + stderr.printf ("Unable to change service state: %s\n", e.message); + } + } - private bool display_current_service_state () { - try { - if (window != null) { - window.set_service_state (yggdrasil_service.get_status ()); - } - } catch (SpawnError e) { - stderr.printf ("Unable to get service state: %s\n", e.message); - } + private bool display_current_service_state () { + try { + if (window != null) { + window.set_service_state (yggdrasil_service.get_status ()); + } + } catch (SpawnError e) { + stderr.printf ("Unable to get service state: %s\n", e.message); + } - return true; - } + return true; + } private void update_yggtk () { try { @@ -142,11 +142,11 @@ namespace Yggtk { } protected override void activate () { - if (window == null) { - window = new AppWindow (this); - } - display_current_service_state (); - Timeout.add_seconds (1, display_current_service_state); + if (window == null) { + window = new AppWindow (this); + } + display_current_service_state (); + Timeout.add_seconds (1, display_current_service_state); window.show (); } diff --git a/src/yggdrasil-service-openrc.vala b/src/yggdrasil-service-openrc.vala index d4321b3..9956c3c 100644 --- a/src/yggdrasil-service-openrc.vala +++ b/src/yggdrasil-service-openrc.vala @@ -15,29 +15,29 @@ namespace Yggtk { - public class YggdrasilServiceOpenRC : Object, YggdrasilService { + public class YggdrasilServiceOpenRC : Object, YggdrasilService { - public bool get_status () throws SpawnError { - string cmd_stdout, cmd_stderr; - int cmd_status = -1; + public bool get_status () throws SpawnError { + string cmd_stdout, cmd_stderr; + int cmd_status = -1; - Process.spawn_command_line_sync ("rc-service yggdrasil status", out cmd_stdout, out cmd_stderr, out cmd_status); + Process.spawn_command_line_sync ("rc-service yggdrasil status", out cmd_stdout, out cmd_stderr, out cmd_status); - if (cmd_status != 0 || cmd_stderr.length > 0 || cmd_stdout.contains ("stopped")) { - return false; - } + if (cmd_status != 0 || cmd_stderr.length > 0 || cmd_stdout.contains ("stopped")) { + return false; + } - return true; - } + return true; + } - public void start () throws SpawnError { - Process.spawn_command_line_sync ("pkexec rc-service yggdrasil start"); - } + public void start () throws SpawnError { + Process.spawn_command_line_sync ("pkexec rc-service yggdrasil start"); + } + + public void stop () throws SpawnError { + Process.spawn_command_line_sync ("pkexec rc-service yggdrasil stop"); + } + + } - public void stop () throws SpawnError { - Process.spawn_command_line_sync ("pkexec rc-service yggdrasil stop"); - } - - } - } \ No newline at end of file diff --git a/src/yggdrasil-service-systemd.vala b/src/yggdrasil-service-systemd.vala index 3fa0646..ce4880d 100644 --- a/src/yggdrasil-service-systemd.vala +++ b/src/yggdrasil-service-systemd.vala @@ -15,29 +15,29 @@ namespace Yggtk { - public class YggdrasilServiceSystemd : Object, YggdrasilService { + public class YggdrasilServiceSystemd : Object, YggdrasilService { - public bool get_status () throws SpawnError { - string cmd_stdout; - int cmd_status = -1; + public bool get_status () throws SpawnError { + string cmd_stdout; + int cmd_status = -1; - Process.spawn_command_line_sync ("systemctl status yggdrasil", out cmd_stdout, null, out cmd_status); + Process.spawn_command_line_sync ("systemctl status yggdrasil", out cmd_stdout, null, out cmd_status); - if (cmd_status == 0 && cmd_stdout.contains ("active (running)")) { - return true; - } + if (cmd_status == 0 && cmd_stdout.contains ("active (running)")) { + return true; + } - return false; - } + return false; + } - public void start () throws SpawnError { - Process.spawn_command_line_sync ("pkexec systemctl start yggdrasil"); - } + public void start () throws SpawnError { + Process.spawn_command_line_sync ("pkexec systemctl start yggdrasil"); + } + + public void stop () throws SpawnError { + Process.spawn_command_line_sync ("pkexec systemctl stop yggdrasil"); + } + + } - public void stop () throws SpawnError { - Process.spawn_command_line_sync ("pkexec systemctl stop yggdrasil"); - } - - } - } \ No newline at end of file diff --git a/src/yggdrasil-service.vala b/src/yggdrasil-service.vala index 03e08d0..a742f34 100644 --- a/src/yggdrasil-service.vala +++ b/src/yggdrasil-service.vala @@ -20,7 +20,7 @@ namespace Yggtk { public abstract bool get_status () throws SpawnError; public abstract void start () throws SpawnError; public abstract void stop () throws SpawnError; - + } } \ No newline at end of file