Skip to content

Commit

Permalink
feat(macos/skia): add badge support
Browse files Browse the repository at this point in the history
  • Loading branch information
spouliot committed Feb 20, 2024
1 parent b1d02ca commit 8a1e244
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Uno.UI.Runtime.Skia.MacOS/MacSkiaHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static unsafe MacSkiaHost()

MacOSAnalyticsInfoExtension.Register();
MacOSApplicationViewExtension.Register();
MacOSBadgeUpdaterExtension.Register();
MacOSClipboardExtension.Register(); // work in progress
MacOSCoreApplicationExtension.Register();
MacOSDisplayInformationExtension.Register();
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI.Runtime.Skia.MacOS/NativeUno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ internal static partial class NativeUno
[LibraryImport("libUnoNativeMac.dylib")]
internal static partial nint uno_app_get_main_window();

[LibraryImport("libUnoNativeMac.dylib", StringMarshalling = StringMarshalling.Utf8)]
internal static partial void uno_application_set_badge(string badge);

[LibraryImport("libUnoNativeMac.dylib", StringMarshalling = StringMarshalling.Utf8)]
internal static partial void uno_application_set_icon(string iconPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bool uno_app_initialize(bool *supportsMetal);
NSWindow* uno_app_get_main_window(void);

id<MTLDevice> uno_application_get_metal_device(void);
void uno_application_set_badge(const char *badge);
void uno_application_set_icon(const char *path);
bool uno_application_open_url(const char *url);
bool uno_application_query_url_support(const char *url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ bool uno_app_initialize(bool *metal)
return device;
}

void uno_application_set_badge(const char *badge)
{
NSApplication *app = [NSApplication sharedApplication];
NSDockTile *dockTile = [app dockTile];
[dockTile setBadgeLabel:[NSString stringWithUTF8String:badge]];
}

void uno_application_set_icon(const char *path)
{
NSApplication *app = [NSApplication sharedApplication];
Expand Down

0 comments on commit 8a1e244

Please sign in to comment.