diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-16 14:33:29 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-16 14:33:29 +0000 |
commit | a9c1df40014ebe548ab111fd28d854f22e231b5f (patch) | |
tree | b663992bcc82b56095900dd378cc1eb8dfa81a6a | |
parent | b6658bbeef45b3b2db730bb8ca2bf0309d2ca917 (diff) | |
download | rockbox-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
-rw-r--r-- | apps/filetypes.c | 15 | ||||
-rw-r--r-- | apps/gui/icon.c | 16 | ||||
-rw-r--r-- | apps/gui/icon.h | 5 | ||||
-rw-r--r-- | apps/settings.h | 2 | ||||
-rw-r--r-- | apps/settings_list.c | 2 | ||||
-rwxr-xr-x | tools/buildzip.pl | 17 |
6 files changed, 44 insertions, 13 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 | }; |
65 | static struct file_type filetypes[MAX_FILETYPES]; | 65 | static struct file_type filetypes[MAX_FILETYPES]; |
66 | static int custom_filetype_icons[MAX_FILETYPES]; | ||
67 | static bool custom_icons_loaded = false; | ||
66 | static int filetype_count = 0; | 68 | static int filetype_count = 0; |
67 | static unsigned char heighest_attr = 0; | 69 | static 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 | ||
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index b844b4bb5b..6e4cd59059 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -74,11 +74,11 @@ static const int default_height[NB_SCREENS] = { | |||
74 | 74 | ||
75 | #define IMG_BUFSIZE (MAX_ICON_HEIGHT * MAX_ICON_WIDTH * \ | 75 | #define IMG_BUFSIZE (MAX_ICON_HEIGHT * MAX_ICON_WIDTH * \ |
76 | Icon_Last_Themeable *LCD_DEPTH/8) | 76 | Icon_Last_Themeable *LCD_DEPTH/8) |
77 | static unsigned char icon_buffer[IMG_BUFSIZE][NB_SCREENS]; | 77 | static unsigned char icon_buffer[NB_SCREENS][IMG_BUFSIZE]; |
78 | static bool custom_icons_loaded[NB_SCREENS] = {false}; | 78 | static bool custom_icons_loaded[NB_SCREENS] = {false}; |
79 | static struct bitmap user_iconset[NB_SCREENS]; | 79 | static struct bitmap user_iconset[NB_SCREENS]; |
80 | 80 | ||
81 | static unsigned char viewer_icon_buffer[IMG_BUFSIZE][NB_SCREENS]; | 81 | static unsigned char viewer_icon_buffer[NB_SCREENS][IMG_BUFSIZE]; |
82 | static bool viewer_icons_loaded[NB_SCREENS] = {false}; | 82 | static bool viewer_icons_loaded[NB_SCREENS] = {false}; |
83 | static struct bitmap viewer_iconset[NB_SCREENS]; | 83 | static struct bitmap viewer_iconset[NB_SCREENS]; |
84 | 84 | ||
@@ -252,13 +252,15 @@ void icons_init(void) | |||
252 | { | 252 | { |
253 | snprintf(path, MAX_PATH, "%s/%s.bmp", | 253 | snprintf(path, MAX_PATH, "%s/%s.bmp", |
254 | ICON_DIR, global_settings.icon_file); | 254 | ICON_DIR, global_settings.icon_file); |
255 | load_icons(path, Iconset_Mainscreen); | 255 | load_icons((global_settings.icon_file[0] == '-')?NULL:path, |
256 | Iconset_Mainscreen); | ||
256 | } | 257 | } |
257 | if (global_settings.viewers_icon_file[0]) | 258 | if (global_settings.viewers_icon_file[0]) |
258 | { | 259 | { |
259 | snprintf(path, MAX_PATH, "%s/%s.bmp", | 260 | snprintf(path, MAX_PATH, "%s/%s.bmp", |
260 | ICON_DIR, global_settings.viewers_icon_file); | 261 | ICON_DIR, global_settings.viewers_icon_file); |
261 | load_icons(path, Iconset_Mainscreen_viewers); | 262 | load_icons((global_settings.viewers_icon_file[0] == '-')?NULL:path, |
263 | Iconset_Mainscreen_viewers); | ||
262 | read_viewer_theme_file(); | 264 | read_viewer_theme_file(); |
263 | } | 265 | } |
264 | else | 266 | else |
@@ -268,13 +270,15 @@ void icons_init(void) | |||
268 | { | 270 | { |
269 | snprintf(path, MAX_PATH, "%s/%s.bmp", | 271 | snprintf(path, MAX_PATH, "%s/%s.bmp", |
270 | ICON_DIR, global_settings.remote_icon_file); | 272 | ICON_DIR, global_settings.remote_icon_file); |
271 | load_icons(path, Iconset_Remotescreen); | 273 | load_icons((global_settings.remote_icon_file[0] == '-')?NULL:path, |
274 | Iconset_Remotescreen); | ||
272 | } | 275 | } |
273 | if (global_settings.remote_viewers_icon_file[0]) | 276 | if (global_settings.remote_viewers_icon_file[0]) |
274 | { | 277 | { |
275 | snprintf(path, MAX_PATH, "%s/%s.bmp", | 278 | snprintf(path, MAX_PATH, "%s/%s.bmp", |
276 | ICON_DIR, global_settings.remote_viewers_icon_file); | 279 | ICON_DIR, global_settings.remote_viewers_icon_file); |
277 | load_icons(path, Iconset_Remotescreen_viewers); | 280 | load_icons((global_settings.remote_viewers_icon_file[0] == '-')?NULL:path, |
281 | Iconset_Remotescreen_viewers); | ||
278 | } | 282 | } |
279 | else | 283 | else |
280 | load_icons(DEFAULT_REMOTE_VIEWER_BMP, Iconset_Remotescreen_viewers); | 284 | load_icons(DEFAULT_REMOTE_VIEWER_BMP, Iconset_Remotescreen_viewers); |
diff --git a/apps/gui/icon.h b/apps/gui/icon.h index fa6919030f..8408ed46b0 100644 --- a/apps/gui/icon.h +++ b/apps/gui/icon.h | |||
@@ -24,15 +24,14 @@ | |||
24 | * char-based displays and bitmap displays */ | 24 | * char-based displays and bitmap displays */ |
25 | #ifdef HAVE_LCD_BITMAP | 25 | #ifdef HAVE_LCD_BITMAP |
26 | typedef const unsigned char * ICON; | 26 | typedef const unsigned char * ICON; |
27 | #define NOICON Icon_NOICON | ||
28 | #else | 27 | #else |
29 | typedef long ICON; | 28 | typedef long ICON; |
30 | #define NOICON Icon_NOICON | ||
31 | #endif | 29 | #endif |
32 | 30 | ||
31 | #define NOICON Icon_NOICON | ||
33 | #define FORCE_INBUILT_ICON 0x80000000 | 32 | #define FORCE_INBUILT_ICON 0x80000000 |
34 | /* Don't #ifdef icon values, or we wont be able to use the same | 33 | /* Don't #ifdef icon values, or we wont be able to use the same |
35 | cmp for every target. */ | 34 | bmp for every target. */ |
36 | enum themable_icons { | 35 | enum themable_icons { |
37 | Icon_NOICON = -1, /* Dont put this in a .bmp */ | 36 | Icon_NOICON = -1, /* Dont put this in a .bmp */ |
38 | Icon_Audio, | 37 | Icon_Audio, |
diff --git a/apps/settings.h b/apps/settings.h index c27b6e602b..1fee6b4838 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -708,8 +708,10 @@ struct user_settings | |||
708 | int alarm_wake_up_screen; | 708 | int alarm_wake_up_screen; |
709 | #endif | 709 | #endif |
710 | /* customizable icons */ | 710 | /* customizable icons */ |
711 | #ifdef HAVE_LCD_BITMAP | ||
711 | unsigned char icon_file[MAX_FILENAME+1]; | 712 | unsigned char icon_file[MAX_FILENAME+1]; |
712 | unsigned char viewers_icon_file[MAX_FILENAME+1]; | 713 | unsigned char viewers_icon_file[MAX_FILENAME+1]; |
714 | #endif | ||
713 | #ifdef HAVE_REMOTE_LCD | 715 | #ifdef HAVE_REMOTE_LCD |
714 | unsigned char remote_icon_file[MAX_FILENAME+1]; | 716 | unsigned char remote_icon_file[MAX_FILENAME+1]; |
715 | unsigned char remote_viewers_icon_file[MAX_FILENAME+1]; | 717 | unsigned char remote_viewers_icon_file[MAX_FILENAME+1]; |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 2ebce0ea77..ce45074f36 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -1167,13 +1167,13 @@ const struct settings_list settings[] = { | |||
1167 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), | 1167 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), |
1168 | FILENAME_SETTING(F_THEMESETTING, viewers_icon_file, "viewers iconset", "", | 1168 | FILENAME_SETTING(F_THEMESETTING, viewers_icon_file, "viewers iconset", "", |
1169 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), | 1169 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), |
1170 | #endif | ||
1170 | #ifdef HAVE_REMOTE_LCD | 1171 | #ifdef HAVE_REMOTE_LCD |
1171 | FILENAME_SETTING(F_THEMESETTING, remote_icon_file, "remote iconset", "", | 1172 | FILENAME_SETTING(F_THEMESETTING, remote_icon_file, "remote iconset", "", |
1172 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), | 1173 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), |
1173 | FILENAME_SETTING(F_THEMESETTING, remote_viewers_icon_file, | 1174 | FILENAME_SETTING(F_THEMESETTING, remote_viewers_icon_file, |
1174 | "remote viewers iconset", "", | 1175 | "remote viewers iconset", "", |
1175 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), | 1176 | ICON_DIR "/", ".bmp", MAX_FILENAME+1), |
1176 | #endif | ||
1177 | #endif /* HAVE_REMOTE_LCD */ | 1177 | #endif /* HAVE_REMOTE_LCD */ |
1178 | }; | 1178 | }; |
1179 | 1179 | ||
diff --git a/tools/buildzip.pl b/tools/buildzip.pl index 8e1ca3b98a..06523c3ae3 100755 --- a/tools/buildzip.pl +++ b/tools/buildzip.pl | |||
@@ -209,6 +209,23 @@ sub buildzip { | |||
209 | 209 | ||
210 | mkdir ".rockbox/wps", 0777; | 210 | mkdir ".rockbox/wps", 0777; |
211 | mkdir ".rockbox/themes", 0777; | 211 | mkdir ".rockbox/themes", 0777; |
212 | if ($bitmap) { | ||
213 | open(THEME, ">.rockbox/themes/rockbox_default_icons.cfg"); | ||
214 | print THEME <<STOP | ||
215 | # this config file was auto-generated to make it | ||
216 | # easy to reset the icons back to default | ||
217 | iconset: - | ||
218 | # taken from apps/gui/icon.c | ||
219 | viewers iconset: /.rockbox/icons/viewers.bmp | ||
220 | remote iconset: - | ||
221 | # taken from apps/gui/icon.c | ||
222 | remote viewers iconset: /.rockbox/icons/remote_viewers.bmp | ||
223 | |||
224 | STOP | ||
225 | ; | ||
226 | close(THEME); | ||
227 | } | ||
228 | |||
212 | mkdir ".rockbox/codepages", 0777; | 229 | mkdir ".rockbox/codepages", 0777; |
213 | 230 | ||
214 | if($bitmap) { | 231 | if($bitmap) { |