mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1208295 - Show an additional action on OS X notifications to open notification settings. r=mstange
This commit is contained in:
parent
446278fadc
commit
6dce1cf3cd
@ -9,3 +9,4 @@ closeButton.title = Close
|
||||
# LOCALIZATION NOTE(actionButton.label): Used as the button label to provide more actions on OS X notifications. OS X will truncate this if it's too long.
|
||||
actionButton.label = …
|
||||
webActions.disable.label = Disable notifications from this site
|
||||
webActions.settings.label = Notification settings
|
||||
|
@ -139,7 +139,8 @@ enum {
|
||||
namespace mozilla {
|
||||
|
||||
enum {
|
||||
OSXNotificationActionDisable = 0
|
||||
OSXNotificationActionDisable = 0,
|
||||
OSXNotificationActionSettings = 1,
|
||||
};
|
||||
|
||||
class OSXNotificationInfo {
|
||||
@ -253,13 +254,15 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsresult rv = sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle;
|
||||
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle, settingsButtonTitle;
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("closeButton.title").get(),
|
||||
getter_Copies(closeButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("actionButton.label").get(),
|
||||
getter_Copies(actionButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.disable.label").get(),
|
||||
getter_Copies(disableButtonTitle));
|
||||
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.settings.label").get(),
|
||||
getter_Copies(settingsButtonTitle));
|
||||
|
||||
notification.hasActionButton = YES;
|
||||
notification.otherButtonTitle = nsCocoaUtils::ToNSString(closeButtonTitle);
|
||||
@ -267,7 +270,8 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
||||
[(NSObject*)notification setValue:@(YES) forKey:@"_showsButtons"];
|
||||
[(NSObject*)notification setValue:@(YES) forKey:@"_alwaysShowAlternateActionMenu"];
|
||||
[(NSObject*)notification setValue:@[
|
||||
nsCocoaUtils::ToNSString(disableButtonTitle)
|
||||
nsCocoaUtils::ToNSString(disableButtonTitle),
|
||||
nsCocoaUtils::ToNSString(settingsButtonTitle)
|
||||
]
|
||||
forKey:@"_alternateActionButtonTitles"];
|
||||
}
|
||||
@ -394,6 +398,9 @@ OSXNotificationCenter::OnActivate(NSString *aAlertName,
|
||||
case OSXNotificationActionDisable:
|
||||
osxni->mObserver->Observe(nullptr, "alertdisablecallback", osxni->mCookie.get());
|
||||
break;
|
||||
case OSXNotificationActionSettings:
|
||||
osxni->mObserver->Observe(nullptr, "alertsettingscallback", osxni->mCookie.get());
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Unknown NSUserNotification additional action clicked");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user