Skip to content

flatpak maxsize 512 bugfix #45

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 14 additions & 5 deletions PupNet/PackageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public PackageBuilder(ConfigurationReader conf, PackageKind kind)
BuildRoot = Path.Combine(Root, AppRootName);
Operations = new(Root);

IconPaths = GetShareIconPaths(Configuration.IconFiles);
IconPaths = GetShareIconPaths(kind, Configuration.IconFiles);

if (IconPaths.Count == 0)
{
// Fallback to embedded icons on Linux
// Should always empty on non-linux systems
IconPaths = GetShareIconPaths(Configuration.DesktopTerminal ? DefaultTerminalIcons : DefaultGuiIcons);
IconPaths = GetShareIconPaths(kind, Configuration.DesktopTerminal ? DefaultTerminalIcons : DefaultGuiIcons);
}

// Should be ico on Windows, or SVG or PNG on linux
Expand Down Expand Up @@ -746,6 +746,13 @@ private static int GetStandardPngSize(string filename)

// Or biggest PNG
int size = GetStandardPngSize(item);

//Flatpak max resolution is 512
if (kind == PackageKind.Flatpak)
{
if(size > 512)
continue;
}

if (size > max)
{
Expand All @@ -759,7 +766,7 @@ private static int GetStandardPngSize(string filename)
return rslt;
}

private string? MapSourceIconToSharePath(string sourcePath)
private string? MapSourceIconToSharePath(PackageKind kind, string sourcePath)
{
if (BuildShareIcons != null)
{
Expand All @@ -774,14 +781,16 @@ private static int GetStandardPngSize(string filename)

if (size > 0)
{
if (kind == PackageKind.Flatpak && size > 512)
return null;
return Path.Combine(BuildShareIcons, "hicolor", $"{size}x{size}", "apps", Configuration.AppId) + ".png";
}
}

return null;
}

private IReadOnlyDictionary<string, string> GetShareIconPaths(IReadOnlyCollection<string> sources)
private IReadOnlyDictionary<string, string> GetShareIconPaths(PackageKind kind,IReadOnlyCollection<string> sources)
{
// Empty on windows
var dict = new Dictionary<string, string>();
Expand All @@ -790,7 +799,7 @@ private IReadOnlyDictionary<string, string> GetShareIconPaths(IReadOnlyCollectio
{
foreach (var item in sources)
{
var dest = MapSourceIconToSharePath(item);
var dest = MapSourceIconToSharePath(kind, item);

if (dest != null)
{
Expand Down