From 49f93644456b44d4e9a9b628f1441b7494a878e1 Mon Sep 17 00:00:00 2001 From: Nikolay Brovko Date: Tue, 28 Jan 2020 03:42:35 +0300 Subject: [PATCH] add browse-peers action and use it instead of button clicked signal think about just use GtkLinkButton instead of overcomplicated xdg-open call --- src/app-window.vala | 6 ------ src/application.vala | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app-window.vala b/src/app-window.vala index cd5f399..13fc8b1 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -65,12 +65,6 @@ namespace Yggtk { Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf); parse (yggconf, peer_ip_entry); - } else { - - Process.spawn_command_line_sync ( - "xdg-open https://github.com/yggdrasil-network/public-peers" - ); - } }); diff --git a/src/application.vala b/src/application.vala index f21e670..bb156b2 100644 --- a/src/application.vala +++ b/src/application.vala @@ -44,7 +44,7 @@ namespace Yggtk { Gtk.main_quit (); } } - + private void add_actions () { SimpleAction update_yggtk_action = new SimpleAction ("update-yggtk", null); update_yggtk_action.activate.connect (update_yggtk); @@ -57,6 +57,10 @@ namespace Yggtk { 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) { @@ -127,6 +131,16 @@ namespace Yggtk { } } + private void browse_peers () { + try { + Process.spawn_command_line_sync ( + "xdg-open https://github.com/yggdrasil-network/public-peers" + ); + } catch (SpawnError e) { + stderr.printf ("Unable to open link with xdg-open: %s\n", e.message); + } + } + protected override void activate () { if (window == null) { window = new AppWindow (this);