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.
|
|
|
|
|
2014-07-10 05:06:41 +00:00
|
|
|
#include "atom/browser/ui/tray_icon_gtk.h"
|
|
|
|
|
|
|
|
#include "base/guid.h"
|
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
|
#include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h"
|
|
|
|
#include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h"
|
2014-05-30 02:31:27 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2014-07-10 05:06:41 +00:00
|
|
|
TrayIconGtk::TrayIconGtk() {
|
|
|
|
}
|
|
|
|
|
|
|
|
TrayIconGtk::~TrayIconGtk() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::SetImage(const gfx::ImageSkia& image) {
|
|
|
|
if (icon_) {
|
|
|
|
icon_->SetImage(image);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
base::string16 empty;
|
|
|
|
if (libgtk2ui::AppIndicatorIcon::CouldOpen())
|
|
|
|
icon_.reset(
|
|
|
|
new libgtk2ui::AppIndicatorIcon(base::GenerateGUID(), image, empty));
|
|
|
|
else
|
|
|
|
icon_.reset(new libgtk2ui::Gtk2StatusIcon(image, empty));
|
|
|
|
icon_->set_delegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::SetPressedImage(const gfx::ImageSkia& image) {
|
|
|
|
icon_->SetPressedImage(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::SetToolTip(const std::string& tool_tip) {
|
|
|
|
icon_->SetToolTip(base::UTF8ToUTF16(tool_tip));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::SetContextMenu(ui::SimpleMenuModel* menu_model) {
|
|
|
|
icon_->UpdatePlatformContextMenu(menu_model);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrayIconGtk::OnClick() {
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|