diff options
author | Brandon Low <lostlogic@rockbox.org> | 2007-06-17 23:10:01 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2007-06-17 23:10:01 +0000 |
commit | f8682a032ed459eeb8b4865cba73706e24734b55 (patch) | |
tree | 3d125a3705135b27b614f0e5ac89b9aa715ebdc8 /apps | |
parent | d88d2557d0398dec19ac21bfcb1f691103715d73 (diff) | |
download | rockbox-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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/filetypes.c | 27 | ||||
-rw-r--r-- | apps/filetypes.h | 2 | ||||
-rw-r--r-- | apps/tree.c | 2 |
3 files changed, 24 insertions, 7 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 @@ | |||
39 | #include "splash.h" | 39 | #include "splash.h" |
40 | #include "buffer.h" | 40 | #include "buffer.h" |
41 | #include "icons.h" | 41 | #include "icons.h" |
42 | #include "logf.h" | ||
42 | 43 | ||
43 | /* max filetypes (plugins & icons stored here) */ | 44 | /* max filetypes (plugins & icons stored here) */ |
44 | #if CONFIG_CODEC == SWCODEC | 45 | #if CONFIG_CODEC == SWCODEC |
@@ -160,7 +161,12 @@ void read_color_theme_file(void) { | |||
160 | { | 161 | { |
161 | if (!settings_parseline(buffer, &ext, &color)) | 162 | if (!settings_parseline(buffer, &ext, &color)) |
162 | continue; | 163 | continue; |
163 | for (i=0; i<filetype_count; i++) | 164 | if (!strcasecmp(ext, "folder")) |
165 | { | ||
166 | custom_colors[0] = hex_to_rgb(color); | ||
167 | continue; | ||
168 | } | ||
169 | for (i=1; i<filetype_count; i++) | ||
164 | { | 170 | { |
165 | if (filetypes[i].extension && | 171 | if (filetypes[i].extension && |
166 | !strcasecmp(ext, filetypes[i].extension)) | 172 | !strcasecmp(ext, filetypes[i].extension)) |
@@ -369,12 +375,23 @@ static int find_attr(int attr) | |||
369 | } | 375 | } |
370 | 376 | ||
371 | #ifdef HAVE_LCD_COLOR | 377 | #ifdef HAVE_LCD_COLOR |
372 | int filetype_get_color(int attr) | 378 | int filetype_get_color(const char * name, int attr) |
373 | { | 379 | { |
374 | int index = find_attr(attr); | 380 | char *extension; |
375 | if (index < 0) | 381 | int i; |
382 | if ((attr & ATTR_DIRECTORY)==ATTR_DIRECTORY) | ||
383 | return custom_colors[0]; | ||
384 | extension = strrchr(name, '.'); | ||
385 | if (!extension) | ||
376 | return -1; | 386 | return -1; |
377 | return custom_colors[index]; | 387 | extension++; |
388 | logf("%s %s",name,extension); | ||
389 | for (i=1; i<filetype_count; i++) | ||
390 | { | ||
391 | if (filetypes[i].extension && | ||
392 | !strcasecmp(extension, filetypes[i].extension)) | ||
393 | return custom_colors[i]; | ||
394 | } | ||
378 | return -1; | 395 | return -1; |
379 | } | 396 | } |
380 | #endif | 397 | #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); | |||
60 | /* Return the attribute (FILE_ATTR_*) of the file */ | 60 | /* Return the attribute (FILE_ATTR_*) of the file */ |
61 | int filetype_get_attr(const char* file); | 61 | int filetype_get_attr(const char* file); |
62 | #ifdef HAVE_LCD_COLOR | 62 | #ifdef HAVE_LCD_COLOR |
63 | int filetype_get_color(int attr); | 63 | int filetype_get_color(const char * name, int attr); |
64 | #endif | 64 | #endif |
65 | int filetype_get_icon(int attr); | 65 | int filetype_get_icon(int attr); |
66 | /* return the plugin filename associated with the file */ | 66 | /* 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) | |||
171 | struct tree_context * local_tc=(struct tree_context *)data; | 171 | struct tree_context * local_tc=(struct tree_context *)data; |
172 | struct entry* dc = local_tc->dircache; | 172 | struct entry* dc = local_tc->dircache; |
173 | struct entry* e = &dc[selected_item]; | 173 | struct entry* e = &dc[selected_item]; |
174 | return filetype_get_color(e->attr); | 174 | return filetype_get_color(e->name, e->attr); |
175 | } | 175 | } |
176 | #endif | 176 | #endif |
177 | 177 | ||