+ /* icons, titles, WM stuff */
+
+ static list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
+
+ if (window_icons.empty()) {
+ Glib::RefPtr<Gdk::Pixbuf> icon;
+ if ((icon = ::get_icon (PROGRAM_NAME "-icon_16px")) != 0) {
+ window_icons.push_back (icon);
+ }
+ if ((icon = ::get_icon (PROGRAM_NAME "-icon_22px")) != 0) {
+ window_icons.push_back (icon);
+ }
+ if ((icon = ::get_icon (PROGRAM_NAME "-icon_32px")) != 0) {
+ window_icons.push_back (icon);
+ }
+ if ((icon = ::get_icon (PROGRAM_NAME "-icon_48px")) != 0) {
+ window_icons.push_back (icon);
+ }
+ }
+
+ if (!window_icons.empty()) {
+ window.set_default_icon_list (window_icons);
+ }
+
+ Gtkmm2ext::WindowTitle title (Glib::get_application_name());
+
+ if (!name.empty()) {
+ title += name;
+ }
+
+ window.set_title (title.get_string());
+ window.set_wmclass (string_compose (X_("%1_%1"), downcase (PROGRAM_NAME), downcase (name)), PROGRAM_NAME);
+
+ window.set_flags (CAN_FOCUS);
+ window.add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
+
+ /* This is a hack to ensure that GTK-accelerators continue to
+ * work. Once we switch over to entirely native bindings, this will be
+ * unnecessary and should be removed
+ */
+ window.add_accel_group (ActionManager::ui_manager->get_accel_group());
+
+ window.signal_configure_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::configure_handler));
+ window.signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::tabbed_window_state_event_handler), owner));
+ window.signal_key_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
+ window.signal_key_release_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
+}
+
+bool
+ARDOUR_UI::key_event_handler (GdkEventKey* ev, Gtk::Window* event_window)
+{
+ Gtkmm2ext::Bindings* bindings = 0;
+ Gtk::Window* window = 0;
+
+ /* until we get ardour bindings working, we are not handling key
+ * releases yet.
+ */
+
+ if (ev->type != GDK_KEY_PRESS) {
+ return false;
+ }
+
+ if (event_window == &_main_window) {
+
+ window = event_window;
+
+ /* find current tab contents */
+
+ Gtk::Widget* w = _tabs.get_nth_page (_tabs.get_current_page());
+
+ /* see if it uses the ardour binding system */
+
+ if (w) {
+ bindings = reinterpret_cast<Gtkmm2ext::Bindings*>(w->get_data ("ardour-bindings"));
+ }
+
+ DEBUG_TRACE (DEBUG::Accelerators, string_compose ("main window key event, bindings = %1, global = %2\n", bindings, &global_bindings));
+
+ } else {
+
+ window = event_window;
+
+ /* see if window uses ardour binding system */
+
+ bindings = reinterpret_cast<Gtkmm2ext::Bindings*>(window->get_data ("ardour-bindings"));
+ }
+
+ /* An empty binding set is treated as if it doesn't exist */
+
+ if (bindings && bindings->empty()) {
+ bindings = 0;
+ }
+
+ return key_press_focus_accelerator_handler (*window, ev, bindings);
+}
+
+static Gtkmm2ext::Bindings*
+get_bindings_from_widget_heirarchy (GtkWidget* w)
+{
+ void* p = NULL;
+
+ while (w) {
+ if ((p = g_object_get_data (G_OBJECT(w), "ardour-bindings")) != 0) {
+ break;