tray_icon_gtk.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "atom/browser/ui/tray_icon_gtk.h"
  5. #include "atom/browser/browser.h"
  6. #include "atom/common/application_info.h"
  7. #include "base/strings/stringprintf.h"
  8. #include "base/strings/utf_string_conversions.h"
  9. #include "ui/gfx/image/image.h"
  10. #include "ui/views/linux_ui/linux_ui.h"
  11. namespace atom {
  12. TrayIconGtk::TrayIconGtk() {}
  13. TrayIconGtk::~TrayIconGtk() {}
  14. void TrayIconGtk::SetImage(const gfx::Image& image) {
  15. if (icon_) {
  16. icon_->SetImage(image.AsImageSkia());
  17. return;
  18. }
  19. const auto toolTip = base::UTF8ToUTF16(GetApplicationName());
  20. icon_ = views::LinuxUI::instance()->CreateLinuxStatusIcon(
  21. image.AsImageSkia(), toolTip, Browser::Get()->GetName().c_str());
  22. icon_->set_delegate(this);
  23. }
  24. void TrayIconGtk::SetToolTip(const std::string& tool_tip) {
  25. icon_->SetToolTip(base::UTF8ToUTF16(tool_tip));
  26. }
  27. void TrayIconGtk::SetContextMenu(AtomMenuModel* menu_model) {
  28. icon_->UpdatePlatformContextMenu(menu_model);
  29. }
  30. void TrayIconGtk::OnClick() {
  31. NotifyClicked();
  32. }
  33. bool TrayIconGtk::HasClickAction() {
  34. return false;
  35. }
  36. // static
  37. TrayIcon* TrayIcon::Create() {
  38. return new TrayIconGtk;
  39. }
  40. } // namespace atom