remove cruft from ArdourUI; improve keyboard icon(s); shrink other plugin GUI buttons...
[ardour.git] / gtk2_ardour / keyboard.cc
index 1ec13512660340704da93dfb3d3a9fb51abd91da..e5fb8d8b1014fa1202852202f1bc06da3d7f5d42 100644 (file)
@@ -76,6 +76,7 @@ bool         Keyboard::_some_magic_widget_has_focus = false;
 
 std::string Keyboard::user_keybindings_path;
 bool Keyboard::can_save_keybindings = false;
+bool Keyboard::bindings_changed_after_save_became_legal = false;
 map<string,string> Keyboard::binding_files;
 string Keyboard::_current_binding_name = _("Unknown");
 map<AccelKey,pair<string,string>,Keyboard::AccelKeyLess> Keyboard::release_keys;
@@ -261,10 +262,20 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
                }
        }
 
-       if (event->type == GDK_KEY_RELEASE && event->keyval == GDK_w && modifier_state_equals (event->state, PrimaryModifier)) {
-               if (current_window) {
-                       current_window->hide ();
-                       current_window = 0;
+       /* Special keys that we want to handle in
+          any dialog, no matter whether it uses
+          the regular set of accelerators or not
+       */
+
+       if (event->type == GDK_KEY_RELEASE && modifier_state_equals (event->state, PrimaryModifier)) {
+               switch (event->keyval) {
+               case GDK_w:
+                       if (current_window) {
+                               current_window->hide ();
+                               current_window = 0;
+                               ret = true;
+                       }
+                       break;
                }
        }
 
@@ -359,7 +370,6 @@ Keyboard::set_snap_modifier (guint mod)
 bool
 Keyboard::is_edit_event (GdkEventButton *ev)
 {
-
        return (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_BUTTON_RELEASE) && 
                (ev->button == Keyboard::edit_button()) && 
                ((ev->state & RelevantModifierKeyMask) == Keyboard::edit_modifier());
@@ -421,6 +431,16 @@ accel_map_changed (GtkAccelMap* map,
                   GdkModifierType mod,
                   gpointer arg)
 {
+       Keyboard::keybindings_changed ();
+}
+
+void
+Keyboard::keybindings_changed ()
+{
+       if (Keyboard::can_save_keybindings) {
+               Keyboard::bindings_changed_after_save_became_legal = true;
+       }
+
        Keyboard::save_keybindings ();
 }
 
@@ -433,7 +453,7 @@ Keyboard::set_can_save_keybindings (bool yn)
 void
 Keyboard::save_keybindings ()
 {
-       if (can_save_keybindings) {
+       if (can_save_keybindings && bindings_changed_after_save_became_legal) {
                Gtk::AccelMap::save (user_keybindings_path);
        } 
 }