
#include <glib.h>

typedef enum {
  ALWAYS_VISIBLE,
  N_WORKSPACES_GT
} KeyListEntryVisibility;

typedef struct {
	char *name;
	KeyListEntryVisibility vis;
	int data;
} KeyListEntry;

static const KeyListEntry metacity_key_list[] =
{
  { "/apps/metacity/window_keybindings/activate_window_menu",      ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/toggle_fullscreen",         ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/toggle_maximized",          ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/maximize",                  ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/unmaximize",                ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/toggle_shaded",             ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/close",                     ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/minimize",                  ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/begin_move",                ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/begin_resize",              ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/toggle_on_all_workspaces",  N_WORKSPACES_GT, 1 },
  /* These next three are out of order compared to the schemas file. */
  { "/apps/metacity/window_keybindings/raise_or_lower",            ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/raise",                     ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/lower",                     ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/maximize_vertically",       ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/maximize_horizontally",     ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/window_keybindings/move_to_workspace_1",       N_WORKSPACES_GT, 1 },
  { "/apps/metacity/window_keybindings/move_to_workspace_2",       N_WORKSPACES_GT, 1 },
  { "/apps/metacity/window_keybindings/move_to_workspace_3",       N_WORKSPACES_GT, 2 },
  { "/apps/metacity/window_keybindings/move_to_workspace_4",       N_WORKSPACES_GT, 3 },
  { "/apps/metacity/window_keybindings/move_to_workspace_5",       N_WORKSPACES_GT, 4 },
  { "/apps/metacity/window_keybindings/move_to_workspace_6",       N_WORKSPACES_GT, 5 },
  { "/apps/metacity/window_keybindings/move_to_workspace_7",       N_WORKSPACES_GT, 6 },
  { "/apps/metacity/window_keybindings/move_to_workspace_8",       N_WORKSPACES_GT, 7 },
  { "/apps/metacity/window_keybindings/move_to_workspace_9",       N_WORKSPACES_GT, 8 },
  { "/apps/metacity/window_keybindings/move_to_workspace_10",      N_WORKSPACES_GT, 9 },
  { "/apps/metacity/window_keybindings/move_to_workspace_11",      N_WORKSPACES_GT, 10 },
  { "/apps/metacity/window_keybindings/move_to_workspace_12",      N_WORKSPACES_GT, 11 },
  { "/apps/metacity/window_keybindings/move_to_workspace_left",    N_WORKSPACES_GT, 1 },
  { "/apps/metacity/window_keybindings/move_to_workspace_right",   N_WORKSPACES_GT, 1 },
  { "/apps/metacity/window_keybindings/move_to_workspace_up",      N_WORKSPACES_GT, 1 },
  { "/apps/metacity/window_keybindings/move_to_workspace_down",    N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_windows",            ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/switch_panels",             ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/cycle_windows",             ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/cycle_group",               ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/cycle_panels",              ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/show_desktop",              ALWAYS_VISIBLE,  0 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_1",     N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_2",     N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_3",     N_WORKSPACES_GT, 2 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_4",     N_WORKSPACES_GT, 3 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_5",     N_WORKSPACES_GT, 4 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_6",     N_WORKSPACES_GT, 5 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_7",     N_WORKSPACES_GT, 6 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_8",     N_WORKSPACES_GT, 7 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_9",     N_WORKSPACES_GT, 8 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_10",    N_WORKSPACES_GT, 9 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_11",    N_WORKSPACES_GT, 10 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_12",    N_WORKSPACES_GT, 11 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_left",  N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_right", N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_up",    N_WORKSPACES_GT, 1 },
  { "/apps/metacity/global_keybindings/switch_to_workspace_down",  N_WORKSPACES_GT, 1 },
  { NULL }
};

int main (int argc, char **argv)
{
	int i;

	g_print ("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
	g_print ("<KeyListEntries _name=\"Window Management\" wm_name=\"Metacity\">\n");
	g_print ("\n");

	for (i = 0; metacity_key_list[i].name; i++) {
		g_print ("\t<KeyListEntry\n");
		if (metacity_key_list[i].vis != ALWAYS_VISIBLE) {
			g_print ("\tname=\"%s\"\n", metacity_key_list[i].name);
			g_print ("\tvalue=\"%d\"\n", metacity_key_list[i].data);
			g_print ("\tkey=\"/apps/metacity/general/num_workspaces\"\n");
			g_print ("\tcomparison=\"gt\" />\n");
		} else {
			g_print ("\tname=\"%s\" />\n", metacity_key_list[i].name);
		}
		g_print ("\n");
	}

	g_print ("</KeyListEntries>\n");

	return 0;
}

