From: Pierre-Luc Beaudoin Date: Sat, 10 Jan 2009 20:48:40 +0000 (+0200) Subject: Merge a patch from Lorenzo Masini to add a ChamplainMarker constructor X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f412908f9efaedb93bd35b33755faca3b88fa1a2;p=libchamplain Merge a patch from Lorenzo Masini to add a ChamplainMarker constructor --- diff --git a/champlain/champlainmarker.c b/champlain/champlainmarker.c index 8170b7f..d9bdf76 100644 --- a/champlain/champlainmarker.c +++ b/champlain/champlainmarker.c @@ -277,3 +277,64 @@ champlain_marker_new_with_label (const gchar *label, return CLUTTER_ACTOR (champlainMarker); } +/** + * champlain_marker_new_with_image: + * @filename: The filename of the image. + * @error: Return location for an error. + * + * Returns a new #ChamplainMarker with a drawn marker containing the given image. + * + */ +ClutterActor * +champlain_marker_new_with_image(const gchar *filename, GError **error) +{ + if (filename == NULL) + return NULL; + + ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new ()); + ClutterActor *actor = clutter_texture_new_from_file(filename, error); + + if (actor == NULL){ + g_object_unref(G_OBJECT(champlainMarker)); + return NULL; + } + + clutter_container_add_actor (CLUTTER_CONTAINER(champlainMarker), actor); + + return CLUTTER_ACTOR (champlainMarker); +} + +/** + * champlain_marker_new_with_image_full: + * @filename: The name of an image file to load. + * @width: Width of the image in pixel or -1. + * @height: Height of the image in pixel or -1. + * @anchor_x: X coordinate of the anchor point. + * @anchor_y: Y coordinate of the anchor point. + * @error: Return location for an error. + * + * Returns a new #ChamplainMarker with a drawn marker containing the given image. + * + */ +ClutterActor * +champlain_marker_new_with_image_full(const gchar *filename, gint width, gint height, gint anchor_x, gint anchor_y, GError **error) +{ + if(filename == NULL) + return NULL; + + ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new()); + ClutterActor *actor = clutter_texture_new_from_file(filename, error); + + if(actor == NULL){ + g_object_unref(G_OBJECT(champlainMarker)); + return NULL; + } + + clutter_actor_set_size(actor, width, height); + + clutter_container_add_actor(CLUTTER_CONTAINER(champlainMarker), actor); + clutter_actor_set_anchor_point(CLUTTER_ACTOR(champlainMarker), anchor_x, anchor_y); + + return CLUTTER_ACTOR(champlainMarker); +} + diff --git a/champlain/champlainmarker.h b/champlain/champlainmarker.h index 8853caf..7708547 100644 --- a/champlain/champlainmarker.h +++ b/champlain/champlainmarker.h @@ -59,4 +59,14 @@ ClutterActor *champlain_marker_new_with_label (const gchar *label, const gchar *font, ClutterColor *text_color, ClutterColor *marker_color); + +ClutterActor *champlain_marker_new_with_image(const gchar *filename, + GError **error); + +ClutterActor *champlain_marker_new_with_image_full(const gchar *filename, + gint width, + gint height, + gint anchor_x, + gint anchor_y, + GError **error); #endif diff --git a/configure.ac b/configure.ac index f5d4a67..87b455c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT(libchamplain, 0.2.7, pierre-luc@pierlux.com) +AC_INIT(libchamplain, 0.2.8, pierre-luc@pierlux.com) AC_CONFIG_SRCDIR([champlain/champlainview.h]) AC_CONFIG_HEADER([config.h]) diff --git a/docs/reference/libchamplain-sections.txt b/docs/reference/libchamplain-sections.txt index 3178c0b..99ba812 100644 --- a/docs/reference/libchamplain-sections.txt +++ b/docs/reference/libchamplain-sections.txt @@ -23,6 +23,8 @@ CHAMPLAIN_IS_VIEW_CLASS ChamplainMarker champlain_marker_new champlain_marker_new_with_label +champlain_marker_new_with_image +champlain_marker_new_with_image_full champlain_marker_set_anchor champlain_marker_set_position diff --git a/docs/reference/tmpl/champlainmarker.sgml b/docs/reference/tmpl/champlainmarker.sgml index d03dcea..8445098 100644 --- a/docs/reference/tmpl/champlainmarker.sgml +++ b/docs/reference/tmpl/champlainmarker.sgml @@ -47,6 +47,30 @@ A marker to identify points of interest on a map @Returns: + + + + + +@filename: +@error: +@Returns: + + + + + + + +@filename: +@width: +@height: +@anchor_x: +@anchor_y: +@error: +@Returns: + +