From bb457bb960c5bd7ed538f9d31477293415739f68 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 10 Jan 2008 21:20:59 +0000 Subject: Merge libs/ardour and gtk2_ardour with 2.0-ongoing R2837. git-svn-id: svn://localhost/ardour2/trunk@2883 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/actions.cc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'gtk2_ardour/actions.cc') diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index 023520c17e..1484c01454 100644 --- a/gtk2_ardour/actions.cc +++ b/gtk2_ardour/actions.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -150,6 +151,14 @@ ActionManager::lookup_entry (const ustring accel_path, Gtk::AccelKey& key) return known; } +struct SortActionsByLabel { + bool operator() (Glib::RefPtr a, Glib::RefPtr b) { + ustring astr = a->get_accel_path(); + ustring bstr = b->get_accel_path(); + return astr < bstr; + } +}; + void ActionManager::get_all_actions (vector& names, vector& paths, vector& keys, vector& bindings) { @@ -162,18 +171,29 @@ ActionManager::get_all_actions (vector& names, vector& paths, ve GList* acts; for (node = list; node; node = g_list_next (node)) { - + GtkActionGroup* group = (GtkActionGroup*) node->data; + + /* first pass: collect them all */ + + typedef std::list > action_list; + action_list the_acts; for (acts = gtk_action_group_list_actions (group); acts; acts = g_list_next (acts)) { - GtkAction* action = (GtkAction*) acts->data; + the_acts.push_back (Glib::wrap (action, true)); + } + + /* now sort by label */ + + SortActionsByLabel cmp; + the_acts.sort (cmp); - Glib::RefPtr act = Glib::wrap (action, true); + for (action_list::iterator a = the_acts.begin(); a != the_acts.end(); ++a) { + + string accel_path = (*a)->get_accel_path (); + ustring label = (*a)->property_label(); - string accel_path = act->get_accel_path (); - ustring label = act->property_label(); - names.push_back (label); paths.push_back (accel_path); -- cgit v1.2.3