mmenu: Split up folder artwork so skinners can have some fun; falls back to exising...
authorskeezix <skeezix@flotsam-vm.(none)>
Thu, 10 Feb 2011 21:10:02 +0000 (16:10 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Thu, 10 Feb 2011 21:10:02 +0000 (16:10 -0500)
minimenu/mmenu.conf
minimenu/mmui.c
minimenu/mmui.h
minimenu/skin/default/mmskin.conf

index e87c1f8..6b212c4 100644 (file)
@@ -62,7 +62,7 @@ catmap_confname               mmcatmap.conf
 
 [filesystem]
 do_browser             1       # if >0, will allow filesystem browsing somehow
 
 [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
 # example:
 # /media -> show /media as a single tab
 # /media/* -> show a tab for each dir in /media
index 193dceb..96e4408 100644 (file)
@@ -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_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 ];
   { IMG_MAX,                  NULL },
 };
 
 unsigned char ui_imagecache ( char *basepath ) {
   unsigned int i;
   char fullpath [ PATH_MAX ];
+  unsigned char try;
 
   // loaded
 
 
   // loaded
 
@@ -256,23 +259,39 @@ unsigned char ui_imagecache ( char *basepath ) {
       exit ( -1 );
     }
 
       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
 
 
   } // 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 ) {
              // 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;
                }
                } else {
                  iconsurface = g_imagecache [ IMG_EXECBIN ].i;
                }
index 464c5f5..15cb631 100644 (file)
@@ -34,6 +34,8 @@ typedef enum {
   IMG_HOURGLASS,
   IMG_FOLDER,
   IMG_EXECBIN,
   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;
   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;
 typedef struct {
   mm_imgcache_e id;
   char *confname;
+  char *alt_confname;
   void /*SDL_Surface*/ *i;
 } mm_imgcache_t;
 
   void /*SDL_Surface*/ *i;
 } mm_imgcache_t;
 
index cd71c14..7c0764c 100644 (file)
@@ -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_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