From: Kaj-Michael Lang Date: Mon, 21 Apr 2008 08:04:04 +0000 (+0300) Subject: Use a helper to get custom key settings X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0efe553f81abeeecd246050949ef3a0d7a35daa3;p=mapper Use a helper to get custom key settings --- diff --git a/src/cb.c b/src/cb.c index 1efbbc5..82a5674 100644 --- a/src/cb.c +++ b/src/cb.c @@ -597,44 +597,53 @@ gtk_show_about_dialog(GTK_WINDOW(_window), return TRUE; } -gboolean -window_cb_key_press(GtkWidget * widget, GdkEventKey * event) +static CustomKey +custom_key_get_type(gint keyval) { -CustomKey custom_key; - -switch (event->keyval) { +switch (keyval) { case HILDON_HARDKEY_UP: - custom_key = CUSTOM_KEY_UP; + return CUSTOM_KEY_UP; break; case HILDON_HARDKEY_DOWN: - custom_key = CUSTOM_KEY_DOWN; + return CUSTOM_KEY_DOWN; break; case HILDON_HARDKEY_LEFT: - custom_key = CUSTOM_KEY_LEFT; + return CUSTOM_KEY_LEFT; break; case HILDON_HARDKEY_RIGHT: - custom_key = CUSTOM_KEY_RIGHT; + return CUSTOM_KEY_RIGHT; break; case HILDON_HARDKEY_SELECT: - custom_key = CUSTOM_KEY_SELECT; + return CUSTOM_KEY_SELECT; break; case HILDON_HARDKEY_INCREASE: - custom_key = CUSTOM_KEY_INCREASE; + return CUSTOM_KEY_INCREASE; break; case HILDON_HARDKEY_DECREASE: - custom_key = CUSTOM_KEY_DECREASE; + return CUSTOM_KEY_DECREASE; break; case HILDON_HARDKEY_FULLSCREEN: - custom_key = CUSTOM_KEY_FULLSCREEN; + return CUSTOM_KEY_FULLSCREEN; break; case HILDON_HARDKEY_ESC: - custom_key = CUSTOM_KEY_ESC; + return CUSTOM_KEY_ESC; break; default: - return FALSE; + return CUSTOM_KEY_ENUM_COUNT; +} + } - switch (_action[custom_key]) { +gboolean +window_cb_key_press(GtkWidget * widget, GdkEventKey * event) +{ +CustomKey custom_key; + +custom_key=custom_key_get_type(event->keyval); +if (custom_key==CUSTOM_KEY_ENUM_COUNT) + return FALSE; + +switch (_action[custom_key]) { case CUSTOM_ACTION_PAN_NORTH: map_pan(0, -PAN_UNITS); break; @@ -649,17 +658,17 @@ switch (event->keyval) { break; case CUSTOM_ACTION_TOGGLE_AUTOCENTER: switch (_center_mode) { - case CENTER_LATLON: - case CENTER_WAS_LEAD: - set_action_activate("autocenter_lead", TRUE); - break; - case CENTER_LEAD: - case CENTER_WAS_LATLON: - set_action_activate("autocenter_latlon", TRUE); - break; - default: - set_action_activate("autocenter_latlon", TRUE); - break; + case CENTER_LATLON: + case CENTER_WAS_LEAD: + set_action_activate("autocenter_lead", TRUE); + break; + case CENTER_LEAD: + case CENTER_WAS_LATLON: + set_action_activate("autocenter_latlon", TRUE); + break; + default: + set_action_activate("autocenter_latlon", TRUE); + break; } break; case CUSTOM_ACTION_ZOOM_IN: