Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 15th, 2010  |  syntax: None  |  size: 7.75 KB  |  views: 107  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: apps/settings.c
  2. ===================================================================
  3. --- apps/settings.c     (revision 24686)
  4. +++ apps/settings.c     (working copy)
  5.  -741,6 +741,7 @@
  6.      /* re-initialize the skin buffer before we start reloading skins */
  7.      skin_buffer_init();
  8.  #ifdef HAVE_LCD_BITMAP
  9. +    skin_backdrop_init();
  10.      skin_font_init();
  11.      if ( global_settings.sbs_file[0] &&
  12.          global_settings.sbs_file[0] != 0xff )
  13. Index: apps/gui/skin_engine/skin_engine.h
  14. ===================================================================
  15. --- apps/gui/skin_engine/skin_engine.h  (revision 24686)
  16. +++ apps/gui/skin_engine/skin_engine.h  (working copy)
  17.  -60,4 +60,10 @@
  18.  
  19.  /* call this in statusbar toggle handlers if needed */
  20.  void skin_statusbar_changed(struct gui_wps*);
  21. +
  22. +
  23. +/* load a backdrop into the skin buffer.
  24. + * reuse buffers if the file is already loaded */
  25. +char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen);
  26. +void skin_backdrop_init(void);
  27.  #endif
  28. Index: apps/gui/skin_engine/skin_parser.c
  29. ===================================================================
  30. --- apps/gui/skin_engine/skin_parser.c  (revision 24686)
  31. +++ apps/gui/skin_engine/skin_parser.c  (working copy)
  32.  -567,7 +567,7 @@
  33.          return -1;
  34.  }
  35.  
  36. -static char *get_image_filename(const char *start, const char* bmpdir,
  37. +char *get_image_filename(const char *start, const char* bmpdir,
  38.                                  char *buf, int buf_size)
  39.  {
  40.      const char *end = strchr(start, '|');
  41.  -2045,45 +2045,8 @@
  42.       */
  43.      if (wps_data->backdrop)
  44.      {
  45. -        char img_path[MAX_PATH];
  46. -        bool loaded = false;
  47. -        size_t buf_size;
  48. -#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
  49. -        if (curr_screen == SCREEN_REMOTE)
  50. -            buf_size = REMOTE_LCD_BACKDROP_BYTES;
  51. -        else
  52. -#endif
  53. -            buf_size = LCD_BACKDROP_BYTES;
  54. -        if (wps_data->backdrop[0] == '-')
  55. -        {
  56. -#if NB_SCREENS > 1
  57. -            if (curr_screen == SCREEN_REMOTE)
  58. -            {
  59. -                wps_data->backdrop = NULL;
  60. -                return true;
  61. -            }
  62. -            else
  63. -#endif
  64. -            {
  65. -                if (!global_settings.backdrop_file[0])
  66. -                {
  67. -                    wps_data->backdrop = NULL;
  68. -                    return true;
  69. -                }
  70. -                snprintf(img_path, sizeof(img_path), "%s/%s.bmp",
  71. -                         BACKDROP_DIR, global_settings.backdrop_file);
  72. -            }
  73. -        }
  74. -        else
  75. -        {
  76. -            get_image_filename(wps_data->backdrop, bmpdir,
  77. -                              img_path, sizeof(img_path));
  78. -        }
  79. -        char *buffer = skin_buffer_alloc(buf_size);
  80. -        if (!buffer)
  81. -            return false;
  82. -        loaded = screens[curr_screen].backdrop_load(img_path, buffer);
  83. -        wps_data->backdrop = loaded ? buffer : NULL;
  84. +        wps_data->backdrop = skin_backdrop_load(wps_data->backdrop,
  85. +                                               bmpdir, curr_screen);
  86.      }
  87.  #endif /* has backdrop support */
  88.  
  89. Index: apps/gui/skin_engine/skin_backdrops.c
  90. ===================================================================
  91. --- apps/gui/skin_engine/skin_backdrops.c       (revision 0)
  92. +++ apps/gui/skin_engine/skin_backdrops.c       (revision 0)
  93.  -0,0 +1,119 @@
  94. +/***************************************************************************
  95. + *             __________               __   ___.
  96. + *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  97. + *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  98. + *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  99. + *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  100. + *                     \/            \/     \/    \/            \/
  101. + * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $
  102. + *
  103. + * Copyright (C) 2010 Jonathan Gordon
  104. + *
  105. + * This program is free software; you can redistribute it and/or
  106. + * modify it under the terms of the GNU General Public License
  107. + * as published by the Free Software Foundation; either version 2
  108. + * of the License, or (at your option) any later version.
  109. + *
  110. + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  111. + * KIND, either express or implied.
  112. + *
  113. + ****************************************************************************/
  114. +
  115. +#include "config.h"
  116. +#include <stdio.h>
  117. +#include <string.h>
  118. +#include <stdlib.h>
  119. +
  120. +#include "settings.h"
  121. +#include "skin_buffer.h"
  122. +#include "wps_internals.h"
  123. +#include "skin_engine.h"
  124. +
  125. +#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
  126. +
  127. +static struct skin_backdrop {
  128. +    char name[MAX_FILENAME+1];
  129. +    char *buffer;
  130. +    enum screen_type screen;
  131. +} backdrops[SKINNABLE_SCREENS_COUNT*NB_SCREENS];
  132. +
  133. +void skin_backdrop_init(void)
  134. +{
  135. +    int i;
  136. +    for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
  137. +    {
  138. +        backdrops[i].name[0] = '\0';
  139. +        backdrops[i].buffer = NULL;
  140. +    }
  141. +}
  142. +
  143. +/* load a backdrop into the skin buffer.
  144. + * reuse buffers if the file is already loaded */
  145. +char* skin_backdrop_load(char* backdrop, char *bmpdir, enum screen_type screen)
  146. +{
  147. +    int i;
  148. +    struct skin_backdrop *bdrop = NULL;
  149. +    char filename[MAX_PATH];
  150. +    size_t buf_size;
  151. +    bool loaded = false;
  152. +#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
  153. +    if (screen == SCREEN_REMOTE)
  154. +        buf_size = REMOTE_LCD_BACKDROP_BYTES;
  155. +    else
  156. +#endif
  157. +        buf_size = LCD_BACKDROP_BYTES;
  158. +    
  159. +    if (backdrop[0] == '-')
  160. +    {
  161. +#if NB_SCREENS > 1
  162. +        if (screen == SCREEN_REMOTE)
  163. +        {
  164. +            return NULL; /* remotes don't have a backdrop setting (yet!) */
  165. +        }
  166. +        else
  167. +#endif
  168. +        {
  169. +            if (!global_settings.backdrop_file[0])
  170. +            {
  171. +                return NULL; /* backdrop setting not set */
  172. +            }
  173. +            snprintf(filename, sizeof(filename), "%s/%s.bmp",
  174. +                     BACKDROP_DIR, global_settings.backdrop_file);
  175. +        }
  176. +    }
  177. +    else
  178. +    {
  179. +        get_image_filename(backdrop, bmpdir, filename, sizeof(filename));
  180. +    }
  181. +    
  182. +    for(i=0;i<SKINNABLE_SCREENS_COUNT*NB_SCREENS;i++)
  183. +    {
  184. +        if (!strcmp(backdrops[i].name, backdrop) && backdrops[i].screen == screen)
  185. +        {
  186. +            return backdrops[i].buffer;
  187. +        }
  188. +        else if (backdrops[i].buffer == NULL)
  189. +        {
  190. +            bdrop = &backdrops[i];
  191. +        }
  192. +    }
  193. +    if (!bdrop)
  194. +        return NULL; /* too many backdrops loaded */
  195. +    
  196. +    bdrop->buffer = skin_buffer_alloc(buf_size);
  197. +    if (!bdrop->buffer)
  198. +        return NULL;
  199. +    loaded = screens[screen].backdrop_load(filename, bdrop->buffer);
  200. +    bdrop->screen = screen;
  201. +    strlcpy(bdrop->name, backdrop, MAX_FILENAME+1);
  202. +    bdrop->name[MAX_FILENAME] = '\0';
  203. +    
  204. +    return loaded ? bdrop->buffer : NULL;
  205. +}
  206. +#else
  207. +
  208. +void skin_backdrop_init(void)
  209. +{
  210. +}
  211. +#endif
  212. +
  213. Index: apps/gui/skin_engine/wps_internals.h
  214. ===================================================================
  215. --- apps/gui/skin_engine/wps_internals.h        (revision 24686)
  216. +++ apps/gui/skin_engine/wps_internals.h        (working copy)
  217.  -353,7 +353,8 @@
  218.  
  219.  /* gui_wps end */
  220.  
  221. -
  222. +char *get_image_filename(const char *start, const char* bmpdir,
  223. +                                char *buf, int buf_size);
  224.  /***** wps_tokens.c ******/
  225.  
  226.  const char *get_token_value(struct gui_wps *gwps,
  227. Index: apps/SOURCES
  228. ===================================================================
  229. --- apps/SOURCES        (revision 24686)
  230. +++ apps/SOURCES        (working copy)
  231.  -87,6 +87,7 @@
  232.  gui/yesno.c
  233.  gui/viewport.c
  234.  
  235. +gui/skin_engine/skin_backdrops.c
  236.  gui/skin_engine/skin_buffer.c
  237.  gui/skin_engine/wps_debug.c
  238.  gui/skin_engine/skin_display.c
clone this paste RAW Paste Data