mirror of
https://github.com/encounter/engine.git
synced 2026-07-10 03:18:43 -07:00
ca4c3f6df3
Creates a starting point for an app delegate. For now it just incorporates the menu and window renaming functionality that's currently in the FDE example, but in the future this will also do forwarding of application lifecycle events to plugins. Fixes https://github.com/flutter/flutter/issues/32419
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h"
|
|
|
|
@interface FlutterAppDelegate ()
|
|
|
|
/**
|
|
* Returns the display name of the application as set in the Info.plist.
|
|
*/
|
|
- (NSString*)applicationName;
|
|
|
|
@end
|
|
|
|
@implementation FlutterAppDelegate
|
|
|
|
// TODO(stuartmorgan): Implement application lifecycle forwarding to plugins here, as is done
|
|
// on iOS. Currently macOS plugins don't have access to lifecycle messages.
|
|
|
|
- (void)applicationWillFinishLaunching:(NSNotification*)notification {
|
|
// Update UI elements to match the application name.
|
|
NSString* applicationName = [self applicationName];
|
|
_mainFlutterWindow.title = applicationName;
|
|
for (NSMenuItem* menuItem in _applicationMenu.itemArray) {
|
|
menuItem.title = [menuItem.title stringByReplacingOccurrencesOfString:@"APP_NAME"
|
|
withString:applicationName];
|
|
}
|
|
}
|
|
|
|
#pragma mark Private Methods
|
|
|
|
- (NSString*)applicationName {
|
|
NSString* applicationName =
|
|
[NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
|
if (!applicationName) {
|
|
applicationName = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"];
|
|
}
|
|
return applicationName;
|
|
}
|
|
|
|
@end
|