forked from len0rd/rockbox
menu.c remove the check for valid menu_callback
instead of checking for menu callback use an empty callback instead this code is a bit strange in that a prior valid callback might be returned so I left the behavior but I question if thats really needed.. Change-Id: Id0c4eb208b33a6fffdbdffc63ea9cc928bba1a6d
This commit is contained in:
parent
d1a4903afb
commit
e6f49e47e3
1 changed files with 31 additions and 37 deletions
34
apps/menu.c
34
apps/menu.c
|
@ -73,6 +73,13 @@ struct menu_data_t
|
||||||
int selected;
|
int selected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int empty_menu_callback(int action, const struct menu_item_ex *this_item, struct gui_synclist *this_list)
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
(void)this_item;
|
||||||
|
(void)this_list;
|
||||||
|
}
|
||||||
|
|
||||||
static void get_menu_callback(const struct menu_item_ex *m,
|
static void get_menu_callback(const struct menu_item_ex *m,
|
||||||
menu_callback_type *menu_callback)
|
menu_callback_type *menu_callback)
|
||||||
{
|
{
|
||||||
|
@ -80,6 +87,9 @@ static void get_menu_callback(const struct menu_item_ex *m,
|
||||||
*menu_callback= m->callback_and_desc->menu_callback;
|
*menu_callback= m->callback_and_desc->menu_callback;
|
||||||
else
|
else
|
||||||
*menu_callback = m->menu_callback;
|
*menu_callback = m->menu_callback;
|
||||||
|
|
||||||
|
if (!*menu_callback)
|
||||||
|
*menu_callback = &empty_menu_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool query_audio_status(int *old_audio_status)
|
static bool query_audio_status(int *old_audio_status)
|
||||||
|
@ -201,7 +211,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
|
||||||
int start_action = ACTION_ENTER_MENUITEM;
|
int start_action = ACTION_ENTER_MENUITEM;
|
||||||
int count = MIN(MENU_GET_COUNT(menu->flags), MAX_MENU_SUBITEMS);
|
int count = MIN(MENU_GET_COUNT(menu->flags), MAX_MENU_SUBITEMS);
|
||||||
int type = (menu->flags&MENU_TYPE_MASK);
|
int type = (menu->flags&MENU_TYPE_MASK);
|
||||||
menu_callback_type menu_callback = NULL;
|
menu_callback_type menu_callback = &empty_menu_callback;
|
||||||
int icon;
|
int icon;
|
||||||
char * title;
|
char * title;
|
||||||
current_subitems_count = 0;
|
current_subitems_count = 0;
|
||||||
|
@ -213,8 +223,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
|
||||||
{
|
{
|
||||||
if (type != MT_RETURN_ID)
|
if (type != MT_RETURN_ID)
|
||||||
get_menu_callback(menu->submenus[i],&menu_callback);
|
get_menu_callback(menu->submenus[i],&menu_callback);
|
||||||
if (menu_callback)
|
|
||||||
{
|
|
||||||
if (menu_callback(ACTION_REQUEST_MENUITEM,
|
if (menu_callback(ACTION_REQUEST_MENUITEM,
|
||||||
type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i], lists)
|
type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i], lists)
|
||||||
!= ACTION_EXIT_MENUITEM)
|
!= ACTION_EXIT_MENUITEM)
|
||||||
|
@ -223,12 +232,6 @@ static int init_menu_lists(const struct menu_item_ex *menu,
|
||||||
current_subitems_count++;
|
current_subitems_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
current_subitems[current_subitems_count] = i;
|
|
||||||
current_subitems_count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_submenus_menu = (struct menu_item_ex *)menu;
|
current_submenus_menu = (struct menu_item_ex *)menu;
|
||||||
|
|
||||||
|
@ -263,7 +266,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
|
||||||
gui_synclist_select_item(lists, find_menu_selection(selected));
|
gui_synclist_select_item(lists, find_menu_selection(selected));
|
||||||
|
|
||||||
get_menu_callback(menu,&menu_callback);
|
get_menu_callback(menu,&menu_callback);
|
||||||
if (callback && menu_callback)
|
if (callback)
|
||||||
start_action = menu_callback(start_action, menu, lists);
|
start_action = menu_callback(start_action, menu, lists);
|
||||||
|
|
||||||
return start_action;
|
return start_action;
|
||||||
|
@ -402,7 +405,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
int stack_top = 0;
|
int stack_top = 0;
|
||||||
|
|
||||||
struct viewport *vps = NULL;
|
struct viewport *vps = NULL;
|
||||||
menu_callback_type menu_callback = NULL;
|
menu_callback_type menu_callback = &empty_menu_callback;
|
||||||
|
|
||||||
/* if hide_theme is true, assume parent has been fixed before passed into
|
/* if hide_theme is true, assume parent has been fixed before passed into
|
||||||
* this function, e.g. with viewport_set_defaults(parent, screen)
|
* this function, e.g. with viewport_set_defaults(parent, screen)
|
||||||
|
@ -441,8 +444,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
action = gui_synclist_do_touchscreen(&lists);
|
action = gui_synclist_do_touchscreen(&lists);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (menu_callback)
|
|
||||||
{
|
|
||||||
int new_action = menu_callback(action, menu, &lists);
|
int new_action = menu_callback(action, menu, &lists);
|
||||||
if (new_action == ACTION_EXIT_AFTER_THIS_MENUITEM)
|
if (new_action == ACTION_EXIT_AFTER_THIS_MENUITEM)
|
||||||
ret = MENU_SELECTED_EXIT; /* exit after return from selection */
|
ret = MENU_SELECTED_EXIT; /* exit after return from selection */
|
||||||
|
@ -450,7 +451,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
redraw_lists = true;
|
redraw_lists = true;
|
||||||
else
|
else
|
||||||
action = new_action;
|
action = new_action;
|
||||||
}
|
|
||||||
|
|
||||||
if (LIKELY(gui_synclist_do_button(&lists, &action)))
|
if (LIKELY(gui_synclist_do_button(&lists, &action)))
|
||||||
continue;
|
continue;
|
||||||
|
@ -586,7 +586,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
bool exiting_menu = false;
|
bool exiting_menu = false;
|
||||||
in_stringlist = false;
|
in_stringlist = false;
|
||||||
|
|
||||||
if (menu_callback)
|
|
||||||
menu_callback(ACTION_EXIT_MENUITEM, menu, &lists);
|
menu_callback(ACTION_EXIT_MENUITEM, menu, &lists);
|
||||||
|
|
||||||
if (menu->flags&MENU_EXITAFTERTHISMENU)
|
if (menu->flags&MENU_EXITAFTERTHISMENU)
|
||||||
|
@ -630,13 +629,10 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
{
|
{
|
||||||
type = (temp->flags&MENU_TYPE_MASK);
|
type = (temp->flags&MENU_TYPE_MASK);
|
||||||
get_menu_callback(temp, &menu_callback);
|
get_menu_callback(temp, &menu_callback);
|
||||||
if (menu_callback)
|
|
||||||
{
|
|
||||||
action = menu_callback(ACTION_ENTER_MENUITEM, temp, &lists);
|
action = menu_callback(ACTION_ENTER_MENUITEM, temp, &lists);
|
||||||
if (action == ACTION_EXIT_MENUITEM)
|
if (action == ACTION_EXIT_MENUITEM)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case MT_MENU:
|
case MT_MENU:
|
||||||
|
@ -715,7 +711,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
}
|
}
|
||||||
if (type != MT_MENU)
|
if (type != MT_MENU)
|
||||||
{
|
{
|
||||||
if (menu_callback)
|
|
||||||
menu_callback(ACTION_EXIT_MENUITEM, temp, &lists);
|
menu_callback(ACTION_EXIT_MENUITEM, temp, &lists);
|
||||||
}
|
}
|
||||||
if (current_submenus_menu != menu)
|
if (current_submenus_menu != menu)
|
||||||
|
@ -750,7 +745,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
|
||||||
|
|
||||||
if (redraw_lists && !done)
|
if (redraw_lists && !done)
|
||||||
{
|
{
|
||||||
if (menu_callback)
|
|
||||||
if (menu_callback(ACTION_REDRAW, menu, &lists) != ACTION_REDRAW)
|
if (menu_callback(ACTION_REDRAW, menu, &lists) != ACTION_REDRAW)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue