summaryrefslogtreecommitdiff
path: root/gtk2_ardour/mtest.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2005-11-22 05:10:12 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2005-11-22 05:10:12 +0000
commitbac3c6bc0f36623e200fe30fc8cc4137ab96fba7 (patch)
treec8ffc7a6c6a0bc875b38cfd896f369dac45ce673 /gtk2_ardour/mtest.cc
parent46cbbae4eecd0d568f056a46745cd59ee8619c29 (diff)
plugin selector from doug; lots and lots of fixes from karsten
git-svn-id: svn://localhost/trunk/ardour2@105 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/mtest.cc')
-rw-r--r--gtk2_ardour/mtest.cc119
1 files changed, 24 insertions, 95 deletions
diff --git a/gtk2_ardour/mtest.cc b/gtk2_ardour/mtest.cc
index adc36c18f4..0ae55c8174 100644
--- a/gtk2_ardour/mtest.cc
+++ b/gtk2_ardour/mtest.cc
@@ -10,23 +10,6 @@ using namespace std;
using namespace sigc;
using namespace Glib;
-struct ActionBinding {
- Glib::ustring name;
- Glib::ustring label;
- Gtk::Action::SlotActivate binding;
- guint key;
- Gdk::ModifierType mods;
-
- ActionBinding (Glib::ustring n, Glib::ustring l, Gtk::Action::SlotActivate b,
- guint k = GDK_VoidSymbol, Gdk::ModifierType m = Gdk::ModifierType (0))
- : name (n),
- label (l),
- binding (b),
- key (k),
- mods (m) {}
-};
-
-
void
printit (string txt)
{
@@ -34,43 +17,15 @@ printit (string txt)
}
Glib::RefPtr<Action>
-make_action (vector<Glib::RefPtr<ActionGroup> >& groups, string name, string label, slot<void> sl, guint key, Gdk::ModifierType mods)
-{
- Glib::RefPtr<Action> last;
-
- for (vector<RefPtr<ActionGroup> >::iterator g = groups.begin(); g != groups.end(); ++g) {
- Glib::RefPtr<Action> act = Action::create (name, label);
- (*g)->add (act, sl);
- AccelMap::add_entry (act->get_accel_path(), key, mods);
- last = act;
- }
-
- return last;
-}
-
-Glib::RefPtr<Action>
-make_action (Glib::RefPtr<ActionGroup> group, Glib::RefPtr<AccelGroup> accel_group, string name, string label, slot<void> sl, guint key, Gdk::ModifierType mods)
+make_action (Glib::RefPtr<ActionGroup> group, string name, string label, RefPtr<AccelGroup> accels, slot<void> sl, guint key, Gdk::ModifierType mods)
{
Glib::RefPtr<Action> act;
act = Action::create (name, label);
group->add (act, sl);
AccelMap::add_entry (act->get_accel_path(), key, mods);
- act->set_accel_group (accel_group);
-
- cerr << "action " << name << " has path " << act->get_accel_path() << endl;
-
- return act;
-}
-Glib::RefPtr<Action>
-make_action (Glib::RefPtr<ActionGroup> group, string name, string label, slot<void> sl, guint key, Gdk::ModifierType mods)
-{
- Glib::RefPtr<Action> act;
-
- act = Action::create (name, label);
- group->add (act, sl);
- AccelMap::add_entry (act->get_accel_path(), key, mods);
+ act->set_accel_group (accels);
cerr << "action " << name << " has path " << act->get_accel_path() << endl;
@@ -78,19 +33,6 @@ make_action (Glib::RefPtr<ActionGroup> group, string name, string label, slot<vo
}
Glib::RefPtr<Action>
-make_action (Glib::RefPtr<ActionGroup> group, string name, string label, slot<void> sl)
-{
- Glib::RefPtr<Action> act;
-
- act = Action::create (name, label);
- group->add (act, sl);
-
- cerr << "action " << name << " has path " << act->get_accel_path() << endl;
-
- return act;
-}
-
-Glib::RefPtr<Action>
make_action (Glib::RefPtr<ActionGroup> group, string name, string label)
{
Glib::RefPtr<Action> act;
@@ -119,34 +61,25 @@ lookup_entry (const ustring accel_path, Gtk::AccelKey& key)
}
RefPtr<ActionGroup>
-make_shared_action_group (ustring name, vector<ActionBinding*>& actions)
+copy_actions (const RefPtr<ActionGroup> src)
{
- RefPtr<ActionGroup> grp = ActionGroup::create (name);
-
- for (vector<ActionBinding*>::iterator i = actions.begin(); i != actions.end(); ++i) {
- RefPtr<Action> act = Action::create ((*i)->name, (*i)->label);
+ RefPtr<ActionGroup> grp = ActionGroup::create (src->get_name());
+
+ ListHandle<RefPtr<Action> > group_actions = src->get_actions();
+
+ for (ListHandle<RefPtr<Action> >::iterator a = group_actions.begin(); a != group_actions.end(); ++a) {
+ RefPtr<Action> act = Action::create ((*a)->get_name(), (*a)->property_label());
grp->add (act);
-
- if ((*i)->key != GDK_VoidSymbol) {
- Gtk::AccelKey key;
-
- /* since this is a shared action, only add it once */
-
- if (!lookup_entry (act->get_accel_path(), key)) {
- AccelMap::add_entry (act->get_accel_path(), (*i)->key, (*i)->mods);
- cerr << "added accel map entry for " << act->get_accel_path() << endl;
- }
- }
}
return grp;
}
-
int
main (int argc, char* argv[])
{
Main app (argc, argv);
+ Window hidden (WINDOW_TOPLEVEL);
Window window (WINDOW_TOPLEVEL);
Window other_window (WINDOW_TOPLEVEL);
Button button ("click me for baz");
@@ -169,42 +102,38 @@ main (int argc, char* argv[])
uimanager = UIManager::create();
other_uimanager = UIManager::create();
+ shared_uimanager = UIManager::create();
actions = ActionGroup::create("MyActions");
other_actions = ActionGroup::create("OtherActions");
+ shared_actions = ActionGroup::create("SharedActions");
uimanager->add_ui_from_file ("mtest.menus");
other_uimanager->add_ui_from_file ("mtest_other.menus");
// AccelMap::load ("mtest.bindings");
- vector<RefPtr<ActionGroup> > all_groups;
- all_groups.push_back (actions);
- all_groups.push_back (other_actions);
-
+ RefPtr<AccelGroup> accels = hidden.get_accel_group();
+
make_action (actions, "TopMenu", "top");
- make_action (actions, "Foo", "foo", bind (sigc::ptr_fun (printit), "foo"), GDK_p, Gdk::ModifierType (0));
+ make_action (actions, "Foo", "foo", accels, bind (sigc::ptr_fun (printit), "foo"), GDK_p, Gdk::ModifierType (0));
make_action (other_actions, "OTopMenu", "otop");
- make_action (other_actions, "OFoo", "foo", bind (sigc::ptr_fun (printit), "o-foo"), GDK_p, Gdk::ModifierType (0));
-
- vector<ActionBinding*> shared_actions;
-
- shared_actions.push_back (new ActionBinding ("Bar", "bar", bind (sigc::ptr_fun (printit), "barshared"), GDK_p, Gdk::CONTROL_MASK));
- shared_actions.push_back (new ActionBinding ("Baz", "baz", bind (sigc::ptr_fun (printit), "baz-shared"), GDK_p, Gdk::SHIFT_MASK));
+ make_action (other_actions, "OFoo", "foo", accels, bind (sigc::ptr_fun (printit), "o-foo"), GDK_p, Gdk::ModifierType (0));
- RefPtr<Action> act = Action::create (shared_actions.back()->name, shared_actions.back()->label);
+ make_action (shared_actions, "Bar", "bar", accels, bind (sigc::ptr_fun (printit), "barshared"), GDK_p, Gdk::CONTROL_MASK);
+ RefPtr<Action> act = make_action (shared_actions, "Baz", "baz", accels, bind (sigc::ptr_fun (printit), "baz-shared"), GDK_p, Gdk::SHIFT_MASK);
act->connect_proxy (button);
act->connect_proxy (other_button);
- uimanager->insert_action_group (actions);
- uimanager->insert_action_group (make_shared_action_group ("shared", shared_actions));
- other_uimanager->insert_action_group (other_actions);
- other_uimanager->insert_action_group (make_shared_action_group ("othershared", shared_actions));
+ uimanager->insert_action_group (copy_actions (actions));
+ uimanager->insert_action_group (copy_actions (shared_actions));
+ other_uimanager->insert_action_group (copy_actions (other_actions));
+ other_uimanager->insert_action_group (copy_actions (shared_actions));
- other_window.add_accel_group (other_uimanager->get_accel_group());
- window.add_accel_group (uimanager->get_accel_group());
+ other_window.add_accel_group (accels);
+ window.add_accel_group (accels);
Gtk::MenuBar* m;