Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjusting how programs are displayed. #2369

Merged
merged 4 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions src/modules/launcher/Plugins/Wox.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public List<Result> Query(Query query)
UWP.Application[] uwps;

lock (IndexLock)
{ // just take the reference inside the lock to eliminate query time issues.
{
// just take the reference inside the lock to eliminate query time issues.
win32 = _win32s;
uwps = _uwps;
}
Expand Down Expand Up @@ -118,7 +119,6 @@ public static void IndexUWPPrograms()
public static void IndexPrograms()
{
var t1 = Task.Run(() => IndexWin32Programs());

var t2 = Task.Run(() => IndexUWPPrograms());

Task.WaitAll(t1, t2);
Expand Down Expand Up @@ -153,32 +153,8 @@ public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
return menuOptions;
}

private void DisableProgram(IProgram programToDelete)
{
if (_settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
return;

if (_uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
_uwps.Where(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;

if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
_win32s.Where(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;

_settings.DisabledProgramSources
.Add(
new Settings.DisabledProgramSource
{
Name = programToDelete.Name,
Location = programToDelete.Location,
UniqueIdentifier = programToDelete.UniqueIdentifier,
Enabled = false
}
);
}

public static void StartProcess(Func<ProcessStartInfo, Process> runProcess, ProcessStartInfo info)
{
bool hide;
try
{
runProcess(info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public Result Result(string query, IPublicAPI api)

var result = new Result
{
SubTitle = Package.Location,
SubTitle = "UWP Application",
Icon = Logo,
Score = score,
ContextData = this,
Expand All @@ -299,12 +299,6 @@ public Result Result(string query, IPublicAPI api)
result.Title = Description;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
}
else if (!string.IsNullOrEmpty(Description))
{
var title = $"{DisplayName}: {Description}";
result.Title = title;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData;
}
else
{
result.Title = DisplayName;
Expand Down
20 changes: 10 additions & 10 deletions src/modules/launcher/Plugins/Wox.Plugin.Program/Programs/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Shell;
using Wox.Infrastructure;
using Wox.Plugin.Program.Logger;
using Wox.Plugin.SharedCommands;

namespace Wox.Plugin.Program.Programs
{
Expand All @@ -22,6 +21,7 @@ public class Win32 : IProgram
public string UniqueIdentifier { get; set; }
public string IcoPath { get; set; }
public string FullPath { get; set; }
public string LnkResolvedPath { get; set; }
public string ParentDirectory { get; set; }
public string ExecutableName { get; set; }
public string Description { get; set; }
Expand Down Expand Up @@ -53,7 +53,7 @@ public Result Result(string query, IPublicAPI api)

var result = new Result
{
SubTitle = FullPath,
SubTitle = "Win32 Application",
IcoPath = IcoPath,
Score = score,
ContextData = this,
Expand All @@ -78,12 +78,6 @@ public Result Result(string query, IPublicAPI api)
result.Title = Description;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, Description).MatchData;
}
else if (!string.IsNullOrEmpty(Description))
{
var title = $"{Name}: {Description}";
result.Title = title;
result.TitleHighlightData = StringMatcher.FuzzySearch(query, title).MatchData;
}
else
{
result.Title = Name;
Expand Down Expand Up @@ -196,6 +190,9 @@ private static Win32 LnkProgram(string path)
var extension = Extension(target);
if (extension == ExeExtension && File.Exists(target))
{
program.LnkResolvedPath = program.FullPath;
program.FullPath = target;

buffer = new StringBuilder(MAX_PATH);
link.GetDescription(buffer, MAX_PATH);
var description = buffer.ToString();
Expand Down Expand Up @@ -356,8 +353,11 @@ private static ParallelQuery<Win32> StartMenuPrograms(string[] suffixes)

var programs1 = paths.AsParallel().Where(p => Extension(p) == ShortcutExtension).Select(LnkProgram);
var programs2 = paths.AsParallel().Where(p => Extension(p) == ApplicationReferenceExtension).Select(Win32Program);
var programs = programs1.Concat(programs2).Where(p => p.Valid);
return programs;
var allValidPrograms = programs1.Concat(programs2).Where(p => p.Valid);
//var programsWithLnk = allValidPrograms.Where(x => !string.IsNullOrEmpty(x.LnkResolvedPath));


return allValidPrograms;
}

private static ParallelQuery<Win32> AppPathsPrograms(string[] suffixes)
Expand Down
Loading