]> err.no Git - mapper/commitdiff
Use widgets
authorKaj-Michael Lang <milang@onion.tal.org>
Sun, 30 Sep 2007 21:31:36 +0000 (00:31 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Sun, 30 Sep 2007 21:31:36 +0000 (00:31 +0300)
src/gps-nmea-parse.c
src/gps-panels.c
src/gps.h
src/osm-db.c
src/osm-db.h
src/ui-common.c
src/ui-common.h

index ae27ca9813f7af6068c41ff01b44f8d51460fca7..337563db9ae9e1c66eb86ecc0b69069fa650a6af 100644 (file)
@@ -26,6 +26,9 @@
 #include "gps-panels.h"
 #include "settings.h"
 
+#include "gtkgps.h"
+#include "gtkcompass.h"
+
 #define GPS_FILTER_MAX_SKIP (10)
 static gint track_drop_cnt=0;
 
@@ -179,8 +182,7 @@ channel_parse_rmc(gchar * sentence)
                                        _gps.vdop>_filter_vdop ? "VDOP" : "-", 
                                        (fabs(_gps.heading-_gps.lheading)<_filter_angle) ? "Angle" : "-",
                                        (_map_location_known==TRUE && (_map_location_dist>_filter_osm)) ? "OSM" : "-", 
-                                       (fabs(_gps.heading-_gps.lheading)<_filter_angle),
-                                       track_drop_cnt);
+                                       fabs(_gps.heading-_gps.lheading), track_drop_cnt);
                        }
                        map_refresh_mark();
                } else {
@@ -334,7 +336,7 @@ channel_parse_gsv(gchar * sentence)
        static guint running_total = 0;
        static guint num_sats_used = 0;
        static guint satcnt = 0;
-       vprintf("%s(): %s\n", __PRETTY_FUNCTION__, sentence);
+       g_printf("%s(): %s\n", __PRETTY_FUNCTION__, sentence);
 
        /* Parse number of messages. */
        token = strsep(&sentence, DELIM);
@@ -359,23 +361,23 @@ channel_parse_gsv(gchar * sentence)
                /* Get token for Satellite Number. */
                token = strsep(&sentence, DELIM);
                if (token && *token)
-                       _gps_sat[satcnt].prn = atoi(token);
+                       _gps.sat[satcnt].prn = atoi(token);
 
                /* Get token for elevation in degrees (0-90). */
                token = strsep(&sentence, DELIM);
                if (token && *token)
-                       _gps_sat[satcnt].elevation = atoi(token);
+                       _gps.sat[satcnt].elevation = atoi(token);
 
                /* Get token for azimuth in degrees to true north (0-359). */
                token = strsep(&sentence, DELIM);
                if (token && *token)
-                       _gps_sat[satcnt].azimuth = atoi(token);
+                       _gps.sat[satcnt].azimuth = atoi(token);
 
                /* Get token for SNR. */
                token = strsep(&sentence, DELIM);
-               if (token && *token && (_gps_sat[satcnt].snr = atoi(token))) {
+               if (token && *token && (_gps.sat[satcnt].snr = atoi(token))) {
                        /* SNR is non-zero - add to total and count as used. */
-                       running_total += _gps_sat[satcnt].snr;
+                       running_total += _gps.sat[satcnt].snr;
                        num_sats_used++;
                }
                satcnt++;
@@ -398,7 +400,7 @@ channel_parse_gsv(gchar * sentence)
                KEEP_DISPLAY_ON();
        }
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+       g_printf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
 gboolean
@@ -408,9 +410,7 @@ channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data)
        vprintf("%s(%d)\n", __PRETTY_FUNCTION__, condition);
 
        if (G_IO_STATUS_NORMAL == g_io_channel_read_chars(_channel,
-                                                         _gps_read_buf_curr,
-                                                         _gps_read_buf_last -
-                                                         _gps_read_buf_curr,
+                                                         _gps_read_buf_curr, _gps_read_buf_last - _gps_read_buf_curr,
                                                          &bytes_read, NULL)) {
                gchar *eol;
 
index 4bc934091bfa2c1e05b6383469f3edcb1ed70139..db495c5cb552bcedcf63479137bdde61f87f900f 100644 (file)
@@ -24,6 +24,8 @@
 #include "route.h"
 
 #include "gps-panels.h"
+#include "gtkgps.h"
+#include "gtkcompass.h"
 
 static GtkWidget *text_lat;
 static GtkWidget *text_lon;
@@ -34,9 +36,6 @@ static GtkWidget *text_time;
 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 *
@@ -78,14 +77,15 @@ text_time = gtk_label_new(NULL);
 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;
 }
@@ -126,24 +126,23 @@ gtk_label_set_label(GTK_LABEL(text_time), "--:--:--");
 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);
@@ -152,39 +151,28 @@ if (_gps.fix < 2) {
        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;
@@ -192,534 +180,20 @@ _gps.satinview = 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];
@@ -829,12 +303,6 @@ g_free(buffer);
 /* 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;
 }
 
@@ -844,9 +312,9 @@ gps_details_dialog(void)
 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);
 
@@ -869,9 +337,9 @@ GtkWidget *label;
 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),
@@ -885,11 +353,7 @@ gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
 _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")),
index 26a2b45fc91bfb28c1c68c5dd5da67e7d712cee2..97ecb448b5b394ff122c49240f3d31bb377f5cf9 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
 
 #include "utils.h"
 #include "mapper-types.h"
-
-/** GPS Data and Satellite **/
-typedef struct _GpsData GpsData;
-struct _GpsData {
-       guint fix;
-       guint fixquality;
-       gdouble lat;
-       gdouble lon;
-       gfloat speed;           /* in knots */
-       gfloat maxspeed;        /* in knots */
-       gfloat avgspeed;        /* -- "" -- */
-       gfloat heading;
-       gfloat lheading;
-       gfloat hdop;
-       gfloat vdop;
-       gfloat pdop;
-       guint satinview;
-       guint satinuse;
-       guint satforfix[12];
-};
-
-typedef struct _GpsSatelliteData GpsSatelliteData;
-struct _GpsSatelliteData {
-       guint prn;
-       guint elevation;
-       guint azimuth;
-       guint snr;
-};
+#include "gpsdata.h"
 
 #define GPS_READ_BUF_SIZE 1024
 
index 200567a0656bcc8ce152dd2705d454e3df3455fb..f95e606e14a73038bd96de486bb294c14a34bba1 100644 (file)
@@ -808,7 +808,9 @@ if (map_loc->street && osm_way_distance(lat, lon, map_loc->street->node_f, map_l
                check_place=TRUE;
                map_loc->changed=TRUE;
        } else {
+#if 0
                g_printf("*** No change in location: %f %d\n", dist, way_dist_range);
+#endif
                /* We are still on the same way as last time */
                check_place=FALSE;
                map_loc->changed=FALSE;
@@ -845,8 +847,10 @@ if (map_loc->changed==TRUE) {
        map_loc->speed=_gps.speed;
 }
 
+#if 0
 g_printf("NFC: %d\n", map_loc->nfcnt);
 g_printf("D: %ld %ld\n", d,(gulong)way_dist_range);
+#endif
 
 if (check_place==TRUE && d>way_dist_range*4) {
        gboolean fs;
@@ -880,7 +884,5 @@ if (check_place==TRUE && d>way_dist_range*4) {
        }
 }
 
-g_print("------\n\n");
-
 return map_loc->street ? TRUE : FALSE;
 }
index edffca019b2977aa8ecd4400f0960dc549d46c68..dbee04396212927ee5bebae539b56b73b5f8bb3f 100644 (file)
@@ -31,5 +31,6 @@ osm_way_node *osm_way_node_new(guint id, gint lat, gint lon, gint flags);
 
 void osm_way_node_free(osm_way_node *n);
 void osm_way_free(osm_way *w);
+void osm_way_nodes_free(osm_way *w);
 
 #endif
index 63c2dfcab44bbabfb12ca3059b4031da1d6648df..adc0d44d3988bc5ac582e4f07425242a8d61a66f 100644 (file)
@@ -18,6 +18,8 @@
 #include <curl/multi.h>
 #include <glib/gi18n.h>
 
+#include "gtkgps.h"
+
 #include "hildon-mapper.h"
 
 #include "utils.h"
@@ -272,7 +274,7 @@ set_action_activate(const char *name, gboolean active)
 {
 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
@@ -630,7 +632,8 @@ void
 mapper_ui_init(void)
 {
 GtkWidget *hbox, *mapvbox, *label, *vbox_main;
-GtkWidget *notebook;
+GtkWidget *gpsvbox;
+GtkNotebook *notebook;
 GdkColor color;
 GError *error = NULL;
 
@@ -687,9 +690,23 @@ toolbar_progress_init();
 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;
@@ -703,14 +720,12 @@ hildon_program_set_common_toolbar(_program, toolbar);
 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
@@ -718,24 +733,20 @@ gtk_widget_show_all(GTK_WIDGET(vbox_main));
 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);
@@ -795,57 +806,6 @@ pango_font_description_set_size(_speed_limit_fontdesc,64 * PANGO_SCALE);
 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));
 
index 84c76d49b5e928dd04f79bf5d09ad0cef2c39d1c..1c21d53018f581fcfa33da196d29d9d7afed81a0 100644 (file)
@@ -40,6 +40,13 @@ GdkPixmap *_map_pixmap;
 
 GtkWidget *_gps_widget;
 
+/* GPS Panel View widget */
+GtkWidget *_gps_sat_view;
+
+/* Compass panel widget */
+GtkWidget *_gps_compass;
+GtkWidget *_gps_signal;
+
 GtkWidget *_sat_details_panel;
 GtkWidget *_sdi_lat;
 GtkWidget *_sdi_lon;
@@ -66,20 +73,11 @@ PangoFontDescription *_speed_limit_fontdesc;
 PangoContext *_sat_panel_context;
 PangoLayout *_sat_panel_layout;
 PangoFontDescription *_sat_panel_fontdesc;
-PangoContext *_heading_panel_context;
-PangoLayout *_heading_panel_layout;
-PangoFontDescription *_heading_panel_fontdesc;
 GdkGC *_sat_info_gc1;
 GdkGC *_sat_info_gc2;
 PangoContext *_sat_info_context;
 PangoLayout *_sat_info_layout;
 PangoFontDescription *_sat_info_fontdesc;
-PangoContext *_sat_details_context;
-PangoLayout *_sat_details_layout;
-PangoFontDescription *_sat_details_fontdesc;
-PangoContext *_sat_details_expose_context;
-PangoLayout *_sat_details_expose_layout;
-PangoFontDescription *_sat_details_expose_fontdesc;
 
 /** THE GdkGC OBJECTS USED FOR DRAWING. */
 GdkGC *_gc[COLORABLE_ENUM_COUNT];