]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Add Tray.setHighlightMode API, fixes #425.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 9 Sep 2014 11:39:39 +0000 (19:39 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 9 Sep 2014 11:39:39 +0000 (19:39 +0800)
atom/browser/api/atom_api_tray.cc
atom/browser/api/atom_api_tray.h
atom/browser/ui/tray_icon.cc
atom/browser/ui/tray_icon.h
atom/browser/ui/tray_icon_cocoa.h
atom/browser/ui/tray_icon_cocoa.mm

index 19ac64d61831d3eaa592766831b69f86090d0a9e..cd95d423d8290ebfcc13318bed1b09b84a4a78db 100644 (file)
@@ -52,6 +52,10 @@ void Tray::SetTitle(const std::string& title) {
   tray_icon_->SetTitle(title);
 }
 
+void Tray::SetHighlightMode(bool highlight) {
+  tray_icon_->SetHighlightMode(highlight);
+}
+
 void Tray::SetContextMenu(Menu* menu) {
   tray_icon_->SetContextMenu(menu->model());
 }
@@ -64,6 +68,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("setPressedImage", &Tray::SetPressedImage)
       .SetMethod("setToolTip", &Tray::SetToolTip)
       .SetMethod("setTitle", &Tray::SetTitle)
+      .SetMethod("setHighlightMode", &Tray::SetHighlightMode)
       .SetMethod("_setContextMenu", &Tray::SetContextMenu);
 }
 
index c50293219dfe24c4a91b33faa36d978be56ee0f1..791cc5611ba7a01cba9336af2ac7fe01fdab610d 100644 (file)
@@ -42,6 +42,7 @@ class Tray : public mate::EventEmitter,
   void SetPressedImage(const gfx::ImageSkia& image);
   void SetToolTip(const std::string& tool_tip);
   void SetTitle(const std::string& title);
+  void SetHighlightMode(bool highlight);
   void SetContextMenu(Menu* menu);
 
  private:
index facd3e111a5d285a75b5b494770f962a0c40c0f0..3f291025a4139d29fc32bdb0ff94efc7276e213a 100644 (file)
@@ -15,6 +15,9 @@ TrayIcon::~TrayIcon() {
 void TrayIcon::SetTitle(const std::string& title) {
 }
 
+void TrayIcon::SetHighlightMode(bool highlight) {
+}
+
 void TrayIcon::NotifyClicked() {
   FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked());
 }
index 46e609a20429f919c7124fdfa220087f74ad7ba3..7eaef16d7b9eb90fe3c7375ef751bb33183f0ee6 100644 (file)
@@ -35,6 +35,10 @@ class TrayIcon {
   // only works on OS X.
   virtual void SetTitle(const std::string& title);
 
+  // Sets whether the status icon is highlighted when it is clicked. This only
+  // works on OS X.
+  virtual void SetHighlightMode(bool highlight);
+
   // Set the context menu for this icon.
   virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
 
index 5c67b8ef60a32390253794dc5c21b0ca5c715577..1ce50a36d45258d36631c3c14c21c55c3d505d41 100644 (file)
@@ -26,6 +26,7 @@ class TrayIconCocoa : public TrayIcon {
   virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE;
   virtual void SetToolTip(const std::string& tool_tip) OVERRIDE;
   virtual void SetTitle(const std::string& title) OVERRIDE;
+  virtual void SetHighlightMode(bool highlight) OVERRIDE;
   virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
 
  private:
index c4867e92552978c38dfba4541e09107114ed7184..4fb1372c04867c6eb1b5610f07748ddfe5f39648 100644 (file)
@@ -72,6 +72,10 @@ void TrayIconCocoa::SetTitle(const std::string& title) {
   [item_ setTitle:base::SysUTF8ToNSString(title)];
 }
 
+void TrayIconCocoa::SetHighlightMode(bool highlight) {
+  [item_ setHighlightMode:highlight];
+}
+
 void TrayIconCocoa::SetContextMenu(ui::SimpleMenuModel* menu_model) {
   menu_.reset([[AtomMenuController alloc] initWithModel:menu_model]);
   [item_ setMenu:[menu_ menu]];