diff options
Diffstat (limited to 'src/window.vala')
-rw-r--r-- | src/window.vala | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/window.vala b/src/window.vala index 8e38676..5cdfc65 100644 --- a/src/window.vala +++ b/src/window.vala @@ -32,20 +32,38 @@ namespace JadupcSupport [GtkChild] private unowned Gtk.Label infobarText; [GtkChild] private unowned Gtk.Image infobarIcon; + private Tmate.Config configFactory; + private Tmate.Session tmate; + private ulong? session_handler = null; + public Window (Gtk.Application app) { Object (application: app); utils.realize_all(this); // Realize all children to pacify Gtk. icon_name = "com.jadupc.support"; + configFactory = new Tmate.Config(); + tmate = new Tmate.Session(); infobar.response.connect(() => infobar.set_revealed(false)); + + tmate.address.connect((stype, addr) => { + if(Tmate.SessionType.SSH in stype) + on_session_connect(addr); + }); + sessionbutton.clicked.connect(() => { if (infobar.revealed) infobar.revealed = false; session.label = _("Connecting..."); view.visible_child_name = "inprogress"; - Timeout.add_once(3000, () => on_session_connect("test@tty.jadupc.com")); + + var config = configFactory.get(); + session_handler = tmate.started.connect(() => { + configFactory.delete(config); + tmate.disconnect(session_handler); + }); + tmate.start(config); }); terminal.child_exited.connect(status => { @@ -85,8 +103,10 @@ namespace JadupcSupport session.label = @"<a href=\"ssh://$url\">ssh://$url</a>"; view.visible_child_name = "terminal"; terminal.has_focus = true; + debug(url); + debug(tmate.socket); - terminal.spawn_async(Vte.PtyFlags.DEFAULT, "~", {"sh"}, {@"PATH=$(Config.SECURE_PATH)"}, + terminal.spawn_async(Vte.PtyFlags.DEFAULT, "~", {"tmate", "-S", tmate.socket, "attach"}, {@"PATH=$(Config.SECURE_PATH)"}, SpawnFlags.SEARCH_PATH_FROM_ENVP, null, -1, null, spawn_async_cb); } } |