Add app.dock.setIcon to change icon of dock
This commit is contained in:
parent
31624995bc
commit
7229d2462a
5 changed files with 23 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "atom/common/native_mate_converters/net_converter.h"
|
#include "atom/common/native_mate_converters/net_converter.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||||
|
#include "atom/common/native_mate_converters/image_converter.h"
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "net/ssl/ssl_cert_request_info.h"
|
#include "net/ssl/ssl_cert_request_info.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
#include "ui/gfx/image/image.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
@ -448,6 +450,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
dict.SetMethod("dockHide", base::Bind(&Browser::DockHide, browser));
|
dict.SetMethod("dockHide", base::Bind(&Browser::DockHide, browser));
|
||||||
dict.SetMethod("dockShow", base::Bind(&Browser::DockShow, browser));
|
dict.SetMethod("dockShow", base::Bind(&Browser::DockShow, browser));
|
||||||
dict.SetMethod("dockSetMenu", &DockSetMenu);
|
dict.SetMethod("dockSetMenu", &DockSetMenu);
|
||||||
|
dict.SetMethod("dockSetIcon", base::Bind(&Browser::DockSetIcon, browser));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ if (process.platform === 'darwin') {
|
||||||
getBadge: bindings.dockGetBadgeText,
|
getBadge: bindings.dockGetBadgeText,
|
||||||
hide: bindings.dockHide,
|
hide: bindings.dockHide,
|
||||||
show: bindings.dockShow,
|
show: bindings.dockShow,
|
||||||
setMenu: bindings.dockSetMenu
|
setMenu: bindings.dockSetMenu,
|
||||||
|
setIcon: bindings.dockSetIcon
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,10 @@ namespace ui {
|
||||||
class MenuModel;
|
class MenuModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace gfx {
|
||||||
|
class Image;
|
||||||
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class LoginHandler;
|
class LoginHandler;
|
||||||
|
@ -91,6 +95,9 @@ class Browser : public WindowListObserver {
|
||||||
|
|
||||||
// Set docks' menu.
|
// Set docks' menu.
|
||||||
void DockSetMenu(ui::MenuModel* model);
|
void DockSetMenu(ui::MenuModel* model);
|
||||||
|
|
||||||
|
// Set docks' icon.
|
||||||
|
void DockSetIcon(const gfx::Image& image);
|
||||||
#endif // defined(OS_MACOSX)
|
#endif // defined(OS_MACOSX)
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
|
|
@ -102,4 +102,9 @@ void Browser::DockSetMenu(ui::MenuModel* model) {
|
||||||
[delegate setApplicationDockMenu:model];
|
[delegate setApplicationDockMenu:model];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Browser::DockSetIcon(const gfx::Image& image) {
|
||||||
|
[[NSApplication sharedApplication]
|
||||||
|
setApplicationIconImage:image.AsNSImage()];
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -512,6 +512,12 @@ Shows the dock icon.
|
||||||
|
|
||||||
Sets the application's [dock menu][dock-menu].
|
Sets the application's [dock menu][dock-menu].
|
||||||
|
|
||||||
|
### `app.dock.setIcon(image)` _OS X_
|
||||||
|
|
||||||
|
* `image` [NativeImage](native-image.md)
|
||||||
|
|
||||||
|
Sets the `image` associated with this dock icon.
|
||||||
|
|
||||||
[dock-menu]:https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/concepts/dockconcepts.html#//apple_ref/doc/uid/TP30000986-CH2-TPXREF103
|
[dock-menu]:https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/concepts/dockconcepts.html#//apple_ref/doc/uid/TP30000986-CH2-TPXREF103
|
||||||
[tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
|
[tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks
|
||||||
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
|
||||||
|
|
Loading…
Reference in a new issue