summaryrefslogtreecommitdiff
path: root/gtk2_ardour/keyeditor.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-10 22:22:29 +0000
committerDavid Robillard <d@drobilla.net>2008-01-10 22:22:29 +0000
commit8a2e30816ee392b871c5918f769f68cc0196a893 (patch)
treeeb85739049c0adc6186eea635aaaf65ef03f038f /gtk2_ardour/keyeditor.cc
parentbb457bb960c5bd7ed538f9d31477293415739f68 (diff)
Merge with 2.0-ongoing R2883.
git-svn-id: svn://localhost/ardour2/trunk@2885 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/keyeditor.cc')
-rw-r--r--gtk2_ardour/keyeditor.cc73
1 files changed, 68 insertions, 5 deletions
diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc
index 4f378d2dbc..c914b6282b 100644
--- a/gtk2_ardour/keyeditor.cc
+++ b/gtk2_ardour/keyeditor.cc
@@ -10,6 +10,8 @@
#include <pbd/strsplit.h>
#include <pbd/replace_all.h>
+#include <ardour/profile.h>
+
#include "actions.h"
#include "keyboard.h"
#include "keyeditor.h"
@@ -22,7 +24,10 @@ using namespace Gdk;
using namespace PBD;
KeyEditor::KeyEditor ()
- : ArdourDialog (_("Keybinding Editor"), false)
+ : ArdourDialog (_("Shortcut Editor"), false)
+ , unbind_button (_("Remove shortcut"))
+ , unbind_box (BUTTONBOX_END)
+
{
can_bind = false;
last_state = 0;
@@ -31,7 +36,7 @@ KeyEditor::KeyEditor ()
view.set_model (model);
view.append_column (_("Action"), columns.action);
- view.append_column (_("Binding"), columns.binding);
+ view.append_column (_("Shortcut"), columns.binding);
view.set_headers_visible (true);
view.get_selection()->set_mode (SELECTION_SINGLE);
view.set_reorderable (false);
@@ -45,11 +50,49 @@ KeyEditor::KeyEditor ()
scroller.add (view);
scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+ unbind_box.pack_start (unbind_button, false, false);
+
+ unbind_button.signal_clicked().connect (mem_fun (*this, &KeyEditor::unbind));
+
+ get_vbox()->set_spacing (6);
get_vbox()->pack_start (scroller);
+
+ if (!ARDOUR::Profile->get_sae()) {
+ get_vbox()->pack_start (unbind_box, false, false);
+ unbind_box.show ();
+ unbind_button.show ();
+ }
+
get_vbox()->set_border_width (12);
- scroller.show ();
view.show ();
+ scroller.show ();
+
+ unbind_button.set_sensitive (false);
+}
+
+void
+KeyEditor::unbind ()
+{
+ TreeModel::iterator i = view.get_selection()->get_selected();
+
+ unbind_button.set_sensitive (false);
+
+ if (i != model->children().end()) {
+ string path = (*i)[columns.path];
+
+ if (!(*i)[columns.bindable]) {
+ return;
+ }
+
+ bool result = AccelMap::change_entry (path,
+ 0,
+ (ModifierType) 0,
+ true);
+ if (result) {
+ (*i)[columns.binding] = string ();
+ }
+ }
}
void
@@ -69,6 +112,28 @@ KeyEditor::on_unmap ()
void
KeyEditor::action_selected ()
{
+ if (view.get_selection()->count_selected_rows() == 0) {
+ return;
+ }
+
+ TreeModel::iterator i = view.get_selection()->get_selected();
+
+ unbind_button.set_sensitive (false);
+
+ if (i != model->children().end()) {
+
+ string path = (*i)[columns.path];
+
+ if (!(*i)[columns.bindable]) {
+ return;
+ }
+
+ string binding = (*i)[columns.binding];
+
+ if (!binding.empty()) {
+ unbind_button.set_sensitive (true);
+ }
+ }
}
bool
@@ -112,8 +177,6 @@ KeyEditor::on_key_release_event (GdkEventKey* ev)
(*i)[columns.binding] = string();
}
}
-
-
}
out: