2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-05-30 02:31:27 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/tray_icon_gtk.h"
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2016-06-20 08:35:45 +00:00
|
|
|
#include "base/strings/stringprintf.h"
|
2014-07-10 05:06:41 +00:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/browser.h"
|
|
|
|
#include "shell/common/application_info.h"
|
2015-01-03 03:17:02 +00:00
|
|
|
#include "ui/gfx/image/image.h"
|
2018-11-06 19:00:37 +00:00
|
|
|
#include "ui/views/linux_ui/linux_ui.h"
|
2014-05-30 02:31:27 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
TrayIconGtk::TrayIconGtk() {}
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
TrayIconGtk::~TrayIconGtk() {}
|
2014-07-10 05:06:41 +00:00
|
|
|
|
2015-01-03 02:43:56 +00:00
|
|
|
void TrayIconGtk::SetImage(const gfx::Image& image) {
|
2014-07-10 05:06:41 +00:00
|
|
|
if (icon_) {
|
2015-01-03 02:43:56 +00:00
|
|
|
icon_->SetImage(image.AsImageSkia());
|
2014-07-10 05:06:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-24 10:49:10 +00:00
|
|
|
const auto toolTip = base::UTF8ToUTF16(GetApplicationName());
|
2018-11-06 19:00:37 +00:00
|
|
|
icon_ = views::LinuxUI::instance()->CreateLinuxStatusIcon(
|
|
|
|
image.AsImageSkia(), toolTip, Browser::Get()->GetName().c_str());
|
2014-07-10 05:06:41 +00:00
|
|
|
icon_->set_delegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::SetToolTip(const std::string& tool_tip) {
|
|
|
|
icon_->SetToolTip(base::UTF8ToUTF16(tool_tip));
|
|
|
|
}
|
|
|
|
|
2016-07-06 23:04:18 +00:00
|
|
|
void TrayIconGtk::SetContextMenu(AtomMenuModel* menu_model) {
|
2014-07-10 05:06:41 +00:00
|
|
|
icon_->UpdatePlatformContextMenu(menu_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::OnClick() {
|
2015-05-21 07:22:52 +00:00
|
|
|
NotifyClicked();
|
2014-07-10 05:06:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TrayIconGtk::HasClickAction() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-30 15:57:54 +00:00
|
|
|
// static
|
|
|
|
TrayIcon* TrayIcon::Create() {
|
2014-07-10 05:06:41 +00:00
|
|
|
return new TrayIconGtk;
|
2014-05-30 15:57:54 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 02:31:27 +00:00
|
|
|
} // namespace atom
|