mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-26 04:44:59 +00:00
enhance: refactor terminal functionality to support flatpak
This commit is contained in:
parent
4deac98c4e
commit
066d79db2b
3 changed files with 36 additions and 7 deletions
|
@ -35,8 +35,15 @@ namespace SourceGit.Native
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsFlatpak())
|
||||||
|
{
|
||||||
|
return shell.Exec;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Models.ExternalTool> FindExternalTools()
|
public List<Models.ExternalTool> FindExternalTools()
|
||||||
{
|
{
|
||||||
|
@ -71,18 +78,34 @@ namespace SourceGit.Native
|
||||||
|
|
||||||
public void OpenTerminal(string workdir)
|
public void OpenTerminal(string workdir)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal))
|
if (string.IsNullOrEmpty(OS.ShellOrTerminal))
|
||||||
{
|
{
|
||||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo();
|
var startInfo = new ProcessStartInfo();
|
||||||
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir;
|
startInfo.WorkingDirectory = string.IsNullOrEmpty(workdir) ? home : workdir;
|
||||||
|
if (IsFlatpak())
|
||||||
|
{
|
||||||
|
startInfo.FileName = "flatpak-spawn";
|
||||||
|
startInfo.ArgumentList.Add("--host");
|
||||||
|
startInfo.ArgumentList.Add(OS.ShellOrTerminal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
startInfo.FileName = OS.ShellOrTerminal;
|
startInfo.FileName = OS.ShellOrTerminal;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
App.RaiseException(workdir, e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenWithDefaultEditor(string file)
|
public void OpenWithDefaultEditor(string file)
|
||||||
{
|
{
|
||||||
|
@ -117,5 +140,11 @@ namespace SourceGit.Native
|
||||||
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
||||||
return File.Exists(path) ? path : FindExecutable("fleet");
|
return File.Exists(path) ? path : FindExecutable("fleet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsFlatpak()
|
||||||
|
{
|
||||||
|
var container = Environment.GetEnvironmentVariable("container");
|
||||||
|
return container == "flatpak";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace SourceGit.Native
|
||||||
public static void OpenTerminal(string workdir)
|
public static void OpenTerminal(string workdir)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(ShellOrTerminal))
|
if (string.IsNullOrEmpty(ShellOrTerminal))
|
||||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||||
else
|
else
|
||||||
_backend.OpenTerminal(workdir);
|
_backend.OpenTerminal(workdir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ namespace SourceGit.Native
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal))
|
if (string.IsNullOrEmpty(OS.ShellOrTerminal) || !File.Exists(OS.ShellOrTerminal))
|
||||||
{
|
{
|
||||||
App.RaiseException(workdir, $"Can not found terminal! Please confirm that the correct shell/terminal has been configured.");
|
App.RaiseException(workdir, $"Terminal is not specified! Please confirm that the correct shell/terminal has been configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue