mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
Merge branch 'feature/open_with' from PR #33
This commit is contained in:
commit
7866a11037
13 changed files with 143 additions and 83 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
|
@ -30,7 +31,15 @@ namespace SourceGit.Native
|
|||
|
||||
public string FindVSCode()
|
||||
{
|
||||
if (File.Exists("/usr/share/code/code")) return "/usr/share/code/code";
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
@ -27,11 +28,17 @@ namespace SourceGit.Native
|
|||
|
||||
public string FindVSCode()
|
||||
{
|
||||
if (File.Exists("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"))
|
||||
{
|
||||
return "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
||||
}
|
||||
var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet";
|
||||
if (File.Exists(toolPath))
|
||||
return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace SourceGit.Native
|
|||
|
||||
string FindGitExecutable();
|
||||
string FindVSCode();
|
||||
string FindFleet();
|
||||
|
||||
void OpenTerminal(string workdir);
|
||||
void OpenInFileManager(string path, bool select);
|
||||
|
@ -20,39 +21,33 @@ namespace SourceGit.Native
|
|||
void OpenWithDefaultEditor(string file);
|
||||
}
|
||||
|
||||
public static string GitInstallPath
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static string GitInstallPath { get; set; }
|
||||
|
||||
public static string VSCodeExecutableFile
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static string VSCodeExecutableFile { get; set; }
|
||||
|
||||
public static string FleetExecutableFile { get; set; }
|
||||
|
||||
static OS()
|
||||
{
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
_backend = new MacOS();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else if (OperatingSystem.IsWindows())
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
_backend = new Windows();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
_backend = new MacOS();
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
_backend = new Linux();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Platform unsupported!!!");
|
||||
}
|
||||
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
FleetExecutableFile = _backend.FindFleet();
|
||||
}
|
||||
|
||||
public static void SetupApp(AppBuilder builder)
|
||||
|
@ -103,5 +98,22 @@ namespace SourceGit.Native
|
|||
}
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -116,30 +116,21 @@ namespace SourceGit.Native
|
|||
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");
|
||||
var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_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 toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe");
|
||||
if (File.Exists(toolPath)) return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
|
||||
if (File.Exists(toolPath)) return toolPath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
BIN
src/SourceGit/Resources/ExternalToolIcons/fleet.png
Normal file
BIN
src/SourceGit/Resources/ExternalToolIcons/fleet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
src/SourceGit/Resources/ExternalToolIcons/vscode.png
Normal file
BIN
src/SourceGit/Resources/ExternalToolIcons/vscode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -80,7 +80,6 @@
|
|||
<StreamGeometry x:Key="Icons.Eye">M520 168C291 168 95 311 16 512c79 201 275 344 504 344 229 0 425-143 504-344-79-201-275-344-504-344zm0 573c-126 0-229-103-229-229s103-229 229-229c126 0 229 103 229 229s-103 229-229 229zm0-367c-76 0-137 62-137 137s62 137 137 137S657 588 657 512s-62-137-137-137z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.EyeClose">M734 128c-33-19-74-8-93 25l-41 70c-28-6-58-9-90-9-294 0-445 298-445 298s82 149 231 236l-31 54c-19 33-8 74 25 93 33 19 74 8 93-25L759 222C778 189 767 147 734 128zM305 512c0-115 93-208 207-208 14 0 27 1 40 4l-37 64c-1 0-2 0-2 0-77 0-140 63-140 140 0 26 7 51 20 71l-37 64C324 611 305 564 305 512zM771 301 700 423c13 27 20 57 20 89 0 110-84 200-192 208l-51 89c12 1 24 2 36 2 292 0 446-298 446-298S895 388 771 301z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Empty">M469 235V107h85v128h-85zm-162-94 85 85-60 60-85-85 60-60zm469 60-85 85-60-60 85-85 60 60zm-549 183A85 85 0 01302 341H722a85 85 0 0174 42l131 225A85 85 0 01939 652V832a85 85 0 01-85 85H171a85 85 0 01-85-85v-180a85 85 0 0112-43l131-225zM722 427H302l-100 171h255l10 29a59 59 0 002 5c2 4 5 9 9 14 8 9 18 17 34 17 16 0 26-7 34-17a72 72 0 0011-18l0-0 10-29h255l-100-171zM853 683H624a155 155 0 01-12 17C593 722 560 747 512 747c-48 0-81-25-99-47a155 155 0 01-12-17H171v149h683v-149z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.VSCode">M719 85 388 417l-209-165L87 299v427l92 47 210-164L720 939 939 850V171zM186 610V412l104 104zm526 55L514 512l198-153z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Statistics">M447 561a26 26 0 0126 26v171H421v-171a26 26 0 0126-26zm-98 65a26 26 0 0126 26v104H323v-104a26 26 0 0126-26zm0 0M561 268a32 32 0 0132 30v457h-65V299a32 32 0 0132-32zm0 0M675 384a26 26 0 0126 26v348H649v-350a26 26 0 0126-24zm0 0M801 223v579H223V223h579M805 171H219A49 49 0 00171 219v585A49 49 0 00219 853h585A49 49 0 00853 805V219A49 49 0 00805 171z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.Hotkeys">M512 0C229.216 0 0 229.216 0 512c0 282.752 229.216 512 512 512s512-229.248 512-512c0-282.784-229.216-512-512-512z m0 957.92C266.112 957.92 66.08 757.888 66.08 512S266.112 66.08 512 66.08 957.92 266.112 957.92 512 757.888 957.92 512 957.92zM192 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM384 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM576 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM832 320h-64a32 32 0 0 0-32 32v128h-160a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h256a32 32 0 0 0 32-32v-192a32 32 0 0 0-32-32zM320 544v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h96a32 32 0 0 0 32-32zM384 576h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM800 640H256a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h544a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32z</StreamGeometry>
|
||||
<StreamGeometry x:Key="Icons.LayoutHorizontal">M875 117H149C109 117 75 151 75 192v640c0 41 34 75 75 75h725c41 0 75-34 75-75V192c0-41-34-75-75-75zM139 832V192c0-6 4-11 11-11h331v661H149c-6 0-11-4-11-11zm747 0c0 6-4 11-11 11H544v-661H875c6 0 11 4 11 11v640z</StreamGeometry>
|
||||
|
|
19
src/SourceGit/Resources/Locales.Designer.cs
generated
19
src/SourceGit/Resources/Locales.Designer.cs
generated
|
@ -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>
|
||||
|
@ -2985,6 +2993,15 @@ namespace SourceGit.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Open in.
|
||||
/// </summary>
|
||||
public static string Text_Repository_OpenWith {
|
||||
get {
|
||||
return ResourceManager.GetString("Text.Repository.OpenWith", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Refresh.
|
||||
/// </summary>
|
||||
|
|
|
@ -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>
|
||||
|
@ -1302,6 +1305,9 @@
|
|||
<data name="Text.Preference.Appearance" xml:space="preserve">
|
||||
<value>APPEARANCE</value>
|
||||
</data>
|
||||
<data name="Text.Repository.OpenWith" xml:space="preserve">
|
||||
<value>Open in</value>
|
||||
</data>
|
||||
<data name="Text.SelfUpdate.Title" xml:space="preserve">
|
||||
<value>Software Update</value>
|
||||
</data>
|
||||
|
|
|
@ -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>
|
||||
|
@ -1302,6 +1305,9 @@
|
|||
<data name="Text.Preference.Appearance" xml:space="preserve">
|
||||
<value>Appearance</value>
|
||||
</data>
|
||||
<data name="Text.Repository.OpenWith" xml:space="preserve">
|
||||
<value>Open in</value>
|
||||
</data>
|
||||
<data name="Text.SelfUpdate.Title" xml:space="preserve">
|
||||
<value>Software Update</value>
|
||||
</data>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<ItemGroup>
|
||||
<AvaloniaResource Include="App.ico" />
|
||||
<AvaloniaResource Include="Resources/Fonts/*" />
|
||||
<AvaloniaResource Include="Resources/ExternalToolIcons/*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -49,12 +49,6 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
} = new AvaloniaList<string>();
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsVSCodeFound
|
||||
{
|
||||
get => !string.IsNullOrEmpty(Native.OS.VSCodeExecutableFile);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Models.GitFlow GitFlow
|
||||
{
|
||||
|
@ -286,6 +280,11 @@ namespace SourceGit.ViewModels
|
|||
Native.OS.OpenInVSCode(_fullpath);
|
||||
}
|
||||
|
||||
public void OpenInFleet()
|
||||
{
|
||||
Native.OS.OpenInFleet(_fullpath);
|
||||
}
|
||||
|
||||
public void OpenInTerminal()
|
||||
{
|
||||
Native.OS.OpenTerminal(_fullpath);
|
||||
|
|
|
@ -17,21 +17,34 @@
|
|||
<Button Classes="icon_button" Width="32" Command="{Binding OpenInFileManager}" ToolTip.Tip="{DynamicResource Text.Repository.Explore}">
|
||||
<Path Width="15" Height="13" Data="{StaticResource Icons.Folder.Open}"/>
|
||||
</Button>
|
||||
|
||||
<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 OpenInTerminal}" ToolTip.Tip="{DynamicResource Text.Repository.Terminal}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.Terminal}"/>
|
||||
</Button>
|
||||
|
||||
<Button Classes="icon_button" Width="32" ToolTip.Tip="{DynamicResource Text.Repository.OpenWith}">
|
||||
<Path Width="13" Height="13" Data="{StaticResource Icons.OpenWith}"/>
|
||||
<Button.Flyout>
|
||||
<MenuFlyout Placement="BottomEdgeAlignedLeft" VerticalOffset="-8">
|
||||
<MenuItem Header="{DynamicResource Text.Repository.Fleet}" Command="{Binding OpenInFleet}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="/Resources/ExternalToolIcons/fleet.png" Width="13" Height="13" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{DynamicResource Text.Repository.VSCode}" Command="{Binding OpenInVSCode}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="/Resources/ExternalToolIcons/vscode.png" Width="13" Height="13" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
<ToggleButton Width="32"
|
||||
Background="Transparent"
|
||||
IsChecked="{Binding IsSearching, Mode=TwoWay}"
|
||||
ToolTip.Tip="{DynamicResource Text.Repository.Search}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Search}"/>
|
||||
</ToggleButton>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
|
|
Loading…
Reference in a new issue