From 179a306076f976660fd5dd26620c962727ddd629 Mon Sep 17 00:00:00 2001 From: skeezix Date: Thu, 10 Feb 2011 16:10:02 -0500 Subject: [PATCH] mmenu: Split up folder artwork so skinners can have some fun; falls back to exising artwork conf-key --- minimenu/mmenu.conf | 2 +- minimenu/mmui.c | 59 +++++++++++++++++++++++-------- minimenu/mmui.h | 3 ++ minimenu/skin/default/mmskin.conf | 4 ++- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/minimenu/mmenu.conf b/minimenu/mmenu.conf index e87c1f8..6b212c4 100644 --- a/minimenu/mmenu.conf +++ b/minimenu/mmenu.conf @@ -62,7 +62,7 @@ catmap_confname mmcatmap.conf [filesystem] do_browser 1 # if >0, will allow filesystem browsing somehow -tab_searchpaths /media/* # for each chunk in searchpath, show a tab (if not empty). +tab_searchpaths /media/*:/ # for each chunk in searchpath, show a tab (if not empty). # example: # /media -> show /media as a single tab # /media/* -> show a tab for each dir in /media diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 193dceb..96e4408 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -240,12 +240,15 @@ mm_imgcache_t g_imagecache [ IMG_TRUEMAX ] = { { IMG_HOURGLASS, "graphics.IMG_HOURGLASS", }, { IMG_FOLDER, "graphics.IMG_FOLDER", }, { IMG_EXECBIN, "graphics.IMG_EXECBIN", }, + { IMG_SUBCATFOLDER, "graphics.IMG_SUBCATFOLDER", "graphics.IMG_FOLDER", }, + { IMG_DOTDOTFOLDER, "graphics.IMG_DOTDOTFOLDER", "graphics.IMG_FOLDER", }, { IMG_MAX, NULL }, }; unsigned char ui_imagecache ( char *basepath ) { unsigned int i; char fullpath [ PATH_MAX ]; + unsigned char try; // loaded @@ -256,23 +259,39 @@ unsigned char ui_imagecache ( char *basepath ) { exit ( -1 ); } - char *filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].confname ); + for ( try = 0; try < 2; try++ ) { - if ( ! filename ) { - pnd_log ( pndn_error, "ERROR: Missing filename in conf for key: %s\n", g_imagecache [ i ].confname ); - return ( 0 ); - } + char *filename; - if ( filename [ 0 ] == '/' ) { - strncpy ( fullpath, filename, PATH_MAX ); - } else { - sprintf ( fullpath, "%s/%s", basepath, filename ); - } + if ( try == 0 ) { + filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].confname ); + } else { + if ( g_imagecache [ i ].alt_confname ) { + filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].alt_confname ); + } else { + return ( 0 ); + } + } - if ( ! ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) { - pnd_log ( pndn_error, "ERROR: Couldn't load static cache image: %s\n", fullpath ); - return ( 0 ); - } + if ( ! filename ) { + pnd_log ( pndn_error, "ERROR: (Try %u) Missing filename in conf for key: %s\n", try + 1, g_imagecache [ i ].confname ); + if ( try == 0 ) { continue; } else { return ( 0 ); } + } + + if ( filename [ 0 ] == '/' ) { + strncpy ( fullpath, filename, PATH_MAX ); + } else { + sprintf ( fullpath, "%s/%s", basepath, filename ); + } + + if ( ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) { + break; // no retry needed + } else { + pnd_log ( pndn_error, "ERROR: (Try %u) Couldn't load static cache image: %s\n", try + 1, fullpath ); + if ( try == 0 ) { continue; } else { return ( 0 ); } + } + + } // try twice } // for @@ -704,7 +723,17 @@ void ui_render ( void ) { // filesystem (file or directory icon) if ( appiter -> ref -> object_flags & PND_DISCO_GENERATED ) { if ( appiter -> ref -> object_type == pnd_object_type_directory ) { - iconsurface = g_imagecache [ IMG_FOLDER ].i; + + // is this a subcat, a .., or a filesystem folder? + //iconsurface = g_imagecache [ IMG_FOLDER ].i; + if ( g_categories [ ui_category ] -> fspath ) { + iconsurface = g_imagecache [ IMG_FOLDER ].i; + } else if ( strcmp ( appiter -> ref -> title_en, ".." ) == 0 ) { + iconsurface = g_imagecache [ IMG_DOTDOTFOLDER ].i; + } else { + iconsurface = g_imagecache [ IMG_SUBCATFOLDER ].i; + } + } else { iconsurface = g_imagecache [ IMG_EXECBIN ].i; } diff --git a/minimenu/mmui.h b/minimenu/mmui.h index 464c5f5..15cb631 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -34,6 +34,8 @@ typedef enum { IMG_HOURGLASS, IMG_FOLDER, IMG_EXECBIN, + IMG_SUBCATFOLDER, + IMG_DOTDOTFOLDER, IMG_MAX, // before this point is loaded; after is generated IMG_TRUEMAX } mm_imgcache_e; @@ -41,6 +43,7 @@ typedef enum { typedef struct { mm_imgcache_e id; char *confname; + char *alt_confname; void /*SDL_Surface*/ *i; } mm_imgcache_t; diff --git a/minimenu/skin/default/mmskin.conf b/minimenu/skin/default/mmskin.conf index cd71c14..7c0764c 100644 --- a/minimenu/skin/default/mmskin.conf +++ b/minimenu/skin/default/mmskin.conf @@ -119,4 +119,6 @@ IMG_ARROW_DOWN arrowdown.png IMG_ARROW_SCROLLBAR arrowscroller.png IMG_HOURGLASS hourglass.png IMG_FOLDER /usr/share/icons/gnome/32x32/places/folder.png # in dirbrowser mode -IMG_EXECBIN /usr/share/icons/gnome/32x32/categories/applications-other.png # in dirbrowser mode \ No newline at end of file +IMG_EXECBIN /usr/share/icons/gnome/32x32/categories/applications-other.png # in dirbrowser mode +IMG_SUBCATFOLDER /usr/share/icons/gnome/32x32/places/user-home.png # in dirbrowser mode +IMG_DOTDOTFOLDER /usr/share/icons/gnome/32x32/places/user-trash.png # in dirbrowser mode -- 2.39.2