Merge pull request #7549 from electron/about-panel-options

Support setting about panel options
This commit is contained in:
Cheng Zhao 2016-10-11 20:18:23 +09:00 коммит произвёл GitHub
Родитель 0baa60caab 58ef0bea17
Коммит 4ae190dab9
5 изменённых файлов: 38 добавлений и 1 удалений

Просмотреть файл

@ -850,6 +850,8 @@ void App::BuildPrototype(
base::Bind(&Browser::SetUserActivity, browser)) base::Bind(&Browser::SetUserActivity, browser))
.SetMethod("getCurrentActivityType", .SetMethod("getCurrentActivityType",
base::Bind(&Browser::GetCurrentActivityType, browser)) base::Bind(&Browser::GetCurrentActivityType, browser))
.SetMethod("setAboutPanelOptions",
base::Bind(&Browser::SetAboutPanelOptions, browser))
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
.SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser)) .SetMethod("setUserTasks", base::Bind(&Browser::SetUserTasks, browser))

Просмотреть файл

@ -14,6 +14,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/values.h"
#include "native_mate/arguments.h" #include "native_mate/arguments.h"
#if defined(OS_WIN) #if defined(OS_WIN)
@ -21,7 +22,6 @@
#endif #endif
namespace base { namespace base {
class DictionaryValue;
class FilePath; class FilePath;
} }
@ -146,6 +146,9 @@ class Browser : public WindowListObserver {
// Set docks' icon. // Set docks' icon.
void DockSetIcon(const gfx::Image& image); void DockSetIcon(const gfx::Image& image);
void ShowAboutPanel();
void SetAboutPanelOptions(const base::DictionaryValue& options);
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
#if defined(OS_WIN) #if defined(OS_WIN)
@ -245,6 +248,10 @@ class Browser : public WindowListObserver {
base::string16 app_user_model_id_; base::string16 app_user_model_id_;
#endif #endif
#if defined(OS_MACOSX)
base::DictionaryValue about_panel_options_;
#endif
DISALLOW_COPY_AND_ASSIGN(Browser); DISALLOW_COPY_AND_ASSIGN(Browser);
}; };

Просмотреть файл

@ -253,4 +253,15 @@ void Browser::DockSetIcon(const gfx::Image& image) {
setApplicationIconImage:image.AsNSImage()]; setApplicationIconImage:image.AsNSImage()];
} }
void Browser::ShowAboutPanel() {
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);
[[AtomApplication sharedApplication]
orderFrontStandardAboutPanelWithOptions:options];
}
void Browser::SetAboutPanelOptions(const base::DictionaryValue& options) {
about_panel_options_.Clear();
about_panel_options_.MergeDictionary(&options);
}
} // namespace atom } // namespace atom

Просмотреть файл

@ -87,4 +87,8 @@
atom::Browser::Get()->OnAccessibilitySupportChanged(); atom::Browser::Get()->OnAccessibilitySupportChanged();
} }
- (void)orderFrontStandardAboutPanel:(id)sender {
atom::Browser::Get()->ShowAboutPanel();
}
@end @end

Просмотреть файл

@ -853,6 +853,18 @@ technologies, such as screen readers, has been detected. See
https://www.chromium.org/developers/design-documents/accessibility for more https://www.chromium.org/developers/design-documents/accessibility for more
details. details.
### `app.setAboutPanelOptions(options)` _macOS_
* `options` Object
* `ApplicationName` String (optional) - The app's name.
* `ApplicationVersion` String (optional) - The app's version.
* `Copyright` String (optional) - Copyright information.
* `Credits` String (optional) - Credit information.
* `Version` String (optional) - The app's build version number.
Set the about panel options. This will override the values defined in the app's
`.plist` file. See the [Apple docs][about-panel-options] for more details.
### `app.commandLine.appendSwitch(switch[, value])` ### `app.commandLine.appendSwitch(switch[, value])`
* `switch` String - A command-line switch * `switch` String - A command-line switch
@ -943,3 +955,4 @@ Sets the `image` associated with this dock icon.
[activity-type]: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType [activity-type]: https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSUserActivity_Class/index.html#//apple_ref/occ/instp/NSUserActivity/activityType
[unity-requiremnt]: ../tutorial/desktop-environment-integration.md#unity-launcher-shortcuts-linux [unity-requiremnt]: ../tutorial/desktop-environment-integration.md#unity-launcher-shortcuts-linux
[JumpListBeginListMSDN]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx [JumpListBeginListMSDN]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378398(v=vs.85).aspx
[about-panel-options]: https://developer.apple.com/reference/appkit/nsapplication/1428479-orderfrontstandardaboutpanelwith?language=objc