*/
#include <vector>
+
#include <gtk/gtkaccelmap.h>
+#include <gtk/gtkuimanager.h>
+#include <gtk/gtkactiongroup.h>
+
#include <gtkmm/accelmap.h>
#include <gtkmm/uimanager.h>
vector<RefPtr<Gtk::Action> > ActionManager::plugin_selection_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::range_sensitive_actions;
vector<RefPtr<Gtk::Action> > ActionManager::jack_sensitive_actions;
+vector<RefPtr<Gtk::Action> > ActionManager::jack_opposite_sensitive_actions;
+vector<RefPtr<Gtk::Action> > ActionManager::transport_sensitive_actions;
RefPtr<UIManager> ActionManager::ui_manager;
string ActionManager::unbound_string = "--";
ui_manager = UIManager::create ();
try {
- ui_manager->add_ui_from_file (ARDOUR::find_config_file("ardour-menus.xml"));
+ ui_manager->add_ui_from_file (ARDOUR::find_config_file("ardour-menus.xml"));
} catch (Glib::MarkupError& err) {
error << "badly formatted UI definition file" << endmsg;
} catch (...) {
- std::cerr << "ardour action xml file not found" << endl;
+ error << "Ardour menu definition file not found" << endmsg;
}
-
}
RefPtr<Action>
RefPtr<Action>
ActionManager::get_action (ustring name)
{
- return ui_manager->get_action (name);
+ /* the C++ API for functions used here appears to be broken in
+ gtkmm2.6, so we fall back to the C level.
+ */
+
+ GList* list = gtk_ui_manager_get_action_groups (ui_manager->gobj());
+ GList* node;
+ RefPtr<Action> act;
+
+ if (name.substr (0,9) != "<Actions>") {
+ error << "badly specified action name: " << name << endmsg;
+ return act;
+ }
+
+ ustring::size_type last_slash = name.find_last_of ('/');
+ ustring group_name = name.substr (10, last_slash - 10);
+ ustring action_name = name.substr (last_slash+1);
+
+ for (node = list; node; node = g_list_next (node)) {
+
+ GtkActionGroup* _ag = (GtkActionGroup*) node->data;
+
+ if (group_name == gtk_action_group_get_name (_ag)) {
+
+ GtkAction* _act;
+
+ if ((_act = gtk_action_group_get_action (_ag, action_name.c_str())) != 0) {
+ act = Glib::wrap (_act);
+ break;
+ }
+ }
+ }
+
+ return act;
+}
+
+void
+ActionManager::set_sensitive (vector<RefPtr<Action> >& actions, bool state)
+{
+ for (vector<RefPtr<Action> >::iterator i = actions.begin(); i != actions.end(); ++i) {
+ (*i)->set_sensitive (state);
+ }
+}
+
+void
+ActionManager::uncheck_toggleaction (const std::string& actionname)
+{
+ RefPtr<Action> act = get_action (actionname);
+ if (act) {
+ RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
+ tact->set_active (false);
+ } else {
+ error << "Invalid action name: " << actionname << endmsg;
+ }
}
+