2014-10-31 12:17:05 -06:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-07-09 23:06:41 -06:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2023-01-26 03:15:55 -07:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2018-09-12 18:25:56 -06:00
|
|
|
#include <memory>
|
2014-07-09 23:06:41 -06:00
|
|
|
#include <string>
|
|
|
|
|
2019-06-19 14:46:59 -06:00
|
|
|
#include "shell/browser/ui/tray_icon.h"
|
2022-07-20 05:03:34 -06:00
|
|
|
#include "ui/linux/status_icon_linux.h"
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2022-11-28 12:36:25 -07:00
|
|
|
class StatusIconLinuxDbus;
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2023-01-26 03:15:55 -07:00
|
|
|
class StatusIconGtk;
|
|
|
|
|
|
|
|
class TrayIconLinux : public TrayIcon, public ui::StatusIconLinux::Delegate {
|
2014-07-09 23:06:41 -06:00
|
|
|
public:
|
2023-01-26 03:15:55 -07:00
|
|
|
TrayIconLinux();
|
|
|
|
~TrayIconLinux() override;
|
2014-07-09 23:06:41 -06:00
|
|
|
|
|
|
|
// TrayIcon:
|
2015-01-09 18:24:36 -07:00
|
|
|
void SetImage(const gfx::Image& image) override;
|
|
|
|
void SetToolTip(const std::string& tool_tip) override;
|
2023-06-09 17:08:36 -06:00
|
|
|
void SetContextMenu(raw_ptr<ElectronMenuModel> menu_model) override;
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2022-07-20 05:03:34 -06:00
|
|
|
// ui::StatusIconLinux::Delegate
|
2015-01-09 18:24:36 -07:00
|
|
|
void OnClick() override;
|
|
|
|
bool HasClickAction() override;
|
2019-07-02 19:22:09 -06:00
|
|
|
const gfx::ImageSkia& GetImage() const override;
|
2021-03-16 10:18:45 -06:00
|
|
|
const std::u16string& GetToolTip() const override;
|
2019-07-02 19:22:09 -06:00
|
|
|
ui::MenuModel* GetMenuModel() const override;
|
|
|
|
void OnImplInitializationFailed() override;
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2019-07-02 19:22:09 -06:00
|
|
|
private:
|
2022-12-05 01:59:20 -07:00
|
|
|
enum class StatusIconType {
|
|
|
|
kDbus,
|
2023-01-26 03:15:55 -07:00
|
|
|
kGtk,
|
2022-12-05 01:59:20 -07:00
|
|
|
kNone,
|
2022-11-28 12:36:25 -07:00
|
|
|
};
|
|
|
|
|
2023-01-26 03:15:55 -07:00
|
|
|
ui::StatusIconLinux* GetStatusIcon();
|
|
|
|
|
|
|
|
scoped_refptr<StatusIconLinuxDbus> status_icon_dbus_;
|
|
|
|
std::unique_ptr<StatusIconGtk> status_icon_gtk_;
|
2022-11-28 12:36:25 -07:00
|
|
|
StatusIconType status_icon_type_;
|
|
|
|
|
2019-10-18 13:57:34 -06:00
|
|
|
gfx::ImageSkia image_;
|
2021-03-16 10:18:45 -06:00
|
|
|
std::u16string tool_tip_;
|
2022-11-28 12:36:25 -07:00
|
|
|
raw_ptr<ui::MenuModel> menu_model_ = nullptr;
|
2014-07-09 23:06:41 -06:00
|
|
|
};
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|
2014-07-09 23:06:41 -06:00
|
|
|
|
2023-01-26 03:15:55 -07:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_UI_TRAY_ICON_LINUX_H_
|