]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Add Tray.setTitle API, fixes #560.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 9 Sep 2014 11:33:58 +0000 (19:33 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 9 Sep 2014 11:36:15 +0000 (19:36 +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 86e6cb299532e388044bb0ec49379f0904a2af94..19ac64d61831d3eaa592766831b69f86090d0a9e 100644 (file)
@@ -48,6 +48,10 @@ void Tray::SetToolTip(const std::string& tool_tip) {
   tray_icon_->SetToolTip(tool_tip);
 }
 
+void Tray::SetTitle(const std::string& title) {
+  tray_icon_->SetTitle(title);
+}
+
 void Tray::SetContextMenu(Menu* menu) {
   tray_icon_->SetContextMenu(menu->model());
 }
@@ -59,6 +63,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
       .SetMethod("setImage", &Tray::SetImage)
       .SetMethod("setPressedImage", &Tray::SetPressedImage)
       .SetMethod("setToolTip", &Tray::SetToolTip)
+      .SetMethod("setTitle", &Tray::SetTitle)
       .SetMethod("_setContextMenu", &Tray::SetContextMenu);
 }
 
index 5dce0cbe9546dfb467636cc879c9388cc508e7bc..c50293219dfe24c4a91b33faa36d978be56ee0f1 100644 (file)
@@ -41,6 +41,7 @@ class Tray : public mate::EventEmitter,
   void SetImage(const gfx::ImageSkia& image);
   void SetPressedImage(const gfx::ImageSkia& image);
   void SetToolTip(const std::string& tool_tip);
+  void SetTitle(const std::string& title);
   void SetContextMenu(Menu* menu);
 
  private:
index fdbdf7a5395cca8195ec91860f18f80e9efbde7d..facd3e111a5d285a75b5b494770f962a0c40c0f0 100644 (file)
@@ -12,6 +12,9 @@ TrayIcon::TrayIcon() {
 TrayIcon::~TrayIcon() {
 }
 
+void TrayIcon::SetTitle(const std::string& title) {
+}
+
 void TrayIcon::NotifyClicked() {
   FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked());
 }
index 80de248810bb7502a6a141db64318fead5cc658d..46e609a20429f919c7124fdfa220087f74ad7ba3 100644 (file)
@@ -31,6 +31,10 @@ class TrayIcon {
   // status icon (e.g. Ubuntu Unity).
   virtual void SetToolTip(const std::string& tool_tip) = 0;
 
+  // Sets the title displayed aside of the status icon in the status bar. This
+  // only works on OS X.
+  virtual void SetTitle(const std::string& title);
+
   // Set the context menu for this icon.
   virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
 
index b6a710ce1272886d036ca30c8a5bb36785e5629e..5c67b8ef60a32390253794dc5c21b0ca5c715577 100644 (file)
@@ -25,6 +25,7 @@ class TrayIconCocoa : public TrayIcon {
   virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE;
   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 SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
 
  private:
index ef456897e91f82d00407d667299fbd27e43a49a2..c4867e92552978c38dfba4541e09107114ed7184 100644 (file)
@@ -68,6 +68,10 @@ void TrayIconCocoa::SetToolTip(const std::string& tool_tip) {
   [item_ setToolTip:base::SysUTF8ToNSString(tool_tip)];
 }
 
+void TrayIconCocoa::SetTitle(const std::string& title) {
+  [item_ setTitle:base::SysUTF8ToNSString(title)];
+}
+
 void TrayIconCocoa::SetContextMenu(ui::SimpleMenuModel* menu_model) {
   menu_.reset([[AtomMenuController alloc] initWithModel:menu_model]);
   [item_ setMenu:[menu_ menu]];