aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ui.Common/Helper
diff options
context:
space:
mode:
authorIsaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com>2023-01-15 06:11:52 -0500
committerGitHub <noreply@github.com>2023-01-15 11:11:52 +0000
commit719dc97bbd321e98083f47267feb01db769e5fa6 (patch)
treeba249fdf3b41bb5636f183cdcb4134ef1703049c /Ryujinx.Ui.Common/Helper
parent41bba5310a5324f54fa5c0200aff2bf697ced000 (diff)
Ava UI: `TitleUpdateWindow` Refactor (#4276)
* Start Refactor * Dialogue opens * Changes * Switch to ListBox * Fix bugs and stuff * Fix spacing * Implement OpenLocation * Change icon * Color * Color * Remove background * Make no update the same height * Fix height and smooth scroll * Height * Fix update selection * Make window smaller * Add back remove all button * Make selection more obvious * Hide selection bar on SaveManager * Fix autoscroll * Fix no update not staying selected * Better file opener * Fix * Revert that * Update Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Update Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Update Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Log warning * Update Ryujinx.Ava/UI/ViewModels/TitleUpdateViewModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> Co-authored-by: Ac_K <Acoustik666@gmail.com>
Diffstat (limited to 'Ryujinx.Ui.Common/Helper')
-rw-r--r--Ryujinx.Ui.Common/Helper/OpenHelper.cs68
1 files changed, 62 insertions, 6 deletions
diff --git a/Ryujinx.Ui.Common/Helper/OpenHelper.cs b/Ryujinx.Ui.Common/Helper/OpenHelper.cs
index eaaa7392..35534892 100644
--- a/Ryujinx.Ui.Common/Helper/OpenHelper.cs
+++ b/Ryujinx.Ui.Common/Helper/OpenHelper.cs
@@ -1,19 +1,75 @@
using Ryujinx.Common.Logging;
using System;
using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
namespace Ryujinx.Ui.Common.Helper
{
- public static class OpenHelper
+ public static partial class OpenHelper
{
+ [LibraryImport("shell32.dll", SetLastError = true)]
+ public static partial int SHOpenFolderAndSelectItems(IntPtr pidlFolder, uint cidl, IntPtr apidl, uint dwFlags);
+
+ [LibraryImport("shell32.dll", SetLastError = true)]
+ public static partial void ILFree(IntPtr pidlList);
+
+ [LibraryImport("shell32.dll", SetLastError = true)]
+ public static partial IntPtr ILCreateFromPathW([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
+
public static void OpenFolder(string path)
{
- Process.Start(new ProcessStartInfo
+ if (Directory.Exists(path))
+ {
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = path,
+ UseShellExecute = true,
+ Verb = "open"
+ });
+ }
+ else
{
- FileName = path,
- UseShellExecute = true,
- Verb = "open"
- });
+ Logger.Notice.Print(LogClass.Application, $"Directory \"{path}\" doesn't exist!");
+ }
+ }
+
+ public static void LocateFile(string path)
+ {
+ if (File.Exists(path))
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ IntPtr pidlList = ILCreateFromPathW(path);
+ if (pidlList != IntPtr.Zero)
+ {
+ try
+ {
+ Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0));
+ }
+ finally
+ {
+ ILFree(pidlList);
+ }
+ }
+ }
+ else if (OperatingSystem.IsMacOS())
+ {
+ Process.Start("open", $"-R \"{path}\"");
+ }
+ else if (OperatingSystem.IsLinux())
+ {
+ Process.Start("dbus-send", $"--session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:\"file://{path}\" string:\"\"");
+ }
+ else
+ {
+ OpenFolder(Path.GetDirectoryName(path));
+ }
+ }
+ else
+ {
+ Logger.Notice.Print(LogClass.Application, $"File \"{path}\" doesn't exist!");
+ }
}
public static void OpenUrl(string url)