#include "route.h"
#include "gps-panels.h"
+#include "gtkgps.h"
+#include "gtkcompass.h"
static GtkWidget *text_lat;
static GtkWidget *text_lon;
static GtkWidget *sat_panel;
static GtkWidget *heading_panel;
-static gboolean sat_panel_expose(GtkWidget * widget, GdkEventExpose * event);
-static gboolean heading_panel_expose(GtkWidget * widget, GdkEventExpose * event);
-
static void gps_clear_text_fields(void);
GtkWidget *
gtk_widget_set_size_request(GTK_WIDGET(text_time), -1, 30);
gtk_box_pack_start(GTK_BOX(vbox), text_time, FALSE, TRUE, 0);
-heading_panel = gtk_drawing_area_new();
-gtk_widget_set_size_request(heading_panel, -1, 100);
-gtk_box_pack_start(GTK_BOX(vbox), heading_panel, TRUE, TRUE, 0);
+_gps_signal=gtk_gps_new(GTK_GPS_MODE_SKY, &_gps);
+gtk_widget_set_size_request(_gps_signal, -1, 100);
+gtk_box_pack_start(GTK_BOX(vbox), _gps_signal, TRUE, TRUE, 0);
-gps_clear_text_fields();
+_gps_compass = gtk_compass_new(&_gps);
+gtk_widget_set_size_request(_gps_compass, -1, 100);
+gtk_box_pack_start(GTK_BOX(vbox), _gps_compass, TRUE, TRUE, 0);
-g_signal_connect(G_OBJECT(sat_panel), "expose_event", G_CALLBACK(sat_panel_expose), NULL);
-g_signal_connect(G_OBJECT(heading_panel), "expose_event", G_CALLBACK(heading_panel_expose), NULL);
+gps_clear_text_fields();
return vbox;
}
void
gps_display_data(void)
{
-gchar *buffer, litbuf[16];
-printf("%s()\n", __PRETTY_FUNCTION__);
+gchar buffer[32];
/* local time */
-strftime(litbuf, 15, "%X", localtime(&_pos.time));
-gtk_label_set_label(GTK_LABEL(text_time), litbuf);
+strftime(buffer, 15, "%X", localtime(&_pos.time));
+gtk_label_set_label(GTK_LABEL(text_time), buffer);
if (_gps.fix < 2) {
/* no fix no fun */
gps_clear_text_fields();
} else {
/* latitude */
- lat_format(_gps.lat, litbuf);
- gtk_label_set_label(GTK_LABEL(text_lat), litbuf);
+ lat_format(_gps.lat, buffer);
+ gtk_label_set_label(GTK_LABEL(text_lat), buffer);
/* longitude */
- lon_format(_gps.lon, litbuf);
- gtk_label_set_label(GTK_LABEL(text_lon), litbuf);
+ lon_format(_gps.lon, buffer);
+ gtk_label_set_label(GTK_LABEL(text_lon), buffer);
/* speed */
gps_display_data_speed(text_speed, _gps.speed);
switch (_units) {
case UNITS_MI:
case UNITS_NM:
- buffer = g_strdup_printf("Alt: %.1f ft", _pos.altitude * 3.2808399f);
+ g_snprintf(buffer, 32, "Alt: %.1f ft", _pos.altitude * 3.2808399f);
break;
default:
- buffer = g_strdup_printf("Alt: %.1f m", _pos.altitude);
+ g_snprintf(buffer, 32, "Alt: %.1f m", _pos.altitude);
}
gtk_label_set_label(GTK_LABEL(text_alt), buffer);
- g_free(buffer);
/* DOP */
- buffer = g_strdup_printf("%.1f/%.1f/%.1f", _gps.hdop, _gps.vdop, _gps.pdop);
+ g_snprintf(buffer, 32, "%.1f/%.1f/%.1f", _gps.hdop, _gps.vdop, _gps.pdop);
gtk_label_set_label(GTK_LABEL(text_dop), buffer);
- g_free(buffer);
-}
-/* refresh sat panel */
-gtk_widget_queue_draw_area(GTK_WIDGET(sat_panel), 0, 0,
- sat_panel->allocation.width,
- sat_panel->allocation.height);
-
-/* refresh heading panel */
-gtk_widget_queue_draw_area(GTK_WIDGET(heading_panel), 0, 0,
- heading_panel->allocation.width,
- heading_panel->allocation.height);
+ gtk_gps_refresh(_gps_sat_view);
+ gtk_gps_refresh(_gps_signal);
+ gtk_compass_refresh(_gps_compass);
+}
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
return;
}
void
gps_hide_text(void)
{
-printf("%s()\n", __PRETTY_FUNCTION__);
-
/* Clear gps data */
_gps.fix = 1;
_gps.satinuse = 0;
if (_gps_info)
gps_display_data();
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
void
gps_show_info(void)
{
-printf("%s()\n", __PRETTY_FUNCTION__);
-
if (_gps_info && _enable_gps)
gtk_widget_show_all(GTK_WIDGET(_gps_widget));
else {
gps_hide_text();
gtk_widget_hide_all(GTK_WIDGET(_gps_widget));
}
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-static void
-draw_sat_info(GtkWidget * widget, guint x0, guint y0,
- guint width, guint height, gboolean showsnr)
-{
-GdkGC *gc;
-guint step, i, j, snr_height, bymargin, xoffset, yoffset;
-guint x, y, x1, y1;
-gchar *tmp = NULL;
-printf("%s()\n", __PRETTY_FUNCTION__);
-
-xoffset = x0;
-yoffset = y0;
-/* Bootom margin - 12% */
-bymargin = height * 0.88f;
-
-/* Bottom line */
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + 5, yoffset + bymargin,
- xoffset + width - 10 - 2, yoffset + bymargin);
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + 5, yoffset + bymargin - 1,
- xoffset + width - 10 - 2, yoffset + bymargin - 1);
-
-if (_gps.satinview > 0) {
- /* Left margin - 5pix, Right margin - 5pix */
- step = (width - 10) / _gps.satinview;
-
- for (i = 0; i < _gps.satinview; i++) {
- /* Sat used or not */
- gc = _sat_info_gc1;
- for (j = 0; j < _gps.satinuse; j++) {
- if (_gps.satforfix[j] == _gps_sat[i].prn) {
- gc = _sat_info_gc2;
- break;
- }
- }
-
- x = 5 + i * step;
- snr_height = _gps_sat[i].snr * height * 0.78f / 100;
- y = height * 0.1f + (height * 0.78f - snr_height);
-
- /* draw sat rectangle... */
- gdk_draw_rectangle(widget->window,
- gc,
- TRUE,
- xoffset + x,
- yoffset + y, step - 2, snr_height);
-
- if (showsnr && _gps_sat[i].snr > 0) {
- /* ...snr.. */
- tmp = g_strdup_printf("%02d", _gps_sat[i].snr);
- pango_layout_set_text(_sat_info_layout, tmp, 2);
- pango_layout_get_pixel_size(_sat_info_layout,
- &x1, &y1);
- gdk_draw_layout(widget->window,
- widget->style->
- fg_gc[GTK_STATE_NORMAL],
- xoffset + x + ((step - 2) -
- x1) / 2,
- yoffset + y - 15,
- _sat_info_layout);
- g_free(tmp);
- }
-
- /* ...and sat number */
- tmp = g_strdup_printf("%02d", _gps_sat[i].prn);
- pango_layout_set_text(_sat_info_layout, tmp, 2);
- pango_layout_get_pixel_size(_sat_info_layout, &x1, &y1);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- xoffset + x + ((step - 2) - x1) / 2,
- yoffset + bymargin + 1,
- _sat_info_layout);
- g_free(tmp);
- }
-}
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-return;
-}
-
-static gboolean
-sat_panel_expose(GtkWidget * widget, GdkEventExpose * event)
-{
-gchar *tmp = NULL;
-guint x, y;
-printf("%s()\n", __PRETTY_FUNCTION__);
-
-draw_sat_info(widget, 0, 0,
- widget->allocation.width,
- widget->allocation.height, FALSE);
-
-/* Sat View/In Use */
-tmp = g_strdup_printf("%d/%d", _gps.satinuse, _gps.satinview);
-pango_layout_set_text(_sat_panel_layout, tmp, -1);
-pango_layout_set_alignment(_sat_panel_layout, PANGO_ALIGN_LEFT);
-gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- 20, 2, _sat_panel_layout);
-g_free(tmp);
-
-switch (_gps.fix) {
-case 2:
-case 3:
- tmp = g_strdup_printf("%dD fix", _gps.fix);
-break;
-default:
- tmp = g_strdup_printf("nofix");
-break;
-}
-
-pango_layout_set_text(_sat_panel_layout, tmp, -1);
-pango_layout_set_alignment(_sat_panel_layout, PANGO_ALIGN_RIGHT);
-pango_layout_get_pixel_size(_sat_panel_layout, &x, &y);
-gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- widget->allocation.width - 20 - x, 2,
- _sat_panel_layout);
-g_free(tmp);
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-return TRUE;
-}
-
-static gboolean
-heading_panel_expose(GtkWidget * widget, GdkEventExpose * event)
-{
-guint size, xoffset, yoffset, i, x, y;
-gint dir;
-gfloat tmp;
-gchar *text;
-printf("%s()\n", __PRETTY_FUNCTION__);
-
-size = MIN(widget->allocation.width, widget->allocation.height);
-if (widget->allocation.width > widget->allocation.height) {
- xoffset = (widget->allocation.width - widget->allocation.height) / 2;
- yoffset = 0;
-} else {
- xoffset = 0;
- yoffset = (widget->allocation.height - widget->allocation.width) / 2;
-}
-pango_font_description_set_size(_heading_panel_fontdesc, 12 * PANGO_SCALE);
-pango_layout_set_font_description(_heading_panel_layout, _heading_panel_fontdesc);
-pango_layout_set_alignment(_heading_panel_layout, PANGO_ALIGN_CENTER);
-
-text = g_strdup_printf("%3.0f°", _gps.heading);
-pango_layout_set_text(_heading_panel_layout, text, -1);
-pango_layout_get_pixel_size(_heading_panel_layout, &x, &y);
-
-gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- xoffset + size / 2 - x / 2,
- yoffset + size - y - 2, _heading_panel_layout);
-g_free(text);
-
-gdk_draw_arc(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- FALSE,
- xoffset, yoffset + size / 2, size, size, 0, 64 * 180);
-
-/* Simple arrow for heading */
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + size / 2 + 3,
- yoffset + size - y - 5,
- xoffset + size / 2, yoffset + size / 2 + 5);
-
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + size / 2 - 3,
- yoffset + size - y - 5,
- xoffset + size / 2, yoffset + size / 2 + 5);
-
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + size / 2 - 3,
- yoffset + size - y - 5,
- xoffset + size / 2, yoffset + size - y - 8);
-
-gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + size / 2 + 3,
- yoffset + size - y - 5,
- xoffset + size / 2, yoffset + size - y - 8);
-
-gint angle[5] = { -90, -45, 0, 45, 90 };
-gint fsize[5] = { 0, 4, 10, 4, 0 };
-for (i = 0; i < 5; i++) {
- dir = (gint) (_gps.heading / 45) * 45 + angle[i];
-
- switch (dir) {
- case 0:
- case 360:
- text = g_strdup("N");
- break;
- case 45:
- case 405:
- text = g_strdup("NE");
- break;
- case 90:
- text = g_strdup("E");
- break;
- case 135:
- text = g_strdup("SE");
- break;
- case 180:
- text = g_strdup("S");
- break;
- case 225:
- text = g_strdup("SW");
- break;
- case 270:
- case -90:
- text = g_strdup("W");
- break;
- case 315:
- case -45:
- text = g_strdup("NW");
- break;
- default:
- text = g_strdup("??");
- break;
- }
-
- tmp = ((dir - _gps.heading) * (1.f / 180.f)) * PI;
- gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + size / 2 + ((size / 2 - 5) * sinf(tmp)),
- yoffset + size - ((size / 2 - 5) * cosf(tmp)),
- xoffset + size / 2 + ((size / 2 + 5) * sinf(tmp)),
- yoffset + size - ((size / 2 + 5) * cosf(tmp)));
-
- x = fsize[i];
- if (abs((guint) (_gps.heading / 45) * 45 - _gps.heading)
- > abs((guint) (_gps.heading / 45) * 45 + 45 - _gps.heading)
- && (i > 0))
- x = fsize[i - 1];
-
- pango_font_description_set_size(_heading_panel_fontdesc, (10 + x) * PANGO_SCALE);
- pango_layout_set_font_description(_heading_panel_layout, _heading_panel_fontdesc);
- pango_layout_set_text(_heading_panel_layout, text, -1);
- pango_layout_get_pixel_size(_heading_panel_layout, &x, &y);
- x = xoffset + size / 2 + ((size / 2 + 15) * sinf(tmp)) - x / 2,
- y = yoffset + size - ((size / 2 + 15) * cosf(tmp)) - y / 2,
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- x, y, _heading_panel_layout);
- g_free(text);
-
- if (_dest.valid || _next_way) {
- GdkColor color;
- GdkGC *gc;
- gdouble t;
-
- gc = gdk_gc_new(widget->window);
- gdk_gc_set_line_attributes(gc, 6, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-
- if (_dest.valid) {
- gdouble dc=calculate_course(_gps.lat,_gps.lon, _dest.lat, _dest.lon);
-
- color.red = 0x5000;
- color.green = 0xffff;
- color.blue = 0;
- gdk_gc_set_rgb_fg_color(gc, &color);
-
- t = ((dc-_gps.heading) * (1.f / 180.f)) * PI;
- gdk_draw_line(widget->window,gc,
- xoffset + size / 2 + ((size / 2 - 5) * sin(t)),
- yoffset + size - ((size / 2 - 5) * cos(t)),
- xoffset + size / 2 + ((size / 2 + 5) * sin(t)),
- yoffset + size - ((size / 2 + 5) * cos(t)));
-
-
- }
-
- if (_next_way) {
- gdouble lat,lon;
- gdouble wc;
-
- unit2latlon(_next_way->point->unitx,_next_way->point->unity, lat, lon);
- wc=calculate_course(_gps.lat,_gps.lon, lat, lon);
-
- color.red = 0;
- color.green = 0xffff;
- color.blue = 0;
- gdk_gc_set_rgb_fg_color(gc, &color);
-
- t = ((wc-_gps.heading) * (1.f / 180.f)) * PI;
- gdk_draw_line(widget->window,gc,
- xoffset + size / 2 + ((size / 2 - 5) * sin(t)),
- yoffset + size - ((size / 2 - 5) * cos(t)),
- xoffset + size / 2 + ((size / 2 + 5) * sin(t)),
- yoffset + size - ((size / 2 + 5) * cos(t)));
-
- }
- g_object_unref(gc);
- }
-
-}
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-return TRUE;
}
-static void
-draw_sat_details(GtkWidget * widget, guint x0, guint y0,
- guint width, guint height)
-{
-guint i, j, x, y, size, halfsize, xoffset, yoffset;
-guint x1, y1;
-gfloat tmp;
-GdkColor color;
-GdkGC *gc1, *gc2, *gc3, *gc;
-gchar *buffer = NULL;
-guint line[12] = { 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330 };
-
-printf("%s()\n", __PRETTY_FUNCTION__);
-
-size = MIN(width, height);
-halfsize = size / 2;
-if (width > height) {
- xoffset = x0 + (width - height - 10) / 2;
- yoffset = y0 + 5;
-} else {
- xoffset = x0 + 5;
- yoffset = y0 + (height - width - 10) / 2;
-}
-
-/* 90 */
-gdk_draw_arc(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- FALSE,
- xoffset + 2, yoffset + 2, size - 4, size - 4, 0, 64 * 360);
-
-/* 60 */
-gdk_draw_arc(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- FALSE,
- xoffset + size / 6, yoffset + size / 6,
- size / 6 * 4, size / 6 * 4, 0, 64 * 360);
-
-/* 30 */
-gdk_draw_arc(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- FALSE,
- xoffset + size / 6 * 2, yoffset + size / 6 * 2,
- size / 6 * 2, size / 6 * 2, 0, 64 * 360);
-
-for (i = 0; i < 6; i++) {
- /* line */
- tmp = (line[i] * (1.f / 180.f)) * PI;
- gdk_draw_line(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- xoffset + halfsize + (halfsize - 2) * sinf(tmp),
- yoffset + halfsize - (halfsize - 2) * cosf(tmp),
- xoffset + halfsize - (halfsize - 2) * sinf(tmp),
- yoffset + halfsize + (halfsize - 2) * cosf(tmp));
-}
-
-for (i = 0; i < 12; i++) {
- tmp = (line[i] * (1.f / 180.f)) * PI;
- /* azimuth */
- if (line[i] == 0)
- buffer = g_strdup_printf("N");
- else
- buffer = g_strdup_printf("%d°", line[i]);
- pango_layout_set_text(_sat_details_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_layout, &x, &y);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (xoffset + halfsize +
- (halfsize - size / 12) * sinf(tmp)) - x / 2,
- (yoffset + halfsize -
- (halfsize - size / 12) * cosf(tmp)) - y / 2,
- _sat_details_layout);
- g_free(buffer);
-}
-
-/* elevation 30 */
-tmp = (30 * (1.f / 180.f)) * PI;
-buffer = g_strdup_printf("30°");
-pango_layout_set_text(_sat_details_layout, buffer, -1);
-pango_layout_get_pixel_size(_sat_details_layout, &x, &y);
-gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (xoffset + halfsize + size / 6 * 2 * sinf(tmp)) - x / 2,
- (yoffset + halfsize - size / 6 * 2 * cosf(tmp)) - y / 2,
- _sat_details_layout);
-g_free(buffer);
-
-/* elevation 60 */
-tmp = (30 * (1.f / 180.f)) * PI;
-buffer = g_strdup_printf("60°");
-pango_layout_set_text(_sat_details_layout, buffer, -1);
-pango_layout_get_pixel_size(_sat_details_layout, &x, &y);
-gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (xoffset + halfsize + size / 6 * sinf(tmp)) - x / 2,
- (yoffset + halfsize - size / 6 * cosf(tmp)) - y / 2,
- _sat_details_layout);
-g_free(buffer);
-
-color.red = 0;
-color.green = 0;
-color.blue = 0;
-gc1 = gdk_gc_new(widget->window);
-gdk_gc_set_rgb_fg_color(gc1, &color);
-
-color.red = 0;
-color.green = 0;
-color.blue = 0xffff;
-gc2 = gdk_gc_new(widget->window);
-gdk_gc_set_rgb_fg_color(gc2, &color);
-
-color.red = 0xffff;
-color.green = 0xffff;
-color.blue = 0xffff;
-gc3 = gdk_gc_new(widget->window);
-gdk_gc_set_rgb_fg_color(gc3, &color);
-
-for (i = 0; i < _gps.satinview; i++) {
- /* Sat used or not */
- gc = gc1;
- for (j = 0; j < _gps.satinuse; j++) {
- if (_gps.satforfix[j] == _gps_sat[i].prn) {
- gc = gc2;
- break;
- }
- }
-
- tmp = (_gps_sat[i].azimuth * (1.f / 180.f)) * PI;
- x = xoffset + halfsize
- + (90 - _gps_sat[i].elevation) * halfsize / 90 * sinf(tmp);
- y = yoffset + halfsize
- - (90 - _gps_sat[i].elevation) * halfsize / 90 * cosf(tmp);
-
- gdk_draw_arc(widget->window,
- gc, TRUE, x - 10, y - 10, 20, 20, 0, 64 * 360);
-
- buffer = g_strdup_printf("%02d", _gps_sat[i].prn);
- pango_layout_set_text(_sat_details_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_layout, &x1, &y1);
- gdk_draw_layout(widget->window,
- gc3,
- x - x1 / 2, y - y1 / 2, _sat_details_layout);
- g_free(buffer);
-}
-g_object_unref(gc1);
-g_object_unref(gc2);
-g_object_unref(gc3);
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-return;
-}
-
-static gboolean
-sat_details_panel_expose(GtkWidget * widget, GdkEventExpose * event)
-{
- guint width, height, x, y;
- gchar *buffer = NULL;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- width = widget->allocation.width;
- height = widget->allocation.height * 0.9;
-
- draw_sat_info(widget, 0, 0, width / 2, height, TRUE);
- draw_sat_details(widget, width / 2, 0, width / 2, height);
-
- buffer = g_strdup_printf("%s: %d; %s: %d",
- _("Satellites in view"), _gps.satinview,
- _("in use"), _gps.satinuse);
- pango_layout_set_text(_sat_details_expose_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_expose_layout, &x, &y);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- 10, height * 0.9 + 10, _sat_details_expose_layout);
- g_free(buffer);
-
- buffer = g_strdup_printf("HDOP: %.01f", _gps.hdop);
- pango_layout_set_text(_sat_details_expose_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_expose_layout, &x, &y);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (width / 8) - x / 2,
- (height / 6) - y / 2, _sat_details_expose_layout);
- g_free(buffer);
- buffer = g_strdup_printf("PDOP: %.01f", _gps.pdop);
- pango_layout_set_text(_sat_details_expose_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_expose_layout, &x, &y);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (width / 8) - x / 2,
- (height / 6) - y / 2 + 20, _sat_details_expose_layout);
- g_free(buffer);
- buffer = g_strdup_printf("VDOP: %.01f", _gps.vdop);
- pango_layout_set_text(_sat_details_expose_layout, buffer, -1);
- pango_layout_get_pixel_size(_sat_details_expose_layout, &x, &y);
- gdk_draw_layout(widget->window,
- widget->style->fg_gc[GTK_STATE_NORMAL],
- (width / 8) - x / 2,
- (height / 6) - y / 2 + 40, _sat_details_expose_layout);
- g_free(buffer);
-
- return TRUE;
-}
-
-gboolean
+gboolean
gps_display_details(void)
{
gchar *buffer, litbuf[16];
/* max speed */
gps_display_data_speed(_sdi_msp, _gps.maxspeed);
-/* refresh sat panel */
-gtk_widget_queue_draw_area(GTK_WIDGET(_sat_details_panel),
- 0, 0,
- _sat_details_panel->allocation.width,
- _sat_details_panel->allocation.height);
-
return TRUE;
}
GtkWidget *dialog;
dialog = gtk_dialog_new_with_buttons(_("GPS Details"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT, NULL);
+ GTK_WINDOW(_window),
+ GTK_DIALOG_MODAL, GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT, NULL);
gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
GtkWidget *notebook;
dialog = gtk_dialog_new_with_buttons(_("GPS Details"),
- GTK_WINDOW(_window),
- GTK_DIALOG_MODAL, GTK_STOCK_OK,
- GTK_RESPONSE_ACCEPT, NULL);
+ GTK_WINDOW(_window),
+ GTK_DIALOG_MODAL, GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT, NULL);
gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 300);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
_sat_details_panel = gtk_drawing_area_new();
gtk_widget_set_size_request(_sat_details_panel, 300, 300);
/* sat details info */
-gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- _sat_details_panel,
- label = gtk_label_new(_("Satellites details")));
-g_signal_connect(G_OBJECT(_sat_details_panel), "expose_event",
- G_CALLBACK(sat_details_panel_expose), NULL);
+gtk_notebook_append_page(GTK_NOTEBOOK(notebook), _sat_details_panel, label = gtk_label_new(_("Satellites details")));
gtk_table_attach(GTK_TABLE(table),
label = gtk_label_new(_("Latitude")),
#include <curl/multi.h>
#include <glib/gi18n.h>
+#include "gtkgps.h"
+
#include "hildon-mapper.h"
#include "utils.h"
{
GtkAction *action = gtk_action_group_get_action(actions, name);
g_assert(action);
-gtk_toggle_action_set_active(action, active);
+gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), active);
}
#if 0
mapper_ui_init(void)
{
GtkWidget *hbox, *mapvbox, *label, *vbox_main;
-GtkWidget *notebook;
+GtkWidget *gpsvbox;
+GtkNotebook *notebook;
GdkColor color;
GError *error = NULL;
notebook = gtk_notebook_new();
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
+info_banner.container=gtk_hbox_new(FALSE, 0);
+info_banner.location=gtk_label_new("");
+info_banner.speed=gtk_label_new("");
+info_banner.distance=gtk_label_new("");
+gtk_label_set_max_width_chars(GTK_LABEL(info_banner.speed), 10);
+gtk_label_set_width_chars(GTK_LABEL(info_banner.speed), 14);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.distance, FALSE, FALSE, 0);
+
+vbox_main = gtk_vbox_new(FALSE, 0);
+gtk_container_add(GTK_CONTAINER(_window), vbox_main);
+
#ifdef WITH_HILDON
/* Create and add widgets and supporting data. */
-gtk_container_add(GTK_CONTAINER(_window), notebook);
+gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
+gtk_container_add(GTK_CONTAINER(_window), vbox_main);
hildon_program_set_common_toolbar(_program, toolbar);
{
GtkMenu *hmenu;
gtk_widget_show_all(GTK_WIDGET(notebook));
gtk_widget_show_all(GTK_WIDGET(toolbar));
#else
-vbox_main = gtk_vbox_new(FALSE, 0);
-gtk_container_add(GTK_CONTAINER(_window), vbox_main);
+_status_bar = gtk_statusbar_new();
gtk_box_pack_start(GTK_BOX(vbox_main), menu_bar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_main), toolbar, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
-
-_status_bar = gtk_statusbar_new();
+gtk_box_pack_start(GTK_BOX(vbox_main), info_banner.container, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0);
gtk_widget_show_all(GTK_WIDGET(vbox_main));
#endif
label = gtk_label_new("Map");
hbox = gtk_hpaned_new();
-info_banner.container=gtk_hbox_new(FALSE, 0);
-info_banner.location=gtk_label_new("");
-info_banner.speed=gtk_label_new("");
-info_banner.distance=gtk_label_new("");
-gtk_label_set_max_width_chars(GTK_LABEL(info_banner.speed), 10);
-gtk_label_set_width_chars(GTK_LABEL(info_banner.speed), 14);
-gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0);
-gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0);
-gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.distance, FALSE, FALSE, 0);
-
gtk_widget_hide(GTK_WIDGET(_progress_item));
mapvbox = gtk_vbox_new(FALSE, 0);
-gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0);
-gtk_notebook_append_page(GTK_WIDGET(notebook), mapvbox, label);
+gtk_notebook_append_page(notebook, mapvbox, label);
gtk_widget_show_all(GTK_WIDGET(mapvbox));
+gpsvbox = gtk_vbox_new(FALSE, 0);
+label = gtk_label_new("Gps");
+_gps_sat_view = gtk_gps_new(GTK_GPS_MODE_SKY, &_gps);
+gtk_box_pack_start(GTK_BOX(gpsvbox), _gps_sat_view, TRUE, TRUE, 0);
+gtk_notebook_append_page(notebook, gpsvbox, label);
+gtk_widget_show_all(GTK_WIDGET(gpsvbox));
+
_gps_widget = gps_info_panel();
gtk_widget_set_size_request(GTK_WIDGET(_gps_widget), 180, 0);
gtk_paned_add1(GTK_PANED(hbox), _gps_widget);
pango_layout_set_font_description(_speed_limit_layout, _speed_limit_fontdesc);
pango_layout_set_alignment(_speed_limit_layout, PANGO_ALIGN_CENTER);
-/* draw_sat_info() */
-_sat_info_gc1 = gdk_gc_new(_map_widget->window);
-color.red = 0;
-color.green = 0;
-color.blue = 0;
-gdk_gc_set_rgb_fg_color(_sat_info_gc1, &color);
-color.red = 0;
-color.green = 0;
-color.blue = 0xffff;
-_sat_info_gc2 = gdk_gc_new(_map_widget->window);
-gdk_gc_set_rgb_fg_color(_sat_info_gc2, &color);
-_sat_info_context = gtk_widget_get_pango_context(_map_widget);
-_sat_info_layout = pango_layout_new(_sat_info_context);
-_sat_info_fontdesc = pango_font_description_new();
-pango_font_description_set_family(_sat_info_fontdesc, "Sans Serif");
-pango_font_description_set_size(_sat_info_fontdesc, 8 * PANGO_SCALE);
-pango_layout_set_font_description(_sat_info_layout, _sat_info_fontdesc);
-pango_layout_set_alignment(_sat_info_layout, PANGO_ALIGN_CENTER);
-
-/* sat_panel_expose() */
-_sat_panel_context = gtk_widget_get_pango_context(_map_widget);
-_sat_panel_layout = pango_layout_new(_sat_panel_context);
-_sat_panel_fontdesc = pango_font_description_new();
-pango_font_description_set_family(_sat_panel_fontdesc, "Sans Serif");
-pango_font_description_set_size(_sat_panel_fontdesc, 12 * PANGO_SCALE);
-pango_layout_set_font_description(_sat_panel_layout, _sat_panel_fontdesc);
-
-/* heading_panel_expose() */
-_heading_panel_context = gtk_widget_get_pango_context(_map_widget);
-_heading_panel_layout = pango_layout_new(_heading_panel_context);
-_heading_panel_fontdesc = pango_font_description_new();
-pango_font_description_set_family(_heading_panel_fontdesc, "Sans Serif");
-
-/* draw_sat_details() */
-_sat_details_context = gtk_widget_get_pango_context(_map_widget);
-_sat_details_layout = pango_layout_new(_sat_details_context);
-_sat_details_fontdesc = pango_font_description_new();
-pango_font_description_set_family(_sat_details_fontdesc, "Sans Serif");
-pango_font_description_set_size(_sat_details_fontdesc, 10 * PANGO_SCALE);
-pango_layout_set_font_description(_sat_details_layout, _sat_details_fontdesc);
-pango_layout_set_alignment(_sat_details_layout, PANGO_ALIGN_CENTER);
-
-/* sat_details_panel_expose() */
-_sat_details_expose_context = gtk_widget_get_pango_context(_map_widget);
-_sat_details_expose_layout = pango_layout_new(_sat_details_expose_context);
-_sat_details_expose_fontdesc = pango_font_description_new();
-pango_font_description_set_family(_sat_details_expose_fontdesc, "Sans Serif");
-pango_layout_set_alignment(_sat_details_expose_layout, PANGO_ALIGN_CENTER);
-pango_font_description_set_size(_sat_details_expose_fontdesc, 12 * PANGO_SCALE);
-pango_layout_set_font_description(_sat_details_expose_layout, _sat_details_expose_fontdesc);
-
_last_spoken_phrase = g_strdup("");
memset(&_autoroute_data, 0, sizeof(_autoroute_data));