From f2d901fe0424bafa39b794117c9547e4969017c6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 4 Mar 2010 20:34:05 +0000 Subject: Fix FlowCanvas key bindings (arrow scrolling and select-connect with enter). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2517 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PatchCanvas.cpp | 36 ++++++++++-------------------------- src/gui/PatchCanvas.hpp | 4 +--- src/gui/PatchWindow.cpp | 31 +++++++------------------------ src/gui/PatchWindow.hpp | 3 +-- 4 files changed, 19 insertions(+), 55 deletions(-) (limited to 'src/gui') diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 2a406191..644f95f6 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -536,39 +536,23 @@ PatchCanvas::canvas_event(GdkEvent* event) break; case GDK_KEY_PRESS: - case GDK_KEY_RELEASE: - ret = canvas_key_event(&event->key); - - default: - break; - } - - return (ret ? true : Canvas::canvas_event(event)); -} - - -bool -PatchCanvas::canvas_key_event(GdkEventKey* event) -{ - switch (event->type) { - case GDK_KEY_PRESS: - switch (event->keyval) { + switch (event->key.keyval) { case GDK_Delete: destroy_selection(); - return true; + ret = true; + break; case GDK_e: - if (event->state == 0) { + if (event->key.state == 0) { _patch->set_editable(!_patch->get_editable()); - return true; - } else { - return false; + ret = true; } - default: - return false; + default: break; } - default: - return false; + + default: break; } + + return (ret ? true : Canvas::canvas_event(event)); } diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index 9aa0eacf..a301f680 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -83,7 +83,7 @@ public: void show_menu(GdkEvent* event); - bool canvas_key_event(GdkEventKey* event); + bool canvas_event(GdkEvent* event); private: enum ControlType { NUMBER, BUTTON }; @@ -119,8 +119,6 @@ private: GraphObject::Properties get_initial_data(); - bool canvas_event(GdkEvent* event); - SharedPtr get_port_view(SharedPtr port); void connect(boost::shared_ptr src, diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index a9fe62d2..361e525a 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -472,7 +472,8 @@ PatchWindow::event_save_as() bool confirm = true; if (Glib::file_test(filename, Glib::FILE_TEST_IS_DIR)) { - if (Glib::file_test(filename + "/manifest.ttl", Glib::FILE_TEST_EXISTS)) { + if (Glib::file_test(Glib::build_filename(filename, "manifest.ttl"), + Glib::FILE_TEST_EXISTS)) { Gtk::MessageDialog confirm_dialog(*this, (boost::format("" "A bundle named \"%1%\" already exists. Replace it?" "") % basename).str(), @@ -615,30 +616,12 @@ PatchWindow::on_hide() bool -PatchWindow::on_key_press_event(GdkEventKey* event) +PatchWindow::on_event(GdkEvent* event) { - bool ret = false; - - ret = _view->canvas()->canvas_key_event(event); - - if (!ret) - ret = Gtk::Window::on_key_press_event(event); - - return ret; -} - - -bool -PatchWindow::on_key_release_event(GdkEventKey* event) -{ - bool ret = false; - - ret = _view->canvas()->canvas_key_event(event); - - if (!ret) - ret = Gtk::Window::on_key_release_event(event); - - return ret; + if (_view->canvas()->canvas_event(event)) + return true; + else + return Gtk::Window::on_event(event); } diff --git a/src/gui/PatchWindow.hpp b/src/gui/PatchWindow.hpp index d4cc87a9..2e03945f 100644 --- a/src/gui/PatchWindow.hpp +++ b/src/gui/PatchWindow.hpp @@ -71,8 +71,7 @@ public: protected: void on_show(); void on_hide(); - bool on_key_press_event(GdkEventKey* event); - bool on_key_release_event(GdkEventKey* event); + bool on_event(GdkEvent* event); private: void patch_port_added(SharedPtr port); -- cgit v1.2.1