summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/pictureflow.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c
index 49c56925ca..24e69147a1 100644
--- a/apps/plugins/pictureflow.c
+++ b/apps/plugins/pictureflow.c
@@ -107,6 +107,10 @@ const struct button_mapping *plugin_contexts[]
107 107
108#define EMPTY_SLIDE CACHE_PREFIX "/emptyslide.pfraw" 108#define EMPTY_SLIDE CACHE_PREFIX "/emptyslide.pfraw"
109 109
110/* Error return values */
111#define ERROR_NO_ALBUMS -1
112#define ERROR_BUFFER_FULL -2
113
110 114
111/** structs we use */ 115/** structs we use */
112 116
@@ -400,7 +404,7 @@ inline PFreal fcos(int iangle)
400 Create an index of all albums from the database. 404 Create an index of all albums from the database.
401 Also store the album names so we can access them later. 405 Also store the album names so we can access them later.
402 */ 406 */
403bool create_album_index(void) 407int create_album_index(void)
404{ 408{
405 rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); 409 rb->memset(&tcs, 0, sizeof(struct tagcache_search) );
406 album_count = 0; 410 album_count = 0;
@@ -416,7 +420,7 @@ bool create_album_index(void)
416 420
417 if ( (album[album_count].name_idx + l) > MAX_ALBUMS*AVG_ALBUM_NAME_LENGTH ) 421 if ( (album[album_count].name_idx + l) > MAX_ALBUMS*AVG_ALBUM_NAME_LENGTH )
418 /* not enough memory */ 422 /* not enough memory */
419 return false; 423 return ERROR_BUFFER_FULL;
420 424
421 rb->strcpy(album_names + album[album_count].name_idx, tcs.result); 425 rb->strcpy(album_names + album[album_count].name_idx, tcs.result);
422 album[album_count].seek = tcs.result_seek; 426 album[album_count].seek = tcs.result_seek;
@@ -424,7 +428,8 @@ bool create_album_index(void)
424 album_count++; 428 album_count++;
425 } 429 }
426 rb->tagcache_search_finish(&tcs); 430 rb->tagcache_search_finish(&tcs);
427 return true; 431
432 return (album_count > 0) ? 0 : ERROR_NO_ALBUMS;
428} 433}
429 434
430/** 435/**
@@ -1478,6 +1483,8 @@ int main_menu(void) {
1478 int selection = 0; 1483 int selection = 0;
1479 int result; 1484 int result;
1480 1485
1486 rb->lcd_set_foreground(LCD_RGBPACK(255,255,255));
1487
1481 MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL, 1488 MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL,
1482 "Settings", "Return", "Quit"); 1489 "Settings", "Return", "Quit");
1483 1490
@@ -1509,6 +1516,7 @@ int main_menu(void) {
1509 */ 1516 */
1510int main(void) 1517int main(void)
1511{ 1518{
1519 int ret;
1512 draw_splashscreen(); 1520 draw_splashscreen();
1513 1521
1514 if ( ! rb->dir_exists( CACHE_PREFIX ) ) { 1522 if ( ! rb->dir_exists( CACHE_PREFIX ) ) {
@@ -1528,9 +1536,13 @@ int main(void)
1528 return PLUGIN_ERROR; 1536 return PLUGIN_ERROR;
1529 } 1537 }
1530 1538
1531 if (!create_album_index()) { 1539 ret = create_album_index();
1540 if (ret == ERROR_BUFFER_FULL) {
1532 rb->splash(HZ, "Not enough memory for album names"); 1541 rb->splash(HZ, "Not enough memory for album names");
1533 return PLUGIN_ERROR; 1542 return PLUGIN_ERROR;
1543 } else if (ret == ERROR_NO_ALBUMS) {
1544 rb->splash(HZ, "No albums found. Please enable database");
1545 return PLUGIN_ERROR;
1534 } 1546 }
1535 1547
1536 if (!create_albumart_cache(false)) { 1548 if (!create_albumart_cache(false)) {
@@ -1586,7 +1598,7 @@ int main(void)
1586 int albumtxt_w, albumtxt_h; 1598 int albumtxt_w, albumtxt_h;
1587 int albumtxt_x = 0, albumtxt_y = 0; 1599 int albumtxt_x = 0, albumtxt_y = 0;
1588 int albumtxt_dir = -1; 1600 int albumtxt_dir = -1;
1589 int ret, c; 1601 int c;
1590 int prev_center_index = -1; 1602 int prev_center_index = -1;
1591 1603
1592 while (true) { 1604 while (true) {