status_icon_gtk.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (c) 2023 Microsoft, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_
  5. #define ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_
  6. #include <memory>
  7. #include "ui/base/glib/glib_integers.h"
  8. #include "ui/base/glib/scoped_gobject.h"
  9. #include "ui/base/glib/scoped_gsignal.h"
  10. #include "ui/linux/status_icon_linux.h"
  11. typedef struct _GtkStatusIcon GtkStatusIcon;
  12. namespace electron {
  13. namespace gtkui {
  14. class MenuGtk;
  15. }
  16. class StatusIconGtk : public ui::StatusIconLinux {
  17. public:
  18. StatusIconGtk();
  19. StatusIconGtk(const StatusIconGtk&) = delete;
  20. StatusIconGtk& operator=(const StatusIconGtk&) = delete;
  21. ~StatusIconGtk() override;
  22. // ui::StatusIconLinux:
  23. void SetIcon(const gfx::ImageSkia& image) override;
  24. void SetToolTip(const std::u16string& tool_tip) override;
  25. void UpdatePlatformContextMenu(ui::MenuModel* model) override;
  26. void RefreshPlatformContextMenu() override;
  27. void OnSetDelegate() override;
  28. private:
  29. void OnClick(GtkStatusIcon* status_icon);
  30. void OnContextMenuRequested(GtkStatusIcon* status_icon,
  31. guint button,
  32. guint32 activate_time);
  33. std::unique_ptr<gtkui::MenuGtk> menu_;
  34. ScopedGObject<GtkStatusIcon> icon_;
  35. std::vector<ScopedGSignal> signals_;
  36. };
  37. } // namespace electron
  38. #endif // ELECTRON_SHELL_BROWSER_UI_STATUS_ICON_GTK_H_