diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui index 24bcc94..6b25144 100644 --- a/data/ui/app-window.ui +++ b/data/ui/app-window.ui @@ -153,6 +153,7 @@ True True Peer Address + False diff --git a/src/app-window.vala b/src/app-window.vala index 13fc8b1..20a6358 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -24,10 +24,10 @@ namespace Yggtk { private Gtk.Switch service_state_switch; [GtkChild] - private Gtk.Button browse_peers_button; + private Gtk.Entry peer_ip_entry; [GtkChild] - private Gtk.Entry peer_ip_entry; + private Gtk.Button save_config_button; [GtkCallback] private bool on_service_state_switch_state_set (bool state) { @@ -35,6 +35,11 @@ namespace Yggtk { 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); } @@ -43,30 +48,10 @@ namespace Yggtk { Object(application: application); - peer_ip_entry.notify["text"].connect (() => { - - if (peer_ip_entry.text != "") { - - browse_peers_button.label = "OK"; - - } else { - - browse_peers_button.label = "Browse"; - - } - - }); - - browse_peers_button.clicked.connect (() => { - - if (browse_peers_button.label == "OK") { - - string yggconf; - Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); - parse (yggconf, peer_ip_entry); - - } - + save_config_button.clicked.connect (() => { + string yggconf; + Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); + parse (yggconf, peer_ip_entry); }); }