mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 1208295
- Show an additional action on OS X notifications to open notification settings. r=mstange
--HG-- extra : commitid : BP0mSNiIk4X extra : rebase_source : 48aeb880868927f3df1310de70645e1e943b3d55
This commit is contained in:
parent
1db1a07bb8
commit
57a6416a3c
@ -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.
|
# 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 = …
|
actionButton.label = …
|
||||||
webActions.disable.label = Disable notifications from this site
|
webActions.disable.label = Disable notifications from this site
|
||||||
|
webActions.settings.label = Notification settings
|
||||||
|
@ -139,7 +139,8 @@ enum {
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
OSXNotificationActionDisable = 0
|
OSXNotificationActionDisable = 0,
|
||||||
|
OSXNotificationActionSettings = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
class OSXNotificationInfo {
|
class OSXNotificationInfo {
|
||||||
@ -253,13 +254,15 @@ OSXNotificationCenter::ShowAlertNotification(const nsAString & aImageUrl, const
|
|||||||
nsCOMPtr<nsIStringBundle> bundle;
|
nsCOMPtr<nsIStringBundle> bundle;
|
||||||
nsresult rv = sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
|
nsresult rv = sbs->CreateBundle("chrome://alerts/locale/alert.properties", getter_AddRefs(bundle));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle;
|
nsXPIDLString closeButtonTitle, actionButtonTitle, disableButtonTitle, settingsButtonTitle;
|
||||||
bundle->GetStringFromName(NS_LITERAL_STRING("closeButton.title").get(),
|
bundle->GetStringFromName(NS_LITERAL_STRING("closeButton.title").get(),
|
||||||
getter_Copies(closeButtonTitle));
|
getter_Copies(closeButtonTitle));
|
||||||
bundle->GetStringFromName(NS_LITERAL_STRING("actionButton.label").get(),
|
bundle->GetStringFromName(NS_LITERAL_STRING("actionButton.label").get(),
|
||||||
getter_Copies(actionButtonTitle));
|
getter_Copies(actionButtonTitle));
|
||||||
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.disable.label").get(),
|
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.disable.label").get(),
|
||||||
getter_Copies(disableButtonTitle));
|
getter_Copies(disableButtonTitle));
|
||||||
|
bundle->GetStringFromName(NS_LITERAL_STRING("webActions.settings.label").get(),
|
||||||
|
getter_Copies(settingsButtonTitle));
|
||||||
|
|
||||||
notification.hasActionButton = YES;
|
notification.hasActionButton = YES;
|
||||||
notification.otherButtonTitle = nsCocoaUtils::ToNSString(closeButtonTitle);
|
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:@"_showsButtons"];
|
||||||
[(NSObject*)notification setValue:@(YES) forKey:@"_alwaysShowAlternateActionMenu"];
|
[(NSObject*)notification setValue:@(YES) forKey:@"_alwaysShowAlternateActionMenu"];
|
||||||
[(NSObject*)notification setValue:@[
|
[(NSObject*)notification setValue:@[
|
||||||
nsCocoaUtils::ToNSString(disableButtonTitle)
|
nsCocoaUtils::ToNSString(disableButtonTitle),
|
||||||
|
nsCocoaUtils::ToNSString(settingsButtonTitle)
|
||||||
]
|
]
|
||||||
forKey:@"_alternateActionButtonTitles"];
|
forKey:@"_alternateActionButtonTitles"];
|
||||||
}
|
}
|
||||||
@ -394,6 +398,9 @@ OSXNotificationCenter::OnActivate(NSString *aAlertName,
|
|||||||
case OSXNotificationActionDisable:
|
case OSXNotificationActionDisable:
|
||||||
osxni->mObserver->Observe(nullptr, "alertdisablecallback", osxni->mCookie.get());
|
osxni->mObserver->Observe(nullptr, "alertdisablecallback", osxni->mCookie.get());
|
||||||
break;
|
break;
|
||||||
|
case OSXNotificationActionSettings:
|
||||||
|
osxni->mObserver->Observe(nullptr, "alertsettingscallback", osxni->mCookie.get());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
NS_WARNING("Unknown NSUserNotification additional action clicked");
|
NS_WARNING("Unknown NSUserNotification additional action clicked");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user