Index: apps/plugins/keybox.c =================================================================== --- apps/plugins/keybox.c (revision 21505) +++ apps/plugins/keybox.c (working copy) @@ -71,7 +71,6 @@ 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 @@ 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) { Index: apps/plugins/calendar.c =================================================================== --- apps/plugins/calendar.c (revision 21505) +++ apps/plugins/calendar.c (working copy) @@ -627,8 +629,9 @@ static int edit_menu_cb(int action, const struct menu_item_ex *this_item) { - (void) this_item; - if (action == ACTION_REQUEST_MENUITEM && memos_in_shown_memory <= 0) + int i = (intptr_t)this_item; + if (action == ACTION_REQUEST_MENUITEM + && memos_in_shown_memory <= 0 && (i==0 || i==1)) return ACTION_EXIT_MENUITEM; return action; } @@ -638,25 +641,11 @@ bool exit = false; int selected = 0; - MENUITEM_RETURNVALUE(edit_menu_remove, "Remove", 0, - edit_menu_cb, Icon_NOICON); - MENUITEM_RETURNVALUE(edit_menu_edit, "Edit", 1, - edit_menu_cb, Icon_NOICON); - MENUITEM_RETURNVALUE(edit_menu_weekly, "New Weekly", 2, - NULL, Icon_NOICON); - MENUITEM_RETURNVALUE(edit_menu_monthly, "New Monthly", 3, - NULL, Icon_NOICON); - MENUITEM_RETURNVALUE(edit_menu_yearly, "New Yearly", 4, - NULL, Icon_NOICON); - MENUITEM_RETURNVALUE(edit_menu_oneoff, "New One off", 5, - NULL, Icon_NOICON); + MENUITEM_STRINGLIST(edit_menu, "Edit menu", edit_menu_cb, + "Remove", "Edit", + "New Weekly", "New Monthly", + "New Yearly", "New One off"); - MAKE_MENU(edit_menu, "Edit menu", - NULL, Icon_NOICON, - &edit_menu_remove, &edit_menu_edit, - &edit_menu_weekly, &edit_menu_monthly, - &edit_menu_yearly, &edit_menu_oneoff); - while (!exit) { switch (rb->do_menu(&edit_menu, &selected, NULL, false))