Diff of /trunk/src/icons.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 185 by harbaum, Sat Nov 14 16:55:33 2009 UTC revision 205 by harbaum, Mon Nov 23 20:12:22 2009 UTC
# Line 24  struct icon_data { Line 24  struct icon_data {
24    GdkPixbuf **data;    GdkPixbuf **data;
25    int count;    int count;
26  } icons[] = {  } icons[] = {
27    { NULL, CACHE_TYPE_MAX+1 },  /* ICON_CACHE_TYPE      */    { NULL, CACHE_TYPE_MAX+5 },  /* ICON_CACHE_TYPE      */
28    { NULL, CACHE_TYPE_MAX+1 },  /* ICON_CACHE_TYPE_SEMI */    { NULL, CACHE_TYPE_MAX+5 },  /* ICON_CACHE_TYPE_SEMI */
29    { NULL, CACHE_TYPE_MAX+1 },  /* ICON_CACHE_TYPE_1_5X */    { NULL, CACHE_TYPE_MAX+5 },  /* ICON_CACHE_TYPE_1_5X */
30    { NULL, CACHE_TYPE_MAX+1 },  /* ICON_CACHE_TYPE_2X   */    { NULL, CACHE_TYPE_MAX+5 },  /* ICON_CACHE_TYPE_2X   */
31    { NULL, CACHE_CONT_MAX+1 },  /* ICON_CACHE_SIZE      */    { NULL, CACHE_CONT_MAX+1 },  /* ICON_CACHE_SIZE      */
32    { NULL, 9 },                 /* ICON_STARS           */    { NULL, 9 },                 /* ICON_STARS           */
33    { NULL, LOG_TYPE_MAX+1 },    /* ICON_LOG             */    { NULL, LOG_TYPE_MAX+1 },    /* ICON_LOG             */
34    { NULL, 9 },                 /* ICON_HEADING         */    { NULL, 9 },                 /* ICON_HEADING         */
35    { NULL, WPT_SYM_MAX+1 },     /* ICON_WPT             */    { NULL, WPT_SYM_MAX+1 },     /* ICON_WPT             */
36    { NULL, 2 },                 /* ICON_TB              */    { NULL, 2 },                 /* ICON_TB              */
37    { NULL, 9 },                 /* ICON_MISC            */    { NULL, 6 },                 /* ICON_MISC            */
38    { NULL, 3 },                 /* ICON_FILE            */    { NULL, 3 },                 /* ICON_FILE            */
39    { NULL, -1 }    { NULL, -1 }
40  };  };
# Line 42  struct icon_data { Line 42  struct icon_data {
42  /* ICON_CACHE_TYPE / ICON_CACHE_TYPE_SEMI / ICON_CACHE_TYPE_2X */  /* ICON_CACHE_TYPE / ICON_CACHE_TYPE_SEMI / ICON_CACHE_TYPE_2X */
43  const char *cache_type_icon_name[] = {  const char *cache_type_icon_name[] = {
44    "traditional", "multi",      "mystery", "virtual", "webcam", "event",    "traditional", "multi",      "mystery", "virtual", "webcam", "event",
45    "letterbox",   "earthcache", "wherigo", "megaevent", "cito"    "letterbox",   "earthcache", "wherigo", "megaevent", "cito",
46    
47      /* special overlays */
48      "ovl_override", "ovl_found", "ovl_note", "ovl_mine",
49    
50      NULL
51  };  };
52    
53  /* ICON_CACHE_SIZE */  /* ICON_CACHE_SIZE */
54  const char *cache_size_icon_name[] = {  const char *cache_size_icon_name[] = {
55    "regular", "small",      "micro", "other", "not_chosen", "large",    "regular", "small",      "micro", "other", "not_chosen", "large",
56    "virtual"    "virtual", NULL
57  };  };
58    
59  /* ICON_STARS      */  /* ICON_STARS      */
60  const char *stars_icon_name[] = {  const char *stars_icon_name[] = {
61    "1", "1_5", "2", "2_5", "3", "3_5", "4", "4_5", "5"    "1", "1_5", "2", "2_5", "3", "3_5", "4", "4_5", "5", NULL
62  };  };
63    
64  /* ICON_LOG        */  /* ICON_LOG        */
# Line 63  const char *log_icon_name[] = { Line 68  const char *log_icon_name[] = {
68    "needsmaint", "coord_update",    "needsmaint", "coord_update",
69    "traffic_cone",    "traffic_cone",
70    "traffic_cone", /* LOG_TYPE_NEEDS_ARCHIVED */    "traffic_cone", /* LOG_TYPE_NEEDS_ARCHIVED */
71    "traffic_cone",    "traffic_cone",
72      NULL
73  };  };
74    
75  /* ICON_HEADING    */  /* ICON_HEADING    */
76  const char *heading_icon_name[] = {  const char *heading_icon_name[] = {
77    "n", "ne", "e", "se", "s", "sw", "w", "nw", "none"    "n", "ne", "e", "se", "s", "sw", "w", "nw", "none", NULL
78  };  };
79    
80  /* ICON_WPT        */  /* ICON_WPT        */
81  const char *wpt_sym_icon_name[] = {  const char *wpt_sym_icon_name[] = {
82    "multistage", "parking", "final", "question",    "multistage", "parking", "final", "question",
83    "trailhead", "refpoint",    "trailhead", "refpoint", NULL
84  };  };
85    
86  /* ICON_TB         */  /* ICON_TB         */
87  const char *tb_icon_name[] = {  const char *tb_icon_name[] = {
88    "tb", "coin"    "tb", "coin", NULL
89  };  };
90    
91  /* ICON_MISC         */  /* ICON_MISC         */
92  const char *misc_icon_name[] = {  const char *misc_icon_name[] = {
93    "maemo-mapper-out", "override", "locked", "unlocked", "found",    "maemo-mapper-out", "locked", "unlocked",
94    "maemo-mapper-in", "note", "delete", "paypal"    "maemo-mapper-in", "delete", "paypal", NULL
95  };  };
96    
97  /* ICON_FILE         */  /* ICON_FILE         */
98  const char *file_icon_name[] = {  const char *file_icon_name[] = {
99    "gc", "folder", "zip"    "gc", "folder", "zip", NULL
100  };  };
101    
102  static void icons_load(int type, char *format, const char *names[]) {  static void icons_load(int type, char *format, const char *names[]) {
# Line 104  static void icons_load(int type, char *f Line 110  static void icons_load(int type, char *f
110    icons[type].data = malloc(sizeof(GdkPixbuf *) * icons[type].count);    icons[type].data = malloc(sizeof(GdkPixbuf *) * icons[type].count);
111    
112    for(i=0;i<icons[type].count;i++) {    for(i=0;i<icons[type].count;i++) {
113      if(names[i]) {      g_assert(names[i]);
       GError *error = NULL;  
       char filename[128];  
       strcpy(filename, ICONPATH);  
       snprintf(filename+strlen(filename),  
               sizeof(filename)-strlen(filename), format, names[i], "png");  
       icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);  
114    
115        GError *error = NULL;
116        char filename[128];
117        strcpy(filename, ICONPATH);
118        snprintf(filename+strlen(filename),
119                 sizeof(filename)-strlen(filename), format, names[i], "png");
120        icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);
121    
122        if(error) {
123          error = NULL;
124          /* try again in local dir */
125          strcpy(filename, "./data/icons/");
126          snprintf(filename+strlen(filename),
127                   sizeof(filename)-strlen(filename), format, names[i], "png");
128          icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);
129    
130        if(error) {        if(error) {
131          /* try gif */          icons[type].data[i] = NULL;
132            g_warning("Could not load cache type icon %s: %s\n",
133                          names[i], error->message);
134            g_error_free(error);
135          error = NULL;          error = NULL;
136          strcpy(filename, ICONPATH);        }
137          snprintf(filename+strlen(filename),      }
                  sizeof(filename)-strlen(filename), format, names[i], "gif");  
         icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);  
   
         if(error) {  
           error = NULL;  
           /* try again in local dir */  
           strcpy(filename, "./data/icons/");  
           snprintf(filename+strlen(filename),  
                    sizeof(filename)-strlen(filename), format, names[i], "png");  
           icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);  
   
           if(error) {  
             error = NULL;  
             /* try gif */  
             strcpy(filename, "./data/icons/");  
             snprintf(filename+strlen(filename),  
                    sizeof(filename)-strlen(filename), format, names[i], "gif");  
             icons[type].data[i] = gdk_pixbuf_new_from_file(filename, &error);  
   
   
             if(error) {  
               icons[type].data[i] = NULL;  
               g_warning("Could not load cache type icon %s: %s\n",  
                         names[i], error->message);  
               g_error_free(error);  
               error = NULL;  
             }  
           }  
         }  
       }  
     } else  
       icons[type].data[i] = NULL;  
138    }    }
139    
140      g_assert(!names[i]);
141  }  }
142    
143  void icons_init(void) {  void icons_init(void) {
# Line 167  void icons_init(void) { Line 155  void icons_init(void) {
155    icons_load(ICON_CACHE_TYPE_2X, "64x64/cache_type_%s.%s", cache_type_icon_name);    icons_load(ICON_CACHE_TYPE_2X, "64x64/cache_type_%s.%s", cache_type_icon_name);
156    
157    /* load cache container/size icons */    /* load cache container/size icons */
158    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
159    icons_load(ICON_CACHE_SIZE, "45x12/cache_size_%s.%s", cache_size_icon_name);    icons_load(ICON_CACHE_SIZE, "45x12/cache_size_%s.%s", cache_size_icon_name);
160    #else
161      icons_load(ICON_CACHE_SIZE, "90x24/cache_size_%s.%s", cache_size_icon_name);
162    #endif
163    
164    /* load cache difficulty/terrain/quality icons */    /* load cache difficulty/terrain/quality icons */
165    icons_load(ICON_STARS, "stars%s.%s", stars_icon_name);  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
166      icons_load(ICON_STARS, "12x12/stars%s.%s", stars_icon_name);
167    #else
168      icons_load(ICON_STARS, "16x16/stars%s.%s", stars_icon_name);
169    #endif
170    
171    /* load cache log icons */    /* load cache log icons */
172    icons_load(ICON_LOG, "32x32/log_icon_%s.%s", log_icon_name);    icons_load(ICON_LOG, "32x32/log_icon_%s.%s", log_icon_name);
173    
174    /* load icons to visualize heading */    /* load icons to visualize heading */
175    icons_load(ICON_HEADING, "heading_%s.%s", heading_icon_name);  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
176      icons_load(ICON_HEADING, "32x32/heading_%s.%s", heading_icon_name);
177    #else
178      icons_load(ICON_HEADING, "48x48/heading_%s.%s", heading_icon_name);
179    #endif
180    
181    /* load icons to visualize heading */    /* load waypoint icons */
182    icons_load(ICON_WPT, "32x32/wpt_%s.%s", wpt_sym_icon_name);    icons_load(ICON_WPT, "32x32/wpt_%s.%s", wpt_sym_icon_name);
183    
184    /* load travelbug icon */    /* load travelbug/coin icons */
185    icons_load(ICON_TB, "32x32/%s.%s", tb_icon_name);    icons_load(ICON_TB, "32x32/%s.%s", tb_icon_name);
186    
187    /* load misc icons */    /* load misc icons */

Legend:
Removed from v.185  
changed lines
  Added in v.205