From: Kaj-Michael Lang Date: Mon, 4 Aug 2008 08:23:09 +0000 (+0300) Subject: MapWidget: Some cleanups and warning fixes X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7614560cb523749452658322bf149757b26dea6b;p=mapper MapWidget: Some cleanups and warning fixes --- diff --git a/libs/libgtkmap/gtkmap.c b/libs/libgtkmap/gtkmap.c index 7e20020..1ed9887 100644 --- a/libs/libgtkmap/gtkmap.c +++ b/libs/libgtkmap/gtkmap.c @@ -1067,7 +1067,7 @@ return TRUE; } static void -gtk_map_render_waypoint(GtkWidget *widget, guint x1, guint y1) +gtk_map_render_waypoint(GtkWidget *widget, guint x, guint y) { GtkMap *map; GtkMapPriv *priv; @@ -1080,11 +1080,22 @@ priv=GTK_MAP_GET_PRIVATE(map); gc=priv->gc_waypoint; -if ((x1 > priv->buf_width_pixels) || (y1 > priv->buf_height_pixels)) +if ((x > priv->buf_width_pixels) || (y > priv->buf_height_pixels)) return; -gdk_draw_arc(widget->window, gc, FALSE, x1 - priv->draw_width, y1 - priv->draw_width, 2 * priv->draw_width, 2 * priv->draw_width, 0, 360 * 64); + +gdk_draw_arc(widget->window, gc, FALSE, x - priv->draw_width, y - priv->draw_width, 2 * priv->draw_width, 2 * priv->draw_width, 0, 360 * 64); } +/** + * gtk_map_render_path_segment: + * @widget + * @unitx1 + * @unity1 + * @unitx2 + * @unity2 + * + * Draw a path segment from unitx/y1 to unitx/y2 + */ static void gtk_map_render_path_segment(GtkWidget *widget, guint unitx1, guint unity1, guint unitx2, guint unity2) { @@ -1111,6 +1122,13 @@ if (!((x1 > priv->buf_width_pixels && x2 > priv->buf_width_pixels) || (x1 < 0 && } } +/** + * gtk_map_render_path: + * @widget + * @path + * @event + * + */ static void gtk_map_render_path(GtkWidget *widget, Path *path, GdkEventExpose *event) { @@ -1128,15 +1146,19 @@ map=GTK_MAP(widget); priv=GTK_MAP_GET_PRIVATE(map); for (curr = path->head, wcurr = path->whead; curr++ != path->tail;) { - /* Draw the line from (curr - 1) to (curr). */ + /* Draw the line from (curr - 1) to (curr). */ gtk_map_render_path_segment(widget, curr[-1].unitx, curr[-1].unity, curr->unitx, curr->unity); + /* Now, check if curr is a waypoint. */ if (wcurr && wcurr <= path->wtail && wcurr->point == curr) { - guint x1 = unit2bufx(wcurr->point->unitx); - guint y1 = unit2bufy(wcurr->point->unity); + guint wx; + guint wy; + + wx=unit2bufx(wcurr->point->unitx); + wy=unit2bufy(wcurr->point->unity); - gtk_map_render_waypoint(widget, x1, y1); + gtk_map_render_waypoint(widget, wx, wy); wcurr++; } } @@ -2071,7 +2093,7 @@ if (new_base_tilex != priv->base_tilex || new_base_tiley != priv->base_tiley) { GTK_MAP_TILE_SIZE_PIXELS, GTK_MAP_TILE_SIZE_PIXELS); } else { - gtk_map_render_tile(GTK_MAP(map), + gtk_map_render_tile(widget, new_base_tilex + new_x, new_base_tiley + new_y, new_x * GTK_MAP_TILE_SIZE_PIXELS, @@ -2136,8 +2158,8 @@ unit2latlon(priv->center.unitx, priv->center.unity, lat, lon); gboolean gtk_map_goto_position(GtkWidget *widget, Position *pos) { -g_return_if_fail(GTK_IS_MAP(widget)); -g_return_if_fail(pos); +g_return_val_if_fail(GTK_IS_MAP(widget), FALSE); +g_return_val_if_fail(pos, FALSE); if (pos->valid==FALSE) return FALSE; @@ -2219,7 +2241,7 @@ priv=GTK_MAP_GET_PRIVATE(map); for (y = 0; y < priv->buf_height_tiles; ++y) for (x = 0; x < priv->buf_width_tiles; ++x) - gtk_map_render_tile(map, priv->base_tilex + x, priv->base_tiley + y, x * GTK_MAP_TILE_SIZE_PIXELS, y * GTK_MAP_TILE_SIZE_PIXELS, FALSE); + gtk_map_render_tile(widget, priv->base_tilex + x, priv->base_tiley + y, x * GTK_MAP_TILE_SIZE_PIXELS, y * GTK_MAP_TILE_SIZE_PIXELS, FALSE); gtk_widget_queue_draw(widget); } @@ -2258,6 +2280,11 @@ gtk_map_set_autozoom(GtkWidget *widget, gboolean az) GtkMap *map; GtkMapPriv *priv; +g_return_val_if_fail(GTK_IS_MAP(widget), FALSE); + +map=GTK_MAP(widget); +priv=GTK_MAP_GET_PRIVATE(map); + /* Check that we have a track path set */ return TRUE; }