popup-menu.cpp 853 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #if defined(Hiro_PopupMenu)
  2. namespace hiro {
  3. auto pPopupMenu::construct() -> void {
  4. gtkMenu = gtk_menu_new();
  5. }
  6. auto pPopupMenu::destruct() -> void {
  7. gtk_widget_destroy(gtkMenu);
  8. }
  9. auto pPopupMenu::append(sAction action) -> void {
  10. if(action->self()) {
  11. gtk_menu_shell_append(GTK_MENU_SHELL(gtkMenu), action->self()->widget);
  12. action->self()->setFont(action->font(true));
  13. action->self()->setVisible(action->visible(true));
  14. }
  15. }
  16. auto pPopupMenu::remove(sAction action) -> void {
  17. }
  18. auto pPopupMenu::setFont(const Font& font) -> void {
  19. for(auto& action : state().actions) {
  20. if(action->self()) action->self()->setFont(action->font(true));
  21. }
  22. }
  23. auto pPopupMenu::setVisible(bool visible) -> void {
  24. if(visible) gtk_menu_popup(GTK_MENU(gtkMenu), nullptr, nullptr, nullptr, nullptr, 0, gtk_get_current_event_time());
  25. }
  26. }
  27. #endif