2 Copyright (C) 2000-2007 Paul Davis
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.
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.
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.
20 #ifndef __libgtkmm2ext_actions_h__
21 #define __libgtkmm2ext_actions_h__
25 #include <gtkmm/action.h>
26 #include <gtkmm/radioaction.h>
27 #include <gtkmm/toggleaction.h>
28 #include <gtkmm/actiongroup.h>
29 #include <gtkmm/accelkey.h>
31 #include "gtkmm2ext/visibility.h"
37 namespace ActionManager {
39 /* Why is this a namespace and not a class?
41 * 1) We want it to behave like a singleton without an instance() method. This
42 * would normally be accomplished by using a set of static methods and member
45 * 2) We need to extend the contents of the (class|namespace) in
46 * gtk2_ardour. We can't do this with a class without inheritance, which is not
47 * what we're looking for because we want a non-instance singleton.
49 * Hence, we use namespacing to allow us to write ActionManager::foobar() as
50 * well as the extensions in gtk2_ardour/actions.h
54 LIBGTKMM2EXT_API extern void init ();
56 LIBGTKMM2EXT_API extern std::string unbound_string; /* the key string returned if an action is not bound */
57 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::UIManager> ui_manager;
59 LIBGTKMM2EXT_API extern void set_sensitive (Glib::RefPtr<Gtk::ActionGroup> group, bool yn);
60 LIBGTKMM2EXT_API extern void set_sensitive (std::vector<Glib::RefPtr<Gtk::Action> >& actions, bool);
61 LIBGTKMM2EXT_API extern std::string get_key_representation (const std::string& accel_path, Gtk::AccelKey& key);
62 LIBGTKMM2EXT_API extern Gtk::Widget* get_widget (const char * name);
63 LIBGTKMM2EXT_API extern void do_action (const char* group, const char* name);
64 LIBGTKMM2EXT_API extern void set_toggle_action (const char* group, const char* name, bool);
65 LIBGTKMM2EXT_API extern void check_toggleaction (const std::string&);
66 LIBGTKMM2EXT_API extern void uncheck_toggleaction (const std::string&);
67 LIBGTKMM2EXT_API extern void set_toggleaction_state (const std::string&, bool);
68 LIBGTKMM2EXT_API extern bool set_toggleaction_state (const char*, const char*, bool);
69 LIBGTKMM2EXT_API extern void save_action_states ();
70 LIBGTKMM2EXT_API extern void enable_active_actions ();
71 LIBGTKMM2EXT_API extern void disable_active_actions ();
73 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ActionGroup> create_action_group (void * owner, std::string const & group_name);
75 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group, const char* name, const char* label);
76 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_action (Glib::RefPtr<Gtk::ActionGroup> group,
77 const char* name, const char* label, sigc::slot<void> sl);
78 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group,
79 Gtk::RadioAction::Group&,
80 const char* name, const char* label,
81 sigc::slot<void,GtkAction*> sl,
83 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_radio_action (Glib::RefPtr<Gtk::ActionGroup> group,
84 Gtk::RadioAction::Group&,
85 const char* name, const char* label,
87 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> register_toggle_action (Glib::RefPtr<Gtk::ActionGroup> group,
88 const char* name, const char* label, sigc::slot<void> sl);
90 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> get_action (const std::string& name, bool or_die = true);
91 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::Action> get_action (char const * group_name, char const * action_name, bool or_die = true);
92 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ToggleAction> get_toggle_action (const std::string& name, bool or_die = true);
93 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::ToggleAction> get_toggle_action (char const * group_name, char const * action_name, bool or_die = true);
94 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (const std::string& name, bool or_die = true);
95 LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (char const * group_name, char const * action_name, bool or_die = true);
97 LIBGTKMM2EXT_API extern void get_actions (void* owner, std::vector<Glib::RefPtr<Gtk::Action> >&);
99 LIBGTKMM2EXT_API extern void get_all_actions (std::vector<std::string>& paths,
100 std::vector<std::string>& labels,
101 std::vector<std::string>& tooltips,
102 std::vector<std::string>& keys,
103 std::vector<Glib::RefPtr<Gtk::Action> >& actions);
107 #endif /* __libgtkmm2ext_actions_h__ */