Index: appmap-gen.c =================================================================== RCS file: /cvs/appmap/appmap-gen.c,v retrieving revision 1.17 diff -u -p -r1.17 appmap-gen.c --- appmap-gen.c 6 Oct 2005 13:08:28 -0000 1.17 +++ appmap-gen.c 17 Oct 2005 16:51:16 -0000 @@ -246,6 +246,87 @@ int filter_appmap_data (Accessible *acce return 1; } +char get_keybinding (Accessible *object) +{ + AccessibleAction *action; + char value = NULL; + char *kb; + char *tmp; + + action = Accessible_getAction (object); + if (action && AccessibleAction_getNActions (action) >= 0) + { + /* + * FIXME: Following code should iterate thro the + * action set to get key binding available for any action + * if not for the first one alone. + */ + kb = AccessibleAction_getKeyBinding (action, 0); + Accessible_unref (action); + if (kb && g_utf8_collate (kb, "") != 0) + { + tmp = strtok (strdup (kb), ";"); + //g_print ("Key binding: %s *****", kb); + SPI_freeString (kb); + if (tmp) + { + value = tmp[strlen (tmp) - 1]; + //g_print ("returned key: %c\n", value); + return value; + } + else + { + //g_print ("returned key: NULL \n"); + return value; + } + } + else + return value; + } + else + { + if (action) + Accessible_unref (action); + return value; + } +} + +char *insert_underscore (char *name, char kb) +{ + char *value; + int i, j; + + j = strlen (name); + value = (char *) malloc (j + 2); + for (i = 0; i < j; i++) + { + /* + * FIXME: Currently taking care of situation where + * key binding character is small case and the character + * in the name is either in lower or upper case. We should + * also take care of the situation where key binding character + * is in uppper case. + */ + if (name[i] != kb && name[i] != kb - 32) + value[i] = name[i]; + else + { + value[i] = '_'; + break; + } + } + if (i != j) + { + for (; i < j; i++) + value[i+1] = name[i]; + value[i + 1] = '\0'; + } + else + value [i] = '\0'; + g_print ("Actual: %s *** returned: %s *** length: %d\n", name, value, j); + return value; +} + char *get_relation_name (Accessible *object) { int i; @@ -270,6 +351,7 @@ char *get_relation_name (Accessible *obj { int j = 0; char *name = NULL; + char kb; Accessible *tmp_obj; tmp_obj = AccessibleRelation_getTarget (relation[i], i); name = Accessible_getName (tmp_obj); @@ -283,10 +365,18 @@ char *get_relation_name (Accessible *obj } label_by = g_strdup (name); SPI_freeString (name); + kb = get_keybinding (tmp_obj); Accessible_unref (tmp_obj); for (j = i; relation[j] != NULL; j++) Accessible_unref (relation[j]); - return label_by; + if (!kb) + return label_by; + else + { + name = insert_underscore (label_by, kb); + g_free (label_by); + return name; + } } Accessible_unref (relation[i]); } @@ -347,6 +437,15 @@ char *add_appmap_data (FILE *fp, Accessi g_free (value); value = NULL; } + if (strstr (stripped_data, "_")) + { + value = strip_delim (stripped_data, '_'); + g_free (stripped_data); + stripped_data = g_strdup (value); + g_free (value); + value = NULL; + } + name = g_strdup_printf ("%s%s", cur_obj_info->prefix, stripped_data); value = g_hash_table_lookup (current_context, name); @@ -397,9 +496,21 @@ char *add_appmap_data (FILE *fp, Accessi } else { + char kb; + char *tmp; if (g_ascii_strcasecmp (cur_obj_info->object_type, "combo_box") != 0) - object_record = g_strdup_printf ("%s={class=%s,parent=%s,child_index=%d,label=%s}\n", name, - cur_obj_info->object_type, parent_name, child_index, label); + { + kb = get_keybinding (accessible); + if (kb) + { + tmp = insert_underscore (label, kb); + g_free (label); + label = g_strdup (tmp); + g_free (tmp); + } + object_record = g_strdup_printf ("%s={class=%s,parent=%s,child_index=%d,label=%s}\n", name, + cur_obj_info->object_type, parent_name, child_index, label); + } else object_record = g_strdup_printf ("%s={class=%s,parent=%s,child_index=%d}\n", name, cur_obj_info->object_type, parent_name, child_index);