accelerator_util.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // Generate a table that contains memu model's accelerators and command ids.
  20. void GenerateAcceleratorTable(AcceleratorTable* table,
  21. atom::AtomMenuModel* model);
  22. // Trigger command from the accelerators table.
  23. bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
  24. const ui::Accelerator& accelerator);
  25. } // namespace accelerator_util
  26. #endif // ATOM_BROWSER_UI_ACCELERATOR_UTIL_H_