3a20f4d5423d636c3617a4a1c76a7e942629fb33
[ardour.git] / gtk2_ardour / 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 __ardour_gtk_actions_h__
21 #define __ardour_gtk_actions_h__
22
23 #include <vector>
24 #include <gtkmm/action.h>
25 #include <gtkmm/radioaction.h>
26 #include <gtkmm/toggleaction.h>
27 #include <gtkmm/actiongroup.h>
28 #include <gtkmm/accelkey.h>
29
30 #include "ardour/rc_configuration.h"
31
32 namespace Gtk {
33         class UIManager;
34 }
35
36 class ActionManager
37 {
38   public:
39         ActionManager() {}
40         virtual ~ActionManager () {}
41
42         static void init ();
43
44         static std::vector<Glib::RefPtr<Gtk::Action> > session_sensitive_actions;
45         static std::vector<Glib::RefPtr<Gtk::Action> > region_list_selection_sensitive_actions;
46         static std::vector<Glib::RefPtr<Gtk::Action> > plugin_selection_sensitive_actions;
47
48         static std::vector<Glib::RefPtr<Gtk::Action> > region_selection_sensitive_actions;
49         static std::vector<Glib::RefPtr<Gtk::Action> > track_selection_sensitive_actions;
50         static std::vector<Glib::RefPtr<Gtk::Action> > point_selection_sensitive_actions;
51         static std::vector<Glib::RefPtr<Gtk::Action> > time_selection_sensitive_actions;
52         static std::vector<Glib::RefPtr<Gtk::Action> > line_selection_sensitive_actions;
53         static std::vector<Glib::RefPtr<Gtk::Action> > playlist_selection_sensitive_actions;
54         static std::vector<Glib::RefPtr<Gtk::Action> > mouse_edit_point_requires_canvas_actions;
55
56         static std::vector<Glib::RefPtr<Gtk::Action> > range_sensitive_actions;
57         static std::vector<Glib::RefPtr<Gtk::Action> > transport_sensitive_actions;
58         static std::vector<Glib::RefPtr<Gtk::Action> > jack_sensitive_actions;
59         static std::vector<Glib::RefPtr<Gtk::Action> > jack_opposite_sensitive_actions;
60         static std::vector<Glib::RefPtr<Gtk::Action> > edit_point_in_region_sensitive_actions;
61
62         static void map_some_state (const char* group, const char* action, bool (ARDOUR::RCConfiguration::*get)() const);
63         static void map_some_state (const char* group, const char* action, sigc::slot<bool>);
64         static void toggle_config_state (const char* group, const char* action, bool (ARDOUR::RCConfiguration::*set)(bool), bool (ARDOUR::RCConfiguration::*get)(void) const);
65         static void toggle_config_state_foo (const char* group, const char* action, sigc::slot<bool, bool>, sigc::slot<bool>);
66
67         static void set_sensitive (std::vector<Glib::RefPtr<Gtk::Action> >& actions, bool);
68
69         static std::string unbound_string;  /* the key string returned if an action is not bound */
70         static Glib::RefPtr<Gtk::UIManager> ui_manager;
71
72         static Gtk::Widget* get_widget (const char * name);
73         static Glib::RefPtr<Gtk::Action> get_action (const char* group, const char* name);
74         static Glib::RefPtr<Gtk::Action> get_action (const char* path);
75
76         static void add_action_group (Glib::RefPtr<Gtk::ActionGroup>);
77
78         static Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, 
79                                                    const char * name, const char * label);
80         static Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, 
81                                                    const char * name, const char * label, sigc::slot<void> sl, 
82                                                    guint key, Gdk::ModifierType mods);
83         static Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, 
84                                                    const char * name, const char * label, sigc::slot<void> sl);
85         
86         static Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group, Gtk::RadioAction::Group&, 
87                                                          const char * name, const char * label, sigc::slot<void> sl, 
88                                                          guint key, Gdk::ModifierType mods);
89         static Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group, Gtk::RadioAction::Group&, 
90                                                          const char * name, const char * label, sigc::slot<void> sl);
91         
92         static Glib::RefPtr<Gtk::Action> register_toggle_action (Glib::RefPtr<Gtk::ActionGroup> group, 
93                                                           const char * name, const char * label, sigc::slot<void> sl, 
94                                                           guint key, Gdk::ModifierType mods);
95         static Glib::RefPtr<Gtk::Action> register_toggle_action (Glib::RefPtr<Gtk::ActionGroup> group, 
96                                                           const char * name, const char * label, sigc::slot<void> sl);
97
98         static bool lookup_entry (const Glib::ustring accel_path, Gtk::AccelKey& key);
99
100         static void get_all_actions (std::vector<std::string>& names, 
101                                      std::vector<std::string>& paths, 
102                                      std::vector<std::string>& keys, 
103                                      std::vector<Gtk::AccelKey>& bindings);
104
105         static void get_all_actions (std::vector<std::string>& groups, 
106                                      std::vector<std::string>& paths, 
107                                      std::vector<Gtk::AccelKey>& bindings);
108
109         static void uncheck_toggleaction (const char * actionname);
110 };
111
112 #endif /* __ardour_gtk_actions_h__ */