Merge lp:~jeremy-munsch/synapse-project/fix-ssh-terminal into lp:synapse-project

Proposed by Jeremy Munsch
Status: Merged
Merged at revision: 664
Proposed branch: lp:~jeremy-munsch/synapse-project/fix-ssh-terminal
Merge into: lp:synapse-project
Diff against target: 118 lines (+64/-22)
3 files modified
src/core/common-actions.vala (+1/-11)
src/core/utils.vala (+62/-0)
src/plugins/ssh-plugin.vala (+1/-11)
To merge this branch: bzr merge lp:~jeremy-munsch/synapse-project/fix-ssh-terminal
Reviewer Review Type Date Requested Status
Rico Tzschichholz Pending
Review via email: mp+277061@code.launchpad.net

Description of the change

Use
  x-terminal-emulator -e 'ssh %s' if x-terminal-emulator is available or default to GLib NEEDS_TERMINAL if a terminal is needed

to respect user default terminal instead of unefficient Glib default terminal
https://mail.gnome.org/archives/vala-list/2012-June/msg00061.html

It is only launching gnome-terminal or xterm, this is not the wanted behaviour.

The -e should work with any terminal emulator, this is i think a reliable and simple solution since synapse is targeting Debian based distros.
The fallback still supports other DE though.

To post a comment you must log in.
Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

I just saw in common actions that the problem is also to fix there.
I will also test if x-terminal-emulator is present and fall back to GLib solution if not.

I think of refactoring this into an Utils method.

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

I just did the just above.

If this is merged modifications would have to be done in PR https://code.launchpad.net/~jeremy-munsch/synapse-project/add-script-execute/+merge/277502 to make usage of the introduced "Utils.open_command_line"

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Was about to say that "x-terminal-emulator" might not be available/set.

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

Oops i made a mistake correcting now
"if (null != Environment.find_program_in_path ("zeal"))"

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

I just saw that redhat based distros use /usr/sbin/alternatives
and that synapse is distributed in redhat (fedora it seems at least).
http://rpmfind.net/linux/rpm2html/search.php?query=synapse

Should i update testing /usr/sbin/alternatives so it could be packaged more easily ?

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

Just updated the branch and corrected the commit message.

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

I have updated this. It now uses gconf to get default terminal, then fallbacks on x-terminal and then fallback on native and not reliable at all vala way.

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

So it is now using GLib.Settings

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

This should be ok now.

Revision history for this message
Jeremy Munsch (jeremy-munsch) wrote :

I have faith it should be ok.

637. By Rico Tzschichholz

plugins: Add suport for MATE Screensaver

638. By Rico Tzschichholz

po: Update translations

639. By Rico Tzschichholz

desktop-file-plugin: correct ApplicationsMatch to DesktopFileMatch

640. By Rico Tzschichholz

src: Drop "using Gee;"

641. By Rico Tzschichholz

src: Drop "using Json;"

642. By Rico Tzschichholz

src: Drop "using Zeitgeist;"

643. By Rico Tzschichholz

src: Drop "using Gtk;"

644. By Rico Tzschichholz

src: Drop "using Cairo;"

645. By Rico Tzschichholz

src: Drop last usages of "using *;"

646. By Rico Tzschichholz

ui: Show release-name in about-dialog only

647. By Rico Tzschichholz

ui: Bump to 2016

648. By Rico Tzschichholz

Release 0.2.99.2

649. By Rico Tzschichholz

ui: Set and update client-window of Gtk.IMMulticontext

650. By Rico Tzschichholz

main: Properly construct OptionEntry

Stop using an empty string where is getting treated as translateable.

651. By Michael Aquilina

Add pass plugin

652. By Rico Tzschichholz

Fix non-matching generic types

653. By Rico Tzschichholz

Fix non-matching generic types of interface implementations

654. By Jeremy Munsch

utils: Add generic method open_command_line
common-actions/ssh-plugin: usage of open_command_line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/core/common-actions.vala'
--- src/core/common-actions.vala 2015-11-18 12:08:18 +0000
+++ src/core/common-actions.vala 2016-12-18 20:17:23 +0000
@@ -153,17 +153,7 @@
153 AppInfo original = app_match.app_info ??153 AppInfo original = app_match.app_info ??
154 new DesktopAppInfo.from_filename (app_match.filename);154 new DesktopAppInfo.from_filename (app_match.filename);
155155
156 try156 Utils.open_command_line (original.get_commandline (), original.get_name (), true);
157 {
158 AppInfo app = AppInfo.create_from_commandline (
159 original.get_commandline (), original.get_name (),
160 AppInfoCreateFlags.NEEDS_TERMINAL);
161 app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
162 }
163 catch (Error err)
164 {
165 warning ("%s", err.message);
166 }
167 }157 }
168 else if (match is UriMatch)158 else if (match is UriMatch)
169 {159 {
170160
=== modified file 'src/core/utils.vala'
--- src/core/utils.vala 2015-11-19 09:11:34 +0000
+++ src/core/utils.vala 2016-12-18 20:17:23 +0000
@@ -112,6 +112,68 @@
112 }112 }
113 }113 }
114114
115 public static void open_command_line (string command, string? app_name = null, bool needs_terminal = false)
116 {
117 AppInfoCreateFlags using_terminal = AppInfoCreateFlags.NONE;
118 string commandline = command;
119 string? application_name = app_name;
120
121 if (needs_terminal)
122 {
123 if (GLib.SettingsSchemaSource.get_default ().lookup ("org.gnome.desktop.default-applications.terminal", true) != null)
124 {
125 application_name = (new GLib.Settings("org.gnome.desktop.default-applications.terminal")).get_string ("exec");
126 }
127
128 if (Environment.find_program_in_path ("x-terminal-emulator") != null)
129 {
130 // try to determine default terminal application and make exceptions
131 try {
132 Regex regex = new Regex ("[a-zA-Z0-9-_]*");
133
134 Process.spawn_command_line_sync ("sh -c \"cat \\\"$(which x-terminal-emulator)\\\" | grep @ | cut -d$ -f1\"",
135 out application_name);
136
137 if (!regex.match (application_name))
138 application_name = "x-terminal-emulator";
139
140 } catch (Error e) {
141 warning ("Error: %s\n", e.message);
142 application_name = "x-terminal-emulator";
143 }
144 }
145
146 if (application_name == null)
147 using_terminal = AppInfoCreateFlags.NEEDS_TERMINAL;
148 }
149
150 if (application_name != null)
151 switch (application_name) {
152 case "terminator":
153 commandline = "%s -x \"%s\"".printf (application_name, commandline);
154 break;
155 case "aterm":
156 commandline = "%s -e %s".printf (application_name, commandline);
157 break;
158 // case "gnome-terminal":
159 // case "x-terminal-emulator":
160 default:
161 commandline = "%s -e '%s'".printf (application_name, commandline);
162 break;
163 }
164
165 try
166 {
167 debug (commandline);
168 AppInfo app = AppInfo.create_from_commandline (commandline, application_name, using_terminal);
169 app.launch (null, Gdk.Display.get_default ().get_app_launch_context ());
170 }
171 catch (Error err)
172 {
173 warning ("%s", err.message);
174 }
175 }
176
115 public static string extract_type_name (Type obj_type)177 public static string extract_type_name (Type obj_type)
116 {178 {
117 string obj_class = obj_type.name ();179 string obj_class = obj_type.name ();
118180
=== modified file 'src/plugins/ssh-plugin.vala'
--- src/plugins/ssh-plugin.vala 2016-02-27 14:12:03 +0000
+++ src/plugins/ssh-plugin.vala 2016-12-18 20:17:23 +0000
@@ -168,17 +168,7 @@
168168
169 public override void do_action ()169 public override void do_action ()
170 {170 {
171 try171 Utils.open_command_line ("ssh %s".printf (title), null, true);
172 {
173 AppInfo ai = AppInfo.create_from_commandline (
174 "ssh %s".printf (this.title),
175 "ssh", AppInfoCreateFlags.NEEDS_TERMINAL);
176 ai.launch (null, null);
177 }
178 catch (Error err)
179 {
180 warning ("%s", err.message);
181 }
182 }172 }
183173
184 public SshHost (string host_name)174 public SshHost (string host_name)