menu_util.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2013 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 SHELL_BROWSER_UI_GTK_MENU_UTIL_H_
  5. #define SHELL_BROWSER_UI_GTK_MENU_UTIL_H_
  6. #include <gtk/gtk.h>
  7. #include <string>
  8. #include "ui/gfx/image/image.h"
  9. namespace ui {
  10. class MenuModel;
  11. }
  12. namespace electron {
  13. namespace gtkui {
  14. // Builds GtkImageMenuItems.
  15. GtkWidget* BuildMenuItemWithImage(const std::string& label, GtkWidget* image);
  16. GtkWidget* BuildMenuItemWithImage(const std::string& label,
  17. const gfx::Image& icon);
  18. GtkWidget* BuildMenuItemWithLabel(const std::string& label);
  19. ui::MenuModel* ModelForMenuItem(GtkMenuItem* menu_item);
  20. // This method is used to build the menu dynamically. The return value is the
  21. // new menu item.
  22. GtkWidget* AppendMenuItemToMenu(int index,
  23. ui::MenuModel* model,
  24. GtkWidget* menu_item,
  25. GtkWidget* menu,
  26. bool connect_to_activate,
  27. GCallback item_activated_cb,
  28. void* this_ptr);
  29. // Gets the ID of a menu item.
  30. // Returns true if the menu item has an ID.
  31. bool GetMenuItemID(GtkWidget* menu_item, int* menu_id);
  32. // Execute command associated with specified id.
  33. void ExecuteCommand(ui::MenuModel* model, int id);
  34. // Creates a GtkMenu from |model_|. block_activation_ptr is used to disable
  35. // the item_activated_callback while we set up the set up the menu items.
  36. // See comments in definition of SetMenuItemInfo for more info.
  37. void BuildSubmenuFromModel(ui::MenuModel* model,
  38. GtkWidget* menu,
  39. GCallback item_activated_cb,
  40. bool* block_activation,
  41. void* this_ptr);
  42. // Sets the check mark, enabled/disabled state and dynamic labels on menu items.
  43. void SetMenuItemInfo(GtkWidget* widget, void* block_activation_ptr);
  44. } // namespace gtkui
  45. } // namespace electron
  46. #endif // SHELL_BROWSER_UI_GTK_MENU_UTIL_H_