Skip to content

Commit

Permalink
(#8) Add icon display for installed applications
Browse files Browse the repository at this point in the history
  • Loading branch information
y0ung3r committed Mar 15, 2024
1 parent cea8a29 commit ca6de79
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ProcessDoctor.Backend.Linux/LinuxProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,28 @@ public override SKBitmap ExtractIcon()
return ExtractStockIcon(iconTheme);
}

var file = FileFactory.NewForPath(ExecutablePath);
// TODO: Understand how to bind ExecutablePath and data from AppInfo
var application = AppInfoAdapter
.GetAll()
.FirstOrDefault(application => application.Executable.Contains(ExecutablePath));

using var fileMetadata = file.QueryInfo(
IconAttributes.Standard,
FileQueryInfoFlags.None,
cancellable: null);
if (application is null)
{
return ExtractStockIcon(iconTheme);
}

using var iconMetadata = iconTheme.LookupIcon(
fileMetadata.Icon,
// TODO: Fix quality, color, size
using var icon = iconTheme.LookupIcon(
application.Icon,
size: 16,
IconLookupFlags.UseBuiltin);

return SKBitmap.Decode(iconMetadata.Filename);
using var buffer = icon.LoadIcon();

return SKBitmap.FromImage(
SKImage.FromPixels(
new SKImageInfo(width: 16, height: 16),
buffer.Pixels));
}

private SKBitmap ExtractStockIcon(IconTheme iconTheme)
Expand Down

0 comments on commit ca6de79

Please sign in to comment.