From 377e1b01c17dbd5831d81333dcdef8a1ac41857c Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 16 Jul 2008 16:38:50 +0300 Subject: [PATCH] MapWidget: add gtk_map_goto_position() function to set center from a Position --- libs/libgtkmap/gtkmap.c | 20 ++++++++++++++++++++ libs/libgtkmap/gtkmap.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/libs/libgtkmap/gtkmap.c b/libs/libgtkmap/gtkmap.c index 98ab2f2..8fcaf7b 100644 --- a/libs/libgtkmap/gtkmap.c +++ b/libs/libgtkmap/gtkmap.c @@ -2045,6 +2045,26 @@ priv=GTK_MAP_GET_PRIVATE(map); unit2latlon(priv->center.unitx, priv->center.unity, lat, lon); } +/** + * gtk_map_goto_position: + * @pos: A Position to center on + * + * Centers map view on given Position if it's valid. + * + * Returns TRUE if Position was valid and view was centered. FALSE otherwise. + */ +gboolean +gtk_map_goto_position(GtkWidget *widget, Position *pos) +{ +g_return_if_fail(GTK_IS_MAP(widget)); +g_return_if_fail(pos); + +if (pos->valid==FALSE) + return FALSE; +gtk_map_set_center_latlon(widget, pos->lat, pos->lon); +return TRUE; +} + /** * gtk_map_pan: * @delta_x: diff --git a/libs/libgtkmap/gtkmap.h b/libs/libgtkmap/gtkmap.h index 3c85199..0b85ab1 100644 --- a/libs/libgtkmap/gtkmap.h +++ b/libs/libgtkmap/gtkmap.h @@ -145,6 +145,8 @@ void gtk_map_get_center(GtkWidget *map, guint *unitx, guint *unity); void gtk_map_set_center_latlon(GtkWidget *map, gdouble lat, gdouble lon); void gtk_map_get_center_latlon(GtkWidget *map, gdouble *lat, gdouble *lon); +gboolean gtk_map_goto_position(GtkWidget *widget, Position *pos); + gboolean gtk_map_set_center_mode(GtkWidget *widget, GtkMapCenterMode mode); GtkMapCenterMode gtk_map_get_center_mode(GtkWidget *widget); -- 2.39.5