summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2007-06-17 23:10:01 +0000
committerBrandon Low <lostlogic@rockbox.org>2007-06-17 23:10:01 +0000
commitf8682a032ed459eeb8b4865cba73706e24734b55 (patch)
tree3d125a3705135b27b614f0e5ac89b9aa715ebdc8
parentd88d2557d0398dec19ac21bfcb1f691103715d73 (diff)
downloadrockbox-f8682a032ed459eeb8b4865cba73706e24734b55.tar.gz
rockbox-f8682a032ed459eeb8b4865cba73706e24734b55.zip
Fix some bugs with the colors stuff. You can now specify folder color with the folder extension.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13659 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/filetypes.c27
-rw-r--r--apps/filetypes.h2
-rw-r--r--apps/tree.c2
-rw-r--r--docs/sample.colors11
4 files changed, 31 insertions, 11 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index a6ccff32ba..89933c8774 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -39,6 +39,7 @@
#include "splash.h"
#include "buffer.h"
#include "icons.h"
+#include "logf.h"
/* max filetypes (plugins & icons stored here) */
#if CONFIG_CODEC == SWCODEC
@@ -160,7 +161,12 @@ void read_color_theme_file(void) {
{
if (!settings_parseline(buffer, &ext, &color))
continue;
- for (i=0; i<filetype_count; i++)
+ if (!strcasecmp(ext, "folder"))
+ {
+ custom_colors[0] = hex_to_rgb(color);
+ continue;
+ }
+ for (i=1; i<filetype_count; i++)
{
if (filetypes[i].extension &&
!strcasecmp(ext, filetypes[i].extension))
@@ -369,12 +375,23 @@ static int find_attr(int attr)
}
#ifdef HAVE_LCD_COLOR
-int filetype_get_color(int attr)
+int filetype_get_color(const char * name, int attr)
{
- int index = find_attr(attr);
- if (index < 0)
+ char *extension;
+ int i;
+ if ((attr & ATTR_DIRECTORY)==ATTR_DIRECTORY)
+ return custom_colors[0];
+ extension = strrchr(name, '.');
+ if (!extension)
return -1;
- return custom_colors[index];
+ extension++;
+ logf("%s %s",name,extension);
+ for (i=1; i<filetype_count; i++)
+ {
+ if (filetypes[i].extension &&
+ !strcasecmp(extension, filetypes[i].extension))
+ return custom_colors[i];
+ }
return -1;
}
#endif
diff --git a/apps/filetypes.h b/apps/filetypes.h
index 13f4e56161..52e60eab1f 100644
--- a/apps/filetypes.h
+++ b/apps/filetypes.h
@@ -60,7 +60,7 @@ void read_color_theme_file(void);
/* Return the attribute (FILE_ATTR_*) of the file */
int filetype_get_attr(const char* file);
#ifdef HAVE_LCD_COLOR
-int filetype_get_color(int attr);
+int filetype_get_color(const char * name, int attr);
#endif
int filetype_get_icon(int attr);
/* return the plugin filename associated with the file */
diff --git a/apps/tree.c b/apps/tree.c
index a790400754..d0fe47fa2c 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -171,7 +171,7 @@ static int tree_get_filecolor(int selected_item, void * data)
struct tree_context * local_tc=(struct tree_context *)data;
struct entry* dc = local_tc->dircache;
struct entry* e = &dc[selected_item];
- return filetype_get_color(e->attr);
+ return filetype_get_color(e->name, e->attr);
}
#endif
diff --git a/docs/sample.colors b/docs/sample.colors
index 2f90dee125..930a34e8dd 100644
--- a/docs/sample.colors
+++ b/docs/sample.colors
@@ -1,4 +1,7 @@
-mp3:904010
-ogg:D04040
-txt:FF0000
-cfg:00FF00
+folder:808080
+ipod:00B0B0
+mp3:00FF00
+flac:00FF00
+ogg:00FF00
+txt:FF0000
+cfg:D00000