mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
provide new API for Gtkmm2ext to allow ActionGroup cleanup
This commit is contained in:
parent
6cdf6b6e42
commit
146df0306c
2 changed files with 37 additions and 0 deletions
|
|
@ -438,6 +438,7 @@ ActionManager::register_radio_action (RefPtr<ActionGroup> group,
|
|||
{
|
||||
string fullpath;
|
||||
|
||||
DEBUG_TRACE (PBD::DEBUG::Actions, string_compose ("creating action %1 in %2\n", name, group->get_name()));
|
||||
RefPtr<Action> act = RadioAction::create (rgroup, name, label);
|
||||
DEBUG_TRACE (PBD::DEBUG::Actions, string_compose ("created action %1 in %2 success: %3\n", name, group->get_name(), (bool) act));
|
||||
RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
|
||||
|
|
@ -562,3 +563,37 @@ ActionManager::get_all_actions (std::vector<std::string>& paths,
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ActionManager::drop_action_group (Glib::RefPtr<ActionGroup> group)
|
||||
{
|
||||
/* Although ActionGroups are refcnt'ed we hold a reference on the
|
||||
actions they contain in our global actions map. So an action group, if
|
||||
to be deleted fully, needs to be passed in here first so that we can
|
||||
drop those references.
|
||||
*/
|
||||
|
||||
string group_name = group->get_name();
|
||||
string::size_type group_name_length = group_name.length();
|
||||
|
||||
for (auto iter = actions.begin(); iter != actions.end(); ) {
|
||||
|
||||
string::size_type pos = iter->first.find (group_name);
|
||||
|
||||
if (pos == 0 && iter->first.length() >= pos+group_name_length && iter->first[group_name_length] == '/') {
|
||||
iter = actions.erase (iter);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto iter = groups.begin(); iter != groups.end(); ++iter) {
|
||||
/* could use ptr equivalence here too */
|
||||
if ((*iter)->get_name() == group_name) {
|
||||
groups.erase (iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ActionManager::ui_manager->remove_action_group (group);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ namespace ActionManager {
|
|||
LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (const std::string& name, bool or_die = true);
|
||||
LIBGTKMM2EXT_API extern Glib::RefPtr<Gtk::RadioAction> get_radio_action (char const * group_name, char const * action_name, bool or_die = true);
|
||||
|
||||
LIBGTKMM2EXT_API extern void drop_action_group (Glib::RefPtr<Gtk::ActionGroup>);
|
||||
|
||||
LIBGTKMM2EXT_API extern void get_actions (void* owner, std::vector<Glib::RefPtr<Gtk::Action> >&);
|
||||
|
||||
LIBGTKMM2EXT_API extern void get_all_actions (std::vector<std::string>& paths,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue