1 #ifndef WF_PANEL_POPOVER_HPP 2 #define WF_PANEL_POPOVER_HPP 3 4 #include <gtkmm/menubutton.h> 5 #include <gtkmm/popover.h> 6 #include <wf-option-wrap.hpp> 7 8 /** 9 * A button which shows a popover on click. It adjusts the popup position 10 * automatically based on panel position (valid values are "top" and "bottom") 11 */ 12 class WayfireMenuButton : public Gtk::MenuButton 13 { 14 bool interactive = true; 15 bool has_focus = false; 16 WfOption<std::string> panel_position; 17 18 /* Make the menu button active on its AutohideWindow */ 19 void set_active_on_window(); 20 21 friend class WayfireAutohidingWindow; 22 /* Set the has_focus property */ 23 void set_has_focus(bool focus); 24 25 public: 26 Gtk::Popover m_popover; 27 28 WayfireMenuButton(const std::string& config_section); ~WayfireMenuButton()29 virtual ~WayfireMenuButton() {} 30 31 /** 32 * Set whether the popup should grab input focus when opened 33 * By default, the menu button interacts with the keyboard. 34 */ 35 void set_keyboard_interactive(bool interactive = true); 36 37 /** @return Whether the menu button interacts with the keyboard */ 38 bool is_keyboard_interactive() const; 39 40 /** @return Whether the popover currently has keyboard focus */ 41 bool is_popover_focused() const; 42 43 /** 44 * Grab the keyboard focus. 45 * Also sets the popover to keyboard interactive. 46 * 47 * NOTE: this works only if the popover was already opened. 48 */ 49 void grab_focus(); 50 }; 51 52 #endif /* end of include guard: WF_PANEL_POPOVER_HPP */ 53