mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
more fixes on the long road to compiling
git-svn-id: svn://localhost/trunk/ardour2@103 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
5d51500490
commit
cdc2d055f1
15 changed files with 217 additions and 266 deletions
|
|
@ -1,10 +1,31 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/accelmap.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtkaccelmap.h>
|
||||
|
||||
using namespace Gtk;
|
||||
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)
|
||||
|
|
@ -12,6 +33,21 @@ printit (string txt)
|
|||
cout << "This is the " << txt << " item\n";
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -67,6 +103,46 @@ make_action (Glib::RefPtr<ActionGroup> group, string name, string label)
|
|||
return act;
|
||||
}
|
||||
|
||||
bool
|
||||
lookup_entry (const ustring accel_path, Gtk::AccelKey& key)
|
||||
{
|
||||
GtkAccelKey gkey;
|
||||
bool known = gtk_accel_map_lookup_entry (accel_path.c_str(), &gkey);
|
||||
|
||||
if (known) {
|
||||
key = AccelKey (gkey.accel_key, Gdk::ModifierType (gkey.accel_mods));
|
||||
} else {
|
||||
key = AccelKey (GDK_VoidSymbol, Gdk::ModifierType (0));
|
||||
}
|
||||
|
||||
return known;
|
||||
}
|
||||
|
||||
RefPtr<ActionGroup>
|
||||
make_shared_action_group (ustring name, vector<ActionBinding*>& actions)
|
||||
{
|
||||
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);
|
||||
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[])
|
||||
{
|
||||
|
|
@ -78,13 +154,12 @@ main (int argc, char* argv[])
|
|||
VBox vpacker;
|
||||
VBox other_vpacker;
|
||||
|
||||
Glib::RefPtr<ActionGroup> shared_actions;
|
||||
Glib::RefPtr<ActionGroup> actions;
|
||||
Glib::RefPtr<ActionGroup> other_actions;
|
||||
Glib::RefPtr<ActionGroup> shared_actions;
|
||||
Glib::RefPtr<UIManager> uimanager;
|
||||
Glib::RefPtr<UIManager> other_uimanager;
|
||||
Glib::RefPtr<UIManager> shared_uimanager;
|
||||
Glib::RefPtr<AccelGroup> shared_accel_group;
|
||||
|
||||
window.set_name ("Editor");
|
||||
window.set_title ("Editor");
|
||||
|
|
@ -94,44 +169,42 @@ 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();
|
||||
|
||||
uimanager->add_ui_from_file ("mtest.menus");
|
||||
other_uimanager->add_ui_from_file ("mtest_other.menus");
|
||||
|
||||
AccelMap::load ("mtest.bindings");
|
||||
// AccelMap::load ("mtest.bindings");
|
||||
|
||||
make_action (shared_actions, "SharedMenuBar", "shared");
|
||||
make_action (shared_actions, "SharedMenu", "sharedm");
|
||||
Glib::RefPtr<Action> act = make_action (shared_actions, "Baz", "baz", bind (sigc::ptr_fun (printit), "baz"), GDK_p, Gdk::MOD1_MASK);
|
||||
vector<RefPtr<ActionGroup> > all_groups;
|
||||
all_groups.push_back (actions);
|
||||
all_groups.push_back (other_actions);
|
||||
|
||||
make_action (actions, "TopMenu", "top");
|
||||
make_action (actions, "Foo", "foo", 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));
|
||||
|
||||
RefPtr<Action> act = Action::create (shared_actions.back()->name, shared_actions.back()->label);
|
||||
|
||||
act->connect_proxy (button);
|
||||
act->connect_proxy (other_button);
|
||||
|
||||
make_action (actions, "TopMenu", "top");
|
||||
make_action (actions, "Foo", "foo", bind (sigc::ptr_fun (printit), "foo"), GDK_p, Gdk::ModifierType (0));
|
||||
make_action (actions, "Bar", "bar", bind (sigc::ptr_fun (printit), "bar"), GDK_p, Gdk::CONTROL_MASK);
|
||||
make_action (other_actions, "OTopMenu", "otop");
|
||||
make_action (other_actions, "OFoo", "foo", bind (sigc::ptr_fun (printit), "o-foo"), GDK_p, Gdk::ModifierType (0));
|
||||
make_action (other_actions, "OBar", "bar", bind (sigc::ptr_fun (printit), "o-bar"), GDK_p, Gdk::CONTROL_MASK);
|
||||
|
||||
other_uimanager->insert_action_group (other_actions);
|
||||
other_uimanager->insert_action_group (shared_actions);
|
||||
|
||||
uimanager->insert_action_group (actions);
|
||||
uimanager->insert_action_group (shared_actions);
|
||||
|
||||
shared_uimanager->insert_action_group (shared_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));
|
||||
|
||||
other_window.add_accel_group (other_uimanager->get_accel_group());
|
||||
other_window.add_accel_group (shared_uimanager->get_accel_group());
|
||||
|
||||
window.add_accel_group (uimanager->get_accel_group());
|
||||
window.add_accel_group (shared_uimanager->get_accel_group());
|
||||
|
||||
Gtk::MenuBar* m;
|
||||
|
||||
|
|
@ -148,19 +221,12 @@ main (int argc, char* argv[])
|
|||
vpacker.pack_start (*m);
|
||||
vpacker.pack_start (button);
|
||||
|
||||
shared_uimanager->add_ui_from_file ("mtest_shared.menu");
|
||||
|
||||
MenuBar* item = dynamic_cast<MenuBar*> (shared_uimanager->get_widget ("/SharedMenuBar"));
|
||||
|
||||
window.add (vpacker);
|
||||
window.show_all ();
|
||||
|
||||
Settings::get_default()->property_gtk_can_change_accels() = true;
|
||||
|
||||
cerr << " shared = " << shared_uimanager->get_accel_group()
|
||||
<< " first = " << uimanager->get_accel_group()
|
||||
<< " second = " << other_uimanager->get_accel_group ()
|
||||
<< endl;
|
||||
AccelMap::save ("mtest.bindings");
|
||||
|
||||
app.run ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue