From: Pierre-Luc Beaudoin Date: Mon, 13 Apr 2009 18:45:29 +0000 (-0400) Subject: Change markers constructors: new_from_file, new_with_image and new_full X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d85eabd8749a5fcdbecd588bec7e34ba713cb217;p=libchamplain Change markers constructors: new_from_file, new_with_image and new_full --- diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c index b100840..415e1bb 100644 --- a/champlain/champlain-marker.c +++ b/champlain/champlain-marker.c @@ -595,9 +595,9 @@ champlain_marker_new (void) */ ClutterActor * champlain_marker_new_with_text (const gchar *text, - const gchar *font, - ClutterColor *text_color, - ClutterColor *marker_color) + const gchar *font, + ClutterColor *text_color, + ClutterColor *marker_color) { ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); @@ -626,7 +626,31 @@ champlain_marker_new_with_text (const gchar *text, * Since: 0.2 */ ClutterActor * -champlain_marker_new_with_image (const gchar *filename, GError **error) +champlain_marker_new_with_image (ClutterActor *actor, + GError **error) +{ + ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); + if (actor != NULL) + { + champlain_marker_set_image (marker, actor); + } + + return CLUTTER_ACTOR (marker); +} + +/** + * champlain_marker_new_from_file: + * @filename: The filename of the image. + * @error: Return location for an error. + * + * Returns a new #ChamplainMarker with a drawn marker containing the given + * image. + * + * Since: 0.2 + */ +ClutterActor * +champlain_marker_new_from_file (const gchar *filename, + GError **error) { if (filename == NULL) return NULL; @@ -643,12 +667,9 @@ champlain_marker_new_with_image (const gchar *filename, GError **error) } /** - * 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. + * champlain_marker_new_full: + * @text: The text + * @actor: The image * @error: Return location for an error. * * Returns a new #ChamplainMarker with a drawn marker containing the given @@ -658,15 +679,10 @@ champlain_marker_new_with_image (const gchar *filename, GError **error) */ ClutterActor * champlain_marker_new_full (const gchar *text, - const gchar *filename, + ClutterActor *actor, GError **error) { - if (filename == NULL) - return NULL; - ChamplainMarker *marker = CHAMPLAIN_MARKER (champlain_marker_new ()); - ClutterActor *actor = clutter_texture_new_from_file (filename, error); - if (actor != NULL) { champlain_marker_set_image (marker, actor); diff --git a/champlain/champlain-marker.h b/champlain/champlain-marker.h index 7269bd4..f7d2157 100644 --- a/champlain/champlain-marker.h +++ b/champlain/champlain-marker.h @@ -61,11 +61,14 @@ ClutterActor *champlain_marker_new (void); ClutterActor *champlain_marker_new_with_text (const gchar *text, const gchar *font, ClutterColor *text_color, ClutterColor *marker_color); -ClutterActor *champlain_marker_new_with_image (const gchar *filename, +ClutterActor *champlain_marker_new_with_image (ClutterActor *actor, + GError **error); + +ClutterActor *champlain_marker_new_from_file (const gchar *filename, GError **error); ClutterActor *champlain_marker_new_full (const gchar *text, - const gchar *image_filename, + ClutterActor *actor, GError **error); void champlain_marker_set_text (ChamplainMarker *marker, diff --git a/demos/markers.c b/demos/markers.c index 6bfa883..19a65e1 100644 --- a/demos/markers.c +++ b/demos/markers.c @@ -54,16 +54,17 @@ create_marker_layer (ChamplainView *view) g_signal_connect_after (marker, "button-release-event", G_CALLBACK (marker_button_release_cb), view); - marker = champlain_marker_new_full ("New York", "/usr/share/icons/gnome/24x24/emblems/emblem-generic.png", NULL); + marker = champlain_marker_new_from_file ("/usr/share/icons/gnome/24x24/emblems/emblem-generic.png", NULL); + champlain_marker_set_text (CHAMPLAIN_MARKER (marker), "New York"); champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 40.77, -73.98); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); - marker = champlain_marker_new_with_image ("/usr/share/icons/Tango/24x24/emblems/emblem-important.png", NULL); + marker = champlain_marker_new_from_file ("/usr/share/icons/Tango/24x24/emblems/emblem-important.png", NULL); champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 47.130885, -70.764141); clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL); - marker = champlain_marker_new_with_image ("/usr/share/icons/Tango/24x24/emblems/emblem-favorite.png", NULL); + marker = champlain_marker_new_from_file ("/usr/share/icons/Tango/24x24/emblems/emblem-favorite.png", NULL); champlain_marker_set_draw_background (CHAMPLAIN_MARKER (marker), FALSE); champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), 45.41484, -71.918907);