2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-07-10 05:06:41 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
2014-07-10 05:06:41 +00:00
|
|
|
#include <string>
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/tray_icon.h"
|
2022-07-20 11:03:34 +00:00
|
|
|
#include "ui/linux/status_icon_linux.h"
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2022-11-28 19:36:25 +00:00
|
|
|
class StatusIconLinuxDbus;
|
|
|
|
|
2014-07-10 05:06:41 +00:00
|
|
|
namespace electron {
|
|
|
|
|
2022-07-20 11:03:34 +00:00
|
|
|
class TrayIconGtk : public TrayIcon, public ui::StatusIconLinux::Delegate {
|
2014-07-10 05:06:41 +00:00
|
|
|
public:
|
|
|
|
TrayIconGtk();
|
2018-05-16 19:12:45 +00:00
|
|
|
~TrayIconGtk() override;
|
2014-07-10 05:06:41 +00:00
|
|
|
|
|
|
|
// TrayIcon:
|
2015-01-10 01:24:36 +00:00
|
|
|
void SetImage(const gfx::Image& image) override;
|
|
|
|
void SetToolTip(const std::string& tool_tip) override;
|
2016-07-06 23:04:18 +00:00
|
|
|
void SetContextMenu(ElectronMenuModel* menu_model) override;
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2022-07-20 11:03:34 +00:00
|
|
|
// ui::StatusIconLinux::Delegate
|
2015-01-10 01:24:36 +00:00
|
|
|
void OnClick() override;
|
|
|
|
bool HasClickAction() override;
|
2019-07-03 01:22:09 +00:00
|
|
|
// The following four methods are only used by StatusIconLinuxDbus, which we
|
|
|
|
// aren't yet using, so they are given stub implementations.
|
|
|
|
const gfx::ImageSkia& GetImage() const override;
|
2021-03-16 16:18:45 +00:00
|
|
|
const std::u16string& GetToolTip() const override;
|
2019-07-03 01:22:09 +00:00
|
|
|
ui::MenuModel* GetMenuModel() const override;
|
|
|
|
void OnImplInitializationFailed() override;
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2019-07-03 01:22:09 +00:00
|
|
|
private:
|
2022-11-28 19:36:25 +00:00
|
|
|
enum StatusIconType {
|
|
|
|
kTypeDbus,
|
|
|
|
kTypeNone,
|
|
|
|
};
|
|
|
|
|
|
|
|
scoped_refptr<StatusIconLinuxDbus> status_icon_;
|
|
|
|
StatusIconType status_icon_type_;
|
|
|
|
|
2019-10-18 19:57:34 +00:00
|
|
|
gfx::ImageSkia image_;
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string tool_tip_;
|
2022-11-28 19:36:25 +00:00
|
|
|
raw_ptr<ui::MenuModel> menu_model_ = nullptr;
|
2014-07-10 05:06:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_GTK_H_
|