76
75
return Gio.GetAllForType (mimeType);
78
ArrayList list = new ArrayList ();
79
MimeApplication[] apps = Mime.GetAllApplications (mimeType);
80
foreach (MimeApplication app in apps) {
81
DesktopApplication dap = (DesktopApplication) Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
77
var list = new List<DesktopApplication> ();
78
var apps = Gnome.Vfs.Mime.GetAllApplications (mimeType);
79
foreach (var app in apps) {
80
var dap = (DesktopApplication) Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
84
return (DesktopApplication[]) list.ToArray (typeof(DesktopApplication));
83
return list.ToArray ();
87
86
protected override string OnGetMimeTypeDescription (string mt)
173
176
result = result.Replace ("#", "%23");
174
177
result = result.Replace ("?", "%3F");
182
delegate string TerminalRunnerHandler (string command, string args, string dir, string title, bool pause);
184
string terminal_command;
185
bool terminal_probed;
186
TerminalRunnerHandler runner;
188
public override IProcessAsyncOperation StartConsoleProcess (string command, string arguments, string workingDirectory,
189
IDictionary<string, string> environmentVariables,
190
string title, bool pauseWhenFinished)
194
string exec = runner (command, arguments, workingDirectory, title, pauseWhenFinished);
195
var psi = new ProcessStartInfo (terminal_command, exec) {
196
CreateNoWindow = true,
197
UseShellExecute = false,
199
foreach (var env in environmentVariables)
200
psi.EnvironmentVariables [env.Key] = env.Value;
202
ProcessWrapper proc = new ProcessWrapper ();
203
proc.StartInfo = psi;
208
#region Terminal runner implementations
210
private static string GnomeTerminalRunner (string command, string args, string dir, string title, bool pause)
212
string extra_commands = pause
213
? BashPause.Replace ("'", "\\\"")
216
return String.Format (@" --disable-factory --title ""{4}"" -e ""bash -c 'cd {3} ; {0} {1} ; {2}'""",
224
private static string XtermRunner (string command, string args, string dir, string title, bool pause)
226
string extra_commands = pause
230
return String.Format (@" -title ""{4}"" -e bash -c ""cd {3} ; '{0}' {1} ; {2}""",
238
private static string EscapeArgs (string args)
240
return args.Replace ("\\", "\\\\").Replace ("\"", "\\\"");
243
private static string EscapeDir (string dir)
245
return dir.Replace (" ", "\\ ");
248
private static string BashPause {
249
get { return @"echo; read -p 'Press any key to continue...' -n1;"; }
254
#region Probing for preferred terminal
256
private void ProbeTerminal ()
258
if (terminal_probed) {
262
terminal_probed = true;
264
string fallback_terminal = "xterm";
265
string preferred_terminal;
266
TerminalRunnerHandler preferred_runner = null;
267
TerminalRunnerHandler fallback_runner = XtermRunner;
269
if (!String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("GNOME_DESKTOP_SESSION_ID"))) {
270
preferred_terminal = "gnome-terminal";
271
preferred_runner = GnomeTerminalRunner;
274
preferred_terminal = fallback_terminal;
275
preferred_runner = fallback_runner;
278
terminal_command = FindExec (preferred_terminal);
279
if (terminal_command != null) {
280
runner = preferred_runner;
284
FindExec (fallback_terminal);
285
runner = fallback_runner;
288
private string FindExec (string command)
290
foreach (string path in GetExecPaths ()) {
291
string full_path = Path.Combine (path, command);
293
FileInfo info = new FileInfo (full_path);
294
// FIXME: System.IO is super lame, should check for 0755
305
private string [] GetExecPaths ()
307
string path = Environment.GetEnvironmentVariable ("PATH");
308
if (String.IsNullOrEmpty (path)) {
309
return new string [] { "/bin", "/usr/bin", "/usr/local/bin" };
312
// this is super lame, should handle quoting/escaping
313
return path.Split (':');
318
//FIXME: probe for terminal
319
static string TerminalCommand {
321
return PropertyService.Get ("MonoDevelop.Shell", "gnome-terminal");
325
public override bool CanOpenTerminal {
331
public override void OpenInTerminal (FilePath directory)
333
Runtime.ProcessService.StartProcess (TerminalCommand, "", directory, null);