From 59033b3a1a95a91d854f2a4729db9f996bfdcbcc Mon Sep 17 00:00:00 2001 From: Ryo Nakano <26003928+ryonakano@users.noreply.github.com> Date: Sat, 27 Nov 2021 12:38:09 +0900 Subject: [PATCH] Lessen warnings on build --- com.github.muriloventuroso.easyssh.yml | 1 - src/Views/SourceListView.vala | 59 ++++++++++---------------- src/Widgets/TerminalBox.vala | 1 - src/Widgets/TerminalWidget.vala | 10 +++-- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/com.github.muriloventuroso.easyssh.yml b/com.github.muriloventuroso.easyssh.yml index 02b8a911..483fda14 100644 --- a/com.github.muriloventuroso.easyssh.yml +++ b/com.github.muriloventuroso.easyssh.yml @@ -24,7 +24,6 @@ modules: - name: easyssh buildsystem: meson config-opts: - - '-Dlibunity=false' - '-Dubuntu-bionic-patched-vte=false' - '-Dpatched-vte=true' sources: diff --git a/src/Views/SourceListView.vala b/src/Views/SourceListView.vala index 78fd2d2b..30403696 100755 --- a/src/Views/SourceListView.vala +++ b/src/Views/SourceListView.vala @@ -135,7 +135,7 @@ namespace EasySSH { var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - box.margin_left = 5; + box.margin_start = 5; welcome = new Welcome(); welcome_accounts = new WelcomeAccounts(); box.add(welcome); @@ -931,9 +931,6 @@ namespace EasySSH { public Host edit_host(string old_name, Host e_host) { var host = hostmanager.get_host_by_name(old_name); - if(host == null){ - return null; - } var group = hostmanager.get_group_by_name(host.group); e_host.notebook = host.notebook; if(host.group == e_host.group) { @@ -1066,24 +1063,11 @@ namespace EasySSH { } #endif var file = File.new_for_path (Application.settings.get_string ("hosts-folder").replace ("%20", " ") + filename); - { - if (file.query_exists ()) { - file.delete (); - } - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - - dos.put_string (data); - } + write_data_to_file (file, data); if(Application.settings.get_boolean ("sync-ssh-config")){ var file_ssh = File.new_for_path (Environment.get_home_dir () + "/.ssh/config"); - { - if (file_ssh.query_exists ()) { - file_ssh.delete (); - } - var dos_ssh = new DataOutputStream (file_ssh.create (FileCreateFlags.REPLACE_DESTINATION)); - dos_ssh.put_string (data_ssh_config); - } + write_data_to_file (file_ssh, data_ssh_config); } } @@ -1119,15 +1103,7 @@ namespace EasySSH { } #endif var file = File.new_for_path (Application.settings.get_string ("hosts-folder").replace ("%20", " ") + filename); - { - if (file.query_exists ()) { - file.delete (); - } - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - - dos.put_string (data); - } - + write_data_to_file (file, data); } public void save_bookmarks() { @@ -1160,15 +1136,7 @@ namespace EasySSH { } #endif var file = File.new_for_path (Application.settings.get_string ("hosts-folder").replace ("%20", " ") + filename); - { - if (file.query_exists ()) { - file.delete (); - } - var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); - - dos.put_string (data); - } - + write_data_to_file (file, data); } public void backup_ssh_config() { @@ -1475,5 +1443,22 @@ namespace EasySSH { } message_dialog.destroy (); } + + private void write_data_to_file (File file, string data) { + if (file.query_exists ()) { + try { + file.delete (); + } catch (Error e) { + warning (e.message); + } + } + + try { + var dos = new DataOutputStream (file.create (FileCreateFlags.REPLACE_DESTINATION)); + dos.put_string (data); + } catch (Error e) { + warning (e.message); + } + } } } diff --git a/src/Widgets/TerminalBox.vala b/src/Widgets/TerminalBox.vala index e8c56d94..cce0b4bb 100755 --- a/src/Widgets/TerminalBox.vala +++ b/src/Widgets/TerminalBox.vala @@ -217,7 +217,6 @@ namespace EasySSH { } private void term_send(string cmd) { - var n_cmd = cmd + "\n"; #if UBUNTU_BIONIC_PATCHED_VTE term.feed_child(cmd, cmd.length); #else diff --git a/src/Widgets/TerminalWidget.vala b/src/Widgets/TerminalWidget.vala index d0df6356..b8678b4f 100755 --- a/src/Widgets/TerminalWidget.vala +++ b/src/Widgets/TerminalWidget.vala @@ -134,7 +134,7 @@ namespace EasySSH { if (uri != null && ! get_has_selection ()) { try { - Gtk.show_uri (null, uri, Gtk.get_current_event_time ()); + Gtk.show_uri_on_window (window, uri, Gtk.get_current_event_time ()); } catch (GLib.Error error) { warning ("Could Not Open link"); } @@ -171,8 +171,12 @@ namespace EasySSH { public void active_shell() { if(ssh){ - this.spawn_sync(Vte.PtyFlags.DEFAULT, null, {"/bin/sh"}, - null, SpawnFlags.SEARCH_PATH, null, out this.child_pid, null); + try { + this.spawn_sync(Vte.PtyFlags.DEFAULT, null, {"/bin/sh"}, + null, SpawnFlags.SEARCH_PATH, null, out this.child_pid, null); + } catch (Error e) { + warning (e.message); + } }else{ string dir = GLib.Environment.get_current_dir (); var shell = Vte.get_user_shell ();