gtk: display hotkey keyname instead of keycode in hotkey gui

This commit is contained in:
punkrockguy318 2012-08-07 13:58:31 +00:00
parent 05d1b19f1e
commit 76617ae6e0
1 changed files with 14 additions and 20 deletions

View File

@ -462,37 +462,31 @@ void flushGtkEvents()
return; return;
} }
enum
{
COMMAND_COLUMN,
KEY_COLUMN,
N_COLUMNS
};
int populate_hotkey_tree_store()
{
return 0;
}
GtkWidget* HotkeyWin; GtkWidget* HotkeyWin;
// creates and opens hotkey config window // creates and opens hotkey config window
void openHotkeyConfig() void openHotkeyConfig()
{ {
enum
{
COMMAND_COLUMN,
KEY_COLUMN,
N_COLUMNS
};
GtkWidget* win = gtk_dialog_new_with_buttons("Hotkey Configuration", GtkWidget* win = gtk_dialog_new_with_buttons("Hotkey Configuration",
GTK_WINDOW(MainWindow), GTK_WINDOW(MainWindow), (GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
(GtkDialogFlags)(GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_CLOSE, GTK_STOCK_CLOSE,
GTK_RESPONSE_OK, GTK_RESPONSE_OK,
NULL); NULL);
HotkeyWin = win; HotkeyWin = win;
GtkWidget *tree; GtkWidget *tree;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *scrollbar;
vbox = gtk_dialog_get_content_area(GTK_DIALOG(win)); vbox = gtk_dialog_get_content_area(GTK_DIALOG(win));
GtkTreeStore *hotkey_store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_INT); GtkTreeStore *hotkey_store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
std::string prefix = "SDL.Hotkeys."; std::string prefix = "SDL.Hotkeys.";
GtkTreeIter iter; // parent GtkTreeIter iter; // parent
@ -507,7 +501,7 @@ void openHotkeyConfig()
g_config->getOption(optionName, &keycode); g_config->getOption(optionName, &keycode);
gtk_tree_store_set(hotkey_store, &iter, gtk_tree_store_set(hotkey_store, &iter,
COMMAND_COLUMN, optionName, COMMAND_COLUMN, optionName,
KEY_COLUMN, keycode, KEY_COLUMN, SDL_GetKeyName((SDLKey)keycode),
-1); -1);
gtk_tree_store_append(hotkey_store, &iter, NULL); // acquire child iterator gtk_tree_store_append(hotkey_store, &iter, NULL); // acquire child iterator
} }
@ -522,9 +516,9 @@ void openHotkeyConfig()
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", KEY_COLUMN, NULL); column = gtk_tree_view_column_new_with_attributes("Key", renderer, "text", KEY_COLUMN, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
GtkAdjustment* adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(tree));
// gtk_container_add(GTK_CONTAINER(win),vbox); scrollbar = gtk_vscrollbar_new(adj);
gtk_box_pack_start(GTK_BOX(vbox), tree , TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox), tree, TRUE, TRUE, 5);
gtk_widget_show_all(win); gtk_widget_show_all(win);
g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL); g_signal_connect(win, "delete-event", G_CALLBACK(closeDialog), NULL);