I am developing a native application for Ubuntu using quickly. How can I disable few key bindings such as prevent Ctrl + F4 from closing the window, and other key combinations?
I am developing a native application for Ubuntu using quickly. How can I disable few key bindings such as prevent Ctrl + F4 from closing the window, and other key combinations?
This is how you'd modify the global keybindings managed by Compiz. However, this would only work for systems using compiz as the window manager. It requires the
python-compizconfig
module. BTW, the default for close window is ALT+F4, it's the general settings plugin.Here's how you could do it programmatically:
Note that to get many of the settings you can use the
keys()
function to list them (i.e.)context.Plugins.keys()
as they are mostly just modified dictionaries.Here's a link to code that helped me figure out how this works, since I can't find any documentation: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/precise/compizconfig-python/precise/view/head:/src/compizconfig.pyx
What might actually be better, is to capture the destroy or delete-event signal sent to the window and test to see if it actually originated with a keypress. I wrote some code and was able to test for the keypress, but even though I can prevent the Gtk.main loop from being terminated, I can't prevent the window from being destroyed. Maybe someone else has an idea about that.
Edit: Here's my code that works correctly, but is there a better way to test for the key combo in the quit_test function?
Edit2: Modified to test for modifier keys and F4 correctly, but this DOES NOT work?! It will work for if I make it test for
Gdk.ModifierType.CONTROL_MASK
, but MOD1 which should be the Alt key doesn't work.