From 73d25744fb01844cc28402dfc4b48a030d270579 Mon Sep 17 00:00:00 2001 From: Johannes Schwarz Date: Fri, 26 Jun 2009 17:59:33 +0000 Subject: FS#10283 simplify plugins' menus by using stringlist with callback (by Teruaki Kawashima - some minor changes by myself) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21523 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/keybox.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'apps/plugins/keybox.c') diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index 5d625a3..08d5131 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c @@ -71,7 +71,6 @@ static uint32_t salt; static union hash pwhash; static bool data_changed = false; -static int context_item_cb(int action, const struct menu_item_ex *this_item); static void encrypt_buffer(char *buf, size_t size, uint32_t *key); static void decrypt_buffer(char *buf, size_t size, uint32_t *key); @@ -105,35 +104,22 @@ static void decrypt(uint32_t* v, uint32_t* k) v[0]=v0; v[1]=v1; } -MENUITEM_RETURNVALUE(context_add_entry, "Add entry", 0, - NULL, Icon_NOICON); -MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1, - &context_item_cb, Icon_NOICON); -MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 2, - &context_item_cb, Icon_NOICON); -MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 3, - &context_item_cb, Icon_NOICON); -MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 4, - &context_item_cb, Icon_NOICON); -MENUITEM_RETURNVALUE(context_debug, "debug", 5, - &context_item_cb, Icon_NOICON); - -MAKE_MENU(context_m, "Context menu", - context_item_cb, Icon_NOICON, - &context_add_entry, &context_edit_title, &context_edit_name, - &context_edit_password, &context_delete_entry); - static int context_item_cb(int action, const struct menu_item_ex *this_item) { if (action == ACTION_REQUEST_MENUITEM && pw_list.num_entries == 0 - && this_item != &context_add_entry) + && ((intptr_t)this_item) != 0) { return ACTION_EXIT_MENUITEM; } return action; } +MENUITEM_STRINGLIST(context_m, "Context menu", context_item_cb, + "Add entry", + "Edit title", "Edit user name", "Edit password", + "Delete entry") + static char * kb_list_cb(int selected_item, void *data, char *buffer, size_t buffer_len) { -- cgit v1.1