|
mousetrap v0.2.0
|
Command with a name, registered to an application. See the manual section on actions for more information. More...
#include <action.hpp>
Public Member Functions | |
| Action (const std::string &id, Application &application) | |
| construct an action with immutable id | |
| Action (detail::ActionInternal *internal) | |
| create from internal | |
| ~Action () | |
| dtor | |
| ActionID | get_id () const |
| get action id | |
| Action (const Action &) | |
| copy ctor delete | |
| Action (Action &&) noexcept | |
| move ctor | |
| Action & | operator= (const Action &)=delete |
| copy assignment deleted, actions should not be duplicated | |
| Action & | operator= (Action &&) noexcept=delete |
| move assignment deleted, actions should not be moved | |
| operator NativeObject () const override | |
| expose as GObject | |
| NativeObject | get_internal () const override |
| get internal | |
| template<typename Function_t > | |
| void | set_function (Function_t f) |
| create action as stateless, given function is executed when action is triggered | |
| template<typename Function_t , typename Data_t > | |
| void | set_function (Function_t f, Data_t data) |
| create action as stateless, given function is executed when action is triggered | |
| template<typename Function_t > | |
| void | set_stateful_function (Function_t f, bool initial_state=false) |
| create action as stateful, given function is executed when action is triggered | |
| template<typename Function_t , typename Data_t > | |
| void | set_stateful_function (Function_t f, Data_t data, bool initial_state=false) |
| create action as stateful, given function is executed when action is triggered | |
| void | set_state (bool new_state) |
| set the state of a stateful action, if the action is not stateful, does nothing | |
| bool | get_state () const |
| get state of a stateful action, if the action is not stateful, returns false | |
| void | activate () |
| trigger the action | |
| void | add_shortcut (const ShortcutTriggerID &trigger) |
| add a shortcut trigger for action, warns but does not throw if trigger is malformed | |
| const std::vector< ShortcutTriggerID > & | get_shortcuts () const |
| get shortcuts for action | |
| void | clear_shortcuts () |
| reset all shortcuts | |
| void | set_enabled (bool is_enabled) |
| set whether triggering the action will execute the registered function | |
| bool | get_enabled () const |
| get whether the action is currently enabled | |
| bool | get_is_stateful () const |
| get whether the action is stateful | |
Public Member Functions inherited from mousetrap::SignalEmitter | |
| void | set_signal_blocked (const std::string &signal_id, bool b) |
| block a signal by id \for_internal_use_only | |
| bool | get_signal_blocked (const std::string &signal_id) const |
| get whether a signal is currently blocked | |
| std::vector< std::string > | get_all_signal_names () |
| get list of possible signal ids \for_internal_use_only | |
| template<typename Function_t > | |
| void | connect_signal (const std::string &signal_id, Function_t *function, void *data=nullptr) |
| connect static function to signal, does not work with lambdas \for_internal_use_only | |
| void | disconnect_signal (const std::string &signal_id) |
| disconnect signal, it may not be invoked until reconnected, if signal is not registered, does nothing. For internal use only | |
| virtual | operator NativeObject () const =0 |
| expose as NativeObject, this is the GLib instance that signals are emitted on \for_internal_use_only | |
| virtual NativeObject | get_internal () const |
| expose internally managed object, \for_internal_use_only | |
Public Member Functions inherited from mousetrap::has_signal_activated< Action > | |
| void | connect_signal_activated (Function_t f, Data_t data) |
| connect handler, will be invoked when signal is emitted. Data is passed to the signal handler function | |
| void | connect_signal_activated (Function_t f) |
| connect handler, will be invoked when signal is emitted | |
| void | set_signal_activated_blocked (bool b) |
| bool | get_signal_activated_blocked () const |
| void | emit_signal_activated (UnusedArgument_t _) |
| invoke signal handler manually | |
| void | disconnect_signal_activated () |
Friends | |
| class | Application |
Additional Inherited Members | |
Static Public Attributes inherited from mousetrap::has_signal_activated< Action > | |
| static const char * | signal_id |
| glib ID | |
Protected Member Functions inherited from mousetrap::SignalEmitter | |
| SignalEmitter () | |
| ctor | |
| ~SignalEmitter () | |
| destructor | |
Protected Member Functions inherited from mousetrap::has_signal_activated< Action > | |
| has_signal_activated (Action *instance) | |
Command with a name, registered to an application. See the manual section on actions for more information.
| signal id | signature | emitted when... |
|---|---|---|
activated | (Action&, void* _, (Data_t)) -> void | Action is triggered |
| mousetrap::Action::Action | ( | const std::string & | id, |
| Application & | application | ||
| ) |
construct an action with immutable id
| id | string, usually of the form scope.action_name |
| application |
| mousetrap::Action::Action | ( | detail::ActionInternal * | internal | ) |
create from internal
| internal |
| void mousetrap::Action::add_shortcut | ( | const ShortcutTriggerID & | trigger | ) |
add a shortcut trigger for action, warns but does not throw if trigger is malformed
| trigger |
References mousetrap::log::critical().
| void mousetrap::Action::clear_shortcuts | ( | ) |
reset all shortcuts
| action |
| bool mousetrap::Action::get_enabled | ( | ) | const |
get whether the action is currently enabled
| ActionID mousetrap::Action::get_id | ( | ) | const |
get action id
Referenced by mousetrap::Application::add_action(), mousetrap::ShortcutEventController::add_action(), mousetrap::MenuModel::add_action(), mousetrap::MenuModel::add_icon(), get_state(), mousetrap::ShortcutEventController::remove_action(), mousetrap::Button::set_action(), mousetrap::PopupMessage::set_button_action(), mousetrap::Widget::set_listens_for_shortcut_actions(), and set_state().
|
overridevirtual |
get internal
Reimplemented from mousetrap::SignalEmitter.
| bool mousetrap::Action::get_is_stateful | ( | ) | const |
get whether the action is stateful
Referenced by mousetrap::MenuModel::add_action(), get_state(), and set_state().
| const std::vector< ShortcutTriggerID > & mousetrap::Action::get_shortcuts | ( | ) | const |
get shortcuts for action
Referenced by mousetrap::ShortcutEventController::add_action(), mousetrap::ShortcutEventController::remove_action(), and mousetrap::Widget::set_listens_for_shortcut_actions().
| bool mousetrap::Action::get_state | ( | ) | const |
get state of a stateful action, if the action is not stateful, returns false
References get_id(), get_is_stateful(), and mousetrap::log::warning().
Referenced by mousetrap::MenuModel::add_action().
|
overridevirtual |
expose as GObject
Implements mousetrap::SignalEmitter.
| void mousetrap::Action::set_enabled | ( | bool | is_enabled | ) |
set whether triggering the action will execute the registered function
| is_enabled |
Referenced by set_function(), and set_stateful_function().
| void mousetrap::Action::set_function | ( | Function_t | f | ) |
create action as stateless, given function is executed when action is triggered
| Function_t | lambda or static function with signature (Action&) -> void |
| f | function |
References set_enabled().
| void mousetrap::Action::set_function | ( | Function_t | f, |
| Data_t | data | ||
| ) |
create action as stateless, given function is executed when action is triggered
| Function_t | lambda or static function with signature (Action&, Data_t) -> void |
| Data_t | arbitrary data type |
| f | function |
| data | data |
References set_enabled().
| void mousetrap::Action::set_state | ( | bool | new_state | ) |
set the state of a stateful action, if the action is not stateful, does nothing
| new_state |
References get_id(), get_is_stateful(), and mousetrap::log::warning().
| void mousetrap::Action::set_stateful_function | ( | Function_t | f, |
| bool | initial_state = false |
||
| ) |
create action as stateful, given function is executed when action is triggered
| Function_t | lambda or static function with signature (Action&, bool) -> bool |
| f | function |
| initial_state | state of the action on initialization |
References set_enabled().
| void mousetrap::Action::set_stateful_function | ( | Function_t | f, |
| Data_t | data, | ||
| bool | initial_state = false |
||
| ) |
create action as stateful, given function is executed when action is triggered
| Function_t | lambda or static function with signature (Action&, bool, Data_t) -> bool |
| f | function |
| data | data |
| initial_state | state of the action on initialization |
References set_enabled().