Add "click" event for TrayIcon.
This commit is contained in:
parent
9699dbb71f
commit
cbd9366898
6 changed files with 43 additions and 1 deletions
|
@ -12,4 +12,8 @@ TrayIcon::TrayIcon() {
|
|||
TrayIcon::~TrayIcon() {
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyClicked() {
|
||||
FOR_EACH_OBSERVER(TrayIconObserver, observers_, OnClicked());
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "atom/browser/ui/tray_icon_observer.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "ui/base/models/simple_menu_model.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -32,10 +34,16 @@ class TrayIcon {
|
|||
// Set the context menu for this icon.
|
||||
virtual void SetContextMenu(ui::SimpleMenuModel* menu_model) = 0;
|
||||
|
||||
void AddObserver(TrayIconObserver* obs) { observers_.AddObserver(obs); }
|
||||
void RemoveObserver(TrayIconObserver* obs) { observers_.RemoveObserver(obs); }
|
||||
void NotifyClicked();
|
||||
|
||||
protected:
|
||||
TrayIcon();
|
||||
|
||||
private:
|
||||
ObserverList<TrayIconObserver> observers_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TrayIcon);
|
||||
};
|
||||
|
||||
|
|
20
atom/browser/ui/tray_icon_observer.h
Normal file
20
atom/browser/ui/tray_icon_observer.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
|
||||
#define ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
|
||||
|
||||
namespace atom {
|
||||
|
||||
class TrayIconObserver {
|
||||
public:
|
||||
virtual void OnClicked() {};
|
||||
|
||||
protected:
|
||||
virtual ~TrayIconObserver() {};
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_UI_TRAY_ICON_OBSERVER_H_
|
Loading…
Add table
Add a link
Reference in a new issue