271 |
|
|
272 |
pos_t *pos = gps_get_pos(context->appdata); |
pos_t *pos = gps_get_pos(context->appdata); |
273 |
if(pos && !isnan(pos->lat) && !isnan(pos->lon)) { |
if(pos && !isnan(pos->lat) && !isnan(pos->lon)) { |
274 |
context->appdata->gps = *pos; /* save position */ |
context->appdata->gps.saved = *pos; /* save position */ |
275 |
|
|
276 |
float arot = |
float arot = |
277 |
gpx_pos_get_bearing(*pos, context->gotoc.pos) * |
gpx_pos_get_bearing(*pos, context->gotoc.pos) * |
353 |
0, 0, width, height); |
0, 0, width, height); |
354 |
|
|
355 |
gps_sat_t *sat = gps_get_sats(context->appdata); |
gps_sat_t *sat = gps_get_sats(context->appdata); |
356 |
if(sat && sat->num) { |
gint sat_num = gps_get_satnum(context->appdata); |
357 |
|
|
358 |
|
if(sat && sat_num) { |
359 |
/* setup required colors */ |
/* setup required colors */ |
360 |
GdkGC *used_gc = gdk_gc_new(context->gotoc.sat_pixmap); |
GdkGC *used_gc = gdk_gc_new(context->gotoc.sat_pixmap); |
361 |
gdk_gc_copy(used_gc, widget->style->black_gc); |
gdk_gc_copy(used_gc, widget->style->black_gc); |
365 |
|
|
366 |
#define SAT_SPACING 3 |
#define SAT_SPACING 3 |
367 |
int i, x; |
int i, x; |
368 |
int swid = (width-SAT_SPACING*(sat->num-1))/sat->num; |
int swid = (width-SAT_SPACING*(sat_num-1))/sat_num; |
369 |
|
|
370 |
/* as of xgps, a ss of 40 and more is "plenty" */ |
/* as of xgps, a ss of 40 and more is "plenty" */ |
371 |
int max_ss = 40; |
int max_ss = 40; |
372 |
for(i=0;i<sat->num;i++) |
for(i=0;i<sat_num;i++) |
373 |
if(sat->ss[i] > max_ss) sat->ss[i] = max_ss; |
if(sat[i].ss > max_ss) sat[i].ss = max_ss; |
374 |
|
|
375 |
if(swid > 40) { |
if(swid > 40) { |
376 |
swid = 40; |
swid = 40; |
377 |
x = (width-sat->num*swid)/2; |
x = (width-sat_num*swid)/2; |
378 |
} else |
} else |
379 |
x = 0; |
x = 0; |
380 |
|
|
381 |
for(i=0;i<sat->num;i++) { |
for(i=0;i<sat_num;i++) { |
382 |
char str[32]; |
char str[32]; |
383 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
384 |
snprintf(str, sizeof(str), "<span size=\"small\">%d</span>", sat->PRN[i]); |
snprintf(str, sizeof(str), "<span size=\"small\">%d</span>", sat[i].prn); |
385 |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, NULL); |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, NULL); |
386 |
pango_layout_set_markup(layout, str, strlen(str)); |
pango_layout_set_markup(layout, str, strlen(str)); |
387 |
#else |
#else |
388 |
snprintf(str, sizeof(str), "%d", sat->PRN[i]); |
snprintf(str, sizeof(str), "%d", sat[i].prn); |
389 |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, str); |
PangoLayout *layout = gtk_widget_create_pango_layout(widget, str); |
390 |
#endif |
#endif |
391 |
|
|
397 |
|
|
398 |
g_object_unref(layout); |
g_object_unref(layout); |
399 |
|
|
400 |
int h = (height-th) * sat->ss[i] / max_ss; |
int h = (height-th) * sat[i].ss / max_ss; |
401 |
|
|
402 |
gdk_draw_rectangle(context->gotoc.sat_pixmap, |
gdk_draw_rectangle(context->gotoc.sat_pixmap, |
403 |
sat->used[i]?used_gc:widget->style->fg_gc[GTK_STATE_NORMAL], |
sat[i].used?used_gc:widget->style->fg_gc[GTK_STATE_NORMAL], |
404 |
TRUE, x, height-h-th, swid, h); |
TRUE, x, height-h-th, swid, h); |
405 |
|
|
406 |
x += SAT_SPACING+swid; |
x += SAT_SPACING+swid; |
407 |
} |
} |
408 |
|
|
|
/* free sat infos */ |
|
|
free(sat->PRN); |
|
|
free(sat->ss); |
|
|
free(sat->used); |
|
409 |
} else { |
} else { |
410 |
PangoLayout *layout = |
PangoLayout *layout = |
411 |
gtk_widget_create_pango_layout(widget, _("No SAT info")); |
gtk_widget_create_pango_layout(widget, _("No SAT info")); |
417 |
|
|
418 |
g_object_unref(layout); |
g_object_unref(layout); |
419 |
} |
} |
|
|
|
|
/* free the sat structure */ |
|
|
if(sat) |
|
|
free(sat); |
|
420 |
} |
} |
421 |
|
|
422 |
/* Create a new backing pixmap of the appropriate size */ |
/* Create a new backing pixmap of the appropriate size */ |
568 |
} |
} |
569 |
#endif |
#endif |
570 |
|
|
571 |
|
/* create "goto" tab */ |
572 |
GtkWidget *goto_cache(cache_context_t *context) { |
GtkWidget *goto_cache(cache_context_t *context) { |
573 |
int i; |
int i; |
574 |
|
|