Ardour  9.0-pre0-427-gd2a3450e2f
libs/gtkmm2ext/gtkmm2ext/actions.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2019 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __libgtkmm2ext_actions_h__
22 #define __libgtkmm2ext_actions_h__
23 
24 #include <vector>
25 #include <exception>
26 
27 #include <gtkmm/action.h>
28 #include <gtkmm/radioaction.h>
29 #include <gtkmm/toggleaction.h>
30 #include <gtkmm/actiongroup.h>
31 #include <gtkmm/accelkey.h>
32 
33 #include "gtkmm2ext/visibility.h"
34 
35 namespace Gtk {
36  class UIManager;
37 }
38 
39 namespace ActionManager {
40 
41 /* Why is this a namespace and not a class?
42  *
43  * 1) We want it to behave like a singleton without an instance() method. This
44  * would normally be accomplished by using a set of static methods and member
45  * variables.
46  *
47  * 2) We need to extend the contents of the (class|namespace) in
48  * gtk2_ardour. We can't do this with a class without inheritance, which is not
49  * what we're looking for because we want a non-instance singleton.
50  *
51  * Hence, we use namespacing to allow us to write ActionManager::foobar() as
52  * well as the extensions in gtk2_ardour/actions.h
53  *
54  */
55 
56  class LIBGTKMM2EXT_API MissingActionException : public std::exception {
57  public:
58  MissingActionException (std::string const & str);
60  const char *what() const throw();
61  private:
62  std::string missing_action_name;
63  };
64 
65  LIBGTKMM2EXT_API extern void init ();
66 
67  LIBGTKMM2EXT_API extern std::string unbound_string; /* the key string returned if an action is not bound */
68  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::UIManager> ui_manager;
69 
70  LIBGTKMM2EXT_API extern void set_sensitive (Glib::RefPtr<Gtk::ActionGroup> group, bool yn);
71  LIBGTKMM2EXT_API extern void set_sensitive (std::vector<Glib::RefPtr<Gtk::Action> >& actions, bool);
72  LIBGTKMM2EXT_API extern std::string get_key_representation (const std::string& accel_path, Gtk::AccelKey& key);
73  LIBGTKMM2EXT_API extern Gtk::Widget* get_widget (const char * name);
74  LIBGTKMM2EXT_API extern void do_action (const char* group, const char* name);
75  LIBGTKMM2EXT_API extern void set_toggle_action (const char* group, const char* name, bool);
76  LIBGTKMM2EXT_API extern void check_toggleaction (const std::string&);
77  LIBGTKMM2EXT_API extern void uncheck_toggleaction (const std::string&);
78  LIBGTKMM2EXT_API extern void set_toggleaction_state (const std::string&, bool);
79  LIBGTKMM2EXT_API extern bool set_toggleaction_state (const char*, const char*, bool);
83 
84  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ActionGroup> create_action_group (void * owner, std::string const & group_name);
85  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ActionGroup> get_action_group (std::string const & group_name);
86 
87  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, const char* name, const char* label);
88  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group,
89  const char* name, const char* label, sigc::slot<void> sl);
90  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group,
91  Gtk::RadioAction::Group&,
92  const char* name, const char* label,
93  sigc::slot<void,GtkAction*> sl,
94  int value);
95  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group,
96  Gtk::RadioAction::Group&,
97  const char* name, const char* label,
98  sigc::slot<void> sl);
99  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_toggle_action (Glib::RefPtr<Gtk::ActionGroup> group,
100  const char* name, const char* label, sigc::slot<void> sl);
101 
102  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> get_action (const std::string& name, bool or_die = true);
103  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> get_action (char const * group_name, char const * action_name, bool or_die = true);
104  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ToggleAction> get_toggle_action (const std::string& name, bool or_die = true);
105  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ToggleAction> get_toggle_action (char const * group_name, char const * action_name, bool or_die = true);
106  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (const std::string& name, bool or_die = true);
107  LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (char const * group_name, char const * action_name, bool or_die = true);
108 
109  LIBGTKMM2EXT_API extern void get_actions (void* owner, std::vector<Glib::RefPtr<Gtk::Action> >&);
110 
111  LIBGTKMM2EXT_API extern void get_all_actions (std::vector<std::string>& paths,
112  std::vector<std::string>& labels,
113  std::vector<std::string>& tooltips,
114  std::vector<std::string>& keys,
115  std::vector<Glib::RefPtr<Gtk::Action> >& actions);
116 
117 };
118 
119 #endif /* __libgtkmm2ext_actions_h__ */
MissingActionException(std::string const &str)
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBGTKMM2EXT_API
Glib::RefPtr< Gtk::RadioAction > get_radio_action(const std::string &name, bool or_die=true)
void set_sensitive(Glib::RefPtr< Gtk::ActionGroup > group, bool yn)
Glib::RefPtr< Gtk::ActionGroup > create_action_group(void *owner, std::string const &group_name)
Glib::RefPtr< Gtk::Action > register_toggle_action(Glib::RefPtr< Gtk::ActionGroup > group, const char *name, const char *label, sigc::slot< void > sl)
Glib::RefPtr< Gtk::ActionGroup > get_action_group(std::string const &group_name)
void check_toggleaction(const std::string &)
std::string get_key_representation(const std::string &accel_path, Gtk::AccelKey &key)
void enable_active_actions()
Glib::RefPtr< Gtk::Action > register_radio_action(Glib::RefPtr< Gtk::ActionGroup > group, Gtk::RadioAction::Group &, const char *name, const char *label, sigc::slot< void, GtkAction * > sl, int value)
void get_actions(void *owner, std::vector< Glib::RefPtr< Gtk::Action > > &)
void set_toggle_action(const char *group, const char *name, bool)
std::string unbound_string
Glib::RefPtr< Gtk::Action > get_action(const std::string &name, bool or_die=true)
void uncheck_toggleaction(const std::string &)
void save_action_states()
Glib::RefPtr< Gtk::ToggleAction > get_toggle_action(const std::string &name, bool or_die=true)
void disable_active_actions()
Glib::RefPtr< Gtk::Action > register_action(Glib::RefPtr< Gtk::ActionGroup > group, const char *name, const char *label)
Gtk::Widget * get_widget(const char *name)
void do_action(const char *group, const char *name)
void set_toggleaction_state(const std::string &, bool)
void get_all_actions(std::vector< std::string > &paths, std::vector< std::string > &labels, std::vector< std::string > &tooltips, std::vector< std::string > &keys, std::vector< Glib::RefPtr< Gtk::Action > > &actions)
Glib::RefPtr< Gtk::UIManager > ui_manager
Definition: ardour_ui.h:188