Diff of /trunk/src/icons.c

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

revision 246 by harbaum, Tue Jan 19 20:26:37 2010 UTC revision 294 by harbaum, Wed Aug 18 18:24:19 2010 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.   * Copyright (C) 2008-2010 Till Harbaum <till@harbaum.org>.
3   *   *
4   * This file is part of GPXView.   * This file is part of GPXView.
5   *   *
# Line 35  struct icon_data { Line 35  struct icon_data {
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, 8 },                            /* ICON_MISC            */    { NULL, 8 },                            /* ICON_MISC            */
38    { NULL, WPT_SYM_MAX+CACHE_TYPE_MAX+10 },/* ICON_POS             */    { NULL, WPT_SYM_MAX+CACHE_TYPE_MAX+11 },/* ICON_POS             */
39    { NULL, 3 },                            /* ICON_FILE            */    { NULL, 3 },                            /* ICON_FILE            */
40      { NULL, ATT_MAX+2 },                    /* ICON_ATT             */
41    { NULL, -1 }    { NULL, -1 }
42  };  };
43    
44    /* ICON_ATT */
45    static const char *att_icon_name[] = {
46      "no", "unknown",
47      "dogs", "fee", "rappelling", "boat",                     // 1-4
48      "scuba", "kids", "onehour", "scenic", "hiking",          // 5-9
49      "climbing", "wading", "swimming", "available", "night",  // 10-14
50      "winter", "unknown", "poisonoak", "snakes", "ticks",     // 15-19
51      "mine", "cliff", "hunting", "danger", "wheelchair",      // 20-24
52      "parking", "public", "water", "restrooms", "phone",      // 25-29
53      "picnic", "camping", "bicycles", "motorcycles", "quads", // 30-34
54      "jeeps", "snowmobiles", "horses", "campfires", "thorn",  // 35-39
55      "stealth", "stroller", "firstaid", "cow", "flashlight",  // 40-44
56      "landf", "unknown", "field_puzzle", "UV", "snowshoes",   // 45-49
57      "skiis", "s_tool", "nightcache", "parkngrab", "abandonedbuilding", // 50-54
58      "hike_short", "hike_med", "hike_long", "fuel", "food",   // 55-59
59      NULL
60    };
61    
62  /* ICON_CACHE_TYPE / ICON_CACHE_TYPE_SEMI / ICON_CACHE_TYPE_2X */  /* ICON_CACHE_TYPE / ICON_CACHE_TYPE_SEMI / ICON_CACHE_TYPE_2X */
63  const char *cache_type_icon_name[] = {  const char *cache_type_icon_name[] = {
64    "traditional", "multi",      "mystery", "virtual", "webcam", "event",    "traditional", "multi",      "mystery", "virtual", "webcam", "event",
# Line 91  const char *tb_icon_name[] = { Line 110  const char *tb_icon_name[] = {
110    
111  /* ICON_MISC         */  /* ICON_MISC         */
112  const char *misc_icon_name[] = {  const char *misc_icon_name[] = {
113    "locked", "unlocked", "delete",    "32x32/locked", "32x32/unlocked", "32x32/delete",
114  #ifdef FREMANTLE  #ifdef FREMANTLE
115    "64x64/paypal",    "64x64/paypal",
116  #else  #else
# Line 128  const char *pos_icon_name[] = { Line 147  const char *pos_icon_name[] = {
147    
148    "pos_wpt", "pos_gps", "pos_geomath", "pos_map", "pos_home",    "pos_wpt", "pos_gps", "pos_geomath", "pos_map", "pos_home",
149    
150    "pos_get", "pos_set", "maemo-mapper",    "pos_get", "pos_set", "maemo-mapper", "clipboard",
151    
152    NULL    NULL
153  };  };
# Line 168  static void icons_load(int type, char *f Line 187  static void icons_load(int type, char *f
187    
188        if(error) {        if(error) {
189          icons[type].data[i] = NULL;          icons[type].data[i] = NULL;
190          g_warning("Could not load cache type icon %s: %s\n",          g_warning("Could not load icon %s: %s\n", names[i], error->message);
                       names[i], error->message);  
191          g_error_free(error);          g_error_free(error);
192          error = NULL;          error = NULL;
193        }        }
# Line 238  void icons_init(void) { Line 256  void icons_init(void) {
256  #endif  #endif
257    
258    /* load file icons */    /* load file icons */
259    icons_load(ICON_FILE, "file_%s.%s", file_icon_name);    icons_load(ICON_FILE, "32x32/file_%s.%s", file_icon_name);
260    
261      /* load attribute icons */
262      icons_load(ICON_ATT, "32x32/att_%s.%s", att_icon_name);
263  }  }
264    
265  void icons_free(void) {  void icons_free(void) {
# Line 272  GtkWidget *icon_get_widget(int type, int Line 293  GtkWidget *icon_get_widget(int type, int
293    return gtk_image_new_from_pixbuf(pbuf);    return gtk_image_new_from_pixbuf(pbuf);
294  }  }
295    
296    /* routine to overlay two pixbufs */
297    GdkPixbuf *pixbuf_overlay(GdkPixbuf *bot, GdkPixbuf *top) {
298      GdkPixbuf *pix = gdk_pixbuf_copy(bot);
299    
300      gdk_pixbuf_composite(top, pix,
301           0, 0, gdk_pixbuf_get_width(bot), gdk_pixbuf_get_height(bot),
302           0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);
303    
304      return pix;
305    }
306    
307    GtkWidget *icon_get_widget_ovl(int type, int num, int ovl) {
308      GdkPixbuf *pbuf0 = icon_get(type, num);
309      GdkPixbuf *pbuf1 = icon_get(type, ovl);
310      if(!pbuf0 || !pbuf1) return NULL;
311    
312      GdkPixbuf *pbuf = pixbuf_overlay(pbuf0, pbuf1);
313      GtkWidget *widget = gtk_image_new_from_pixbuf(pbuf);
314    
315      /* widget now holds a reference */
316      gdk_pixbuf_unref(pbuf);
317    
318      return widget;
319    }
320    
321  GdkPixbuf *icon_bearing(pos_t from, pos_t to) {  GdkPixbuf *icon_bearing(pos_t from, pos_t to) {
322    if(isnan(from.lat) || isnan(from.lon) ||    if(isnan(from.lat) || isnan(from.lon) ||
323       isnan(to.lat) || isnan(to.lon))       isnan(to.lat) || isnan(to.lon))

Legend:
Removed from v.246  
changed lines
  Added in v.294