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

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

revision 46 by harbaum, Wed Aug 5 14:11:00 2009 UTC revision 51 by harbaum, Wed Aug 12 12:16:05 2009 UTC
# Line 24  Line 24 
24  #include "osm-gps-map.h"  #include "osm-gps-map.h"
25  #endif  #endif
26    
27    #define GPS_DEFAULT_ZOOM 13
28    
29  /* equatorial radius in meters */  /* equatorial radius in meters */
30  #define EQ_RADIUS     (6378137.0)  #define EQ_RADIUS     (6378137.0)
31    
# Line 80  static const char *get_proxy_uri(appdata Line 82  static const char *get_proxy_uri(appdata
82  }  }
83    
84  static void map_zoom(map_context_t *context, int step) {  static void map_zoom(map_context_t *context, int step) {
85    int zoom;    gint zoom;
86    OsmGpsMap *map = OSM_GPS_MAP(context->widget);    OsmGpsMap *map = OSM_GPS_MAP(context->widget);
87    g_object_get(map, "zoom", &zoom, NULL);    g_object_get(map, "zoom", &zoom, NULL);
88    zoom = osm_gps_map_set_zoom(map, zoom+step);    zoom = osm_gps_map_set_zoom(map, zoom+step);
# Line 88  static void map_zoom(map_context_t *cont Line 90  static void map_zoom(map_context_t *cont
90    /* enable/disable zoom buttons as required */    /* enable/disable zoom buttons as required */
91    gtk_widget_set_sensitive(context->zoomin, zoom<17);    gtk_widget_set_sensitive(context->zoomin, zoom<17);
92    gtk_widget_set_sensitive(context->zoomout, zoom>1);    gtk_widget_set_sensitive(context->zoomout, zoom>1);
93    
94      /* save new zoom */
95      context->appdata->map.zoom = zoom;
96  }  }
97    
98  static gboolean  static gboolean
# Line 107  cb_map_gps(GtkButton *button, map_contex Line 112  cb_map_gps(GtkButton *button, map_contex
112    pos_t *refpos = get_pos(context->appdata);    pos_t *refpos = get_pos(context->appdata);
113    if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {    if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
114      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
115                                refpos->lat, refpos->lon, 14);                        refpos->lat, refpos->lon, GPS_DEFAULT_ZOOM);
116    } else {    } else {
117      /* no coordinates given: display the entire world */      /* no coordinates given: display the entire world */
118      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
# Line 118  cb_map_gps(GtkButton *button, map_contex Line 123  cb_map_gps(GtkButton *button, map_contex
123  }  }
124    
125  static GtkWidget  static GtkWidget
126  *map_add_button(const gchar *icon, GCallback cb, gpointer data,  *map_add_button(int icon, GCallback cb, gpointer data,
127                  char *tooltip) {                  char *tooltip) {
128    GtkWidget *button = gtk_button_new();    GtkWidget *button = gtk_button_new();
129    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_BUTTON));  
130    g_signal_connect(button, "clicked", cb, data);    g_signal_connect(button, "clicked", cb, data);
131  #ifndef USE_MAEMO  #ifndef USE_MAEMO
132    gtk_widget_set_tooltip_text(button, tooltip);    gtk_widget_set_tooltip_text(button, tooltip);
# Line 133  static GtkWidget Line 137  static GtkWidget
137  static gboolean map_gps_update(gpointer data) {  static gboolean map_gps_update(gpointer data) {
138    map_context_t *context = (map_context_t*)data;    map_context_t *context = (map_context_t*)data;
139    
140      /* get reference position ... */
141    pos_t *refpos = get_pos(context->appdata);    pos_t *refpos = get_pos(context->appdata);
142    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);    gboolean ok = (refpos!= NULL) && !isnan(refpos->lat) && !isnan(refpos->lon);
143    
144    /* get reference position and go there */    /* ... and enable "goto" button if it's valid */
145    gtk_widget_set_sensitive(context->gps, ok);    gtk_widget_set_sensitive(context->gps, ok);
146    
147      if(ok) {
148        float heading = context->appdata->use_gps?
149          gps_get_heading(context->appdata):NAN;
150    
151       osm_gps_map_draw_gps(OSM_GPS_MAP(context->widget),
152                             refpos->lat, refpos->lon, heading);
153      } else
154        osm_gps_map_clear_gps(OSM_GPS_MAP(context->widget));
155    
156    return TRUE;    return TRUE;
157  }  }
158    
# Line 146  static gboolean on_map_configure(GtkWidg Line 160  static gboolean on_map_configure(GtkWidg
160                                   GdkEventConfigure *event,                                   GdkEventConfigure *event,
161                                   map_context_t *context) {                                   map_context_t *context) {
162    
163    cb_map_gps(NULL, context);    /* set default values if they are invalid */
164      if(!context->appdata->map.zoom ||
165         isnan(context->appdata->map.pos.lat) ||
166         isnan(context->appdata->map.pos.lon)) {
167        printf("no valid map position found\n");
168    
169        pos_t *refpos = get_pos(context->appdata);
170        if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
171          /* use gps position if present */
172          context->appdata->map.pos = *refpos;
173          context->appdata->map.zoom = GPS_DEFAULT_ZOOM;
174        } else {
175          /* use world map otherwise */
176          context->appdata->map.pos.lat = 0.0;
177          context->appdata->map.pos.lon = 0.0;
178          context->appdata->map.zoom = 1;
179        }
180      }
181    
182      /* jump to initial position */
183      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
184                                context->appdata->map.pos.lat,
185                                context->appdata->map.pos.lon,
186                                context->appdata->map.zoom);
187    
188    return FALSE;    return FALSE;
189  }  }
190    
# Line 169  typedef struct { Line 206  typedef struct {
206    GMainLoop *loop;    GMainLoop *loop;
207  } popup_context_t;  } popup_context_t;
208    
209    /* draw shape */
210    #define ARROW_BORDER   20
211    #define CORNER_RADIUS  10
212    
213  #ifndef USE_HILDON  #ifndef USE_MAEMO
214  #define POPUP_WIDTH  300  #define POPUP_WIDTH  300
215  #define POPUP_HEIGHT 100  #define POPUP_HEIGHT 100
216  #else  #else
217  #define POPUP_WIDTH  600  #define POPUP_WIDTH  350
218  #define POPUP_HEIGHT 200  #define POPUP_HEIGHT 120
219  #endif  #endif
220    
221  static gboolean  static gboolean
# Line 242  run_unmap_handler(GtkWindow *window, pop Line 282  run_unmap_handler(GtkWindow *window, pop
282    shutdown_loop(context);    shutdown_loop(context);
283  }  }
284    
 /* draw shape */  
 #define ARROW_BORDER   20  
 #define CORNER_RADIUS  10  
   
285  static void popup_window_shape(GtkWidget *window, int tip_x, int tip_y) {  static void popup_window_shape(GtkWidget *window, int tip_x, int tip_y) {
286    GdkBitmap *mask = gdk_pixmap_new(NULL, POPUP_WIDTH, POPUP_HEIGHT, 1);    GdkBitmap *mask = gdk_pixmap_new(NULL, POPUP_WIDTH, POPUP_HEIGHT, 1);
287    
# Line 269  static void popup_window_shape(GtkWidget Line 305  static void popup_window_shape(GtkWidget
305    gdk_gc_set_foreground(gc, &white);    gdk_gc_set_foreground(gc, &white);
306    gdk_gc_set_background(gc, &black);    gdk_gc_set_background(gc, &black);
307    
308      /* the tip is always above or below the "bubble" but never at its side */
309      guint tip_offset = (tip_y == 0)?ARROW_BORDER:0;
310    
311    gdk_draw_rectangle(mask, gc, TRUE,    gdk_draw_rectangle(mask, gc, TRUE,
312                       0, ARROW_BORDER + CORNER_RADIUS,                       0, tip_offset + CORNER_RADIUS,
313                       POPUP_WIDTH,                       POPUP_WIDTH,
314                       POPUP_HEIGHT - 2*CORNER_RADIUS - 2*ARROW_BORDER);                       POPUP_HEIGHT - 2*CORNER_RADIUS - ARROW_BORDER);
315    
316    gdk_draw_rectangle(mask, gc, TRUE,    gdk_draw_rectangle(mask, gc, TRUE,
317                       CORNER_RADIUS, ARROW_BORDER,                       CORNER_RADIUS, tip_offset,
318                       POPUP_WIDTH  - 2*CORNER_RADIUS,                       POPUP_WIDTH  - 2*CORNER_RADIUS,
319                       POPUP_HEIGHT - 2*ARROW_BORDER);                       POPUP_HEIGHT - ARROW_BORDER);
320    
321    int off[][2] = {    int off[][2] = {
322            { CORNER_RADIUS, ARROW_BORDER + CORNER_RADIUS },            { CORNER_RADIUS,               tip_offset + CORNER_RADIUS },
323            { POPUP_WIDTH - CORNER_RADIUS,            { POPUP_WIDTH - CORNER_RADIUS, tip_offset + CORNER_RADIUS },
             ARROW_BORDER + CORNER_RADIUS },  
324            { POPUP_WIDTH - CORNER_RADIUS,            { POPUP_WIDTH - CORNER_RADIUS,
325              POPUP_HEIGHT - CORNER_RADIUS - ARROW_BORDER },              POPUP_HEIGHT - CORNER_RADIUS - ARROW_BORDER + tip_offset},
326            { CORNER_RADIUS,            { CORNER_RADIUS,
327              POPUP_HEIGHT - CORNER_RADIUS  - ARROW_BORDER}};              POPUP_HEIGHT - CORNER_RADIUS  - ARROW_BORDER + tip_offset}};
328    
329    int i;    int i;
330    for(i=0;i<4;i++) {    for(i=0;i<4;i++) {
# Line 305  static void popup_window_shape(GtkWidget Line 343  static void popup_window_shape(GtkWidget
343    gdk_window_shape_combine_mask(window->window, mask, 0, 0);    gdk_window_shape_combine_mask(window->window, mask, 0, 0);
344  }  }
345    
346    /* create a left aligned label (normal ones are centered) */
347    static GtkWidget *gtk_label_left_new(char *str) {
348      GtkWidget *label = gtk_label_new(str);
349      gtk_misc_set_alignment(GTK_MISC(label), 0.f, .5f);
350      return label;
351    }
352    
353    /* the small labels are actually only on maemo small */
354    #ifdef USE_MAEMO
355    #define MARKUP_SMALL "<span size='small'>%s</span>"
356    GtkWidget *gtk_label_small_left_new(char *str) {
357      GtkWidget *label = gtk_label_new("");
358      char *markup = g_markup_printf_escaped(MARKUP_SMALL, str);
359      gtk_label_set_markup(GTK_LABEL(label), markup);
360      g_free(markup);
361      gtk_misc_set_alignment(GTK_MISC(label), 0.f, .5f);
362      return label;
363    }
364    #define gtk_label_big_left_new(a) gtk_label_left_new(a)
365    #else
366    #define gtk_label_small_left_new(a) gtk_label_left_new(a)
367    #define MARKUP_BIG "<span size='x-large'>%s</span>"
368    GtkWidget *gtk_label_big_left_new(char *str) {
369      GtkWidget *label = gtk_label_new("");
370      char *markup = g_markup_printf_escaped(MARKUP_BIG, str);
371      gtk_label_set_markup(GTK_LABEL(label), markup);
372      g_free(markup);
373      gtk_misc_set_alignment(GTK_MISC(label), 0.f, .5f);
374      return label;
375    }
376    #endif
377    
378  void cache_popup(map_context_t *mcontext, cache_t *cache) {  void cache_popup(map_context_t *mcontext, cache_t *cache) {
379    popup_context_t pcontext;    popup_context_t pcontext;
380    pcontext.appdata = mcontext->appdata;    pcontext.appdata = mcontext->appdata;
# Line 345  void cache_popup(map_context_t *mcontext Line 415  void cache_popup(map_context_t *mcontext
415                                     cache->pos.lat, cache->pos.lon,                                     cache->pos.lat, cache->pos.lon,
416                                     &sx, &sy);                                     &sx, &sy);
417    
   printf("screen pos %d/%d\n", sx, sy);  
   
418    gdk_window_get_origin(mcontext->widget->window, &x, &y);    gdk_window_get_origin(mcontext->widget->window, &x, &y);
   printf("window = %d/%d +%d+%d %d*%d\n", x, y,  
          mcontext->widget->allocation.x,  
          mcontext->widget->allocation.y,  
          mcontext->widget->allocation.width,  
          mcontext->widget->allocation.height  
          );  
419    
420    gint ax = 0, ay = 0;    gint ax = 0, ay = 0;
421    if(sx > mcontext->widget->allocation.width/2)    if(sx > mcontext->widget->allocation.width/2)
# Line 362  void cache_popup(map_context_t *mcontext Line 424  void cache_popup(map_context_t *mcontext
424    if(sy > mcontext->widget->allocation.height/2)    if(sy > mcontext->widget->allocation.height/2)
425      ay = POPUP_HEIGHT;      ay = POPUP_HEIGHT;
426    
427  #if !defined(USE_HILDON) || (MAEMO_VERSION_MAJOR < 5)  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
428    GdkColor color;    GdkColor color;
429    gdk_color_parse("darkgray", &color);    gdk_color_parse("darkgray", &color);
430    gtk_widget_modify_bg(GTK_WIDGET(pcontext.window), GTK_STATE_NORMAL, &color);    gtk_widget_modify_bg(GTK_WIDGET(pcontext.window), GTK_STATE_NORMAL, &color);
# Line 373  void cache_popup(map_context_t *mcontext Line 435  void cache_popup(map_context_t *mcontext
435                    y + mcontext->widget->allocation.y + sy - ay);                    y + mcontext->widget->allocation.y + sy - ay);
436    
437    
438    GtkWidget *frame = gtk_frame_new(NULL);    GtkWidget *alignment = gtk_alignment_new(0.5, 0.5, 1.0, 1.0);
439    gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);    gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
440    gtk_container_set_border_width(GTK_CONTAINER(frame),                              CORNER_RADIUS/2 + (ay?0:ARROW_BORDER),
441                                   ARROW_BORDER+CORNER_RADIUS);                              CORNER_RADIUS/2 + (ay?ARROW_BORDER:0),
442    gtk_container_add(GTK_CONTAINER(frame),                              CORNER_RADIUS, CORNER_RADIUS);
443                      gtk_button_new_with_label(cache->name));  
444      /* --- actual content ---- */
445      GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
446    
447    gtk_container_add(GTK_CONTAINER(pcontext.window), frame);    if(cache->id) {
448        GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
449    
450        gtk_box_pack_start(GTK_BOX(ihbox),
451           icon_get_widget(ICON_CACHE_TYPE, cache->type),
452           FALSE, FALSE, 5);
453    
454        gtk_box_pack_start_defaults(GTK_BOX(ihbox),
455                    gtk_label_big_left_new(cache->id));
456    
457        gtk_box_pack_start_defaults(GTK_BOX(vbox), ihbox);
458      }
459    
460      if(cache->name) {
461        GtkWidget *label = gtk_label_small_left_new(cache->name);
462        gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
463        gtk_box_pack_start_defaults(GTK_BOX(vbox), label);
464      }
465    
466      GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
467      if(cache->terrain) {
468        GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
469        gtk_box_pack_start(GTK_BOX(ihbox),
470           gtk_label_small_left_new(_("Terrain:")), FALSE, FALSE, 0);
471        gtk_box_pack_start(GTK_BOX(ihbox),
472           icon_get_widget(ICON_STARS, (int)(cache->terrain*2-2)),
473           FALSE, FALSE, 5);
474        gtk_box_pack_start_defaults(GTK_BOX(hbox), ihbox);
475      }
476    
477      if(cache->difficulty) {
478        GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
479        gtk_box_pack_start(GTK_BOX(ihbox),
480           gtk_label_small_left_new(_("Difficulty:")), FALSE, FALSE, 0);
481        gtk_box_pack_start(GTK_BOX(ihbox),
482           icon_get_widget(ICON_STARS, (int)(cache->difficulty*2-2)),
483           FALSE, FALSE, 5);
484        gtk_box_pack_start_defaults(GTK_BOX(hbox), ihbox);
485      }
486    
487      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
488    
489      gtk_container_add(GTK_CONTAINER(alignment), vbox);
490      /* ----------------------- */
491    
492    
493      gtk_container_add(GTK_CONTAINER(pcontext.window), alignment);
494    
495    /* --------- give the window its shape ----------- */    /* give window its shape */
496    popup_window_shape(pcontext.window, ax, ay);    popup_window_shape(pcontext.window, ax, ay);
497    
498    gtk_widget_show_all(pcontext.window);    gtk_widget_show_all(pcontext.window);
# Line 449  pos_t coord2pos(coord_t coo) { Line 559  pos_t coord2pos(coord_t coo) {
559  }  }
560    
561  static int dist2pixel(map_context_t *context, float km, float lat) {  static int dist2pixel(map_context_t *context, float km, float lat) {
562    int zoom;    gint zoom;
563    g_object_get(OSM_GPS_MAP(context->widget), "zoom", &zoom, NULL);    g_object_get(OSM_GPS_MAP(context->widget), "zoom", &zoom, NULL);
564    
565    /* world at zoom 1 == 512 pixels */    /* world at zoom 1 == 512 pixels */
# Line 459  static int dist2pixel(map_context_t *con Line 569  static int dist2pixel(map_context_t *con
569    return 1000.0*km/m_per_pix;    return 1000.0*km/m_per_pix;
570  }  }
571    
572  #define CLICK_FUZZ (16)  #define CLICK_FUZZ (24)
573    
574  static gboolean  static gboolean
575  on_map_button_press_event(GtkWidget *widget,  on_map_button_press_event(GtkWidget *widget,
# Line 488  on_map_button_press_event(GtkWidget *wid Line 598  on_map_button_press_event(GtkWidget *wid
598  static gboolean  static gboolean
599  on_map_button_release_event(GtkWidget *widget,  on_map_button_release_event(GtkWidget *widget,
600                              GdkEventButton *event, map_context_t *context) {                              GdkEventButton *event, map_context_t *context) {
601    if(context->press_on) {    OsmGpsMap *map = OSM_GPS_MAP(context->widget);
     OsmGpsMap *map = OSM_GPS_MAP(context->widget);  
602    
603      if(context->press_on) {
604      pos_t pos =      pos_t pos =
605        coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));        coord2pos(osm_gps_map_get_co_ordinates(map, event->x, event->y));
606    
# Line 501  on_map_button_release_event(GtkWidget *w Line 611  on_map_button_release_event(GtkWidget *w
611          cache_popup(context, nearest);          cache_popup(context, nearest);
612      }      }
613      context->press_on = NULL;      context->press_on = NULL;
614      } else {
615        /* save new map position */
616        gfloat lat, lon;
617        g_object_get(map, "latitude", &lat, "longitude", &lon, NULL);
618        context->appdata->map.pos.lat = lat;
619        context->appdata->map.pos.lon = lon;
620    }    }
621    
622    return FALSE;    return FALSE;
623  }  }
624    
625    static void save_map_state(map_context_t *context) {
626      /* save map parameters */
627      OsmGpsMap *map = OSM_GPS_MAP(context->widget);
628      gint zoom;
629      g_object_get(map, "zoom", &zoom, NULL);
630      context->appdata->map.zoom = zoom;
631    
632      gfloat lat, lon;
633      g_object_get(map, "latitude", &lat, "longitude", &lon, NULL);
634      context->appdata->map.pos.lat = lat;
635      context->appdata->map.pos.lon = lon;
636    }
637    
638  #if MAEMO_VERSION_MAJOR == 5  #if MAEMO_VERSION_MAJOR == 5
639  static void on_window_destroy(GtkWidget *widget, map_context_t *context) {  static void on_window_destroy(GtkWidget *widget, map_context_t *context) {
640    printf("destroy map view\n");    printf("destroy map view\n");
641    
642      save_map_state(context);
643    
644    /* restore cur_view */    /* restore cur_view */
645    context->appdata->cur_view = context->old_view;    context->appdata->cur_view = context->old_view;
646    
# Line 529  void map(appdata_t *appdata) { Line 659  void map(appdata_t *appdata) {
659    const char *proxy = get_proxy_uri(appdata);    const char *proxy = get_proxy_uri(appdata);
660    
661    context->widget = g_object_new(OSM_TYPE_GPS_MAP,    context->widget = g_object_new(OSM_TYPE_GPS_MAP,
662                  "repo-uri", MAP_SOURCE_OPENSTREETMAP,                   "repo-uri",             MAP_SOURCE_OPENSTREETMAP,
663                  "tile-cache", path,                   "tile-cache",           path,
664                  proxy?"proxy-uri":NULL, proxy,                   "auto-center",          FALSE,
665                     "record-trip-history",  FALSE,
666                     "show-trip-history",    FALSE,
667                   NULL);                   NULL);
668    
669      if(proxy)
670        g_object_set(OSM_GPS_MAP(context->widget),
671                     "proxy-uri", proxy, NULL);
672    
673    g_free(path);    g_free(path);
674    
675    char *name = NULL;    char *name = NULL;
# Line 590  void map(appdata_t *appdata) { Line 726  void map(appdata_t *appdata) {
726    GtkWidget *vbox = gtk_vbox_new(FALSE,0);    GtkWidget *vbox = gtk_vbox_new(FALSE,0);
727    
728    context->zoomin =    context->zoomin =
729      map_add_button(GTK_STOCK_ZOOM_IN, G_CALLBACK(cb_map_zoomin),      map_add_button(10, G_CALLBACK(cb_map_zoomin),
730                     context, _("Zoom in"));                     context, _("Zoom in"));
731    gtk_box_pack_start(GTK_BOX(vbox), context->zoomin, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomin, FALSE, FALSE, 0);
732    
733    context->zoomout =    context->zoomout =
734      map_add_button(GTK_STOCK_ZOOM_OUT, G_CALLBACK(cb_map_zoomout),      map_add_button(11, G_CALLBACK(cb_map_zoomout),
735                     context, _("Zoom out"));                     context, _("Zoom out"));
736    gtk_box_pack_start(GTK_BOX(vbox), context->zoomout, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), context->zoomout, FALSE, FALSE, 0);
737    
738    context->gps =    context->gps =
739      map_add_button(GTK_STOCK_HOME, G_CALLBACK(cb_map_gps),      map_add_button(9, G_CALLBACK(cb_map_gps),
740                     context, _("Jump to GPS position"));                     context, _("Jump to GPS position"));
741    gtk_widget_set_sensitive(context->gps, FALSE);    gtk_widget_set_sensitive(context->gps, FALSE);
742    /* install handler for timed updates of the gps button */    /* install handler for timed updates of the gps button */
# Line 625  void map(appdata_t *appdata) { Line 761  void map(appdata_t *appdata) {
761    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);
762    gtk_widget_show_all(dialog);    gtk_widget_show_all(dialog);
763    gtk_dialog_run(GTK_DIALOG(dialog));    gtk_dialog_run(GTK_DIALOG(dialog));
764      save_map_state(context);
765    gtk_timeout_remove(context->handler_id);    gtk_timeout_remove(context->handler_id);
766    gtk_widget_destroy(dialog);    gtk_widget_destroy(dialog);
767    g_free(context);    g_free(context);

Legend:
Removed from v.46  
changed lines
  Added in v.51