Diff of /trunk/src/map-tool.c

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

revision 33 by harbaum, Tue Jul 28 13:21:40 2009 UTC revision 61 by harbaum, Tue Aug 18 14:32:45 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.   * Copyright (C) 2008-2009 Till Harbaum <till@harbaum.org>.
3   *   *
4   * This file is part of GPXView.   * This file is part of GPXView.
5   *   *
# Line 18  Line 18 
18   */   */
19    
20  #include "gpxview.h"  #include "gpxview.h"
21    #include "converter.h"
22    #include <math.h>    // for isnan
23    
24  #ifdef ENABLE_OSM_GPS_MAP  #ifdef ENABLE_OSM_GPS_MAP
25  #include "osm-gps-map.h"  #include "osm-gps-map.h"
26  #endif  #endif
27    
28  typedef struct {  #define MAP_SOURCE  OSM_GPS_MAP_SOURCE_OPENSTREETMAP
29    GtkWidget *widget;  #define GPS_DEFAULT_ZOOM 13
   GtkWidget *zoomin, *zoomout, *gps;  
   gint handler_id;  
 } map_context_t;  
30    
31  static const char *get_proxy_uri(void) {  #define PROXY_KEY  "/system/http_proxy/"
32    static char proxy_buffer[64];  
33    static const char *get_proxy_uri(appdata_t *appdata) {
34      static char proxy_buffer[64] = "";
35    
36    /* use environment settings if preset */    /* use environment settings if preset */
37    const char *proxy = g_getenv("http_proxy");    const char *proxy = g_getenv("http_proxy");
# Line 39  static const char *get_proxy_uri(void) { Line 40  static const char *get_proxy_uri(void) {
40      return proxy;      return proxy;
41    }    }
42    
43  #if 0    /* ------------- get proxy settings -------------------- */
44    /* otherwise try settings */    if(gconf_client_get_bool(appdata->gconf_client,
45    if(!settings || !settings->proxy ||                             PROXY_KEY "use_http_proxy", NULL)) {
46       !settings->proxy->host) return NULL;  
47        /* we can savely ignore things like "ignore_hosts" since we */
48    snprintf(proxy_buffer, sizeof(proxy_buffer), "%s%s:%u",      /* are pretty sure not inside the net of one of our map renderers */
49             strncmp(settings->proxy->host, "http://", 7)?"http://":"",      /* (unless the user works at google :-) */
50             settings->proxy->host, settings->proxy->port);  
51        /* get basic settings */
52    proxy_buffer[sizeof(proxy_buffer)-1] = 0;      char *host =
53    printf("gconf_proxy: %s\n", proxy_buffer);        gconf_client_get_string(appdata->gconf_client, PROXY_KEY "host", NULL);
54  #endif      if(host) {
55          int port =
56            gconf_client_get_int(appdata->gconf_client, PROXY_KEY "port", NULL);
57    
58          snprintf(proxy_buffer, sizeof(proxy_buffer),
59                   "http://%s:%u", host, port);
60    
61          g_free(host);
62        }
63        return proxy_buffer;
64      }
65    
66    return proxy_buffer;    return NULL;
67  }  }
68    
69  static void map_zoom(map_context_t *context, int step) {  static void map_zoom(map_context_t *context, int step) {
70    int zoom;    gint zoom;
71    OsmGpsMap *map = OSM_GPS_MAP(context->widget);    OsmGpsMap *map = OSM_GPS_MAP(context->widget);
72    g_object_get(map, "zoom", &zoom, NULL);    g_object_get(map, "zoom", &zoom, NULL);
73    zoom = osm_gps_map_set_zoom(map, zoom+step);    zoom = osm_gps_map_set_zoom(map, zoom+step);
74    
75    /* enable/disable zoom buttons as required */    /* enable/disable zoom buttons as required */
76    gtk_widget_set_sensitive(context->zoomin, zoom<17);    gtk_widget_set_sensitive(context->zoomin,
77    gtk_widget_set_sensitive(context->zoomout, zoom>1);             zoom < osm_gps_map_source_get_max_zoom(MAP_SOURCE));
78      gtk_widget_set_sensitive(context->zoomout,
79               zoom > osm_gps_map_source_get_min_zoom(MAP_SOURCE));
80    
81      /* save new zoom */
82      context->appdata->map.zoom = zoom;
83  }  }
84    
85  static gboolean  static gboolean
# Line 80  cb_map_zoomout(GtkButton *button, map_co Line 96  cb_map_zoomout(GtkButton *button, map_co
96    
97  static gboolean  static gboolean
98  cb_map_gps(GtkButton *button, map_context_t *context) {  cb_map_gps(GtkButton *button, map_context_t *context) {
99      pos_t *refpos = get_pos(context->appdata);
100    //  osm_gps_map_set_center(OSM_GPS_MAP(context->widget),    if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
101    //                     DEG2RAD(pos.lat), DEG2RAD(pos.lon));      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
102                          refpos->lat, refpos->lon, GPS_DEFAULT_ZOOM);
103      } else {
104        /* no coordinates given: display the entire world */
105        osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
106                                  0.0, 0.0, 1);
107      }
108    
109    return FALSE;    return FALSE;
110  }  }
111    
112  static GtkWidget  static GtkWidget
113  *map_add_button(const gchar *icon, GCallback cb, gpointer data,  *map_add_button(int icon, GCallback cb, gpointer data,
114                  char *tooltip) {                  char *tooltip) {
115    GtkWidget *button = gtk_button_new();    GtkWidget *button = gtk_button_new();
116    gtk_button_set_image(GTK_BUTTON(button),    gtk_button_set_image(GTK_BUTTON(button), icon_get_widget(ICON_MISC, icon));
                        gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU));  
117    g_signal_connect(button, "clicked", cb, data);    g_signal_connect(button, "clicked", cb, data);
118  #ifndef USE_MAEMO  #ifndef USE_MAEMO
119    gtk_widget_set_tooltip_text(button, tooltip);    gtk_widget_set_tooltip_text(button, tooltip);
# Line 100  static GtkWidget Line 121  static GtkWidget
121    return button;    return button;
122  }  }
123    
124    static int dist2pixel(map_context_t *context, float km, float lat) {
125      return 1000.0*km/osm_gps_map_get_scale(OSM_GPS_MAP(context->widget));
126    }
127    
128  static gboolean map_gps_update(gpointer data) {  static gboolean map_gps_update(gpointer data) {
129    map_context_t *context = (map_context_t*)data;    map_context_t *context = (map_context_t*)data;
130    
131    //  gtk_widget_set_sensitive(context->map.gps, gps_fix);    /* get reference position ... */
132      pos_t *refpos = get_pos(context->appdata);
133      gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);
134    
135      /* ... and enable "goto" button if it's valid */
136      gtk_widget_set_sensitive(context->gps, ok);
137    
138      if(ok) {
139        float heading = NAN;
140        int radius = 0;
141    
142        if(context->appdata->use_gps) {
143          heading = gps_get_heading(context->appdata);
144    
145          /* get error */
146          float eph = gps_get_eph(context->appdata);
147          if(!isnan(eph))
148            radius = dist2pixel(context, eph/1000, refpos->lat);
149        }
150    
151        g_object_set(context->widget, "gps-track-highlight-radius", radius, NULL);
152        osm_gps_map_draw_gps(OSM_GPS_MAP(context->widget),
153                             refpos->lat, refpos->lon, heading);
154      } else
155        osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget));
156    
157    return TRUE;    return TRUE;
158  }  }
159    
160    static gboolean on_map_configure(GtkWidget *widget,
161                                     GdkEventConfigure *event,
162                                     map_context_t *context) {
163    
164      /* set default values if they are invalid */
165      if(!context->appdata->map.zoom ||
166         isnan(context->appdata->map.pos.lat) ||
167         isnan(context->appdata->map.pos.lon)) {
168        printf("no valid map position found\n");
169    
170        pos_t *refpos = get_pos(context->appdata);
171        if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
172          /* use gps position if present */
173          context->appdata->map.pos = *refpos;
174          context->appdata->map.zoom = GPS_DEFAULT_ZOOM;
175        } else {
176          /* use world map otherwise */
177          context->appdata->map.pos.lat = 0.0;
178          context->appdata->map.pos.lon = 0.0;
179          context->appdata->map.zoom = 1;
180        }
181      }
182    
183  void map(appdata_t *appdata) {    /* jump to initial position */
184    map_context_t context;    osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
185                                context->appdata->map.pos.lat,
186                                context->appdata->map.pos.lon,
187                                context->appdata->map.zoom);
188    
189      return FALSE;
190    }
191    
192    GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Map"),  static void map_draw_cachelist(GtkWidget *map, cache_t *cache) {
193                            GTK_WINDOW(appdata->window),    while(cache) {
194                            GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,      GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type);
195                            GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,  
196                            NULL);      osm_gps_map_add_image(OSM_GPS_MAP(map),
197                              cache->pos.lat, cache->pos.lon, icon);
198    
199  #ifndef USE_MAEMO      cache = cache->next;
200    gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 350);    }
201  #else  }
202    gtk_window_set_default_size(GTK_WINDOW(dialog), 800, 480);  
203    static void
204    map_cachelist_nearest(cache_t *cache, pos_t *pos,
205                          cache_t **result, float *distance) {
206      while(cache) {
207        float dist =
208          pow(cache->pos.lat - pos->lat, 2) +
209          pow(cache->pos.lon - pos->lon, 2);
210    
211        if(!(dist > *distance)) {
212          *result = cache;
213          *distance = dist;
214        }
215    
216        cache = cache->next;
217      }
218    }
219    
220    static cache_t *map_closest(map_context_t *context, pos_t *pos) {
221      cache_t *result = NULL;
222      float distance = NAN;
223    
224    #ifdef USE_MAEMO
225      if(!context->appdata->cur_gpx) {
226    #endif
227        /* search all geocaches */
228        gpx_t *gpx = context->appdata->gpx;
229        while(gpx) {
230          map_cachelist_nearest(gpx->cache, pos, &result, &distance);
231          gpx = gpx->next;
232        }
233    #ifdef USE_MAEMO
234      } else {
235        map_cachelist_nearest(context->appdata->cur_gpx->cache,
236                              pos, &result, &distance);
237      }
238    #endif
239    
240      return result;
241    }
242    
243    /* translate between osm-gps-map positions and gpxview ones */
244    pos_t coord2pos(coord_t coo) {
245      pos_t pos;
246      pos.lat = rad2deg(coo.rlat);
247      pos.lon = rad2deg(coo.rlon);
248      return pos;
249    }
250    
251    #define CLICK_FUZZ (24)
252    
253    static gboolean
254    on_map_button_press_event(GtkWidget *widget,
255                                GdkEventButton *event, map_context_t *context) {
256      OsmGpsMap *map = OSM_GPS_MAP(context->widget);
257    
258      /* got a press event without release event? eat it! */
259      if(context->press_on != NULL) {
260        printf("PRESS: already\n");
261        return TRUE;
262      }
263    
264      pos_t pos =
265        coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));
266    
267      cache_t *nearest = map_closest(context, &pos);
268      if(nearest) {
269        float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);
270        if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ)
271          context->press_on = nearest;
272      }
273    
274      return FALSE;
275    }
276    
277    static void
278    cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) {
279      /* convert the pixbuf into something cairo can handle */
280    
281      // Create a new ImageSurface
282      cairo_surface_t *image_surface =
283        cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
284                                   gdk_pixbuf_get_width(buf),
285                                   gdk_pixbuf_get_height(buf));
286    
287      // Create the new Context for the ImageSurface
288      cairo_t *context = cairo_create(image_surface);
289    
290      // Draw the image on the new Context
291      gdk_cairo_set_source_pixbuf(context, buf, 0.0, 0.0);
292      cairo_paint(context);
293    
294      // now draw this onto the original context
295      cairo_set_source_surface(cr, image_surface, x, y);
296    
297      cairo_paint(cr);
298    }
299    
300    #define LINE_SKIP  7
301    
302    static void
303    balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) {
304      cache_t *cache = (cache_t*)data;
305    
306      //  printf("draw cb for \"%s\"\n", cache->name);
307    
308    #if 0
309      /* draw pink background to check clipping */
310      cairo_rectangle (cr, rect->x-20, rect->y-20, rect->w+40, rect->h+40);
311      cairo_set_source_rgba (cr, 1, 0, 0, 0.3);
312      cairo_fill_preserve (cr);
313      cairo_set_line_width (cr, 0);
314      cairo_stroke (cr);
315    #endif
316    
317      /* leave a little border top and left */
318      gint x = rect->x, y = rect->y;
319    
320      /* draw the cache type icon ... */
321      GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type);
322      cairo_draw_pixbuf(cr, icon, x, y);
323    
324      /* ... and right of it the waypoint id */
325      cairo_text_extents_t extents;
326    
327      if(cache->id) {
328        cairo_select_font_face (cr, "Sans",
329                                CAIRO_FONT_SLANT_NORMAL,
330                                CAIRO_FONT_WEIGHT_BOLD);
331    
332        cairo_set_font_size (cr, 20.0);
333        cairo_text_extents (cr, cache->id, &extents);
334    
335        /* display id right of icon vertically centered */
336        x += gdk_pixbuf_get_width(icon) + 5;
337        y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
338        cairo_move_to (cr, x, y);
339        cairo_set_source_rgba (cr, 0, 0, 0, 1);
340        cairo_show_text (cr, cache->id);
341        cairo_stroke (cr);
342    
343        y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP;
344      } else
345        y += gdk_pixbuf_get_height(icon);
346    
347      /* return to the left border and below icon/text */
348      x = rect->x;
349    
350      /* everything from here uses the same font */
351      cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
352                              CAIRO_FONT_WEIGHT_NORMAL);
353      cairo_set_font_size (cr, 14.0);
354    
355      if(cache->name) {
356        /* draw cache name */
357        cairo_text_extents (cr, cache->name, &extents);
358        y += extents.height;
359        cairo_move_to (cr, x, y);
360        cairo_set_source_rgba (cr, 0, 0, 0, 1);
361        cairo_show_text (cr, cache->name);
362        cairo_stroke (cr);
363    
364        /* return to the left border and below text */
365        y += LINE_SKIP;
366        x = rect->x;
367      }
368    
369      if(cache->terrain) {
370        /* draw cache rating */
371        const char *terrain = "Terrain:";
372        icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2));
373        cairo_text_extents (cr, _(terrain), &extents);
374        y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
375    
376        /* draw "Terrain:" string */
377        cairo_move_to (cr, x, y);
378        cairo_set_source_rgba (cr, 0, 0, 0, 1);
379        cairo_show_text (cr, _(terrain));
380        cairo_stroke (cr);
381        x += extents.width + 2;
382    
383        /* draw terrain stars */
384        cairo_draw_pixbuf(cr, icon, x, y -
385                          (gdk_pixbuf_get_height(icon) + extents.height)/2);
386    
387        x += gdk_pixbuf_get_width(icon) + LINE_SKIP;
388        y -= (gdk_pixbuf_get_height(icon) + extents.height)/2;
389      }
390    
391      if(cache->difficulty) {
392        const char *difficulty = "Difficulty:";
393        cairo_text_extents (cr, _(difficulty), &extents);
394        y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
395    
396        /* draw "Difficulty:" string */
397        cairo_move_to (cr, x, y);
398        cairo_set_source_rgba (cr, 0, 0, 0, 1);
399        cairo_show_text (cr, _(difficulty));
400        cairo_stroke (cr);
401        x += extents.width + 2;
402    
403        icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2));
404        cairo_draw_pixbuf(cr, icon, x, y -
405                          (gdk_pixbuf_get_height(icon) + extents.height)/2);
406      }
407    }
408    
409    static gboolean
410    on_map_button_release_event(GtkWidget *widget,
411                                GdkEventButton *event, map_context_t *context) {
412      OsmGpsMap *map = OSM_GPS_MAP(context->widget);
413    
414      if(context->press_on) {
415        coord_t coo;
416        coo = osm_gps_map_get_co_ordinates(map, event->x, event->y);
417    
418        pos_t pos =
419          coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));
420    
421        cache_t *nearest = map_closest(context, &pos);
422        if(nearest && nearest == context->press_on) {
423          float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);
424          if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ) {
425    
426            osm_gps_map_draw_balloon(map, nearest->pos.lat, nearest->pos.lon,
427                                     balloon_draw_cb, nearest);
428          }
429        }
430        context->press_on = NULL;
431      } else {
432        /* save new map position */
433        gfloat lat, lon;
434        g_object_get(map, "latitude", &lat, "longitude", &lon, NULL);
435        context->appdata->map.pos.lat = lat;
436        context->appdata->map.pos.lon = lon;
437      }
438    
439      return FALSE;
440    }
441    
442    static void on_window_destroy(GtkWidget *widget, map_context_t *context) {
443      appdata_t *appdata = context->appdata;
444    
445      printf("destroy map window\n");
446    
447      /* save map parameters */
448      OsmGpsMap *map = OSM_GPS_MAP(context->widget);
449      gint zoom;
450      g_object_get(map, "zoom", &zoom, NULL);
451      context->appdata->map.zoom = zoom;
452    
453      gfloat lat, lon;
454      g_object_get(map, "latitude", &lat, "longitude", &lon, NULL);
455      context->appdata->map.pos.lat = lat;
456      context->appdata->map.pos.lon = lon;
457    
458    #if MAEMO_VERSION_MAJOR == 5
459      /* restore cur_view */
460      context->appdata->cur_view = context->old_view;
461  #endif  #endif
462    
463      gtk_timeout_remove(context->handler_id);
464    
465      g_free(context);
466      appdata->map.context = NULL;
467    }
468    
469    void map(appdata_t *appdata) {
470      map_context_t *context = NULL;
471    
472      /* if the map window already exists, just raise it */
473      if(appdata->map.context) {
474        gtk_window_present(GTK_WINDOW(appdata->map.context->window));
475        return;
476      }
477    
478      context = appdata->map.context = g_new0(map_context_t, 1);
479      context->appdata = appdata;
480    
481    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
482    
483    char *path = g_strdup_printf("%s/map/", appdata->image_path);    char *path = g_strdup_printf("%s/map/", appdata->image_path);
484      const char *proxy = get_proxy_uri(appdata);
485    
486    context.widget = g_object_new(OSM_TYPE_GPS_MAP,    context->widget = g_object_new(OSM_TYPE_GPS_MAP,
487                  "repo-uri", MAP_SOURCE_OPENSTREETMAP,                   "map-source",               MAP_SOURCE,
488                  "proxy-uri", get_proxy_uri(),                   "tile-cache",               path,
489                  "tile-cache", path,                   "auto-center",              FALSE,
490                     "record-trip-history",      FALSE,
491                     "show-trip-history",        FALSE,
492                     proxy?"proxy-uri":NULL,     proxy,
493                   NULL);                   NULL);
494    
495    g_free(path);    g_free(path);
496    
497  #if 0    char *name = NULL;
498    g_signal_connect(G_OBJECT(context.widget), "button-release-event",  #ifdef USE_MAEMO
499                     G_CALLBACK(on_map_button_release_event), &context);    if(!appdata->cur_gpx) {
500    #endif
501        /* draw all geocaches */
502        gpx_t *gpx = appdata->gpx;
503        while(gpx) {
504          map_draw_cachelist(context->widget, gpx->cache);
505          gpx = gpx->next;
506        }
507        name = g_strdup(_("all geocaches"));
508    #ifdef USE_MAEMO
509      } else {
510        map_draw_cachelist(context->widget, appdata->cur_gpx->cache);
511        name = g_strdup(appdata->cur_gpx->name);
512      }
513    #endif
514    
515      char *title = g_strdup_printf(_("Map - %s"), name);
516      g_free(name);
517    
518    #ifdef USE_MAEMO
519    #ifdef USE_STACKABLE_WINDOW
520      context->window = hildon_stackable_window_new();
521    #else
522      context->window = hildon_window_new();
523    #endif
524    #else
525      context->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
526  #endif  #endif
527    
528    gtk_box_pack_start_defaults(GTK_BOX(hbox), context.widget);    gtk_window_set_title(GTK_WINDOW(context->window), title);
529    
530    #ifndef USE_MAEMO
531      gtk_window_set_default_size(GTK_WINDOW(context->window), 640, 480);
532    #endif
533    
534      g_free(title);
535    
536      g_signal_connect(G_OBJECT(context->widget), "configure-event",
537                       G_CALLBACK(on_map_configure), context);
538    
539      g_signal_connect(G_OBJECT(context->widget), "button-press-event",
540                       G_CALLBACK(on_map_button_press_event), context);
541    
542      g_signal_connect(G_OBJECT(context->widget), "button-release-event",
543                       G_CALLBACK(on_map_button_release_event), context);
544    
545      gtk_box_pack_start_defaults(GTK_BOX(hbox), context->widget);
546    /* zoom button box */    /* zoom button box */
547    GtkWidget *vbox = gtk_vbox_new(FALSE,0);    GtkWidget *vbox = gtk_vbox_new(FALSE,0);
548    
549    context.zoomin =    context->zoomin =
550      map_add_button(GTK_STOCK_ZOOM_IN, G_CALLBACK(cb_map_zoomin),      map_add_button(10, G_CALLBACK(cb_map_zoomin),
551                     &context, _("Zoom in"));                     context, _("Zoom in"));
552    gtk_box_pack_start(GTK_BOX(vbox), context.zoomin, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomin, FALSE, FALSE, 0);
553    
554    context.zoomout =    context->zoomout =
555      map_add_button(GTK_STOCK_ZOOM_OUT, G_CALLBACK(cb_map_zoomout),      map_add_button(11, G_CALLBACK(cb_map_zoomout),
556                     &context, _("Zoom out"));                     context, _("Zoom out"));
557    gtk_box_pack_start(GTK_BOX(vbox), context.zoomout, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomout, FALSE, FALSE, 0);
558    
559    context.gps =    context->gps =
560      map_add_button(GTK_STOCK_HOME, G_CALLBACK(cb_map_gps),      map_add_button(9, G_CALLBACK(cb_map_gps),
561                     &context, _("Jump to GPS position"));                     context, _("Jump to GPS position"));
562    gtk_widget_set_sensitive(context.gps, FALSE);    gtk_widget_set_sensitive(context->gps, FALSE);
563    
564    /* install handler for timed updates of the gps button */    /* install handler for timed updates of the gps button */
565    context.handler_id = gtk_timeout_add(1000, map_gps_update, &context);    context->handler_id = gtk_timeout_add(1000, map_gps_update, context);
566    gtk_box_pack_start(GTK_BOX(vbox), context.gps, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->gps, FALSE, FALSE, 0);
567    
568    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
569    
570    gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox);  #if MAEMO_VERSION_MAJOR == 5
571      /* prevent some of the main screen things */
572    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);    context->old_view = appdata->cur_view;
573      appdata->cur_view = NULL;
574    #endif
575    
576    gtk_widget_show_all(dialog);    g_signal_connect(G_OBJECT(context->window), "destroy",
577                       G_CALLBACK(on_window_destroy), context);
578    
579    gtk_dialog_run(GTK_DIALOG(dialog));    gtk_container_add(GTK_CONTAINER(context->window), hbox);
580      gtk_widget_show_all(GTK_WIDGET(context->window));
   gtk_widget_destroy(dialog);  
   
581  }  }

Legend:
Removed from v.33  
changed lines
  Added in v.61