ChamplainPoint *point = champlain_point_new (lat, lon);
self->priv->points = g_list_append (self->priv->points, point);
+ g_object_notify (G_OBJECT (self), "visible");
return point;
}
ChamplainPoint *point = champlain_point_new (lat, lon);
self->priv->points = g_list_insert (self->priv->points, point, pos);
+ g_object_notify (G_OBJECT (self), "visible");
return point;
}
next = g_list_next (next);
}
g_list_free (self->priv->points);
+ g_object_notify (G_OBJECT (self), "visible");
}
/**
gdouble from_longitude;
} GoToContext;
+typedef struct {
+ ChamplainView *view;
+ ChamplainPolygon *polygon;
+} PolygonRedrawContext;
+
struct _ChamplainViewPrivate
{
ClutterActor *stage;
/* champlain_view_go_to's context, kept for stop_go_to */
GoToContext *goto_context;
+ /* notify_polygon_cb's context, kept for idle cb */
+ guint polygon_redraw_id;
+
/* Lines and shapes */
GList *polygons;
ClutterActor *polygon_layer; /* Contains the polygons */
cairo_destroy (cr);
}
+static gboolean
+redraw_polygon_on_idle (PolygonRedrawContext *ctx)
+{
+ draw_polygon (ctx->view, ctx->polygon);
+ ctx->view->priv->polygon_redraw_id = 0;
+ // ctx is freed by g_idle_add_full
+ return FALSE;
+}
+
static void
-notify_polygon_visible_cb (ChamplainPolygon *polygon,
+notify_polygon_cb (ChamplainPolygon *polygon,
GParamSpec *arg1,
ChamplainView *view)
{
- draw_polygon (view, polygon);
+ PolygonRedrawContext *ctx;
+
+ if (view->priv->polygon_redraw_id != 0)
+ return;
+
+ ctx = g_new0 (PolygonRedrawContext, 1);
+ ctx->view = view;
+ ctx->polygon = polygon;
+
+ view->priv->polygon_redraw_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) redraw_polygon_on_idle, ctx, g_free);
}
static void
priv->longitude = 0.0f;
priv->goto_context = NULL;
priv->map = NULL;
+ priv->polygon_redraw_id = 0;
/* Setup viewport */
priv->viewport = g_object_ref (tidy_viewport_new ());
view->priv->polygons = g_list_append (view->priv->polygons, g_object_ref (polygon));
- g_signal_connect (polygon, "notify::visible",
- G_CALLBACK (notify_polygon_visible_cb), view);
+ g_signal_connect (polygon, "notify",
+ G_CALLBACK (notify_polygon_cb), view);
if (view->priv->viewport_size.width == 0 ||
view->priv->viewport_size.height == 0)