summaryrefslogtreecommitdiff
path: root/apps/filetypes.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/filetypes.c')
-rw-r--r--apps/filetypes.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index e826efc7dc..a6ccff32ba 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -34,12 +34,11 @@
34#include "plugin.h" 34#include "plugin.h"
35#include "filetypes.h" 35#include "filetypes.h"
36#include "screens.h" 36#include "screens.h"
37#include "icons.h"
38#include "dir.h" 37#include "dir.h"
39#include "file.h" 38#include "file.h"
40#include "icons.h"
41#include "splash.h" 39#include "splash.h"
42#include "buffer.h" 40#include "buffer.h"
41#include "icons.h"
43 42
44/* max filetypes (plugins & icons stored here) */ 43/* max filetypes (plugins & icons stored here) */
45#if CONFIG_CODEC == SWCODEC 44#if CONFIG_CODEC == SWCODEC
@@ -125,6 +124,9 @@ struct file_type {
125static struct file_type filetypes[MAX_FILETYPES]; 124static struct file_type filetypes[MAX_FILETYPES];
126static int custom_filetype_icons[MAX_FILETYPES]; 125static int custom_filetype_icons[MAX_FILETYPES];
127static bool custom_icons_loaded = false; 126static bool custom_icons_loaded = false;
127#ifdef HAVE_LCD_COLOR
128static int custom_colors[MAX_FILETYPES];
129#endif
128static int filetype_count = 0; 130static int filetype_count = 0;
129static unsigned char heighest_attr = 0; 131static unsigned char heighest_attr = 0;
130 132
@@ -136,6 +138,41 @@ static char *filetypes_strdup(char* string)
136} 138}
137static void read_builtin_types(void); 139static void read_builtin_types(void);
138static void read_config(char* config_file); 140static void read_config(char* config_file);
141#ifdef HAVE_LCD_COLOR
142/* Colors file format is similar to icons:
143 * ext:hex_color
144 * load a colors file from a theme with:
145 * filetype colors: filename.colors */
146void read_color_theme_file(void) {
147 char buffer[MAX_PATH];
148 int fd;
149 char *ext, *color;
150 int i;
151 for (i = 0; i < filetype_count; i++) {
152 custom_colors[i] = -1;
153 }
154 snprintf(buffer, MAX_PATH, "%s/%s.colors", THEME_DIR,
155 global_settings.colors_file);
156 fd = open(buffer, O_RDONLY);
157 if (fd < 0)
158 return;
159 while (read_line(fd, buffer, MAX_PATH) > 0)
160 {
161 if (!settings_parseline(buffer, &ext, &color))
162 continue;
163 for (i=0; i<filetype_count; i++)
164 {
165 if (filetypes[i].extension &&
166 !strcasecmp(ext, filetypes[i].extension))
167 {
168 custom_colors[i] = hex_to_rgb(color);
169 break;
170 }
171 }
172 }
173 close(fd);
174}
175#endif
139#ifdef HAVE_LCD_BITMAP 176#ifdef HAVE_LCD_BITMAP
140void read_viewer_theme_file(void) 177void read_viewer_theme_file(void)
141{ 178{
@@ -162,7 +199,8 @@ void read_viewer_theme_file(void)
162 continue; 199 continue;
163 for (i=0; i<filetype_count; i++) 200 for (i=0; i<filetype_count; i++)
164 { 201 {
165 if (filetypes[i].extension && !strcasecmp(ext, filetypes[i].extension)) 202 if (filetypes[i].extension &&
203 !strcasecmp(ext, filetypes[i].extension))
166 { 204 {
167 if (*icon == '*') 205 if (*icon == '*')
168 custom_filetype_icons[i] = atoi(icon+1); 206 custom_filetype_icons[i] = atoi(icon+1);
@@ -198,6 +236,9 @@ void filetype_init(void)
198#ifdef HAVE_LCD_BITMAP 236#ifdef HAVE_LCD_BITMAP
199 read_viewer_theme_file(); 237 read_viewer_theme_file();
200#endif 238#endif
239#ifdef HAVE_LCD_COLOR
240 read_color_theme_file();
241#endif
201} 242}
202 243
203/* remove all white spaces from string */ 244/* remove all white spaces from string */
@@ -327,6 +368,17 @@ static int find_attr(int attr)
327 return -1; 368 return -1;
328} 369}
329 370
371#ifdef HAVE_LCD_COLOR
372int filetype_get_color(int attr)
373{
374 int index = find_attr(attr);
375 if (index < 0)
376 return -1;
377 return custom_colors[index];
378 return -1;
379}
380#endif
381
330int filetype_get_icon(int attr) 382int filetype_get_icon(int attr)
331{ 383{
332 int index = find_attr(attr); 384 int index = find_attr(attr);