John Stowers <[email protected]> writes: > > > > Yes, a patch for this would be great. It would also be worthwhile to > > > rename the functions to osm_gps_map_poi_{add,remove} to match the work > > > going on in the tracks-rework / gtk-3.0 branch. > > > > Please no, keep it generic! I think the _image interface is more > > then enough (once it uses opaque pointers) to handle POIs and > > anything else that might be rendered this way. So don't make it > > POI specific please! > > Good point. I had overlooked this. The image/poi stuff should be the > same API (excepting for the opaque pointer change)
Indeed--not just the interface, but the implementation would also be identical. Ideally, I'd suggest just adding the extra argument to osm_gps_map_image_remove(), and changing the osm_gps_image_add() so that it returns its image_t pointer as the opaque identifier (cf. attached patch). The only reasons that I suggested a new function with "poi" in the name were that I wasn't sure you were ready to break backward-compatibility, and I couldn't think of a better term for a `specific instance of an image associated with a distinct point' (or `specific image-bearing point in which client code is interested') than "POI" :) -- "Don't be afraid to ask (λf.((λx.xx) (λr.f(rr))))."
>From 99ccba69fe38944446e3d5762652bcfbb9d8e337 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen <[email protected]> Date: Thu, 20 May 2010 00:36:53 -0400 Subject: [PATCH] Include instance-identifiers in the `image' API. A specific image-instance is identified by an opaque pointer, returned from osm_gps_map_add_image() and which can be passed to osm_gps_remove_image() to specify which image-instance to remove. When calling osm_gps_remove_image(), NULL arguments are taken as meaning `unspecified'. If both arguments are given as non-NULL, then the specified instance is removed only if it is an instance of the specified GdkPixbuf. If osm_gps_map_remove_image() is called with a NULL instance-ID, the traditional behaviour of removing an unspecified instance of the given GdkPixbuf is used. If the GdkPixbuf argument is NULL, then the specified instance is removed regardless of its pixbuf. If both arguments are NULL, then an unspecified image is removed. --- python/osmgpsmap.defs | 3 ++- src/osm-gps-map.c | 18 +++++++++++------- src/osm-gps-map.h | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/python/osmgpsmap.defs b/python/osmgpsmap.defs index 079304a..ea9c391 100644 --- a/python/osmgpsmap.defs +++ b/python/osmgpsmap.defs @@ -192,7 +192,7 @@ (define-method add_image (of-object "OsmGpsMap") (c-name "osm_gps_map_add_image") - (return-type "none") + (return-type "gsize") (parameters '("float" "latitude") '("float" "longitude") @@ -206,6 +206,7 @@ (return-type "gboolean") (parameters '("GdkPixbuf*" "image") + '("gsize" "instance_id" (default "0")) ) ) diff --git a/src/osm-gps-map.c b/src/osm-gps-map.c index aea9e0b..5583266 100644 --- a/src/osm-gps-map.c +++ b/src/osm-gps-map.c @@ -2637,14 +2637,15 @@ osm_gps_map_clear_tracks (OsmGpsMap *map) osm_gps_map_map_redraw_idle(map); } -void +gpointer osm_gps_map_add_image_with_alignment (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image, float xalign, float yalign) { - g_return_if_fail (OSM_IS_GPS_MAP (map)); + image_t *im = NULL; + + g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL); if (image) { OsmGpsMapPrivate *priv = map->priv; - image_t *im; //cache w/h for speed, and add image to list im = g_new0(image_t,1); @@ -2664,16 +2665,18 @@ osm_gps_map_add_image_with_alignment (OsmGpsMap *map, float latitude, float long osm_gps_map_map_redraw_idle(map); } + + return im; } -void +gpointer osm_gps_map_add_image (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image) { - osm_gps_map_add_image_with_alignment (map, latitude, longitude, image, 0.5, 0.5); + return osm_gps_map_add_image_with_alignment (map, latitude, longitude, image, 0.5, 0.5); } gboolean -osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image) +osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image, gpointer instance) { OsmGpsMapPrivate *priv = map->priv; if (priv->images) { @@ -2681,7 +2684,8 @@ osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image) for(list = priv->images; list != NULL; list = list->next) { image_t *im = list->data; - if (im->image == image) + if ((instance == NULL || im == instance) && + (image == NULL || im->image == image)) { priv->images = g_slist_remove_link(priv->images, list); g_object_unref(im->image); diff --git a/src/osm-gps-map.h b/src/osm-gps-map.h index 704e720..2fbd3da 100644 --- a/src/osm-gps-map.h +++ b/src/osm-gps-map.h @@ -122,9 +122,9 @@ int osm_gps_map_zoom_out (OsmGpsMap *map); void osm_gps_map_add_track (OsmGpsMap *map, GSList *track); void osm_gps_map_replace_track (OsmGpsMap *map, GSList *old_track, GSList *new_track); void osm_gps_map_clear_tracks (OsmGpsMap *map); -void osm_gps_map_add_image (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image); -void osm_gps_map_add_image_with_alignment (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image, float xalign, float yalign); -gboolean osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image); +gpointer osm_gps_map_add_image (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image); +gpointer osm_gps_map_add_image_with_alignment (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image, float xalign, float yalign); +gboolean osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image, gpointer instance_id); void osm_gps_map_clear_images (OsmGpsMap *map); void osm_gps_map_draw_gps (OsmGpsMap *map, float latitude, float longitude, float heading); void osm_gps_map_clear_gps (OsmGpsMap *map); -- 1.5.6.5
_______________________________________________ This message is sent to you from [email protected] mailing list. Visit http://lists.osgeo.org/mailman/listinfo/foss-gps to manage your subscription For more information, check http://wiki.osgeo.org/wiki/FOSS-GPS
