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