remove tabs, empty whitespaced lines, unnecessary this keyword

This commit is contained in:
Nikolay Brovko 2020-01-28 04:39:53 +03:00
parent 77fd314253
commit c2df644c9f
No known key found for this signature in database
GPG Key ID: 32258A3DEC9B6F07
5 changed files with 82 additions and 82 deletions

View File

@ -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) {

View File

@ -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 ();
}

View File

@ -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");
}
}
}

View File

@ -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");
}
}
}

View File

@ -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;
}
}