mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-26 12:55:00 +00:00
ux: Add system default terminal option.
This commit is contained in:
parent
467a39b2e9
commit
8a255cd260
5 changed files with 35 additions and 24 deletions
|
@ -128,7 +128,7 @@ namespace SourceGit.Views
|
|||
Dispatcher.UIThread.Post(() => InstalledMonospaceFonts.AddRange(sysMonoFonts));
|
||||
});
|
||||
|
||||
ExternalTerminals = [..OS.ExternalTerminals.Select(x => x.Name)];
|
||||
ExternalTerminals = ["", ..OS.ExternalTerminals.Select(x => x.Name)];
|
||||
|
||||
var ver = string.Empty;
|
||||
if (pref.IsGitConfigured)
|
||||
|
@ -261,32 +261,47 @@ namespace SourceGit.Views
|
|||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string terminalName && !string.IsNullOrWhiteSpace(terminalName))
|
||||
{
|
||||
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalTerminalIcons/{terminalName}.png", UriKind.RelativeOrAbsolute));
|
||||
return new Bitmap(icon);
|
||||
}
|
||||
var iconKey = value is string terminalName && !string.IsNullOrWhiteSpace(terminalName) ?
|
||||
terminalName :
|
||||
GetSystemDefaultTerminalIconKey();
|
||||
|
||||
return null;
|
||||
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalTerminalIcons/{iconKey}.png", UriKind.RelativeOrAbsolute));
|
||||
return new Bitmap(icon);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
private string GetSystemDefaultTerminalIconKey()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
return "git-bash";
|
||||
}
|
||||
else if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
return "osascript";
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
return "gnome-terminal";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TerminalOrShellNameToLocalizedNameConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string terminalName && !string.IsNullOrWhiteSpace(terminalName))
|
||||
{
|
||||
var name = App.Text($"Preference.General.DefaultTerminalOrShell.{terminalName}");
|
||||
return name;
|
||||
}
|
||||
|
||||
return null;
|
||||
return value is string terminalName && !string.IsNullOrWhiteSpace(terminalName) ?
|
||||
App.Text($"Preference.General.DefaultTerminalOrShell.{terminalName}") :
|
||||
App.Text($"Preference.General.DefaultTerminalOrShell");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue