summaryrefslogtreecommitdiff
path: root/apps/filetypes.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-04-16 14:33:29 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-04-16 14:33:29 +0000
commita9c1df40014ebe548ab111fd28d854f22e231b5f (patch)
treeb663992bcc82b56095900dd378cc1eb8dfa81a6a /apps/filetypes.c
parentb6658bbeef45b3b2db730bb8ca2bf0309d2ca917 (diff)
downloadrockbox-a9c1df40014ebe548ab111fd28d854f22e231b5f.tar.gz
rockbox-a9c1df40014ebe548ab111fd28d854f22e231b5f.zip
* its name[rows][columns] you drongo!
* make custom viewer icons work slightly better * minor nit-picks to keep crop happy * create a /.rockbox/themes/default_rockbox_icons.cfg to restore the default icons easily git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13183 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/filetypes.c')
-rw-r--r--apps/filetypes.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c
index 25dc0fe7da..832d67799b 100644
--- a/apps/filetypes.c
+++ b/apps/filetypes.c
@@ -63,6 +63,8 @@ struct file_type {
63 char* extension; /* NULL for none */ 63 char* extension; /* NULL for none */
64}; 64};
65static struct file_type filetypes[MAX_FILETYPES]; 65static struct file_type filetypes[MAX_FILETYPES];
66static int custom_filetype_icons[MAX_FILETYPES];
67static bool custom_icons_loaded = false;
66static int filetype_count = 0; 68static int filetype_count = 0;
67static unsigned char heighest_attr = 0; 69static unsigned char heighest_attr = 0;
68 70
@@ -81,6 +83,10 @@ void read_viewer_theme_file(void)
81 int fd; 83 int fd;
82 char *ext, *icon; 84 char *ext, *icon;
83 int i; 85 int i;
86 custom_icons_loaded = false;
87 for (i=0; i<filetype_count; i++)
88 custom_filetype_icons[i] = Icon_Questionmark;
89
84 snprintf(buffer, MAX_PATH, "%s/%s.icons", ICON_DIR, 90 snprintf(buffer, MAX_PATH, "%s/%s.icons", ICON_DIR,
85 global_settings.viewers_icon_file); 91 global_settings.viewers_icon_file);
86 fd = open(buffer, O_RDONLY); 92 fd = open(buffer, O_RDONLY);
@@ -95,16 +101,17 @@ void read_viewer_theme_file(void)
95 if (filetypes[i].extension && !strcasecmp(ext, filetypes[i].extension)) 101 if (filetypes[i].extension && !strcasecmp(ext, filetypes[i].extension))
96 { 102 {
97 if (*icon == '*') 103 if (*icon == '*')
98 filetypes[i].icon = atoi(icon+1); 104 custom_filetype_icons[i] = atoi(icon+1);
99 else if (*icon == '-') 105 else if (*icon == '-')
100 filetypes[i].icon = Icon_NOICON; 106 custom_filetype_icons[i] = Icon_NOICON;
101 else if (*icon >= '0' && *icon <= '9') 107 else if (*icon >= '0' && *icon <= '9')
102 filetypes[i].icon = Icon_Last_Themeable + atoi(icon); 108 custom_filetype_icons[i] = Icon_Last_Themeable + atoi(icon);
103 break; 109 break;
104 } 110 }
105 } 111 }
106 } 112 }
107 close(fd); 113 close(fd);
114 custom_icons_loaded = true;
108} 115}
109#endif 116#endif
110 117
@@ -258,6 +265,8 @@ int filetype_get_icon(int attr)
258 int index = find_attr(attr); 265 int index = find_attr(attr);
259 if (index < 0) 266 if (index < 0)
260 return Icon_NOICON; 267 return Icon_NOICON;
268 if (custom_icons_loaded)
269 return custom_filetype_icons[index];
261 return filetypes[index].icon; 270 return filetypes[index].icon;
262} 271}
263 272