mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
project: reorganize the structure of the project.
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
parent
96e60da7ad
commit
96d4150d26
319 changed files with 37 additions and 53 deletions
123
src/Native/Linux.cs
Normal file
123
src/Native/Linux.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Dialogs;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Native
|
||||
{
|
||||
[SupportedOSPlatform("linux")]
|
||||
internal class Linux : OS.IBackend
|
||||
{
|
||||
public void SetupApp(AppBuilder builder)
|
||||
{
|
||||
builder.With(new FontManagerOptions()
|
||||
{
|
||||
DefaultFamilyName = "fonts:SourceGit#JetBrains Mono",
|
||||
});
|
||||
|
||||
// Free-desktop file picker has an extra black background panel.
|
||||
builder.UseManagedSystemDialogs();
|
||||
}
|
||||
|
||||
public string FindGitExecutable()
|
||||
{
|
||||
if (File.Exists("/usr/bin/git"))
|
||||
return "/usr/bin/git";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindVSCode()
|
||||
{
|
||||
var toolPath = "/usr/share/code/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
{
|
||||
if (!File.Exists("/usr/bin/xdg-open"))
|
||||
{
|
||||
App.RaiseException("", $"You should install xdg-open first!");
|
||||
return;
|
||||
}
|
||||
|
||||
Process.Start("xdg-open", $"\"{url}\"");
|
||||
}
|
||||
|
||||
public void OpenInFileManager(string path, bool select)
|
||||
{
|
||||
if (!File.Exists("/usr/bin/xdg-open"))
|
||||
{
|
||||
App.RaiseException("", $"You should install xdg-open first!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
Process.Start("xdg-open", $"\"{path}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
var dir = Path.GetDirectoryName(path);
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
Process.Start("xdg-open", $"\"{dir}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenTerminal(string workdir)
|
||||
{
|
||||
var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir;
|
||||
if (File.Exists("/usr/bin/gnome-terminal"))
|
||||
{
|
||||
Process.Start("/usr/bin/gnome-terminal", $"--working-directory=\"{dir}\"");
|
||||
}
|
||||
else if (File.Exists("/usr/bin/konsole"))
|
||||
{
|
||||
Process.Start("/usr/bin/konsole", $"--workdir \"{dir}\"");
|
||||
}
|
||||
else if (File.Exists("/usr/bin/xfce4-terminal"))
|
||||
{
|
||||
Process.Start("/usr/bin/xfce4-terminal", $"--working-directory=\"{dir}\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
App.RaiseException("", $"Only supports gnome-terminal/konsole/xfce4-terminal!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenWithDefaultEditor(string file)
|
||||
{
|
||||
if (!File.Exists("/usr/bin/xdg-open"))
|
||||
{
|
||||
App.RaiseException("", $"You should install xdg-open first!");
|
||||
return;
|
||||
}
|
||||
|
||||
var proc = Process.Start("xdg-open", $"\"{file}\"");
|
||||
proc.WaitForExit();
|
||||
|
||||
if (proc.ExitCode != 0)
|
||||
{
|
||||
App.RaiseException("", $"Failed to open \"{file}\"");
|
||||
}
|
||||
|
||||
proc.Close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue