From 7e2c8de467af4d1d1968dcd922a33122c1efbf8e Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 16 Oct 2009 11:34:35 +0200 Subject: [PATCH] [AdgPath] Return the current point as a const AdgPair * Consistency improvements: renamed adg_path_get_current_point() to adg_path_current_point() and return a const AdgPair * instead of modifying a couple of double passed as arguments. --- adg/adg-path.c | 29 +++++++++++++---------------- adg/adg-path.h | 4 +--- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/adg/adg-path.c b/adg/adg-path.c index 0efed0d6..cc4be795 100644 --- a/adg/adg-path.c +++ b/adg/adg-path.c @@ -163,38 +163,35 @@ adg_path_new(void) } /** - * adg_path_get_current_point: + * adg_path_current_point: * @path: an #AdgPath - * @x: where to store the x coordinate of the current point - * @y: where to store the y coordinate of the current point * * Gets the current point of @path, which is conceptually the * final point reached by the path so far. * - * If there is no defined current point, @x and @y will both be set - * to 0 and a warning will be triggered. It is possible to check this - * in advance with adg_path_has_current_point(). + * If there is no defined current point, %NULL is returned. + * It is possible to check this in advance with + * adg_path_has_current_point(). * * Most #AdgPath methods alter the current point and most of them * expect a current point to be defined otherwise will fail triggering * a warning. Check the description of every method for specific details. + * + * Returns: the current point or %NULL on no current point set or errors **/ -void -adg_path_get_current_point(AdgPath *path, gdouble *x, gdouble *y) +const AdgPair * +adg_path_current_point(AdgPath *path) { AdgPathPrivate *data; - g_return_if_fail(ADG_IS_PATH(path)); + g_return_val_if_fail(ADG_IS_PATH(path), NULL); data = path->data; - if (data->cp_is_valid) { - *x = data->cp.x; - *y = data->cp.y; - } else { - *x = *y = 0.; - g_return_if_reached(); - } + if (!data->cp_is_valid) + return NULL; + + return &data->cp; } /** diff --git a/adg/adg-path.h b/adg/adg-path.h index 7c6f5b4b..cad261ae 100644 --- a/adg/adg-path.h +++ b/adg/adg-path.h @@ -54,9 +54,7 @@ struct _AdgPathClass { GType adg_path_get_type (void) G_GNUC_CONST; AdgPath * adg_path_new (void); -void adg_path_get_current_point (AdgPath *path, - gdouble *x, - gdouble *y); +const AdgPair * adg_path_current_point (AdgPath *path); gboolean adg_path_has_current_point (AdgPath *path); void adg_path_append (AdgPath *path, -- 2.11.4.GIT