summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-02-27 09:16:47 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-02-27 09:16:47 +0000
commit9144be5253e0a25c3edf7bfb809498b5d2883173 (patch)
treeaab2f03c822c24916d73a92428dd65fbccdf915b /apps
parent2816dc9c13f204234b613db5199d2c787a11f0d8 (diff)
downloadrockbox-9144be5253e0a25c3edf7bfb809498b5d2883173.tar.gz
rockbox-9144be5253e0a25c3edf7bfb809498b5d2883173.tar.bz2
rockbox-9144be5253e0a25c3edf7bfb809498b5d2883173.zip
returning ACTION_EXIT_AFTER_THIS_MENUITEM from a menu callback will exit
the menu when the subitem returns. Use this with the preset item context menus git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12501 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/action.h2
-rw-r--r--apps/menu.c7
-rw-r--r--apps/recorder/radio.c10
3 files changed, 18 insertions, 1 deletions
diff --git a/apps/action.h b/apps/action.h
index 9519bd0fc7..a1d54b22d8 100644
--- a/apps/action.h
+++ b/apps/action.h
@@ -156,6 +156,8 @@ enum {
/* main menu */
ACTION_REQUEST_MENUITEM,
ACTION_EXIT_MENUITEM,
+ ACTION_EXIT_AFTER_THIS_MENUITEM, /* if a menu returns this the menu will exit
+ once the subitem returns */
ACTION_ENTER_MENUITEM,
ACTION_MENU_WPS,
diff --git a/apps/menu.c b/apps/menu.c
index 986c6b7034..0081d4964d 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -614,7 +614,14 @@ int do_menu(const struct menu_item_ex *start_menu)
if (menu_callback)
{
+ int old_action = action;
action = menu_callback(action, menu);
+ if (action == ACTION_EXIT_AFTER_THIS_MENUITEM)
+ {
+ action = old_action;
+ ret = MENU_SELECTED_EXIT; /* will exit after returning
+ from selection */
+ }
}
if (gui_synclist_do_button(&lists,action,LIST_WRAP_UNLESS_HELD))
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 555c3493a0..b86ad0d230 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -1211,8 +1211,16 @@ MENUITEM_FUNCTION(radio_edit_preset_item, ID2P(LANG_FM_EDIT_PRESET),
radio_edit_preset, NULL, NOICON);
MENUITEM_FUNCTION(radio_delete_preset_item, ID2P(LANG_FM_DELETE_PRESET),
radio_delete_preset, NULL, NOICON);
+int radio_preset_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_STD_OK)
+ return ACTION_EXIT_AFTER_THIS_MENUITEM;
+ return action;
+}
MAKE_MENU(handle_radio_preset_menu, ID2P(LANG_FM_BUTTONBAR_PRESETS),
- NULL, NOICON, &radio_edit_preset_item, &radio_delete_preset_item);
+ radio_preset_callback, NOICON, &radio_edit_preset_item,
+ &radio_delete_preset_item);
/* present a list of preset stations */
char * presets_get_name(int selected_item, void * data, char *buffer)
{