status_icon.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2020 Slack Technologies, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. // Copyright (c) 2020 The Chromium Authors. All rights reserved.
  5. // Use of this source code is governed by a BSD-style license that can be
  6. // found in the LICENSE file.
  7. #include "shell/browser/ui/gtk/status_icon.h"
  8. #include <gtk/gtk.h>
  9. #include <memory>
  10. #include "base/strings/stringprintf.h"
  11. #include "shell/browser/ui/gtk/app_indicator_icon.h"
  12. #include "shell/browser/ui/gtk/gtk_status_icon.h"
  13. namespace electron {
  14. namespace gtkui {
  15. namespace {
  16. int indicators_count = 0;
  17. }
  18. bool IsStatusIconSupported() {
  19. #if GTK_CHECK_VERSION(3, 90, 0)
  20. NOTIMPLEMENTED();
  21. return false;
  22. #else
  23. return true;
  24. #endif
  25. }
  26. std::unique_ptr<views::StatusIconLinux> CreateLinuxStatusIcon(
  27. const gfx::ImageSkia& image,
  28. const base::string16& tool_tip,
  29. const char* id_prefix) {
  30. #if GTK_CHECK_VERSION(3, 90, 0)
  31. NOTIMPLEMENTED();
  32. return nullptr;
  33. #else
  34. if (AppIndicatorIcon::CouldOpen()) {
  35. ++indicators_count;
  36. return std::unique_ptr<views::StatusIconLinux>(new AppIndicatorIcon(
  37. base::StringPrintf("%s%d", id_prefix, indicators_count), image,
  38. tool_tip));
  39. } else {
  40. return std::unique_ptr<views::StatusIconLinux>(
  41. new GtkStatusIcon(image, tool_tip));
  42. }
  43. return nullptr;
  44. #endif
  45. }
  46. } // namespace gtkui
  47. } // namespace electron