menu_gtk.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_
  5. #define ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_
  6. #include "base/functional/callback.h"
  7. #include "base/memory/raw_ptr.h"
  8. #include "ui/base/glib/scoped_gobject.h"
  9. #include "ui/base/glib/scoped_gsignal.h"
  10. typedef struct _GtkMenu GtkMenu;
  11. typedef struct _GtkWidget GtkWidget;
  12. namespace ui {
  13. class MenuModel;
  14. }
  15. namespace electron::gtkui {
  16. class MenuGtk {
  17. public:
  18. explicit MenuGtk(ui::MenuModel* model);
  19. virtual ~MenuGtk();
  20. // Refreshes all the menu item labels and menu item checked/enabled states.
  21. void Refresh();
  22. GtkMenu* GetGtkMenu();
  23. private:
  24. // Callback for when a menu item is activated.
  25. void OnMenuItemActivated(GtkWidget* menu_item);
  26. raw_ptr<ui::MenuModel> menu_model_; // not owned
  27. ScopedGObject<GtkWidget> gtk_menu_;
  28. bool block_activation_ = false;
  29. std::vector<ScopedGSignal> signals_;
  30. };
  31. } // namespace electron::gtkui
  32. #endif // ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_