menu_gtk.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/memory/raw_ptr.h"
  7. #include "ui/base/glib/scoped_gobject.h"
  8. #include "ui/base/glib/scoped_gsignal.h"
  9. typedef struct _GtkMenu GtkMenu;
  10. typedef struct _GtkWidget GtkWidget;
  11. namespace ui {
  12. class MenuModel;
  13. }
  14. namespace electron::gtkui {
  15. class MenuGtk {
  16. public:
  17. explicit MenuGtk(ui::MenuModel* model);
  18. virtual ~MenuGtk();
  19. // Refreshes all the menu item labels and menu item checked/enabled states.
  20. void Refresh();
  21. GtkMenu* GetGtkMenu();
  22. private:
  23. // Callback for when a menu item is activated.
  24. void OnMenuItemActivated(GtkWidget* menu_item);
  25. raw_ptr<ui::MenuModel> menu_model_; // not owned
  26. ScopedGObject<GtkWidget> gtk_menu_;
  27. bool block_activation_ = false;
  28. std::vector<ScopedGSignal> signals_;
  29. };
  30. } // namespace electron::gtkui
  31. #endif // ELECTRON_SHELL_BROWSER_UI_GTK_MENU_GTK_H_