mousetrap v0.2.0
Loading...
Searching...
No Matches
mousetrap::Application Class Reference

object representing an entire application, supplies the main render loop, mapping of actions More...

#include <application.hpp>

Inheritance diagram for mousetrap::Application:
mousetrap::SignalEmitter mousetrap::StyleManager mousetrap::has_signal_activate< Application > mousetrap::has_signal_shutdown< Application >

Public Member Functions

 Application (const ApplicationID &id, bool allow_multiple_instances=false)
 construct new action
 
 Application (detail::ApplicationInternal *internal)
 construct from internal
 
 ~Application ()
 destroy action, should only be called at the very end of main
 
 Application (const Application &)=delete
 copy ctor delete
 
 Application (Application &&) noexcept
 move ctor
 
Applicationoperator= (const Application &)=delete
 copy assignment deleted
 
Applicationoperator= (Application &&) noexcept
 move assignment
 
 operator NativeObject () const override
 
 operator GtkApplication * () const
 expose as GtkApplication
 
NativeObject get_internal () const override
 expose internally managed object, \for_internal_use_only
 
ApplicationID get_id () const
 get id
 
int run ()
 start the main render loop
 
void quit ()
 immediately exit the application, this forces mousetrap::Application::run to return
 
void hold ()
 mark the application such that quitting regularly will be prevented, use mousetrap::Application::release to undo this
 
void release ()
 undo a previous mousetrap::Application::hold()
 
void mark_as_busy ()
 mark that the application is currently doing a long-running application. Call mousetrap::Application::unmark_as_busy to undo this
 
void unmark_as_busy ()
 undo a previous call to mousetrap::Application::mark_as_busy
 
bool get_is_marked_as_busy () const
 get whether mark_as_busy was called
 
bool get_is_holding () const
 get whether application is currently holding, preventing exiting
 
void add_action (const Action &action)
 add an action to application, see the manual page on actions for details
 
void remove_action (const ActionID &id)
 remove an action from application
 
Action get_action (const ActionID &id)
 lookup action based on action id
 
bool has_action (const ActionID &id)
 check if application has an action with given id registered
 
void set_current_theme (Theme)
 set the current style theme, this will affect all windows
 
Theme get_current_theme () const
 get current style theme
 
- 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_activate< Application >
void connect_signal_activate (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_activate (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_activate_blocked (bool b)
 
bool get_signal_activate_blocked () const
 
void emit_signal_activate ()
 invoke signal handler manually
 
void disconnect_signal_activate ()
 
- Public Member Functions inherited from mousetrap::has_signal_shutdown< Application >
void connect_signal_shutdown (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_shutdown (Function_t f)
 connect handler, will be invoked when signal is emitted
 
void set_signal_shutdown_blocked (bool b)
 Set whether signal emission should trigger the signal handler.
 
bool get_signal_shutdown_blocked () const
 get whether signal emission should trigger the signal handler
 
void emit_signal_shutdown ()
 invoke signal handler manually
 
void disconnect_signal_shutdown ()
 disconnect the signal handler
 

Static Public Member Functions

static void test ()
 
- Static Public Member Functions inherited from mousetrap::StyleManager
static void add_style_class (const StyleClass &)
 update / add a style class
 
static void remove_style_class (const StyleClass &)
 remove style class
 
static StyleClass get_style_class (const std::string &)
 retrieve style class
 
static void add_css (const std::string &)
 run arbitrary css code
 
static std::string define_color (const std::string &name, RGBA color)
 define a color, can be used by prefixing the given name with @
 
static std::string define_color (const std::string &name, HSVA color)
 define a color, can be used by prefixing the given name with @
 
static std::string color_to_css (RGBA)
 convert mousetrap color to css
 
static std::string color_to_css (HSVA)
 convert mousetrap color to css
 

Additional Inherited Members

- Static Public Attributes inherited from mousetrap::has_signal_activate< Application >
static const char * signal_id
 glib ID
 
- Static Public Attributes inherited from mousetrap::has_signal_shutdown< Application >
static const char * signal_id
 
- Protected Member Functions inherited from mousetrap::SignalEmitter
 SignalEmitter ()
 ctor
 
 ~SignalEmitter ()
 destructor
 
- Protected Member Functions inherited from mousetrap::has_signal_activate< Application >
 has_signal_activate (Application *instance)
 
- Protected Member Functions inherited from mousetrap::has_signal_shutdown< Application >
 has_signal_shutdown (Application *instance)
 ctor protected
 

Detailed Description

object representing an entire application, supplies the main render loop, mapping of actions

signal id signature emitted when...
activate (Application&, (Data_t)) -> void Widget is activated, usually by pressing Enter while it is in focus or otherwise triggering interaction with it
shutdown (Application&, (Data_t)) -> void Application was requested to close, usually by the last window being closed

Constructor & Destructor Documentation

◆ Application() [1/2]

mousetrap::Application::Application ( const ApplicationID &  id,
bool  allow_multiple_instances = false 
)

construct new action

Parameters
idvalid application id, see

References mousetrap::log::critical().

◆ Application() [2/2]

mousetrap::Application::Application ( detail::ApplicationInternal *  internal)

construct from internal

Parameters
internal

Member Function Documentation

◆ add_action()

void mousetrap::Application::add_action ( const Action action)

add an action to application, see the manual page on actions for details

Parameters
actionpointer to action, the user is responsible for making sure the action stays in scope

References mousetrap::Action::get_id(), and mousetrap::log::warning().

◆ get_action()

Action mousetrap::Application::get_action ( const ActionID &  id)

lookup action based on action id

Parameters
id
Returns
thin wrapper around action, this is a newly created wrapper around the internal action object, not the mousetrap::Action instance initially registered via Application::add_action

References mousetrap::log::critical().

◆ get_current_theme()

Theme mousetrap::Application::get_current_theme ( ) const

get current style theme

Returns
theme

◆ get_id()

ApplicationID mousetrap::Application::get_id ( ) const

get id

Returns
id

◆ get_internal()

NativeObject mousetrap::Application::get_internal ( ) const
overridevirtual

expose internally managed object, \for_internal_use_only

Reimplemented from mousetrap::SignalEmitter.

◆ has_action()

bool mousetrap::Application::has_action ( const ActionID &  id)

check if application has an action with given id registered

Parameters
id
Returns
true if action with id is registered, false otherwise

Referenced by remove_action().

◆ operator NativeObject()

mousetrap::Application::operator NativeObject ( ) const
overridevirtual

◆ remove_action()

void mousetrap::Application::remove_action ( const ActionID &  id)

remove an action from application

Parameters
id

References has_action().

◆ run()

int mousetrap::Application::run ( )

start the main render loop

Returns
1 on error, 0 otherwise

◆ set_current_theme()

void mousetrap::Application::set_current_theme ( Theme  theme)

set the current style theme, this will affect all windows

Parameters
themetheme to use

References mousetrap::log::critical(), and mousetrap::log::warning().


The documentation for this class was generated from the following files: