24 |
|
|
25 |
/* |
/* |
26 |
* TODO: |
* TODO: |
|
* - draw caches only once |
|
|
* - prefer duplicates from selected files |
|
27 |
* - make semi-transparent caches selectable |
* - make semi-transparent caches selectable |
28 |
*/ |
*/ |
29 |
|
|
53 |
/* use environment settings if preset */ |
/* use environment settings if preset */ |
54 |
const char *proxy = g_getenv("http_proxy"); |
const char *proxy = g_getenv("http_proxy"); |
55 |
if(proxy) { |
if(proxy) { |
56 |
printf("http_proxy: %s\n", proxy); |
printf("map http proxy from env: %s\n", proxy); |
57 |
return proxy; |
return proxy; |
58 |
} |
} |
59 |
|
|
74 |
|
|
75 |
snprintf(proxy_buffer, sizeof(proxy_buffer), |
snprintf(proxy_buffer, sizeof(proxy_buffer), |
76 |
"http://%s:%u", host, port); |
"http://%s:%u", host, port); |
77 |
|
printf("map http proxy from gconf: %s\n ", proxy_buffer); |
78 |
|
|
79 |
g_free(host); |
g_free(host); |
80 |
} |
} |
153 |
} |
} |
154 |
|
|
155 |
static void map_draw_cache(GtkWidget *map, cache_t *cache, gboolean semi) { |
static void map_draw_cache(GtkWidget *map, cache_t *cache, gboolean semi) { |
156 |
GdkPixbuf *icon = icon_get(semi?ICON_CACHE_TYPE_SEMI:ICON_CACHE_TYPE, |
int type = semi?ICON_CACHE_TYPE_SEMI:ICON_CACHE_TYPE; |
157 |
cache->type); |
|
158 |
|
GdkPixbuf *icon = icon_get(type, cache->type); |
159 |
|
|
160 |
/* check if there's also an overwritten coordinate */ |
/* check if there's also an overwritten coordinate */ |
161 |
if(cache->notes && cache->notes->override) { |
if(cache->notes && cache->notes->override) { |
162 |
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
GdkPixbuf *over = icon_get(type, 11); |
163 |
|
|
164 |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
165 |
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
492 |
} |
} |
493 |
|
|
494 |
#ifndef BIG_BALLOONS |
#ifndef BIG_BALLOONS |
495 |
#define LINE_SKIP 7 |
#define ICON_SIZE ICON_CACHE_TYPE |
496 |
|
#else |
497 |
|
#define ICON_SIZE ICON_CACHE_TYPE_1_5X |
498 |
|
#endif |
499 |
|
|
500 |
|
#ifndef BIG_BALLOONS |
501 |
|
#define FONT_SIZE 14.0 |
502 |
#else |
#else |
503 |
#define LINE_SKIP 12 |
#define FONT_SIZE 22.0 |
504 |
#endif |
#endif |
505 |
|
#define LINE_SKIP (FONT_SIZE/4) |
506 |
|
|
507 |
|
|
508 |
static void |
static void |
509 |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
530 |
gint x = event->data.draw.rect->x, y = event->data.draw.rect->y; |
gint x = event->data.draw.rect->x, y = event->data.draw.rect->y; |
531 |
|
|
532 |
/* draw the cache type icon ... */ |
/* draw the cache type icon ... */ |
533 |
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
GdkPixbuf *icon = icon_get(ICON_SIZE, cache->type); |
534 |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y); |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y); |
535 |
|
|
536 |
if(cache->notes && cache->notes->override) { |
if(cache->notes && cache->notes->override) { |
537 |
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
GdkPixbuf *over = icon_get(ICON_SIZE, 11); |
538 |
cairo_draw_pixbuf(event->data.draw.cr, over, x, y); |
cairo_draw_pixbuf(event->data.draw.cr, over, x, y); |
539 |
} |
} |
540 |
|
|
570 |
x = event->data.draw.rect->x; |
x = event->data.draw.rect->x; |
571 |
|
|
572 |
/* everything from here uses the same font */ |
/* everything from here uses the same font */ |
573 |
cairo_select_font_face (event->data.draw.cr, "Sans", CAIRO_FONT_SLANT_NORMAL, |
cairo_select_font_face (event->data.draw.cr, "Sans", |
574 |
|
CAIRO_FONT_SLANT_NORMAL, |
575 |
CAIRO_FONT_WEIGHT_NORMAL); |
CAIRO_FONT_WEIGHT_NORMAL); |
576 |
#ifndef BIG_BALLOONS |
|
577 |
cairo_set_font_size (event->data.draw.cr, 14.0); |
cairo_set_font_size (event->data.draw.cr, FONT_SIZE); |
|
#else |
|
|
cairo_set_font_size (event->data.draw.cr, 22.0); |
|
|
#endif |
|
578 |
|
|
579 |
if(cache->name) { |
if(cache->name) { |
580 |
/* draw cache name */ |
/* draw cache name */ |
581 |
cairo_text_extents (event->data.draw.cr, cache->name, &extents); |
cairo_text_extents (event->data.draw.cr, cache->name, &extents); |
582 |
y += extents.height; |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing); |
|
cairo_move_to (event->data.draw.cr, x, y); |
|
583 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
584 |
cairo_show_text (event->data.draw.cr, cache->name); |
cairo_show_text (event->data.draw.cr, cache->name); |
585 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
586 |
|
|
587 |
/* return to the left border and below text */ |
/* return to the left border and below text */ |
588 |
y += LINE_SKIP; |
y += LINE_SKIP + FONT_SIZE; |
589 |
x = event->data.draw.rect->x; |
x = event->data.draw.rect->x; |
590 |
} |
} |
591 |
|
|
592 |
if(cache->terrain) { |
if(cache->terrain) { |
593 |
|
int text_y = 0, icon_y = 0; |
594 |
|
|
595 |
/* draw cache rating */ |
/* draw cache rating */ |
596 |
const char *terrain = "Terrain:"; |
const char *terrain = "Terrain:"; |
597 |
icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); |
icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); |
598 |
cairo_text_extents (event->data.draw.cr, _(terrain), &extents); |
cairo_text_extents (event->data.draw.cr, _(terrain), &extents); |
599 |
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
600 |
|
if(gdk_pixbuf_get_height(icon) > FONT_SIZE) |
601 |
|
text_y = (gdk_pixbuf_get_height(icon) - FONT_SIZE)/2; |
602 |
|
else |
603 |
|
icon_y = (FONT_SIZE - gdk_pixbuf_get_height(icon))/2; |
604 |
|
|
605 |
/* draw "Terrain:" string */ |
/* draw "Terrain:" string */ |
606 |
cairo_move_to (event->data.draw.cr, x, y); |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing + text_y); |
607 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
608 |
cairo_show_text (event->data.draw.cr, _(terrain)); |
cairo_show_text (event->data.draw.cr, _(terrain)); |
609 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
610 |
x += extents.width + 2; |
x += extents.width + 2; |
611 |
|
|
612 |
/* draw terrain stars */ |
/* draw terrain stars */ |
613 |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y - |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y + icon_y); |
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
|
614 |
|
|
615 |
x += gdk_pixbuf_get_width(icon) + LINE_SKIP; |
x += gdk_pixbuf_get_width(icon) + LINE_SKIP; |
|
y -= (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
616 |
} |
} |
617 |
|
|
618 |
if(cache->difficulty) { |
if(cache->difficulty) { |
619 |
|
int text_y = 0, icon_y = 0; |
620 |
|
|
621 |
const char *difficulty = "Difficulty:"; |
const char *difficulty = "Difficulty:"; |
622 |
|
icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); |
623 |
cairo_text_extents (event->data.draw.cr, _(difficulty), &extents); |
cairo_text_extents (event->data.draw.cr, _(difficulty), &extents); |
|
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
624 |
|
|
625 |
|
if(gdk_pixbuf_get_height(icon) > FONT_SIZE) |
626 |
|
text_y = (gdk_pixbuf_get_height(icon) - FONT_SIZE)/2; |
627 |
|
else |
628 |
|
icon_y = (FONT_SIZE - gdk_pixbuf_get_height(icon))/2; |
629 |
|
|
630 |
/* draw "Difficulty:" string */ |
/* draw "Difficulty:" string */ |
631 |
cairo_move_to (event->data.draw.cr, x, y); |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing + text_y); |
632 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
633 |
cairo_show_text (event->data.draw.cr, _(difficulty)); |
cairo_show_text (event->data.draw.cr, _(difficulty)); |
634 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
635 |
x += extents.width + 2; |
x += extents.width + 2; |
636 |
|
|
637 |
icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y + icon_y); |
|
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y - |
|
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
|
638 |
} |
} |
639 |
} else if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK) { |
} else if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK) { |
640 |
printf("click %s event at %d %d\n", |
printf("click %s event at %d %d\n", |
791 |
|
|
792 |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
static gboolean on_focus_in(GtkWidget *widget, GdkEventFocus *event, |
793 |
gpointer data) { |
gpointer data) { |
794 |
|
map_context_t *context = (map_context_t*)data; |
795 |
|
|
796 |
printf("map got focus\n"); |
printf("map got focus\n"); |
797 |
map_setup((map_context_t*)data); |
|
798 |
|
#ifdef USE_MAEMO |
799 |
|
/* re-enable refresh of map */ |
800 |
|
if(!context->handler_id) |
801 |
|
context->handler_id = gtk_timeout_add(1000, map_gps_update, context); |
802 |
|
#endif |
803 |
|
|
804 |
|
map_setup(context); |
805 |
return FALSE; |
return FALSE; |
806 |
} |
} |
807 |
|
|
808 |
|
#ifdef USE_MAEMO |
809 |
|
static gboolean on_focus_out(GtkWidget *widget, GdkEventFocus *event, |
810 |
|
gpointer data) { |
811 |
|
map_context_t *context = (map_context_t*)data; |
812 |
|
|
813 |
|
printf("map lost focus\n"); |
814 |
|
gtk_timeout_remove(context->handler_id); |
815 |
|
context->handler_id = 0; |
816 |
|
|
817 |
|
return FALSE; |
818 |
|
} |
819 |
|
#endif |
820 |
|
|
821 |
void map_update(appdata_t *appdata) { |
void map_update(appdata_t *appdata) { |
822 |
printf("map_update\n"); |
printf("map_update\n"); |
823 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
911 |
g_signal_connect(G_OBJECT(context->widget), "focus-in-event", |
g_signal_connect(G_OBJECT(context->widget), "focus-in-event", |
912 |
G_CALLBACK(on_focus_in), context); |
G_CALLBACK(on_focus_in), context); |
913 |
|
|
914 |
|
#ifdef USE_MAEMO |
915 |
|
g_signal_connect(G_OBJECT(context->widget), "focus-out-event", |
916 |
|
G_CALLBACK(on_focus_out), context); |
917 |
|
#endif |
918 |
|
|
919 |
g_signal_connect(G_OBJECT(context->widget), "configure-event", |
g_signal_connect(G_OBJECT(context->widget), "configure-event", |
920 |
G_CALLBACK(on_map_configure), context); |
G_CALLBACK(on_map_configure), context); |
921 |
|
|