Now that it's all cute and all over your system, you can use key tables!
You'll probably want to be altering the way all of your keys work and changing which keys perform which actions. To keep you from killing yourself, I made a default configuration file with all of the default key bindings for gtk+-1.2.10. This file is also located in the patched gtk source under gtk/gdkkeytable_defaultrc. It is not necessary to have this file for all of this to work, but it is damned useful since I don't have a handy reference for you, right now.
Now, the way I would change my bindings is to selectively copy and paste from the default file into my ~/.gtkrc. Make sure you get the whole entry for a particular table. Here's an example of the config for the gtknotebook widget.
keytable "GtkNotebook"
{
"GtkNotebookUp" = "Up"
"GtkNotebookLeft" = "Left"
"GtkNotebookDown" = "Down"
"GtkNotebookRight" = "Right"
"GtkNotebookTabNext" = "Tab", "ISO_Left_Tab"
"GtkNotebookTabFirst" = "Home"
"GtkNotebookTabLast" = "End"
"GtkNotebookTabSel" = "Return", "space"
}
Let me warn you: yes, these names are all case sensitive. From the name of the table to the name of each action to the name of each key. I'm sorry. :) For a list of possible keys, you may want to check out gdk/gdkkeysyms.h. It *SHOULD* parse anything that's in there so long as you don't put the "GDK_" in front of each key. e.g. - 'GDK_Down' becomes 'Down'.
In an effort to help you come up with handy ways to remap keys, try replacing every instance of Up, Down, Left, Right with k, j, h, l. or <ctrl>p, <ctrl>n, <ctrl>b, <ctrl>f. I want to warn you to keep some kind of reasoning behind your bindings.... but it's your computer. :)
Want to test all of this out? Pick a widget of fun and remap its keys, now go to the examples/ directory under your gtk source tree. Find the example with that widget's name on it, make and run it. If no such example exists, feel free to run gtk/testgtk under the source tree and find your widget in the resulting test menu.
Good luck.
Having said that, let's get into the Seven(okay, Six) Habits of Key Table Using Widgets...
#include <gdkkeytable.h>
#include <gtkrc.h>
static GtkWidgetClass *parent_class = NULL;
static GdkKeyTable *calendar_key_table = NULL;
enum {
GTK_WINDOW_ACTIVATE_SELECTED,
GTK_WINDOW_ACTIVATE_DEFAULT,
GTK_WINDOW_SEL_UP,
GTK_WINDOW_SEL_DOWN,
GTK_WINDOW_SEL_LEFT,
GTK_WINDOW_SEL_RIGHT,
GTK_WINDOW_SEL_TAB_FORWARD,
GTK_WINDOW_SEL_TAB_BACKWARD,
};
plug_key_table = gdk_key_table_new();
plug_key_table->name = g_strdup("GtkPlug"); /*very important to name your table!!!!! */
/* adding an entry with a single key, simply use the addentry function */
gdk_key_table_addentry(plug_key_table, GTK_PLUG_ACTIVATE_SELECTED,
"GtkPlugActivateSelected", 0, GDK_space);
/* adding an entry with multiple keys requires holding on to the newly created entry. be sure to declare a temporary GdkKeyEntry and then use the addkey function on it. */
temp_ke = gdk_key_table_addentry(plug_key_table, GTK_PLUG_ACTIVATE_DEFAULT,
"GtkPlugActivateDefault", 0, GDK_Return);
gdk_key_entry_addkey(temp_ke, 0, GDK_KP_Enter);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_UP,
"GtkPlugDirUp", 0, GDK_Up);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_DOWN,
"GtkPlugDirDown", 0, GDK_Down);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_LEFT,
"GtkPlugDirLeft", 0, GDK_Left);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_RIGHT,
"GtkPlugDirRight", 0, GDK_Right);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_TAB_FORWARD,
"GtkPlugDirTabForward", 0, GDK_Tab);
gdk_key_table_addentry(plug_key_table, GTK_PLUG_DIR_TAB_BACKWARD,
"GtkPlugDirTabBackward", GDK_SHIFT_MASK, GDK_Tab);
/* Now that our table has been defined, let gtkrc put the user's changes in it */
gtk_rc_keytable_set_from_config(plug_key_table);
guint thekey;
thekey = gdk_key_table_getaction(plug_key_table, event);
/* where 'plug_key_table' is the name of your keytable, and 'event' is the incoming GdkEventKey passed with the key_press signal */
switch(thekey){
case ENUMERATED_THING_1:
...
break;
case ENUMERATED_THING_2:
...
etc.
...
};