diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/menu.h | 26 | ||||
-rw-r--r-- | apps/plugins/chessbox/chessbox.c | 3 | ||||
-rw-r--r-- | apps/plugins/chopper.c | 3 | ||||
-rw-r--r-- | apps/plugins/dice.c | 3 | ||||
-rw-r--r-- | apps/plugins/disktidy.c | 3 | ||||
-rw-r--r-- | apps/plugins/minesweeper.c | 3 | ||||
-rw-r--r-- | apps/plugins/snake.c | 3 | ||||
-rw-r--r-- | apps/plugins/star.c | 3 | ||||
-rw-r--r-- | apps/plugins/test_codec.c | 4 | ||||
-rw-r--r-- | apps/plugins/wavrecord.c | 5 | ||||
-rw-r--r-- | apps/plugins/wormlet.c | 4 |
11 files changed, 34 insertions, 26 deletions
diff --git a/apps/menu.h b/apps/menu.h index 7b26bbc90c..0c1000ab2f 100644 --- a/apps/menu.h +++ b/apps/menu.h | |||
@@ -98,9 +98,26 @@ struct menu_item_ex { | |||
98 | 98 | ||
99 | typedef int (*menu_callback_type)(int action, | 99 | typedef int (*menu_callback_type)(int action, |
100 | const struct menu_item_ex *this_item); | 100 | const struct menu_item_ex *this_item); |
101 | int do_menu(const struct menu_item_ex *menu, int *start_selected); | ||
102 | bool do_setting_from_menu(const struct menu_item_ex *temp); | 101 | bool do_setting_from_menu(const struct menu_item_ex *temp); |
103 | 102 | ||
103 | /* | ||
104 | int do_menu(const struct menu_item_ex *menu, int *start_selected) | ||
105 | |||
106 | Return value - usually one of the GO_TO_* values from root_menu.h, | ||
107 | however, some of the following defines can cause this to | ||
108 | return a different value. | ||
109 | |||
110 | *menu - The menu to run, can be a pointer to a MAKE_MENU() variable, | ||
111 | MENUITEM_STRINGLIST() or MENUITEM_RETURNVALUE() variable. | ||
112 | |||
113 | *start_selected - the item to select when the menu is first run. | ||
114 | When do_menu() returns, this will be set to the | ||
115 | index of the selected item at the time of the exit. | ||
116 | This is always set, even if the menu was cancelled. | ||
117 | If NULL it is ignored and the firs item starts selected | ||
118 | */ | ||
119 | int do_menu(const struct menu_item_ex *menu, int *start_selected); | ||
120 | |||
104 | /* In all the following macros the argument names are as follows: | 121 | /* In all the following macros the argument names are as follows: |
105 | - name: The name for the variable (so it can be used in a MAKE_MENU() | 122 | - name: The name for the variable (so it can be used in a MAKE_MENU() |
106 | - str: the string to display for this menu item. use ID2P() for LANG_* id's | 123 | - str: the string to display for this menu item. use ID2P() for LANG_* id's |
@@ -126,8 +143,9 @@ bool do_setting_from_menu(const struct menu_item_ex *temp); | |||
126 | {.callback_and_desc = & name##__}}; | 143 | {.callback_and_desc = & name##__}}; |
127 | 144 | ||
128 | /* Use this To create a list of Strings (or ID2P()'s ) | 145 | /* Use this To create a list of Strings (or ID2P()'s ) |
129 | When the user enters this list and selects one, the menu will exits | 146 | When the user enters this list and selects one, the menu will exit |
130 | and its return value will be the index of the chosen item */ | 147 | and do_menu() will return value the index of the chosen item. |
148 | if the user cancels, GO_TO_PREVIOUS will be returned */ | ||
131 | #define MENUITEM_STRINGLIST(name, str, callback, ... ) \ | 149 | #define MENUITEM_STRINGLIST(name, str, callback, ... ) \ |
132 | static const char *name##_[] = {__VA_ARGS__}; \ | 150 | static const char *name##_[] = {__VA_ARGS__}; \ |
133 | static const struct menu_callback_with_desc name##__ = \ | 151 | static const struct menu_callback_with_desc name##__ = \ |
@@ -138,7 +156,7 @@ bool do_setting_from_menu(const struct menu_item_ex *temp); | |||
138 | { .strings = name##_},{.callback_and_desc = & name##__}}; | 156 | { .strings = name##_},{.callback_and_desc = & name##__}}; |
139 | 157 | ||
140 | 158 | ||
141 | /* returns a value associated with the item */ | 159 | /* causes do_menu() to return a value associated with the item */ |
142 | #define MENUITEM_RETURNVALUE(name, str, val, cb, icon) \ | 160 | #define MENUITEM_RETURNVALUE(name, str, val, cb, icon) \ |
143 | static const struct menu_callback_with_desc name##_ = {cb,str,icon}; \ | 161 | static const struct menu_callback_with_desc name##_ = {cb,str,icon}; \ |
144 | static const struct menu_item_ex name = \ | 162 | static const struct menu_item_ex name = \ |
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index f2ae95b4f2..9f9e1099af 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c | |||
@@ -528,8 +528,7 @@ static int cb_menu(void) | |||
528 | 528 | ||
529 | while(!menu_quit) | 529 | while(!menu_quit) |
530 | { | 530 | { |
531 | selection = rb->do_menu(&menu, &selection); | 531 | switch(rb->do_menu(&menu, &selection)) |
532 | switch(selection) | ||
533 | { | 532 | { |
534 | case 0: | 533 | case 0: |
535 | menu_quit = true; | 534 | menu_quit = true; |
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 89f6e3db13..26e70d3e42 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c | |||
@@ -647,8 +647,7 @@ static int chopMenu(int menunum) | |||
647 | rb->lcd_clear_display(); | 647 | rb->lcd_clear_display(); |
648 | 648 | ||
649 | while (!menu_quit) { | 649 | while (!menu_quit) { |
650 | result=rb->do_menu(&menu,&result); | 650 | switch(rb->do_menu(&menu, &result)) |
651 | switch (result) | ||
652 | { | 651 | { |
653 | case 0: /* Start New Game */ | 652 | case 0: /* Start New Game */ |
654 | menu_quit=true; | 653 | menu_quit=true; |
diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c index 1113654230..0875248bdc 100644 --- a/apps/plugins/dice.c +++ b/apps/plugins/dice.c | |||
@@ -235,8 +235,7 @@ static bool dice_menu(int *num_dice, int *side_index) { | |||
235 | }; | 235 | }; |
236 | 236 | ||
237 | while (!menu_quit) { | 237 | while (!menu_quit) { |
238 | selection = rb->do_menu(&menu, &selection); | 238 | switch(rb->do_menu(&menu, &selection)) |
239 | switch(selection) | ||
240 | { | 239 | { |
241 | case 0: | 240 | case 0: |
242 | menu_quit = true; | 241 | menu_quit = true; |
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index da2e76fb56..4340770e09 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c | |||
@@ -355,8 +355,7 @@ int tidy_lcd_menu(void) | |||
355 | 355 | ||
356 | while (!menu_quit) | 356 | while (!menu_quit) |
357 | { | 357 | { |
358 | selection = rb->do_menu(&menu,&selection); | 358 | switch(rb->do_menu(&menu, &selection)) |
359 | switch(selection) | ||
360 | { | 359 | { |
361 | 360 | ||
362 | case 0: | 361 | case 0: |
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c index 9dc983e4c1..31d699501d 100644 --- a/apps/plugins/minesweeper.c +++ b/apps/plugins/minesweeper.c | |||
@@ -410,8 +410,7 @@ enum minesweeper_status menu( void ) | |||
410 | #endif | 410 | #endif |
411 | 411 | ||
412 | while (!menu_quit) { | 412 | while (!menu_quit) { |
413 | selection=rb->do_menu(&menu,&selection); | 413 | switch(rb->do_menu(&menu, &selection)) |
414 | switch(selection) | ||
415 | { | 414 | { |
416 | case 0: | 415 | case 0: |
417 | result = MINESWEEPER_WIN; /* start playing */ | 416 | result = MINESWEEPER_WIN; /* start playing */ |
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c index fa357a8418..6acbb808aa 100644 --- a/apps/plugins/snake.c +++ b/apps/plugins/snake.c | |||
@@ -342,8 +342,7 @@ void game_init(void) { | |||
342 | "Quit"); | 342 | "Quit"); |
343 | 343 | ||
344 | while (!menu_quit) { | 344 | while (!menu_quit) { |
345 | selection = rb->do_menu(&menu, &selection); | 345 | switch(rb->do_menu(&menu, &selection)) |
346 | switch(selection) | ||
347 | { | 346 | { |
348 | case 0: | 347 | case 0: |
349 | menu_quit = true; /* start playing */ | 348 | menu_quit = true; /* start playing */ |
diff --git a/apps/plugins/star.c b/apps/plugins/star.c index 56cbe8c75d..2e27fd280b 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c | |||
@@ -876,8 +876,7 @@ static int star_menu(void) | |||
876 | 876 | ||
877 | while(!menu_quit) | 877 | while(!menu_quit) |
878 | { | 878 | { |
879 | selection = rb->do_menu(&menu, &selection); | 879 | switch(rb->do_menu(&menu, &selection)) |
880 | switch(selection) | ||
881 | { | 880 | { |
882 | case 0: | 881 | case 0: |
883 | menu_quit = true; | 882 | menu_quit = true; |
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 748b07141b..9f452de184 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -452,7 +452,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
452 | unsigned char* codec_stack_copy; | 452 | unsigned char* codec_stack_copy; |
453 | size_t codec_stack_size; | 453 | size_t codec_stack_size; |
454 | struct thread_entry* codecthread_id; | 454 | struct thread_entry* codecthread_id; |
455 | int result; | 455 | int result, selection = 0; |
456 | char* ch; | 456 | char* ch; |
457 | int line = 0; | 457 | int line = 0; |
458 | 458 | ||
@@ -529,7 +529,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
529 | 529 | ||
530 | rb->lcd_clear_display(); | 530 | rb->lcd_clear_display(); |
531 | 531 | ||
532 | result=rb->do_menu(&menu,&result); | 532 | result=rb->do_menu(&menu,&selection); |
533 | 533 | ||
534 | if (result==0) { | 534 | if (result==0) { |
535 | wavinfo.fd = -1; | 535 | wavinfo.fd = -1; |
diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index 645a968342..528d790ed5 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c | |||
@@ -3717,9 +3717,8 @@ static int recording_menu(void) | |||
3717 | "Set channels", "Set Source", "Start recording", "Quit"); | 3717 | "Set channels", "Set Source", "Start recording", "Quit"); |
3718 | 3718 | ||
3719 | while (!done) | 3719 | while (!done) |
3720 | { | 3720 | { |
3721 | rb->do_menu(&menu, &result); | 3721 | switch (rb->do_menu(&menu, &result)) |
3722 | switch (result) | ||
3723 | { | 3722 | { |
3724 | case 0: /* Set sample rate */ | 3723 | case 0: /* Set sample rate */ |
3725 | rb->set_option("Sample rate", &reccfg.samplerate, INT, freqs, 9, NULL); | 3724 | rb->set_option("Sample rate", &reccfg.samplerate, INT, freqs, 9, NULL); |
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index c4607cd618..94cf1bdee3 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c | |||
@@ -2533,9 +2533,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
2533 | rb->button_clear_queue(); | 2533 | rb->button_clear_queue(); |
2534 | 2534 | ||
2535 | while (!menu_quit) { | 2535 | while (!menu_quit) { |
2536 | result = rb->do_menu(&menu, &result); | 2536 | switch(rb->do_menu(&menu, &result)) |
2537 | |||
2538 | switch(result) | ||
2539 | { | 2537 | { |
2540 | case 0: | 2538 | case 0: |
2541 | rb->lcd_setfont(FONT_SYSFIXED); | 2539 | rb->lcd_setfont(FONT_SYSFIXED); |