summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-08-06 12:44:12 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-08-06 12:44:12 +0000
commitc4dc61a2a6f4db707fb0201266f5b634aad1badd (patch)
tree79326e7598350eba222a93b8f25c80ef75d20889
parentc3aec89bec35c4d896904fb6d8a64d120e28fb52 (diff)
downloadrockbox-c4dc61a2a6f4db707fb0201266f5b634aad1badd.tar.gz
rockbox-c4dc61a2a6f4db707fb0201266f5b634aad1badd.zip
a bit of code polish for rockpaint and disktidy.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22187 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/disktidy.c89
-rw-r--r--apps/plugins/rockpaint.c41
2 files changed, 65 insertions, 65 deletions
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c
index 53af3a2f95..b7b9aa1770 100644
--- a/apps/plugins/disktidy.c
+++ b/apps/plugins/disktidy.c
@@ -141,7 +141,7 @@ bool tidy_remove_item(char *item, int attr)
141 if (file[rb->strlen(file)-1] == '*') 141 if (file[rb->strlen(file)-1] == '*')
142 { 142 {
143 if (!rb->strncmp(file, item, rb->strlen(file)-1)) 143 if (!rb->strncmp(file, item, rb->strlen(file)-1))
144 rem = true; 144 rem = true;
145 } 145 }
146 else if (!rb->strcmp(file, item)) 146 else if (!rb->strcmp(file, item))
147 rem = true; 147 rem = true;
@@ -192,12 +192,12 @@ enum tidy_return tidy_removedir(const char *name, int *removed)
192 int button; 192 int button;
193 DIR *dir; 193 DIR *dir;
194 char fullname[MAX_PATH]; 194 char fullname[MAX_PATH];
195 195
196 /* display status text */ 196 /* display status text */
197 tidy_lcd_status(name, removed); 197 tidy_lcd_status(name, removed);
198 198
199 rb->yield(); 199 rb->yield();
200 200
201 dir = rb->opendir(name); 201 dir = rb->opendir(name);
202 if (dir) 202 if (dir)
203 { 203 {
@@ -216,12 +216,12 @@ enum tidy_return tidy_removedir(const char *name, int *removed)
216 rb->closedir(dir); 216 rb->closedir(dir);
217 return TIDY_RETURN_USB; 217 return TIDY_RETURN_USB;
218 } 218 }
219 219
220 rb->yield(); 220 rb->yield();
221 221
222 /* get absolute path */ 222 /* get absolute path */
223 tidy_get_absolute_path(entry, fullname, name); 223 tidy_get_absolute_path(entry, fullname, name);
224 224
225 if (entry->attribute & ATTR_DIRECTORY) 225 if (entry->attribute & ATTR_DIRECTORY)
226 { 226 {
227 /* dir ignore "." and ".." */ 227 /* dir ignore "." and ".." */
@@ -259,12 +259,12 @@ enum tidy_return tidy_clean(const char *name, int *removed)
259 int del; /* has the item been deleted */ 259 int del; /* has the item been deleted */
260 DIR *dir; 260 DIR *dir;
261 char fullname[MAX_PATH]; 261 char fullname[MAX_PATH];
262 262
263 /* display status text */ 263 /* display status text */
264 tidy_lcd_status(name, removed); 264 tidy_lcd_status(name, removed);
265 265
266 rb->yield(); 266 rb->yield();
267 267
268 dir = rb->opendir(name); 268 dir = rb->opendir(name);
269 if (dir) 269 if (dir)
270 { 270 {
@@ -283,9 +283,9 @@ enum tidy_return tidy_clean(const char *name, int *removed)
283 rb->closedir(dir); 283 rb->closedir(dir);
284 return TIDY_RETURN_USB; 284 return TIDY_RETURN_USB;
285 } 285 }
286 286
287 rb->yield(); 287 rb->yield();
288 288
289 if (entry->attribute & ATTR_DIRECTORY) 289 if (entry->attribute & ATTR_DIRECTORY)
290 { 290 {
291 /* directory ignore "." and ".." */ 291 /* directory ignore "." and ".." */
@@ -293,17 +293,17 @@ enum tidy_return tidy_clean(const char *name, int *removed)
293 (rb->strcmp(entry->d_name, "..") != 0)) 293 (rb->strcmp(entry->d_name, "..") != 0))
294 { 294 {
295 del = 0; 295 del = 0;
296 296
297 /* get absolute path */ 297 /* get absolute path */
298 tidy_get_absolute_path(entry, fullname, name); 298 tidy_get_absolute_path(entry, fullname, name);
299 299
300 if (tidy_remove_item(entry->d_name, entry->attribute)) 300 if (tidy_remove_item(entry->d_name, entry->attribute))
301 { 301 {
302 /* delete dir */ 302 /* delete dir */
303 tidy_removedir(fullname, removed); 303 tidy_removedir(fullname, removed);
304 del = 1; 304 del = 1;
305 } 305 }
306 306
307 if (del == 0) 307 if (del == 0)
308 { 308 {
309 /* dir not deleted so clean it */ 309 /* dir not deleted so clean it */
@@ -318,11 +318,11 @@ enum tidy_return tidy_clean(const char *name, int *removed)
318 if (tidy_remove_item(entry->d_name, entry->attribute)) 318 if (tidy_remove_item(entry->d_name, entry->attribute))
319 { 319 {
320 *removed += 1; /* increment removed files counter */ 320 *removed += 1; /* increment removed files counter */
321 321
322 /* get absolute path */ 322 /* get absolute path */
323 char fullname[MAX_PATH]; 323 char fullname[MAX_PATH];
324 tidy_get_absolute_path(entry, fullname, name); 324 tidy_get_absolute_path(entry, fullname, name);
325 325
326 /* delete file */ 326 /* delete file */
327 rb->remove(fullname); 327 rb->remove(fullname);
328 del = 1; 328 del = 1;
@@ -338,23 +338,23 @@ enum tidy_return tidy_clean(const char *name, int *removed)
338 } 338 }
339} 339}
340 340
341enum plugin_status tidy_do(void) 341enum tidy_return tidy_do(void)
342{ 342{
343 /* clean disk and display num of items removed */ 343 /* clean disk and display num of items removed */
344 int removed = 0; 344 int removed = 0;
345 enum tidy_return status; 345 enum tidy_return status;
346 char text[24]; /* "Cleaned up nnnnn items" */ 346 char text[24]; /* "Cleaned up nnnnn items" */
347 347
348#ifdef HAVE_ADJUSTABLE_CPU_FREQ 348#ifdef HAVE_ADJUSTABLE_CPU_FREQ
349 rb->cpu_boost(true); 349 rb->cpu_boost(true);
350#endif 350#endif
351 351
352 status = tidy_clean("/", &removed); 352 status = tidy_clean("/", &removed);
353 353
354#ifdef HAVE_ADJUSTABLE_CPU_FREQ 354#ifdef HAVE_ADJUSTABLE_CPU_FREQ
355 rb->cpu_boost(false); 355 rb->cpu_boost(false);
356#endif 356#endif
357 357
358 if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT)) 358 if ((status == TIDY_RETURN_OK) || (status == TIDY_RETURN_ABORT))
359 { 359 {
360 rb->lcd_clear_display(); 360 rb->lcd_clear_display();
@@ -436,29 +436,32 @@ int list_action_callback(int action, struct gui_synclist *lists)
436 return action; 436 return action;
437} 437}
438 438
439int tidy_lcd_menu(void) 439enum tidy_return tidy_lcd_menu(void)
440{ 440{
441 int selection, ret = 3; 441 int selection = 0;
442 enum tidy_return status = TIDY_RETURN_OK;
442 bool menu_quit = false; 443 bool menu_quit = false;
443 444
444 MENUITEM_STRINGLIST(menu,"Disktidy Menu",NULL,"Start Cleaning", 445 MENUITEM_STRINGLIST(menu, "Disktidy Menu", NULL,
445 "Files to Clean","Quit"); 446 "Start Cleaning", "Files to Clean",
446 447 "Quit");
448
447 while (!menu_quit) 449 while (!menu_quit)
448 { 450 {
449 switch(rb->do_menu(&menu, &selection, NULL, false)) 451 switch(rb->do_menu(&menu, &selection, NULL, false))
450 { 452 {
451
452 case 0: 453 case 0:
453 menu_quit = true; /* start cleaning */ 454 menu_quit = true; /* start cleaning */
454 break; 455 break;
455 456
456 case 1: 457 case 1:
457 { 458 {
458 bool show_icons = rb->global_settings->show_icons; 459 bool show_icons = rb->global_settings->show_icons;
459 struct simplelist_info list; 460 struct simplelist_info list;
460 rb->global_settings->show_icons = true; /* force the icons so its readable */ 461 /* force the icons so its readable */
461 rb->simplelist_info_init(&list, "Files to Clean", tidy_type_count, NULL); 462 rb->global_settings->show_icons = true;
463 rb->simplelist_info_init(&list, "Files to Clean",
464 tidy_type_count, NULL);
462 list.get_icon = get_icon; 465 list.get_icon = get_icon;
463 list.get_name = get_name; 466 list.get_name = get_name;
464 list.action_callback = list_action_callback; 467 list.action_callback = list_action_callback;
@@ -466,21 +469,20 @@ int tidy_lcd_menu(void)
466 rb->global_settings->show_icons = show_icons; 469 rb->global_settings->show_icons = show_icons;
467 } 470 }
468 break; 471 break;
469 472
470 default: 473 default:
471 ret = 99; /* exit plugin */ 474 status = TIDY_RETURN_ABORT; /* exit plugin */
472 menu_quit = true; 475 menu_quit = true;
473 break; 476 break;
474 } 477 }
475 } 478 }
476 return ret; 479 return status;
477} 480}
478 481
479/* this is the plugin entry point */ 482/* this is the plugin entry point */
480enum plugin_status plugin_start(const void* parameter) 483enum plugin_status plugin_start(const void* parameter)
481{ 484{
482 enum tidy_return status; 485 enum tidy_return status;
483 int ret;
484 (void)parameter; 486 (void)parameter;
485 487
486 tidy_type_count = 0; 488 tidy_type_count = 0;
@@ -491,7 +493,7 @@ enum plugin_status plugin_start(const void* parameter)
491 rb->splash(3*HZ, "Missing disktidy.config file"); 493 rb->splash(3*HZ, "Missing disktidy.config file");
492 return PLUGIN_ERROR; 494 return PLUGIN_ERROR;
493 } 495 }
494 ret = tidy_lcd_menu(); 496 status = tidy_lcd_menu();
495 if (tidy_loaded_and_changed) 497 if (tidy_loaded_and_changed)
496 { 498 {
497 int fd = rb->creat(CUSTOM_FILES); 499 int fd = rb->creat(CUSTOM_FILES);
@@ -507,7 +509,7 @@ enum plugin_status plugin_start(const void* parameter)
507 rb->close(fd); 509 rb->close(fd);
508 } 510 }
509 } 511 }
510 if (ret == 99) 512 if (status == TIDY_RETURN_ABORT)
511 return PLUGIN_OK; 513 return PLUGIN_OK;
512 while (true) 514 while (true)
513 { 515 {
@@ -520,17 +522,16 @@ enum plugin_status plugin_start(const void* parameter)
520 case TIDY_RETURN_ERROR: 522 case TIDY_RETURN_ERROR:
521 return PLUGIN_ERROR; 523 return PLUGIN_ERROR;
522 case TIDY_RETURN_USB: 524 case TIDY_RETURN_USB:
523 return PLUGIN_USB_CONNECTED; 525 return PLUGIN_USB_CONNECTED;
524 case TIDY_RETURN_ABORT: 526 case TIDY_RETURN_ABORT:
525 return PLUGIN_OK; 527 return PLUGIN_OK;
526 } 528 }
527 } 529 }
528 530
529 if (rb->default_event_handler(rb->button_get(false)) == SYS_USB_CONNECTED) 531 if (rb->default_event_handler(rb->button_get(false)) == SYS_USB_CONNECTED)
530 return PLUGIN_USB_CONNECTED; 532 return PLUGIN_USB_CONNECTED;
531 533
532 rb->yield(); 534 rb->yield();
533 535
534
535 return PLUGIN_OK; 536 return PLUGIN_OK;
536} 537}
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 458f6b552a..2a848c2049 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -312,16 +312,11 @@ static void goto_menu(void);
312static int load_bitmap( const char *filename ); 312static int load_bitmap( const char *filename );
313static int save_bitmap( char *filename ); 313static int save_bitmap( char *filename );
314static void draw_rect_full( int x1, int y1, int x2, int y2 ); 314static void draw_rect_full( int x1, int y1, int x2, int y2 );
315extern int errno;
316 315
317/*********************************************************************** 316/***********************************************************************
318 * Global variables 317 * Global variables
319 ***********************************************************************/ 318 ***********************************************************************/
320 319
321#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
322int errno;
323#endif
324
325static int drawcolor=0; /* Current color (in palette) */ 320static int drawcolor=0; /* Current color (in palette) */
326static int bgdrawcolor=9; /* Current background color (in palette) */ 321static int bgdrawcolor=9; /* Current background color (in palette) */
327bool isbg = false; /* gruik ugly hack alert */ 322bool isbg = false; /* gruik ugly hack alert */
@@ -518,7 +513,8 @@ static void buffer_putsxyofs( fb_data *buf, int buf_width, int buf_height,
518 513
519 bits = rb->font_get_bits( pf, ch ); 514 bits = rb->font_get_bits( pf, ch );
520 515
521 buffer_mono_bitmap_part( buf, buf_width, buf_height, bits, ofs, 0, width, x, y, width - ofs, pf->height); 516 buffer_mono_bitmap_part( buf, buf_width, buf_height, bits, ofs, 0,
517 width, x, y, width - ofs, pf->height);
522 518
523 x += width - ofs; 519 x += width - ofs;
524 ofs = 0; 520 ofs = 0;
@@ -539,9 +535,9 @@ enum {
539 }; 535 };
540enum { 536enum {
541 /* Select action menu */ 537 /* Select action menu */
542 SELECT_MENU_CUT, SELECT_MENU_COPY, SELECT_MENU_INVERT, 538 SELECT_MENU_CUT, SELECT_MENU_COPY,
543 SELECT_MENU_HFLIP, SELECT_MENU_VFLIP, SELECT_MENU_ROTATE90, 539 SELECT_MENU_INVERT, SELECT_MENU_HFLIP, SELECT_MENU_VFLIP,
544 SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270, 540 SELECT_MENU_ROTATE90, SELECT_MENU_ROTATE180, SELECT_MENU_ROTATE270,
545 SELECT_MENU_CANCEL, 541 SELECT_MENU_CANCEL,
546 }; 542 };
547enum { 543enum {
@@ -562,9 +558,10 @@ MENUITEM_STRINGLIST(speed_menu, "Choose Speed", NULL,
562MENUITEM_STRINGLIST(gridsize_menu, "Grid Size", NULL, 558MENUITEM_STRINGLIST(gridsize_menu, "Grid Size", NULL,
563 "No grid", "5px", "10px", "20px"); 559 "No grid", "5px", "10px", "20px");
564MENUITEM_STRINGLIST(select_menu, "Select...", NULL, 560MENUITEM_STRINGLIST(select_menu, "Select...", NULL,
565 "Cut", "Copy", "Invert", "Horizontal Flip" , 561 "Cut", "Copy",
566 "Vertical Flip", "Rotate 90°", 562 "Invert", "Horizontal Flip", "Vertical Flip",
567 "Rotate 180°", "Rotate 270°", "Cancel"); 563 "Rotate 90°", "Rotate 180°", "Rotate 270°",
564 "Cancel");
568MENUITEM_STRINGLIST(text_menu, "Text", NULL, 565MENUITEM_STRINGLIST(text_menu, "Text", NULL,
569 "Set Text", "Change Font", 566 "Set Text", "Change Font",
570 "Preview", "Apply", "Cancel"); 567 "Preview", "Apply", "Cancel");
@@ -1574,20 +1571,20 @@ static void draw_line( int x1, int y1, int x2, int y2 )
1574 int deltax = x2 - x1; 1571 int deltax = x2 - x1;
1575 int deltay = y2 - y1; 1572 int deltay = y2 - y1;
1576 int i; 1573 int i;
1577 1574
1578 int xerr = abs(deltax); 1575 int xerr = abs(deltax);
1579 int yerr = abs(deltay); 1576 int yerr = abs(deltay);
1580 int xstep = deltax > 0 ? 1 : -1; 1577 int xstep = deltax > 0 ? 1 : -1;
1581 int ystep = deltay > 0 ? 1 : -1; 1578 int ystep = deltay > 0 ? 1 : -1;
1582 int err; 1579 int err;
1583 1580
1584 if (yerr > xerr) 1581 if (yerr > xerr)
1585 { 1582 {
1586 /* more vertical */ 1583 /* more vertical */
1587 err = yerr; 1584 err = yerr;
1588 xerr <<= 1; 1585 xerr <<= 1;
1589 yerr <<= 1; 1586 yerr <<= 1;
1590 1587
1591 /* to leave off the last pixel of the line, leave off the "+ 1" */ 1588 /* to leave off the last pixel of the line, leave off the "+ 1" */
1592 for (i = abs(deltay) + 1; i; --i) 1589 for (i = abs(deltay) + 1; i; --i)
1593 { 1590 {
@@ -1606,7 +1603,7 @@ static void draw_line( int x1, int y1, int x2, int y2 )
1606 err = xerr; 1603 err = xerr;
1607 xerr <<= 1; 1604 xerr <<= 1;
1608 yerr <<= 1; 1605 yerr <<= 1;
1609 1606
1610 for (i = abs(deltax) + 1; i; --i) 1607 for (i = abs(deltax) + 1; i; --i)
1611 { 1608 {
1612 draw_pixel(x, y); 1609 draw_pixel(x, y);
@@ -1702,7 +1699,7 @@ static void draw_curve( int x1, int y1, int x2, int y2,
1702 draw_line( ((xl1>>3)+1)>>1, ((yl1>>3)+1)>>1, 1699 draw_line( ((xl1>>3)+1)>>1, ((yl1>>3)+1)>>1,
1703 ((xr3>>3)+1)>>1, ((yr3>>3)+1)>>1 ); 1700 ((xr3>>3)+1)>>1, ((yr3>>3)+1)>>1 );
1704 } 1701 }
1705 } 1702 }
1706#undef PUSH 1703#undef PUSH
1707#undef POP 1704#undef POP
1708 } 1705 }
@@ -2090,8 +2087,8 @@ static void linear_gradient( int x1, int y1, int x2, int y2 )
2090 rgb2hsv( r2, g2, b2, &h2, &s2, &v2 ); 2087 rgb2hsv( r2, g2, b2, &h2, &s2, &v2 );
2091 2088
2092#define PUSH( x0, y0 ) \ 2089#define PUSH( x0, y0 ) \
2093 buffer.coord[i].x = (short)(x0); \ 2090 buffer.coord[i].x = (short)(x0); \
2094 buffer.coord[i].y = (short)(y0); \ 2091 buffer.coord[i].y = (short)(y0); \
2095 i++; 2092 i++;
2096#define POP( a, b ) \ 2093#define POP( a, b ) \
2097 i--; \ 2094 i--; \
@@ -2186,8 +2183,8 @@ static void radial_gradient( int x1, int y1, int x2, int y2 )
2186 rgb2hsv( r2, g2, b2, &h2, &s2, &v2 ); 2183 rgb2hsv( r2, g2, b2, &h2, &s2, &v2 );
2187 2184
2188#define PUSH( x0, y0 ) \ 2185#define PUSH( x0, y0 ) \
2189 buffer.coord[i].x = (short)(x0); \ 2186 buffer.coord[i].x = (short)(x0); \
2190 buffer.coord[i].y = (short)(y0); \ 2187 buffer.coord[i].y = (short)(y0); \
2191 i++; 2188 i++;
2192#define POP( a, b ) \ 2189#define POP( a, b ) \
2193 i--; \ 2190 i--; \
@@ -2564,7 +2561,9 @@ static bool rockpaint_loop( void )
2564 int button=0,i,j; 2561 int button=0,i,j;
2565 int accelaration; 2562 int accelaration;
2566 2563
2564 x = 10;
2567 toolbar(); 2565 toolbar();
2566 x = 0; y = 0;
2568 restore_screen(); 2567 restore_screen();
2569 inv_cursor(true); 2568 inv_cursor(true);
2570 2569