Open In Fleet

This commit is contained in:
Enner Pérez 2024-03-28 00:49:32 -05:00
parent 91bc1ee8ab
commit cde5fc8f73
11 changed files with 149 additions and 59 deletions

View file

@ -33,6 +33,13 @@ namespace SourceGit.Native
if (File.Exists("/usr/share/code/code")) return "/usr/share/code/code";
return string.Empty;
}
public string FindFleet()
{
var path = "~/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
if (File.Exists(path)) return path;
return string.Empty;
}
public void OpenBrowser(string url)
{

View file

@ -34,6 +34,16 @@ namespace SourceGit.Native
return string.Empty;
}
public string FindFleet()
{
if (File.Exists("/Applications/Fleet.app/Contents/MacOS/Fleet"))
{
return "/Applications/Fleet.app/Contents/MacOS/Fleet";
}
return string.Empty;
}
public void OpenBrowser(string url)
{

View file

@ -3,6 +3,8 @@ using System.Diagnostics;
using Avalonia;
// ReSharper disable InconsistentNaming
namespace SourceGit.Native
{
public static class OS
@ -13,6 +15,7 @@ namespace SourceGit.Native
string FindGitExecutable();
string FindVSCode();
string FindFleet();
void OpenTerminal(string workdir);
void OpenInFileManager(string path, bool select);
@ -20,39 +23,36 @@ namespace SourceGit.Native
void OpenWithDefaultEditor(string file);
}
public static string GitInstallPath
public static string GitInstallPath { get; set; }
public static string VSCodeExecutableFile { get; set; }
public static string FleetExecutableFile { get; set; }
public enum Platforms
{
get;
set;
Unknown = 0,
Windows = 1,
MacOS = 2,
Linux
}
public static string VSCodeExecutableFile
{
get;
set;
}
public static Platforms Platform => OperatingSystem.IsWindows() ? Platforms.Windows : OperatingSystem.IsMacOS() ? Platforms.MacOS : OperatingSystem.IsLinux() ? Platforms.Linux : Platforms.Unknown;
static OS()
{
if (OperatingSystem.IsMacOS())
_backend = Platform switch
{
_backend = new MacOS();
VSCodeExecutableFile = _backend.FindVSCode();
}
else if (OperatingSystem.IsWindows())
{
_backend = new Windows();
VSCodeExecutableFile = _backend.FindVSCode();
}
else if (OperatingSystem.IsLinux())
{
_backend = new Linux();
VSCodeExecutableFile = _backend.FindVSCode();
}
else
{
throw new Exception("Platform unsupported!!!");
}
#pragma warning disable CA1416
Platforms.Windows => new Windows(),
Platforms.MacOS => new MacOS(),
Platforms.Linux => new Linux(),
#pragma warning restore CA1416
_ => throw new Exception("Platform unsupported!!!")
};
VSCodeExecutableFile = _backend.FindVSCode();
FleetExecutableFile = _backend.FindFleet();
}
public static void SetupApp(AppBuilder builder)
@ -95,13 +95,24 @@ namespace SourceGit.Native
Process.Start(new ProcessStartInfo()
{
WorkingDirectory = repo,
FileName = VSCodeExecutableFile,
Arguments = $"\"{repo}\"",
UseShellExecute = false,
WorkingDirectory = repo, FileName = VSCodeExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false,
});
}
private static readonly IBackend _backend = null;
public static void OpenInFleet(string repo)
{
if (string.IsNullOrEmpty(FleetExecutableFile))
{
App.RaiseException(repo, "Fleet can NOT be found in your system!!!");
return;
}
Process.Start(new ProcessStartInfo()
{
WorkingDirectory = repo, FileName = FleetExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false,
});
}
}
}

View file

@ -103,34 +103,15 @@ namespace SourceGit.Native
public string FindVSCode()
{
var root = Microsoft.Win32.RegistryKey.OpenBaseKey(
Microsoft.Win32.RegistryHive.LocalMachine,
Environment.Is64BitOperatingSystem ? Microsoft.Win32.RegistryView.Registry64 : Microsoft.Win32.RegistryView.Registry32);
var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1");
if (vscode != null)
{
return vscode.GetValue("DisplayIcon") as string;
}
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
if (vscode != null)
{
return vscode.GetValue("DisplayIcon") as string;
}
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1");
if (vscode != null)
{
return vscode.GetValue("DisplayIcon") as string;
}
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
if (vscode != null)
{
return vscode.GetValue("DisplayIcon") as string;
}
var vscodePath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe");
if (File.Exists(vscodePath)) return vscodePath;
return string.Empty;
}
public string FindFleet()
{
var vscodePath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
if (File.Exists(vscodePath)) return vscodePath;
return string.Empty;
}

View file

@ -0,0 +1,50 @@
<svg xmlns="http://www.w3.org/2000/svg" width="70" height="70" fill="none" viewBox="0 0 70 70">
<defs>
<radialGradient id="a" cx="0" cy="0" r="1" gradientTransform="matrix(22.35433 -20.58122 27.17129 29.51214 38.648 42.538)" gradientUnits="userSpaceOnUse">
<stop offset=".771" stop-color="#001AFF"/>
<stop offset="1" stop-color="#8ACEFF"/>
</radialGradient>
<radialGradient id="b" cx="0" cy="0" r="1" gradientTransform="rotate(-30.543 79.837 -70.068) scale(16.777 22.1489)" gradientUnits="userSpaceOnUse">
<stop offset=".719" stop-color="#FA00FF" stop-opacity="0"/>
<stop offset="1" stop-color="#FF00D6" stop-opacity=".44"/>
</radialGradient>
<radialGradient id="c" cx="0" cy="0" r="1" gradientTransform="rotate(49.385 -19.814 41.858) scale(47.8852)" gradientUnits="userSpaceOnUse">
<stop offset=".026" stop-color="#8DFDFD"/>
<stop offset=".271" stop-color="#87FBFB"/>
<stop offset=".484" stop-color="#74D6F4"/>
<stop offset=".932" stop-color="#0038FF"/>
</radialGradient>
<radialGradient id="d" cx="0" cy="0" r="1" gradientTransform="rotate(137.237 9.434 23.195) scale(32.8316)" gradientUnits="userSpaceOnUse">
<stop offset=".267" stop-color="#0500FF" stop-opacity="0"/>
<stop offset="1" stop-color="#0500FF" stop-opacity=".15"/>
</radialGradient>
<radialGradient id="e" cx="0" cy="0" r="1" gradientTransform="rotate(75.198 -4.629 32.631) scale(51.1484)" gradientUnits="userSpaceOnUse">
<stop offset=".42" stop-color="#FF00E5" stop-opacity="0"/>
<stop offset=".774" stop-color="#FF00F5" stop-opacity=".64"/>
<stop offset=".899" stop-color="#BE46FF" stop-opacity=".87"/>
</radialGradient>
<radialGradient id="g" cx="0" cy="0" r="1" gradientTransform="matrix(2.73484 22.75837 -34.39872 4.13365 29.458 35.276)" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#00B2FF"/>
<stop offset=".571" stop-color="#74C5FF"/>
<stop offset=".979" stop-color="#9FD7FF"/>
</radialGradient>
<linearGradient id="f" x1="11.644" x2="82.363" y1="42.432" y2="43.401" gradientUnits="userSpaceOnUse">
<stop offset=".432" stop-color="#FE62EE" stop-opacity="0"/>
<stop offset=".818" stop-color="#FD3AF5" stop-opacity=".47"/>
</linearGradient>
<linearGradient id="h" x1="33.054" x2="37.35" y1="23.191" y2="49.344" gradientUnits="userSpaceOnUse">
<stop offset=".042" stop-color="#0038FF"/>
<stop offset=".724" stop-color="#48BFF1" stop-opacity=".59"/>
<stop offset="1" stop-color="#74C5FF" stop-opacity="0"/>
</linearGradient>
</defs>
<path fill="url(#a)" d="M65.153 30.85c0 9.496-10.163 17.194-22.7 17.194-12.536 0-22.699-7.698-22.699-17.194 0-9.496 10.163-17.194 22.7-17.194 12.536 0 22.699 7.698 22.699 17.194z"/>
<path fill="url(#b)" d="M65.153 30.85c0 9.496-10.163 17.194-22.7 17.194-12.536 0-22.699-7.698-22.699-17.194 0-9.496 10.163-17.194 22.7-17.194 12.536 0 22.699 7.698 22.699 17.194z"/>
<path fill="url(#c)" d="M66 35c0 17.12-13.88 31-31 31C17.88 66 4 52.12 4 35 4 17.88 17.88 4 35 4c8.046 3.642 16.464 17.194 19.99 21.429 3.524 4.235 12.648 9.571 8.176-1.623C65.073 26.832 66 31.852 66 35z"/>
<path fill="url(#d)" d="M66 35c0 17.12-13.88 31-31 31C17.88 66 4 52.12 4 35 4 17.88 17.88 4 35 4c8.046 3.642 16.464 17.194 19.99 21.429 3.524 4.235 12.648 9.571 8.176-1.623C65.073 26.832 66 31.852 66 35z"/>
<path fill="url(#e)" d="M66 35c0 17.12-13.88 31-31 31C17.88 66 4 52.12 4 35 4 17.88 17.88 4 35 4c8.046 3.642 16.464 17.194 19.99 21.429 3.524 4.235 12.648 9.571 8.176-1.623C65.073 26.832 66 31.852 66 35z"/>
<path fill="url(#f)" d="M66 35c0 17.12-13.88 31-31 31C17.88 66 4 52.12 4 35 4 17.88 17.88 4 35 4c8.046 3.642 16.464 17.194 19.99 21.429 3.524 4.235 12.648 9.571 8.176-1.623C65.073 26.832 66 31.852 66 35z"/>
<path fill="url(#g)" d="M56.651 39.682c1.658 7.764-6.511 16.089-18.246 18.594-11.734 2.505-22.59-1.757-24.248-9.52-1.658-7.764 6.511-16.089 18.246-18.594 11.734-2.506 22.59 1.757 24.248 9.52z"/>
<path fill="url(#h)" d="M56.651 39.682c1.658 7.764-6.511 16.089-18.246 18.594-11.734 2.505-22.59-1.757-24.248-9.52-1.658-7.764 6.511-16.089 18.246-18.594 11.734-2.506 22.59 1.757 24.248 9.52z"/>
<path fill="#D6F8F8" fill-opacity=".19" fill-rule="evenodd" d="M51.462 49.883c3.074-3.133 4.386-6.66 3.698-9.882-.688-3.223-3.326-5.907-7.411-7.51-4.073-1.6-9.412-2.037-15.028-.838-5.616 1.199-10.31 3.779-13.375 6.901-3.074 3.133-4.386 6.66-3.698 9.883.688 3.223 3.326 5.906 7.412 7.51 4.072 1.6 9.41 2.037 15.027.838 5.616-1.2 10.31-3.779 13.375-6.902zm-13.057 8.393c11.735-2.505 19.904-10.83 18.246-18.594-1.658-7.763-12.514-12.026-24.248-9.52-11.735 2.505-19.904 10.83-18.246 18.593 1.658 7.764 12.514 12.026 24.248 9.521z" clip-rule="evenodd"/>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -2967,6 +2966,15 @@ namespace SourceGit.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Open In Fleet.
/// </summary>
public static string Text_Repository_Fleet {
get {
return ResourceManager.GetString("Text.Repository.Fleet", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to LOCAL BRANCHES.
/// </summary>

View file

@ -342,6 +342,9 @@
<data xml:space="preserve" name="Text.Repository.VSCode">
<value>Open In Visual Studio Code</value>
</data>
<data xml:space="preserve" name="Text.Repository.Fleet">
<value>Open In Fleet</value>
</data>
<data xml:space="preserve" name="Text.Repository.Terminal">
<value>Open In Git Bash</value>
</data>

View file

@ -342,6 +342,9 @@
<data xml:space="preserve" name="Text.Repository.VSCode">
<value>Open In Visual Studio Code</value>
</data>
<data xml:space="preserve" name="Text.Repository.Fleet">
<value>Open In Fleet</value>
</data>
<data xml:space="preserve" name="Text.Repository.Terminal">
<value>Open In Git Bash</value>
</data>

View file

@ -44,6 +44,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<PackageReference Include="Avalonia.Svg" Version="11.0.0.16" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
@ -57,4 +58,8 @@
<TrimmerRootAssembly Include="SourceGit" />
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Include="Resources\ExternalToolIcons\*" />
</ItemGroup>
</Project>

View file

@ -54,6 +54,12 @@ namespace SourceGit.ViewModels
{
get => !string.IsNullOrEmpty(Native.OS.VSCodeExecutableFile);
}
[JsonIgnore]
public bool IsFleetFound
{
get => !string.IsNullOrEmpty(Native.OS.FleetExecutableFile);
}
[JsonIgnore]
public Models.GitFlow GitFlow
@ -285,6 +291,11 @@ namespace SourceGit.ViewModels
{
Native.OS.OpenInVSCode(_fullpath);
}
public void OpenInFleet()
{
Native.OS.OpenInFleet(_fullpath);
}
public void OpenInTerminal()
{

View file

@ -21,6 +21,7 @@
<Button Classes="icon_button" Width="32" Command="{Binding OpenInVSCode}" IsVisible="{Binding IsVSCodeFound}" ToolTip.Tip="{DynamicResource Text.Repository.VSCode}">
<Path Width="13" Height="13" Data="{StaticResource Icons.VSCode}"/>
</Button>
<Button Classes="icon_button" Width="32" Command="{Binding OpenInFleet}" IsVisible="{Binding IsFleetFound}" ToolTip.Tip="{DynamicResource Text.Repository.Fleet}" Content="{SvgImage /Resources/ExternalToolIcons/fleet_icon.svg}" />
<Button Classes="icon_button" Width="32" Command="{Binding OpenInTerminal}" ToolTip.Tip="{DynamicResource Text.Repository.Terminal}">
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>