improve scroll and drag behaviour of volume-controller knob
[ardour.git] / libs / gtkmm2ext / actions.cc
index 3fc9def399974f20484b42b6429f0b77662e1784..84a738f278559a84f1a6149327d6e9a8bbaa3abf 100644 (file)
@@ -250,23 +250,29 @@ ActionManager::get_action (const char* path)
                return RefPtr<Action>();
        }
 
-       char copy[strlen(path)+1];
-
-       if (*path == '/') {
-               const char* cslash = strchr (path, '/');
-               if (!cslash) {
-                       return RefPtr<Action> ();
-               }       
-               strcpy (copy, cslash+1);
-       } else {
-               strcpy (copy, path);
+       /* Skip <Actions>/ in path */
+
+       int len = strlen (path);
+
+       if (len < 3) {
+               /* shortest possible path: "a/b" */
+               return RefPtr<Action>();
        }
 
+       if (len > 10 && !strncmp (path, "<Actions>/", 10 )) {
+               path = path+10;
+       } else if (path[0] == '/') {
+               path++;
+       }
+
+       char copy[len+1];
+       strcpy (copy, path);
        char* slash = strchr (copy, '/');
        if (!slash) {
                return RefPtr<Action> ();
        }
        *slash = '\0';
+
        return get_action (copy, ++slash);
        
 }
@@ -338,8 +344,20 @@ ActionManager::set_sensitive (vector<RefPtr<Action> >& actions, bool state)
        }
 }
 
+void
+ActionManager::check_toggleaction (string n)
+{
+       set_toggleaction_state (n, true);
+}
+
 void
 ActionManager::uncheck_toggleaction (string n)
+{
+       set_toggleaction_state (n, false);
+}
+
+void
+ActionManager::set_toggleaction_state (string n, bool s)
 {
        char const * name = n.c_str ();
        
@@ -363,7 +381,7 @@ ActionManager::uncheck_toggleaction (string n)
         RefPtr<Action> act = get_action (group_name, action_name);
        if (act) {
                RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
-                       tact->set_active (false);
+                       tact->set_active (s);
        } else {
                error << string_compose (_("Unknown action name: %1"),  name) << endmsg;
        }