diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2005-12-30 00:34:21 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2005-12-30 00:34:21 +0000 |
commit | d43cc4e7b5e95d4f4a8ed4d8fff99b6f846fe074 (patch) | |
tree | 4c4f688bb32f42fe91f45cdcbf39efdf04fa2461 /gtk2_ardour/actions.cc | |
parent | 0faaa3ad7bf0cedf68eda1dd43e232363b9f7f04 (diff) |
many changes, read the diffs
git-svn-id: svn://localhost/trunk/ardour2@214 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/actions.cc')
-rw-r--r-- | gtk2_ardour/actions.cc | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index 01dbde829a..5e33dc8aeb 100644 --- a/gtk2_ardour/actions.cc +++ b/gtk2_ardour/actions.cc @@ -19,6 +19,7 @@ */ #include <vector> +#include <string.h> #include <gtk/gtkaccelmap.h> #include <gtk/gtkuimanager.h> @@ -32,6 +33,7 @@ #include <ardour/ardour.h> #include "actions.h" +#include "i18n.h" using namespace std; using namespace Gtk; @@ -199,35 +201,25 @@ ActionManager::get_widget (const char * name) } RefPtr<Action> -ActionManager::get_action (const char * _name) +ActionManager::get_action (const char* group_name, const char* action_name) { /* the C++ API for functions used here appears to be broken in gtkmm2.6, so we fall back to the C level. */ - ustring name(_name); 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)) { - + if (strcmp (group_name, gtk_action_group_get_name (_ag)) == 0) { + GtkAction* _act; - if ((_act = gtk_action_group_get_action (_ag, action_name.c_str())) != 0) { + if ((_act = gtk_action_group_get_action (_ag, action_name)) != 0) { act = Glib::wrap (_act, true); break; } @@ -246,14 +238,33 @@ ActionManager::set_sensitive (vector<RefPtr<Action> >& actions, bool state) } void -ActionManager::uncheck_toggleaction (const char * actionname) +ActionManager::uncheck_toggleaction (const char * name) { - RefPtr<Action> act = get_action (actionname); + char *last_slash = strrchr (name, '/'); + + if (last_slash == 0) { + fatal << string_compose (_("programmer error: %1 %2"), X_("illegal toggle action name"), name) << endmsg; + /*NOTREACHED*/ + return; + } + + /* 10 = strlen ("<Actions>/") */ + size_t len = last_slash - (name + 10); + + char* group_name = new char[len+1]; + memcpy (group_name, name + 10, len); + group_name[len] = '\0'; + + char* action_name = last_slash + 1; + + RefPtr<Action> act = get_action (group_name, action_name); if (act) { RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act); tact->set_active (false); } else { - error << "Invalid action name: " << actionname << endmsg; + error << "Unknown action name: " << name << endmsg; } + + delete [] group_name; } |