(RMenu) Now shows no entries available when trying to enter a dir that has

no files with valid extensions - can also exit out of this dir
This commit is contained in:
twinaphex 2013-09-29 01:34:34 +02:00
parent 5a81028f96
commit 91f2d76fbe
2 changed files with 53 additions and 25 deletions

View File

@ -4,10 +4,11 @@ static bool directory_parse(void *data, const char *path)
struct string_list *list = dir_list_new(path,
filebrowser->current_dir.extensions, true);
if(!list || list->size < 1)
if(!list)
return false;
dir_list_sort(list, true);
if (list->size)
dir_list_sort(list, true);
filebrowser->current_dir.ptr = 0;
strlcpy(filebrowser->current_dir.directory_path,
@ -56,34 +57,46 @@ bool filebrowser_iterate(void *data, unsigned action)
switch(action)
{
case FILEBROWSER_ACTION_UP:
if (!filebrowser->list->size)
break;
filebrowser->current_dir.ptr--;
if (filebrowser->current_dir.ptr >= filebrowser->list->size)
filebrowser->current_dir.ptr = filebrowser->list->size - 1;
break;
case FILEBROWSER_ACTION_DOWN:
if (!filebrowser->list->size)
break;
filebrowser->current_dir.ptr++;
if (filebrowser->current_dir.ptr >= filebrowser->list->size)
filebrowser->current_dir.ptr = 0;
break;
case FILEBROWSER_ACTION_LEFT:
if (!filebrowser->list->size)
break;
if (filebrowser->current_dir.ptr <= 5)
filebrowser->current_dir.ptr = 0;
else
filebrowser->current_dir.ptr -= 5;
break;
case FILEBROWSER_ACTION_RIGHT:
if (!filebrowser->list->size)
break;
filebrowser->current_dir.ptr = (min(filebrowser->current_dir.ptr + 5,
filebrowser->list->size-1));
filebrowser->list->size-1));
break;
case FILEBROWSER_ACTION_SCROLL_UP:
if (!filebrowser->list->size)
break;
if (filebrowser->current_dir.ptr <= entries_to_scroll)
filebrowser->current_dir.ptr= 0;
else
filebrowser->current_dir.ptr -= entries_to_scroll;
break;
case FILEBROWSER_ACTION_SCROLL_DOWN:
if (!filebrowser->list->size)
break;
filebrowser->current_dir.ptr = (min(filebrowser->current_dir.ptr +
entries_to_scroll, filebrowser->list->size-1));
entries_to_scroll, filebrowser->list->size-1));
break;
case FILEBROWSER_ACTION_OK:
ret = directory_parse(filebrowser, GET_CURRENT_PATH(filebrowser));

View File

@ -444,38 +444,53 @@ static void render_text(void *data)
if (render_browser)
{
unsigned file_count = rgui->browser->list->size;
unsigned current_index = 0;
unsigned page_number = 0;
unsigned page_base = 0;
unsigned i;
float y_increment = POSITION_Y_START;
font_params_t font_parms = {0};
current_index = rgui->browser->current_dir.ptr;
page_number = current_index / NUM_ENTRY_PER_PAGE;
page_base = page_number * NUM_ENTRY_PER_PAGE;
font_parms.scale = FONT_SIZE_VARIABLE;
for (i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i)
if (rgui->browser->list->size)
{
char fname_tmp[128];
fill_pathname_base(fname_tmp, rgui->browser->list->elems[i].data, sizeof(fname_tmp));
y_increment += POSITION_Y_INCREMENT;
unsigned file_count = rgui->browser->list->size;
unsigned current_index = 0;
unsigned page_number = 0;
unsigned page_base = 0;
unsigned i;
float y_increment = POSITION_Y_START;
current_index = rgui->browser->current_dir.ptr;
page_number = current_index / NUM_ENTRY_PER_PAGE;
page_base = page_number * NUM_ENTRY_PER_PAGE;
for (i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i)
{
char fname_tmp[128];
fill_pathname_base(fname_tmp, rgui->browser->list->elems[i].data, sizeof(fname_tmp));
y_increment += POSITION_Y_INCREMENT;
#ifdef HAVE_MENU_PANEL
//check if this is the currently selected file
if (strcmp(rgui->browser->current_dir.path, rgui->browser->list->elems[i].data) == 0)
menu_panel->y = y_increment;
//check if this is the currently selected file
if (strcmp(rgui->browser->current_dir.path, rgui->browser->list->elems[i].data) == 0)
menu_panel->y = y_increment;
#endif
font_parms.x = POSITION_X;
font_parms.y = y_increment;
font_parms.color = i == current_index ? YELLOW : rgui->browser->list->elems[i].attr.b ? GREEN : WHITE;
if (driver.video_poke->set_osd_msg)
driver.video_poke->set_osd_msg(driver.video_data, fname_tmp, &font_parms);
}
}
else
{
char entry[128];
font_parms.x = POSITION_X;
font_parms.y = y_increment;
font_parms.color = i == current_index ? YELLOW : rgui->browser->list->elems[i].attr.b ? GREEN : WHITE;
font_parms.y = POSITION_Y_START + POSITION_Y_INCREMENT;
font_parms.color = WHITE;
strlcpy(entry, "No entries available.", sizeof(entry));
if (driver.video_poke->set_osd_msg)
driver.video_poke->set_osd_msg(driver.video_data, fname_tmp, &font_parms);
driver.video_poke->set_osd_msg(driver.video_data, entry, &font_parms);
}
}