Skip to content

Commit 2796215

Browse files
authored
Merge pull request #2508 from flooxo/open_target
Add open target for program shortcuts
2 parents fdb1860 + f73e3d5 commit 2796215

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<system:String x:Key="flowlauncher_plugin_program_run_as_administrator">Run As Administrator</system:String>
7474
<system:String x:Key="flowlauncher_plugin_program_open_containing_folder">Open containing folder</system:String>
7575
<system:String x:Key="flowlauncher_plugin_program_disable_program">Disable this program from displaying</system:String>
76+
<system:String x:Key="flowlauncher_plugin_program_open_target_folder">Open target folder</system:String>
7677

7778
<system:String x:Key="flowlauncher_plugin_program_plugin_name">Program</system:String>
7879
<system:String x:Key="flowlauncher_plugin_program_plugin_description">Search programs in Flow Launcher</system:String>

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,20 @@ public string UniqueIdentifier
3939
public string FullPath { get; set; }
4040

4141
/// <summary>
42-
/// Path of the executable for .lnk, or the URL for .url. Arguments are included if any.
42+
/// Path of the executable for .lnk, or the URL for .url
4343
/// </summary>
4444
public string LnkResolvedPath { get; set; }
4545

4646
/// <summary>
47-
/// Path of the actual executable file. Args are included.
47+
/// Path of the actual executable file
4848
/// </summary>
4949
public string ExecutablePath => LnkResolvedPath ?? FullPath;
5050

51+
/// <summary>
52+
/// Arguments for the executable.
53+
/// </summary>
54+
public string Args { get; set; }
55+
5156
public string ParentDirectory { get; set; }
5257

5358
/// <summary>
@@ -261,11 +266,29 @@ public List<Result> ContextMenus(IPublicAPI api)
261266
},
262267
IcoPath = "Images/folder.png",
263268
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe838"),
264-
}
269+
},
265270
};
271+
if (Extension(FullPath) == ShortcutExtension)
272+
{
273+
contextMenus.Add(OpenTargetFolderContextMenuResult(api));
274+
}
266275
return contextMenus;
267276
}
268277

278+
private Result OpenTargetFolderContextMenuResult(IPublicAPI api)
279+
{
280+
return new Result
281+
{
282+
Title = api.GetTranslation("flowlauncher_plugin_program_open_target_folder"),
283+
Action = _ =>
284+
{
285+
api.OpenDirectory(Path.GetDirectoryName(ExecutablePath), ExecutablePath);
286+
return true;
287+
},
288+
IcoPath = "Images/folder.png",
289+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe8de"),
290+
};
291+
}
269292

270293
public override string ToString()
271294
{
@@ -327,7 +350,7 @@ private static Win32 LnkProgram(string path)
327350
var args = _helper.arguments;
328351
if (!string.IsNullOrEmpty(args))
329352
{
330-
program.LnkResolvedPath += " " + args;
353+
program.Args = args;
331354
}
332355

333356
var description = _helper.description;
@@ -624,7 +647,7 @@ public static IEnumerable<T> DistinctBy<T, R>(IEnumerable<T> source, Func<T, R>
624647
private static IEnumerable<Win32> ProgramsHasher(IEnumerable<Win32> programs)
625648
{
626649
var startMenuPaths = GetStartMenuPaths();
627-
return programs.GroupBy(p => p.ExecutablePath.ToLowerInvariant())
650+
return programs.GroupBy(p => (p.ExecutablePath + p.Args).ToLowerInvariant())
628651
.AsParallel()
629652
.SelectMany(g =>
630653
{

0 commit comments

Comments
 (0)