+}
+
+
+/* Constructors */
+/**
+ * grits_marker_new:
+ * @label: a short description of the marker
+ *
+ * Create a new GritsMarker which shows the given label when drawn.
+ *
+ * Returns: the new #GritsMarker.
+ */
+GritsMarker *grits_marker_new(const gchar *label)
+{
+ GritsMarker *marker = g_object_new(GRITS_TYPE_MARKER, NULL);
+
+ marker->display_mask = GRITS_MARKER_DMASK_POINT |
+ GRITS_MARKER_DMASK_LABEL;
+
+ //g_debug("GritsMarker: new - %s", label);
+ /* specify size of point and size of surface */
+ marker->outline = 2;
+ marker->radius = 3;
+ marker->width = 128;
+ marker->height = 32;
+ marker->icon_width = marker->radius * 2;
+ marker->icon_height = marker->radius * 3;
+
+ marker->xoff = marker->radius+marker->outline;
+ marker->yoff = marker->height-(marker->radius+marker->outline);
+ marker->cairo = cairo_create(cairo_image_surface_create(
+ CAIRO_FORMAT_ARGB32, marker->width, marker->height));
+
+ marker->label = g_strdup(label);
+
+ render_all(marker);
+
+ return marker;
+}
+
+/**
+ * grits_marker_icon_new:
+ * @label: The label to display if GRITS_MARKER_DMASK_LABEL is set
+ * @filename: The filename of the icon
+ * @angle: The angle to rotate the icon (0 is north)
+ * @flip: Whether to flip the image so that it's never upside down.
+ * Useful for non-symmetric icons which have an "up".
+ * @display_mask: A bitmask which specifies which items to display.
+ *
+ * Create a new marker with a label, point, icon (png), or any
+ * combination of the above.
+ *
+ * Returns: the new #GritsMarker
+ */
+GritsMarker *grits_marker_icon_new(const gchar *label, const gchar *filename,
+ guint angle, gboolean flip, guint display_mask)
+{
+ GritsMarker *marker = g_object_new(GRITS_TYPE_MARKER, NULL);
+
+ marker->label = g_strdup(label);
+ marker->angle = angle;
+ marker->flip = flip;
+ marker->display_mask = display_mask;
+
+ if (display_mask & GRITS_MARKER_DMASK_ICON) {
+ g_assert(filename != NULL);
+ g_debug("GritsMarker: marker_icon_new - marker image %s",
+ filename);
+ marker->icon_img = cairo_image_surface_create_from_png(filename);
+ if (cairo_surface_status(marker->icon_img)) {
+ g_warning("GritsMarker: marker_icon_new - "
+ "error reading file %s", filename);
+ /* convert it to a point, better than nothing */
+ marker->display_mask &= ~GRITS_MARKER_DMASK_ICON;
+ marker->display_mask |= GRITS_MARKER_DMASK_POINT;
+ marker->icon_width = 4;
+ marker->icon_height = 8;
+
+ } else {
+ marker->icon_width =
+ cairo_image_surface_get_width(marker->icon_img);
+ marker->icon_height =
+ cairo_image_surface_get_height(marker->icon_img);
+ }
+ } else {
+ marker->icon_img = NULL;
+ marker->icon_width = 4; /* room for the point if there is one */
+ marker->icon_height = 8;
+ }
+ g_debug("GritsMarker: marker_icon_new - width = %d, height = %d",
+ marker->icon_width, marker->icon_height);
+
+ marker->outline = 2;
+ marker->radius = 3;
+ /* this is the surface size, a guess really */
+ marker->width = marker->icon_width + 128;
+ marker->height = marker->icon_height + 64;
+
+ marker->xoff = marker->width/2;
+ marker->yoff = marker->height/2;
+ marker->cairo = cairo_create(cairo_image_surface_create(
+ CAIRO_FORMAT_ARGB32, marker->width, marker->height));
+ /* clear the surface just in case */
+ cairo_set_operator(marker->cairo, CAIRO_OPERATOR_SOURCE);
+ //cairo_set_source_rgba(marker->cairo, 1.0, 0.0, 0.0, 0.3); // debug
+ cairo_set_source_rgba(marker->cairo, 1.0, 0.0, 0.0, 0.0);
+ cairo_paint(marker->cairo);
+ cairo_set_operator(marker->cairo, CAIRO_OPERATOR_OVER);
+
+ render_all(marker);
+
+ if (marker->icon_img)
+ cairo_surface_destroy(marker->icon_img);