[FOSS-GPS] Instance-IDs for osm-gps-map's `image' API

Joshua Judson Rosen rozzin at geekspace.com
Fri May 21 09:44:02 EDT 2010


John Stowers <john.stowers.lists at gmail.com> writes:
> On Thu, May 20, 2010 at 5:14 PM, Joshua Judson Rosen <rozzin at geekspace.com>
> wrote:
> >
> > 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).
[...]
> Looking over the patch, I wonder if this implementation is flexible
> enough, while not making the API too confusing, for the behavior you
> are trying to enable (removing either a single poi/image, or a whole
> group of pois/images).
> 
> The limitation appears to be the assumption that the same pixbuf be
> used as a handle for a group of pois/images. Is this something that is
> useful/true in practice or will the app still need to keep around the
> pointer to each added poi/image anyway (in which case we might as well
> keep the implementation simple, and thus remove() only accepts the
> opaque pointer)
> 
> What do you think?

Speaking only for FoxtrotGPS, I have a patch that I'm going to want to
integrate at some point that enables distinct items in the same general class
(e.g.: different POIs) to have have different icons; so we're ultimately
not going to find much use in osm-gps-map's current remove_image() behaviour.

For maximal flexibility, I'd probably also add a `user_data' member
to image_t, add an add_image_with_data() function that associates
its `data' argument with the newly_created image_t, make add_image()
associate the newly-created image_t with *itself* and return the same
pointer; then you can drop the old GdkPixbuf argument from remove_image().
It'd also be good to add a foreach_image() function that can be used to
to iterate over all of the images with at least a 2-argument (key, userparm)
callback like they have in various places in GLib and GTK+.

A patch would, of course be a better illustration of what I'm talking about,
but I'm on my way out to work right now; I can put one together tonight,
though.

I don't know about osm_gps_map_add_image_with_alignment(); maybe
it's complicated enough already that nobody would even notice
another argument?

-- 
"Don't be afraid to ask (λf.((λx.xx) (λr.f(rr))))."


More information about the FOSS-GPS mailing list