accelerator_util.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_
  5. #define ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_
  6. #include <map>
  7. #include <string>
  8. #include "atom/browser/ui/atom_menu_model.h"
  9. #include "ui/base/accelerators/accelerator.h"
  10. namespace accelerator_util {
  11. typedef struct {
  12. int position;
  13. atom::AtomMenuModel* model;
  14. } MenuItem;
  15. typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
  16. // Parse a string as an accelerator.
  17. bool StringToAccelerator(const std::string& description,
  18. ui::Accelerator* accelerator);
  19. // Set platform accelerator for the Accelerator.
  20. void SetPlatformAccelerator(ui::Accelerator* accelerator);
  21. // Generate a table that contains memu model's accelerators and command ids.
  22. void GenerateAcceleratorTable(AcceleratorTable* table,
  23. atom::AtomMenuModel* model);
  24. // Trigger command from the accelerators table.
  25. bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
  26. const ui::Accelerator& accelerator);
  27. } // namespace accelerator_util
  28. #endif // ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_