Bind TrayIcon to JS.

This commit is contained in:
Cheng Zhao 2014-05-30 23:57:54 +08:00
parent 52d8d6fdb3
commit 6c7fe80ec5
13 changed files with 169 additions and 11 deletions

View file

@ -15,6 +15,8 @@ class TrayIcon {
public:
static TrayIcon* Create();
virtual ~TrayIcon();
// Sets the image associated with this status icon.
virtual void SetImage(const gfx::ImageSkia& image) = 0;
@ -32,7 +34,6 @@ class TrayIcon {
protected:
TrayIcon();
virtual ~TrayIcon();
private:
DISALLOW_COPY_AND_ASSIGN(TrayIcon);

View file

@ -18,15 +18,15 @@ namespace atom {
class TrayIconCocoa : public TrayIcon {
public:
TrayIconCocoa();
virtual ~TrayIconCocoa();
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 SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
private:
TrayIconCocoa();
virtual ~TrayIconCocoa();
base::scoped_nsobject<NSStatusItem> item_;
// Status menu shown when right-clicking the system icon.

View file

@ -41,9 +41,13 @@ void TrayIconCocoa::SetToolTip(const std::string& tool_tip) {
}
void TrayIconCocoa::SetContextMenu(ui::SimpleMenuModel* menu_model) {
TrayIcon::SetContextMenu(menu_model);
menu_.reset([[AtomMenuController alloc] initWithModel:menu_model]);
[item_ setMenu:[menu_ menu]];
}
// static
TrayIcon* TrayIcon::Create() {
return new TrayIconCocoa;
}
} // namespace atom

View file

@ -24,4 +24,9 @@ void TrayIconGtk::SetToolTip(const std::string& tool_tip) {
void TrayIconGtk::SetContextMenu(ui::SimpleMenuModel* menu_model) {
}
// static
TrayIcon* TrayIcon::Create() {
return new TrayIconGtk;
}
} // namespace atom

View file

@ -13,15 +13,15 @@ namespace atom {
class TrayIconGtk : public TrayIcon {
public:
TrayIconGtk();
virtual ~TrayIconGtk();
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 SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
private:
TrayIconGtk();
virtual ~TrayIconGtk();
DISALLOW_COPY_AND_ASSIGN(TrayIconGtk);
};

View file

@ -24,4 +24,9 @@ void TrayIconWin::SetToolTip(const std::string& tool_tip) {
void TrayIconWin::SetContextMenu(ui::SimpleMenuModel* menu_model) {
}
// static
TrayIcon* TrayIcon::Create() {
return new TrayIconWin;
}
} // namespace atom

View file

@ -13,15 +13,15 @@ namespace atom {
class TrayIconWin : public TrayIcon {
public:
TrayIconWin();
virtual ~TrayIconWin();
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 SetContextMenu(ui::SimpleMenuModel* menu_model) OVERRIDE;
private:
TrayIconWin();
virtual ~TrayIconWin();
DISALLOW_COPY_AND_ASSIGN(TrayIconWin);
};