add on_peer_ip_entry_changed handler to show/hide save config button

This commit is contained in:
Nikolay Brovko 2020-01-28 04:38:49 +03:00
parent 49f9364445
commit 77fd314253
No known key found for this signature in database
GPG Key ID: 32258A3DEC9B6F07
2 changed files with 12 additions and 26 deletions

View File

@ -153,6 +153,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="secondary_icon_tooltip_text" translatable="yes">Peer Address</property>
<signal name="changed" handler="on_peer_ip_entry_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>

View File

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