From 11a839a98982abc4ee6e039c930dc1736a49873a Mon Sep 17 00:00:00 2001 From: oupson Date: Fri, 3 Mar 2023 18:33:11 +0100 Subject: [PATCH] Extract terminal configuration to his own function and fix null pty warning --- src/terminalpane.vala | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/terminalpane.vala b/src/terminalpane.vala index 6723d5f..5e21f06 100644 --- a/src/terminalpane.vala +++ b/src/terminalpane.vala @@ -31,19 +31,13 @@ namespace Footerm { private Footerm.Model.Server? server; - public TerminalPane() { - - this.terminal.char_size_changed.connect(() => { - int rows = 0; - int columns = 0; - this.terminal.get_pty().get_size(out rows, out columns); - this.channel.request_pty_size(columns, rows); - }); + construct { + this.configure_terminal(); } public void connect(Footerm.Model.Server server) { this.server = server; - this.terminal.set_enable_sixel(true); + this.connect_to_server.begin((obj, res) => { try { this.connect_to_server.end(res); @@ -51,11 +45,18 @@ namespace Footerm { warning("Failed to connect to the server : %s", e.message); } }); + } + + private void configure_terminal() { + this.terminal.set_enable_sixel(true); this.terminal.char_size_changed.connect(() => { - int rows = 0; - int columns = 0; - this.terminal.get_pty().get_size(out rows, out columns); - this.channel.request_pty_size(columns, rows); + var pty = this.terminal.get_pty(); + if (pty != null && this.channel != null) { + int rows = 0; + int columns = 0; + pty.get_size(out rows, out columns); + this.channel.request_pty_size(columns, rows); + } }); }