]> err.no Git - mapper/commitdiff
Use a helper to get custom key settings
authorKaj-Michael Lang <milang@tal.org>
Mon, 21 Apr 2008 08:04:04 +0000 (11:04 +0300)
committerKaj-Michael Lang <milang@tal.org>
Mon, 21 Apr 2008 08:04:04 +0000 (11:04 +0300)
src/cb.c

index 1efbbc566ec2416b082a53c83ce5e07483bfdcc8..82a5674364232e9b6fadbabb90cf9d664ca52b09 100644 (file)
--- 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: