[dia/zbrown/graphene-rect: 4/11] general: assorted cleanups




commit 79ae82ab6cf35622fcdf2ad70afaacd3895e2975
Author: Zander Brown <zbrown gnome org>
Date:   Tue Apr 6 02:00:24 2021 +0100

    general: assorted cleanups

 lib/boundingbox.c              |  61 ++++++++------
 lib/boundingbox.h              |  10 +--
 lib/dia_dirs.c                 |   6 +-
 lib/diarenderer.h              | 108 ++++++++++++-------------
 lib/font.c                     |  25 +++---
 lib/object.h                   | 176 ++++++++++++++++++++++-------------------
 lib/persistence.c              |   1 +
 lib/textline.c                 |  61 ++++++++------
 objects/UML/class.c            |  25 +++---
 objects/custom/custom_object.c |  52 ++++++------
 10 files changed, 290 insertions(+), 235 deletions(-)
---
diff --git a/lib/boundingbox.c b/lib/boundingbox.c
index 09c964ff2..84c8dcc68 100644
--- a/lib/boundingbox.c
+++ b/lib/boundingbox.c
@@ -17,12 +17,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
-#define _DEFAULT_SOURCE 1
 #include <math.h>
-#include <string.h> /* memcmp() */
-
 #include <glib.h>
 
 #include "geometry.h"
@@ -46,12 +43,11 @@ static inline void _polybezier_bbox (const BezPoint        *pts,
 
 /**
  * bernstein_develop:
- *
- * @p: x- or y-part of the four points
- * @A:
- * @B:
- * @C:
- * @D:
+ * @p: (array fixed-size=4): x- or y-part of the four points
+ * @A: (out caller-allocates): point 0
+ * @B: (out caller-allocates): point 1
+ * @C: (out caller-allocates): point 2
+ * @D: (out caller-allocates): point 3
  *
  * Translates x- or y- part of bezier points to Bernstein polynom coefficients
  *
@@ -76,7 +72,8 @@ bernstein_develop (const double  p[4],
 
 /**
  * bezier_eval:
- * @p: x- or y-values of four points describing the bezier
+ * @p: (array fixed-size=4): x- or y-values of four points describing
+ *     the bezier
  * @u: position on the curve [0 .. 1]
  *
  * Evaluates the Bernstein polynoms for a given position
@@ -94,7 +91,8 @@ bezier_eval (const double p[4], double u)
 
 /**
  * bezier_eval_tangent:
- * @p: x- or y-values of four points describing the bezier
+ * @p: (array fixed-size=4): x- or y-values of four points describing
+ *     the bezier
  * @u: position on the curve between[0 .. 1]
  *
  * Calculates the tangent for a given point on a bezier curve
@@ -112,8 +110,10 @@ bezier_eval_tangent (const double p[4], double u)
 
 /**
  * bicubicbezier_extrema:
- * @p: x- or y-values of four points describing the bezier
- * @u: The position of the extrema [0 .. 1]
+ * @p: (array fixed-size=4): x- or y-values of four points describing
+ *                           the bezier
+ * @u: (out caller-allocates) (array fixed-size=2): The position of the
+ *                                                  extrema [0 .. 1]
  *
  * Calculates the extrma of the given curve in x- or y-direction.
  *
@@ -285,9 +285,11 @@ bicubicbezier2D_bbox (const graphene_vec2_t *p0,
  * @p1: One end of the line.
  * @p2: The other end of the line.
  * @extra: Extra information
- * @rect: The box that the line and extra stuff fits inside.
+ * @rect: (out caller-allocates): The box that the line and extra stuff fits inside.
  *
  * Calculate the bounding box for a simple line.
+ *
+ * The calculation includes line width and arrwos with the right @extra
  */
 static inline void
 _line_bbox (const Point        *p1,
@@ -334,9 +336,13 @@ line_bbox (const graphene_vec2_t *p1,
  * @width: The width of the ellipse.
  * @height: The height of the ellipse.
  * @extra: Extra information required.
- * @rect: The bounding box that the ellipse fits inside.
+ * @rect: (out caller-allocates): The bounding box that the ellipse fits inside.
  *
  * Calculate the bounding box of an ellipse.
+ *
+ * The calculation includes line width with the right @extra
+ *
+ * Since: 0.98
  */
 static inline void
 _ellipse_bbox (const Point          *centre,
@@ -357,8 +363,8 @@ _ellipse_bbox (const Point          *centre,
 
 void
 ellipse_bbox (const Point           *centre,
-              float                  width,
-              float                  height,
+              double                 width,
+              double                 height,
               const ElementBBExtras *extra,
               graphene_rect_t       *rect)
 {
@@ -418,9 +424,11 @@ free_polybezier_space (BezPoint *points)
  * @extra: Extra space information
  * @closed: Whether the polyline is closed or not.
  * @rect: (out caller-allocates): The bounding box that includes the points
- * and extra spacing.
+ *                                and extra spacing.
  *
  * Calculate the boundingbox for a polyline.
+ *
+ * The calcualtion includes line width and arrwos with the right @extra
  */
 static inline void
 _polyline_bbox (const Point        *pts,
@@ -470,9 +478,12 @@ polyline_bbox (const Point        *pts,
  * @numpoints: The number of elements in `pts'
  * @extra: Extra spacing information.
  * @closed: True if the bezier points form a closed line.
- * @rect: Return value: The enclosing rectangle will be stored here.
+ * @rect: (out caller-allocates): Return value: The enclosing rectangle will
+ *                                be stored here.
  *
  * Calculate a bounding box for a set of bezier points.
+ *
+ * The calculation includes line width and arrwos with the right @extra
  */
 static inline void
 _polybezier_bbox (const BezPoint     *pts,
@@ -482,7 +493,7 @@ _polybezier_bbox (const BezPoint     *pts,
                   DiaRectangle       *rect)
 {
   Point vx, vn, vsc, vp;
-  int i, prev, next;
+  int prev, next;
   DiaRectangle rt;
   PolyBBExtras bextra, start_bextra, end_bextra, full_bextra;
   LineBBExtras lextra, start_lextra, end_lextra, full_lextra;
@@ -546,12 +557,14 @@ _polybezier_bbox (const BezPoint     *pts,
   bextra.end_trans = extra->middle_trans;
 
 
-  for (i = 1; i < numpoints; i++) {
+  for (int i = 1; i < numpoints; i++) {
     next = (i + 1) % numpoints;
     prev = (i - 1) % numpoints;
+
     if (closed && (next == 0)) {
       next = 1;
     }
+
     if (closed && (prev == 0)) {
       prev = numpoints - 1;
     }
@@ -754,9 +767,11 @@ polybezier_bbox (const BezPoint     *pts,
  * rectangle_bbox:
  * @rin: A rectangle to find bbox for.
  * @extra: Extra information required to find bbox.
- * @rout: Return value: The enclosing bounding box.
+ * @rout: (out caller-allocates): Return value: The enclosing bounding box.
  *
  * Figure out a bounding box for a rectangle (fairly simple:)
+ *
+ * The calcualtion includes line width with the right @extra
  */
 static inline void
 _rectangle_bbox (const DiaRectangle    *rin,
diff --git a/lib/boundingbox.h b/lib/boundingbox.h
index 6832485f9..07ed71115 100644
--- a/lib/boundingbox.h
+++ b/lib/boundingbox.h
@@ -38,9 +38,9 @@ G_BEGIN_DECLS
  * Polygon/Polyline bounding box extras
  */
 struct _PolyBBExtras {
-  float start_long, start_trans;
-  float middle_trans;
-  float end_long, end_trans;
+  double start_long, start_trans;
+  double middle_trans;
+  double end_long, end_trans;
 };
 
 
@@ -76,8 +76,8 @@ void   rectangle_bbox         (const graphene_rect_t *rin,
                                const ElementBBExtras *extra,
                                graphene_rect_t       *rout);
 void   ellipse_bbox           (const Point           *centre,
-                               float                  width,
-                               float                  height,
+                               double                 width,
+                               double                 height,
                                const ElementBBExtras *extra,
                                graphene_rect_t       *rect);
 void   polyline_bbox          (const Point           *pts,
diff --git a/lib/dia_dirs.c b/lib/dia_dirs.c
index ba15e89e4..335bf285b 100644
--- a/lib/dia_dirs.c
+++ b/lib/dia_dirs.c
@@ -116,7 +116,7 @@ dia_get_locale_directory (void)
 
 /**
  * dia_config_filename:
- * @subfile: Name of the subfile.
+ * @file: Name of the file.
  *
  * Get the name of a file under the Dia config directory. If no home
  * directory can be found, uses a temporary directory.
@@ -127,7 +127,7 @@ dia_get_locale_directory (void)
  * Since: dawn-of-time
  */
 char *
-dia_config_filename (const char *subfile)
+dia_config_filename (const char *file)
 {
   const char *homedir;
 
@@ -136,7 +136,7 @@ dia_config_filename (const char *subfile)
     homedir = g_get_tmp_dir (); /* put config stuff in /tmp -- not ideal, but
                                  * we should not reach this state */
   }
-  return g_build_filename (homedir, ".dia", subfile, NULL);
+  return g_build_filename (homedir, ".dia", file, NULL);
 }
 
 
diff --git a/lib/diarenderer.h b/lib/diarenderer.h
index 1db11d907..137ee4bf0 100644
--- a/lib/diarenderer.h
+++ b/lib/diarenderer.h
@@ -119,7 +119,7 @@ struct _DiaRendererClass
   void     (*draw_object)                       (DiaRenderer      *renderer,
                                                  DiaObject        *object,
                                                  DiaMatrix        *matrix);
-  real     (*get_text_width)                    (DiaRenderer      *renderer,
+  double   (*get_text_width)                    (DiaRenderer      *renderer,
                                                  const gchar      *text,
                                                  int               length);
 
@@ -131,14 +131,14 @@ struct _DiaRendererClass
   void     (*end_render)                        (DiaRenderer      *renderer);
 
   void     (*set_linewidth)                     (DiaRenderer      *renderer,
-                                                 real              linewidth);
+                                                 double            linewidth);
   void     (*set_linecaps)                      (DiaRenderer      *renderer,
                                                  LineCaps          mode);
   void     (*set_linejoin)                      (DiaRenderer      *renderer,
                                                  LineJoin          mode);
   void     (*set_linestyle)                     (DiaRenderer      *renderer,
                                                  LineStyle         mode,
-                                                 real              length);
+                                                 double            length);
   void     (*set_fillstyle)                     (DiaRenderer      *renderer,
                                                  FillStyle         mode);
 
@@ -153,22 +153,22 @@ struct _DiaRendererClass
                                                  Color            *stroke);
   void     (*draw_arc)                          (DiaRenderer      *renderer,
                                                  Point            *center,
-                                                 real              width,
-                                                 real              height,
-                                                 real              angle1,
-                                                 real              angle2,
+                                                 double            width,
+                                                 double            height,
+                                                 double            angle1,
+                                                 double            angle2,
                                                  Color            *color);
   void     (*fill_arc)                          (DiaRenderer      *renderer,
                                                  Point            *center,
-                                                 real              width,
-                                                 real              height,
-                                                 real              angle1,
-                                                 real              angle2,
+                                                 double            width,
+                                                 double            height,
+                                                 double            angle1,
+                                                 double            angle2,
                                                  Color            *color);
   void     (*draw_ellipse)                      (DiaRenderer      *renderer,
                                                  Point            *center,
-                                                 real              width,
-                                                 real              height,
+                                                 double            width,
+                                                 double            height,
                                                  Color            *fill,
                                                  Color            *stroke);
   void     (*draw_string)                       (DiaRenderer      *renderer,
@@ -178,8 +178,8 @@ struct _DiaRendererClass
                                                  Color            *color);
   void     (*draw_image)                        (DiaRenderer      *renderer,
                                                  Point            *point,
-                                                 real              width,
-                                                 real              height,
+                                                 double            width,
+                                                 double            height,
                                                  DiaImage         *image);
 
   /*
@@ -221,16 +221,16 @@ struct _DiaRendererClass
                                                  Point            *lr_corner,
                                                  Color            *fill,
                                                  Color            *stroke,
-                                                 real              radius);
+                                                 double            radius);
   void     (*draw_rounded_polyline)             (DiaRenderer      *renderer,
                                                  Point            *points,
                                                  int               num_points,
                                                  Color            *color,
-                                                 real              radius );
+                                                 double            radius );
   void     (*draw_line_with_arrows)             (DiaRenderer      *renderer,
                                                  Point            *start,
                                                  Point            *end,
-                                                 real              line_width,
+                                                 double            line_width,
                                                  Color            *line_color,
                                                  Arrow            *start_arrow,
                                                  Arrow            *end_arrow);
@@ -238,29 +238,29 @@ struct _DiaRendererClass
                                                  Point            *start,
                                                  Point            *end,
                                                  Point            *midpoint,
-                                                 real              line_width,
+                                                 double            line_width,
                                                  Color            *color,
                                                  Arrow            *start_arrow,
                                                  Arrow            *end_arrow);
   void     (*draw_polyline_with_arrows)         (DiaRenderer      *renderer,
                                                  Point            *points,
                                                  int               num_points,
-                                                 real              line_width,
+                                                 double            line_width,
                                                  Color            *color,
                                                  Arrow            *start_arrow,
                                                  Arrow            *end_arrow);
   void     (*draw_rounded_polyline_with_arrows) (DiaRenderer      *renderer,
                                                  Point            *points,
                                                  int               num_points,
-                                                 real              line_width,
+                                                 double            line_width,
                                                  Color            *color,
                                                  Arrow            *start_arrow,
                                                  Arrow            *end_arrow,
-                                                 real              radius);
+                                                 double            radius);
   void     (*draw_bezier_with_arrows)           (DiaRenderer      *renderer,
                                                  BezPoint         *points,
                                                  int               num_points,
-                                                 real              line_width,
+                                                 double            line_width,
                                                  Color            *color,
                                                  Arrow            *start_arrow,
                                                  Arrow            *end_arrow);
@@ -271,12 +271,12 @@ struct _DiaRendererClass
   void     (*draw_rotated_text)                 (DiaRenderer      *renderer,
                                                  Text             *text,
                                                  Point            *center,
-                                                 real              angle);
+                                                 double            angle);
   void     (*draw_rotated_image)                (DiaRenderer      *renderer,
                                                  Point            *point,
-                                                 real              width,
-                                                 real              height,
-                                                 real              angle,
+                                                 double            width,
+                                                 double            height,
+                                                 double            angle,
                                                  DiaImage         *image);
 };
 
@@ -287,21 +287,21 @@ void     dia_renderer_draw_layer                        (DiaRenderer      *self,
 void     dia_renderer_draw_object                       (DiaRenderer      *self,
                                                          DiaObject        *object,
                                                          DiaMatrix        *matrix);
-real     dia_renderer_get_text_width                    (DiaRenderer      *self,
+double   dia_renderer_get_text_width                    (DiaRenderer      *self,
                                                          const gchar      *text,
                                                          int               length);
 void     dia_renderer_begin_render                      (DiaRenderer      *self,
                                                          const DiaRectangle *update);
 void     dia_renderer_end_render                        (DiaRenderer      *self);
 void     dia_renderer_set_linewidth                     (DiaRenderer      *self,
-                                                         real              linewidth);
+                                                         double            linewidth);
 void     dia_renderer_set_linecaps                      (DiaRenderer      *self,
                                                          LineCaps          mode);
 void     dia_renderer_set_linejoin                      (DiaRenderer      *self,
                                                          LineJoin          mode);
 void     dia_renderer_set_linestyle                     (DiaRenderer      *self,
                                                          LineStyle         mode,
-                                                         real              length);
+                                                         double            length);
 void     dia_renderer_set_fillstyle                     (DiaRenderer      *self,
                                                          FillStyle         mode);
 void     dia_renderer_set_font                          (DiaRenderer      *self,
@@ -320,22 +320,22 @@ void     dia_renderer_draw_polygon                      (DiaRenderer      *self,
                                                          Color            *stroke);
 void     dia_renderer_draw_arc                          (DiaRenderer      *self,
                                                          Point            *center,
-                                                         real              width,
-                                                         real              height,
-                                                         real              angle1,
-                                                         real              angle2,
+                                                         double            width,
+                                                         double            height,
+                                                         double            angle1,
+                                                         double            angle2,
                                                          Color            *color);
 void     dia_renderer_fill_arc                          (DiaRenderer      *self,
                                                          Point            *center,
-                                                         real              width,
-                                                         real              height,
-                                                         real              angle1,
-                                                         real              angle2,
+                                                         double            width,
+                                                         double            height,
+                                                         double            angle1,
+                                                         double            angle2,
                                                          Color            *color);
 void     dia_renderer_draw_ellipse                      (DiaRenderer      *self,
                                                          Point            *center,
-                                                         real              width,
-                                                         real              height,
+                                                         double            width,
+                                                         double            height,
                                                          Color            *fill,
                                                          Color            *stroke);
 void     dia_renderer_draw_string                       (DiaRenderer      *self,
@@ -345,8 +345,8 @@ void     dia_renderer_draw_string                       (DiaRenderer      *self,
                                                          Color            *color);
 void     dia_renderer_draw_image                        (DiaRenderer      *self,
                                                          Point            *point,
-                                                         real              width,
-                                                         real              height,
+                                                         double            width,
+                                                         double            height,
                                                          DiaImage         *image);
 void     dia_renderer_draw_bezier                       (DiaRenderer      *self,
                                                          BezPoint         *points,
@@ -378,16 +378,16 @@ void     dia_renderer_draw_rounded_rect                 (DiaRenderer      *self,
                                                          Point            *lr_corner,
                                                          Color            *fill,
                                                          Color            *stroke,
-                                                         real              radius);
+                                                         double            radius);
 void     dia_renderer_draw_rounded_polyline             (DiaRenderer      *self,
                                                          Point            *points,
                                                          int               num_points,
                                                          Color            *color,
-                                                         real              radius);
+                                                         double            radius);
 void     dia_renderer_draw_line_with_arrows             (DiaRenderer      *self,
                                                          Point            *start,
                                                          Point            *end,
-                                                         real              line_width,
+                                                         double            line_width,
                                                          Color            *line_color,
                                                          Arrow            *start_arrow,
                                                          Arrow            *end_arrow);
@@ -395,29 +395,29 @@ void     dia_renderer_draw_arc_with_arrows              (DiaRenderer      *self,
                                                          Point            *start,
                                                          Point            *end,
                                                          Point            *midpoint,
-                                                         real              line_width,
+                                                         double            line_width,
                                                          Color            *color,
                                                          Arrow            *start_arrow,
                                                          Arrow            *end_arrow);
 void     dia_renderer_draw_polyline_with_arrows         (DiaRenderer      *self,
                                                          Point            *points,
                                                          int               num_points,
-                                                         real              line_width,
+                                                         double            line_width,
                                                          Color            *color,
                                                          Arrow            *start_arrow,
                                                          Arrow            *end_arrow);
 void     dia_renderer_draw_rounded_polyline_with_arrows (DiaRenderer      *self,
                                                          Point            *points,
                                                          int               num_points,
-                                                         real              line_width,
+                                                         double            line_width,
                                                          Color            *color,
                                                          Arrow            *start_arrow,
                                                          Arrow            *end_arrow,
-                                                         real              radius);
+                                                         double            radius);
 void     dia_renderer_draw_bezier_with_arrows           (DiaRenderer      *self,
                                                          BezPoint         *points,
                                                          int               num_points,
-                                                         real              line_width,
+                                                         double            line_width,
                                                          Color            *color,
                                                          Arrow            *start_arrow,
                                                          Arrow            *end_arrow);
@@ -428,12 +428,12 @@ void     dia_renderer_set_pattern                       (DiaRenderer      *self,
 void     dia_renderer_draw_rotated_text                 (DiaRenderer      *self,
                                                          Text             *text,
                                                          Point            *center,
-                                                         real              angle);
+                                                         double            angle);
 void     dia_renderer_draw_rotated_image                (DiaRenderer      *self,
                                                          Point            *point,
-                                                         real              width,
-                                                         real              height,
-                                                         real              angle,
+                                                         double            width,
+                                                         double            height,
+                                                         double            angle,
                                                          DiaImage         *image);
 
 void     dia_renderer_bezier_fill                       (DiaRenderer      *self,
diff --git a/lib/font.c b/lib/font.c
index 5e406bcbb..ec8f841df 100644
--- a/lib/font.c
+++ b/lib/font.c
@@ -414,36 +414,39 @@ dia_font_get_style(const DiaFont* font)
 }
 
 
-const char*
-dia_font_get_family(const DiaFont* font)
+const char *
+dia_font_get_family(const DiaFont *font)
 {
-  return pango_font_description_get_family(font->pfd);
+  return pango_font_description_get_family (font->pfd);
 }
 
 
 const PangoFontDescription *
-dia_font_get_description (const DiaFont* font)
+dia_font_get_description (const DiaFont *font)
 {
   return font->pfd;
 }
 
 
-real
-dia_font_get_height(const DiaFont* font)
+double
+dia_font_get_height (const DiaFont *font)
 {
   return font->height;
 }
 
-real
-dia_font_get_size(const DiaFont* font)
+
+double
+dia_font_get_size (const DiaFont *font)
 {
-  if (!pango_font_description_get_size_is_absolute (font->pfd))
+  if (!pango_font_description_get_size_is_absolute (font->pfd)) {
     g_warning ("dia_font_get_size() : no absolute size");
-  return pdu_to_dcm(pango_font_description_get_size(font->pfd));
+  }
+  return pdu_to_dcm (pango_font_description_get_size (font->pfd));
 }
 
+
 void
-dia_font_set_height(DiaFont* font, real height)
+dia_font_set_height (DiaFont *font, double height)
 {
   _dia_font_adjust_size (font, height, FALSE);
 }
diff --git a/lib/object.h b/lib/object.h
index 0487aabbd..d72448fb2 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -196,8 +196,8 @@ typedef void                   (*DrawFunc)                  (DiaObject        *o
 typedef double                 (*DistanceFunc)              (DiaObject        *obj,
                                                              Point            *point);
 typedef void                   (*SelectFunc)                (DiaObject        *obj,
-                                                            Point            *clicked_point,
-                                                            DiaRenderer      *interactive_renderer);
+                                                             Point            *clicked_point,
+                                                             DiaRenderer      *interactive_renderer);
 typedef DiaObject             *(*CopyFunc)                  (DiaObject        *obj);
 typedef DiaObjectChange       *(*MoveFunc)                  (DiaObject        *obj,
                                                              Point            *pos);
@@ -214,11 +214,18 @@ typedef DiaObjectChange       *(*ApplyPropertiesDialogFunc) (DiaObject        *o
 typedef DiaObjectChange       *(*ApplyPropertiesListFunc)   (DiaObject        *obj,
                                                              GPtrArray        *props);
 typedef const PropDescription *(*DescribePropsFunc)         (DiaObject        *obj);
-typedef void (* GetPropsFunc) (DiaObject *obj, GPtrArray *props);
-typedef void (* SetPropsFunc) (DiaObject *obj, GPtrArray *props);
-typedef DiaMenu *(*ObjectMenuFunc) (DiaObject* obj, Point *position);
-typedef gboolean (*TextEditFunc) (DiaObject *obj, Text *text, TextEditState state, gchar *textchange);
-typedef gboolean (*TransformFunc) (DiaObject *obj, const DiaMatrix *m);
+typedef void                   (*GetPropsFunc)              (DiaObject        *obj,
+                                                             GPtrArray        *props);
+typedef void                   (*SetPropsFunc)              (DiaObject        *obj,
+                                                             GPtrArray        *props);
+typedef DiaMenu               *(*ObjectMenuFunc)            (DiaObject        *obj,
+                                                             Point            *position);
+typedef gboolean               (*TextEditFunc)              (DiaObject        *obj,
+                                                             Text             *text,
+                                                             TextEditState     state,
+                                                             char             *textchange);
+typedef gboolean               (*TransformFunc)             (DiaObject        *obj,
+                                                             const DiaMatrix  *m);
 
 
 
@@ -496,86 +503,89 @@ struct _DiaObjectType {
   { "meta", PROP_TYPE_DICT, offsetof(DiaObject, meta) }
 
 
-void                   dia_object_draw                (DiaObject              *self,
-                                                       DiaRenderer            *renderer);
-double                 dia_object_distance_from       (DiaObject              *self,
-                                                       Point                  *point);
+void                   dia_object_draw                      (DiaObject              *self,
+                                                             DiaRenderer            *renderer);
+double                 dia_object_distance_from             (DiaObject              *self,
+                                                             Point                  *point);
 // TODO: Probably shouldn't pass renderer here
-void                   dia_object_select              (DiaObject              *self,
-                                                       Point                  *point,
-                                                       DiaRenderer            *renderer);
+void                   dia_object_select                    (DiaObject              *self,
+                                                             Point                  *point,
+                                                             DiaRenderer            *renderer);
 // Note: wraps copy
-DiaObject             *dia_object_clone               (DiaObject              *self);
-DiaObjectChange       *dia_object_move                (DiaObject              *self,
-                                                       Point                  *to);
-DiaObjectChange       *dia_object_move_handle         (DiaObject              *self,
-                                                       Handle                 *handle,
-                                                       Point                  *to,
-                                                       ConnectionPoint        *cp,
-                                                       HandleMoveReason        reason,
-                                                       ModifierKeys            modifiers);
+DiaObject             *dia_object_clone                      (DiaObject              *self);
+DiaObjectChange       *dia_object_move                       (DiaObject              *self,
+                                                              Point                  *to);
+DiaObjectChange       *dia_object_move_handle                (DiaObject              *self,
+                                                              Handle                 *handle,
+                                                              Point                  *to,
+                                                              ConnectionPoint        *cp,
+                                                              HandleMoveReason        reason,
+                                                              ModifierKeys            modifiers);
 // Note: Wraps get_properties
-GtkWidget             *dia_object_get_editor          (DiaObject              *self,
-                                                       gboolean                is_default);
-DiaObjectChange       *dia_object_apply_editor        (DiaObject              *self,
-                                                       GtkWidget              *editor);
-DiaMenu               *dia_object_get_menu            (DiaObject              *self,
-                                                       Point                  *at);
-const PropDescription *dia_object_describe_properties (DiaObject              *self);
-void                   dia_object_get_properties      (DiaObject              *self,
-                                                       GPtrArray              *list);
-void                   dia_object_set_properties      (DiaObject              *self,
-                                                       GPtrArray              *list);
-DiaObjectChange       *dia_object_apply_properties    (DiaObject              *self,
-                                                       GPtrArray              *list);
-gboolean               dia_object_edit_text           (DiaObject              *self,
-                                                       Text                   *text,
-                                                       TextEditState           state,
-                                                       gchar                  *textchange);
-gboolean               dia_object_transform           (DiaObject              *self,
-                                                       const DiaMatrix        *m);
-void                   dia_object_add_handle           (DiaObject               *self,
-                                                        Handle                  *handle,
-                                                        int                      index,
-                                                        HandleId                 id,
-                                                        HandleType               type,
-                                                        HandleConnectType        connect_type);
-void                   dia_object_add_connection_point (DiaObject               *self,
-                                                        ConnectionPoint         *cp,
-                                                        int                      index,
-                                                        ConnectionPointFlags     flags);
-
-
-gboolean       dia_object_defaults_load (const gchar *filename,
-                                         gboolean create_lazy,
-                                        DiaContext *ctx);
-DiaObject  *dia_object_default_get  (const DiaObjectType *type, gpointer user_data);
-DiaObject  *dia_object_default_create (const DiaObjectType *type,
-                                    Point *startpoint,
-                                    void *user_data,
-                                    Handle **handle1,
-                                    Handle **handle2);
-gboolean         dia_object_defaults_save (const gchar *filename, DiaContext *ctx);
-DiaLayer        *dia_object_get_parent_layer(DiaObject *obj);
-gboolean         dia_object_is_selected (const DiaObject *obj);
-void                   dia_object_get_bounding_box     (DiaObject               *obj,
-                                                        graphene_rect_t         *bbox);
-void                   dia_object_set_bounding_box     (DiaObject               *obj,
-                                                        graphene_rect_t         *bbox);
-void                   dia_object_get_enclosing_box    (DiaObject               *obj,
-                                                        graphene_rect_t         *ebox);
-void                   dia_object_set_enclosing_box    (DiaObject               *obj,
-                                                        graphene_rect_t         *ebox);
-DiaObject       *dia_object_get_parent_with_flags(DiaObject *obj, guint flags);
-gboolean         dia_object_is_selectable(DiaObject *obj);
-/* The below is for debugging purposes only. */
-gboolean   dia_object_sanity_check(const DiaObject *obj, const gchar *msg);
-
+GtkWidget             *dia_object_get_editor                 (DiaObject              *self,
+                                                              gboolean                is_default);
+DiaObjectChange       *dia_object_apply_editor               (DiaObject              *self,
+                                                              GtkWidget              *editor);
+DiaMenu               *dia_object_get_menu                   (DiaObject              *self,
+                                                              Point                  *at);
+const PropDescription *dia_object_describe_properties        (DiaObject              *self);
+void                   dia_object_get_properties             (DiaObject              *self,
+                                                              GPtrArray              *list);
+void                   dia_object_set_properties             (DiaObject              *self,
+                                                              GPtrArray              *list);
+DiaObjectChange       *dia_object_apply_properties           (DiaObject              *self,
+                                                              GPtrArray              *list);
+gboolean               dia_object_edit_text                  (DiaObject              *self,
+                                                              Text                   *text,
+                                                              TextEditState           state,
+                                                              char                   *textchange);
+gboolean               dia_object_transform                  (DiaObject              *self,
+                                                             const DiaMatrix        *m);
+void                   dia_object_add_handle                 (DiaObject               *self,
+                                                              Handle                  *handle,
+                                                              int                      index,
+                                                              HandleId                 id,
+                                                              HandleType               type,
+                                                              HandleConnectType        connect_type);
+void                   dia_object_add_connection_point       (DiaObject               *self,
+                                                              ConnectionPoint         *cp,
+                                                              int                      index,
+                                                              ConnectionPointFlags     flags);
+gboolean               dia_object_defaults_load              (const char              *filename,
+                                                              gboolean                 create_lazy,
+                                                              DiaContext              *ctx);
+DiaObject             *dia_object_default_get                (const DiaObjectType     *type,
+                                                              gpointer                 user_data);
+DiaObject             *dia_object_default_create             (const DiaObjectType     *type,
+                                                              Point                   *startpoint,
+                                                              void                    *user_data,
+                                                              Handle                 **handle1,
+                                                              Handle                 **handle2);
+gboolean               dia_object_defaults_save              (const char              *filename,
+                                                              DiaContext              *ctx);
+DiaLayer              *dia_object_get_parent_layer           (DiaObject               *obj);
+gboolean               dia_object_is_selected                (const DiaObject         *obj);
+void                   dia_object_get_bounding_box           (DiaObject               *obj,
+                                                              graphene_rect_t         *bbox);
+void                   dia_object_set_bounding_box           (DiaObject               *obj,
+                                                              graphene_rect_t         *bbox);
+void                   dia_object_get_enclosing_box          (DiaObject               *obj,
+                                                              graphene_rect_t         *ebox);
+void                   dia_object_set_enclosing_box          (DiaObject               *obj,
+                                                              graphene_rect_t         *ebox);
+DiaObject             *dia_object_get_parent_with_flags      (DiaObject               *obj,
+                                                              guint                    flags);
+gboolean               dia_object_is_selectable              (DiaObject               *obj);
+/* For debugging purposes only. */
+gboolean               dia_object_sanity_check               (const DiaObject         *obj,
+                                                              const char              *msg);
 /** convenience functions for meta info */
-void   dia_object_set_meta (DiaObject *obj, const gchar *key, const gchar *value);
-gchar *dia_object_get_meta (DiaObject *obj, const gchar *key);
-
-int dia_object_get_num_connections (DiaObject *obj);
+void                   dia_object_set_meta                   (DiaObject               *obj,
+                                                              const char              *key,
+                                                              const char              *value);
+char                  *dia_object_get_meta                   (DiaObject               *obj,
+                                                              const char              *key);
+int                    dia_object_get_num_connections        (DiaObject               *obj);
 
 /* standard way to load/save properties of an object */
 void          object_load_props(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx);
diff --git a/lib/persistence.c b/lib/persistence.c
index f84e71c49..c0d54a17a 100644
--- a/lib/persistence.c
+++ b/lib/persistence.c
@@ -729,6 +729,7 @@ wininfo_in_range (const PersistentWindow *wininfo)
 
 /**
  * persistence_register_window:
+ * @window: the #GtkWindow to track
  *
  * Register a window with a role for persitence
  *
diff --git a/lib/textline.c b/lib/textline.c
index 359a1312e..cc99e2181 100644
--- a/lib/textline.c
+++ b/lib/textline.c
@@ -160,30 +160,34 @@ text_line_get_font(const TextLine *text_line)
   return text_line->font;
 }
 
-real
-text_line_get_height(const TextLine *text_line)
+
+double
+text_line_get_height (const TextLine *text_line)
 {
   return text_line->height;
 }
 
-real
-text_line_get_width(const TextLine *text_line)
+
+double
+text_line_get_width (const TextLine *text_line)
 {
-  text_line_cache_values((TextLine *)text_line);
+  text_line_cache_values ((TextLine *) text_line);
   return text_line->width;
 }
 
-real
-text_line_get_ascent(const TextLine *text_line)
+
+double
+text_line_get_ascent (const TextLine *text_line)
 {
-  text_line_cache_values((TextLine *)text_line);
+  text_line_cache_values ((TextLine *) text_line);
   return text_line->ascent;
 }
 
-real
-text_line_get_descent(const TextLine *text_line)
+
+double
+text_line_get_descent (const TextLine *text_line)
 {
-  text_line_cache_values((TextLine *)text_line);
+  text_line_cache_values ((TextLine *) text_line);
   return text_line->descent;
 }
 
@@ -253,8 +257,9 @@ clear_layout_offset (TextLine *text_line)
   }
 }
 
+
 static void
-text_line_cache_values(TextLine *text_line)
+text_line_cache_values (TextLine *text_line)
 {
   if (!text_line->clean ||
       text_line->chars != text_line->chars_cache ||
@@ -266,23 +271,30 @@ text_line_cache_values(TextLine *text_line)
     clear_layout_offset (text_line);
 
     if (text_line->chars == NULL ||
-       text_line->chars[0] == '\0') {
+        text_line->chars[0] == '\0') {
       /* caclculate reasonable ascent/decent even for empty string */
-      text_line->offsets =
-        dia_font_get_sizes("XjgM149", text_line->font, text_line->height,
-                          &text_line->width, &text_line->ascent,
-                          &text_line->descent, &n_offsets,
-                          &text_line->layout_offsets);
+      text_line->offsets = dia_font_get_sizes ("XjgM149",
+                                               text_line->font,
+                                               text_line->height,
+                                               &text_line->width,
+                                               &text_line->ascent,
+                                               &text_line->descent,
+                                               &n_offsets,
+                                               &text_line->layout_offsets);
       clear_layout_offset (text_line);
       g_clear_pointer (&text_line->offsets, g_free);
-      text_line->offsets = g_new (real,0); /* another way to assign NULL;) */
+
+      text_line->offsets = g_new (double, 0); /* another way to assign NULL;) */
       text_line->width = 0;
     } else {
-      text_line->offsets =
-       dia_font_get_sizes(text_line->chars, text_line->font, text_line->height,
-                          &text_line->width, &text_line->ascent,
-                          &text_line->descent, &n_offsets,
-                          &text_line->layout_offsets);
+      text_line->offsets = dia_font_get_sizes (text_line->chars,
+                                               text_line->font,
+                                               text_line->height,
+                                               &text_line->width,
+                                               &text_line->ascent,
+                                               &text_line->descent,
+                                               &n_offsets,
+                                               &text_line->layout_offsets);
     }
     text_line->clean = TRUE;
     text_line->chars_cache = text_line->chars;
@@ -291,6 +303,7 @@ text_line_cache_values(TextLine *text_line)
   }
 }
 
+
 /*!
  * \brief Move glyphs to approximate a desired total width
  *
diff --git a/objects/UML/class.c b/objects/UML/class.c
index c05d62534..ddb7e5262 100644
--- a/objects/UML/class.c
+++ b/objects/UML/class.c
@@ -614,14 +614,15 @@ static void
 uml_underline_text (DiaRenderer  *renderer,
                     Point         StartPoint,
                     DiaFont      *font,
-                    real          font_height,
-                    gchar        *string,
+                    double        font_height,
+                    const char   *string,
                     Color        *color,
-                    real          line_width,
-                    real          underline_width)
+                    double        line_width,
+                    double        underline_width)
 {
   Point UnderlineStartPoint;
   Point UnderlineEndPoint;
+  const char *tmp = string;
   char *whitespaces;
   int first_non_whitespace = 0;
 
@@ -629,22 +630,26 @@ uml_underline_text (DiaRenderer  *renderer,
   UnderlineStartPoint.y += font_height * 0.1;
   UnderlineEndPoint = UnderlineStartPoint;
 
-  whitespaces = string;
-  while (whitespaces &&
-         g_unichar_isspace (g_utf8_get_char (whitespaces))) {
-    whitespaces = g_utf8_next_char (whitespaces);
+  while (tmp && g_unichar_isspace (g_utf8_get_char (tmp))) {
+    tmp = g_utf8_next_char (tmp);
   }
-  first_non_whitespace = whitespaces - string;
+
+  first_non_whitespace = tmp - string;
+
   whitespaces = g_strdup (string);
   whitespaces[first_non_whitespace] = '\0';
+
   UnderlineStartPoint.x += dia_font_string_width (whitespaces, font, font_height);
-  g_clear_pointer (&whitespaces, g_free);
   UnderlineEndPoint.x += dia_font_string_width (string, font, font_height);
+
   dia_renderer_set_linewidth (renderer, underline_width);
   dia_renderer_draw_line (renderer, &UnderlineStartPoint, &UnderlineEndPoint, color);
   dia_renderer_set_linewidth (renderer, line_width);
+
+  g_clear_pointer (&whitespaces, g_free);
 }
 
+
 /**
  * Create a documentation tag from a comment.
  *
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index b2a2aedc5..a486c2d71 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -359,20 +359,20 @@ custom_setup_properties (ShapeInfo *info, xmlNodePtr node)
   prop_desc_list_calculate_quarks (info->props);
 
   /* 2nd pass after quarks & ops have been filled in */
-  for (i = n_props-1; i < n_props-1+info->n_ext_attr; i++)
-    if ((info->props[i].ops) && (info->props[i].ops->get_data_size))
-    { /* if prop valid & supported */
+  for (i = n_props-1; i < n_props-1+info->n_ext_attr; i++) {
+    if ((info->props[i].ops) && (info->props[i].ops->get_data_size)) {
+      /* if prop valid & supported */
       int size;
       info->prop_offsets[i].name = info->props[i].name;
       info->prop_offsets[i].type = info->props[i].type;
       info->prop_offsets[i].offset = offs;
       /* FIXME:
-        custom_object.c:328: warning: passing arg 1 of pointer to function
-        from incompatible pointer type
-        We don't have a Property* here so there is not much we can do about.
-        Maybe it even works cause the sizeof() in *_get_data_size can be
-        calculated at compile time. Anyway, a mess ;) --hb
-      */
+       * custom_object.c:328: warning: passing arg 1 of pointer to function
+       * from incompatible pointer type
+       * We don't have a Property* here so there is not much we can do about.
+       * Maybe it even works cause the sizeof() in *_get_data_size can be
+       * calculated at compile time. Anyway, a mess ;) --hb
+       */
       size = info->props[i].ops->get_data_size (&info->props[i]);
       info->ext_attr_size += size;
       offs += size;
@@ -382,10 +382,12 @@ custom_setup_properties (ShapeInfo *info, xmlNodePtr node)
       /* hope this is enough to have this prop ignored */
       info->props[i].flags = PROP_FLAG_DONT_SAVE | PROP_FLAG_OPTIONAL;
     }
+  }
 }
 
+
 static PropDescription *
-custom_describe_props(Custom *custom)
+custom_describe_props (Custom *custom)
 {
   return custom->info->props;
 }
@@ -423,10 +425,10 @@ transform_subshape_coord (Custom                 *custom,
 
   if (subshape->default_scale == 0.0) {
     ShapeInfo *info = custom->info;
-    real svg_width = info->shape_bounds.right - info->shape_bounds.left;
-    real svg_height = info->shape_bounds.bottom - info->shape_bounds.top;
-    real h_scale = info->default_height / svg_height;
-    real v_scale = info->default_width / svg_width;
+    double svg_width = info->shape_bounds.right - info->shape_bounds.left;
+    double svg_height = info->shape_bounds.bottom - info->shape_bounds.top;
+    double h_scale = info->default_height / svg_height;
+    double v_scale = info->default_width / svg_width;
 
     subshape->default_scale = (v_scale > h_scale ? h_scale : v_scale);
   }
@@ -499,8 +501,9 @@ transform_subshape_coord (Custom                 *custom,
   out->y += yoffs;
 }
 
-static real
-custom_transform_length(Custom *custom, real length)
+
+static double
+custom_transform_length (Custom *custom, double length)
 {
   if (custom->current_subshape != NULL) {
     GraphicElementSubShape* subshape = custom->current_subshape;
@@ -508,12 +511,13 @@ custom_transform_length(Custom *custom, real length)
     return custom->subscale * subshape->default_scale * length;
   } else {
     /* maybe we should consider the direction? */
-    return sqrt (fabs(custom->xscale * custom->yscale)) * length;
+    return sqrt (fabs (custom->xscale * custom->yscale)) * length;
   }
 }
 
+
 static void
-transform_size(Custom *custom, real w1, real h1, real *w2, real *h2)
+transform_size (Custom *custom, double w1, double h1, double *w2, double *h2)
 {
   if (custom->current_subshape != NULL) {
     GraphicElementSubShape* subshape = custom->current_subshape;
@@ -574,13 +578,14 @@ custom_distance_from (Custom *custom, Point *point)
   static GArray *arr = NULL, *barr = NULL;
   Point p1, p2;
   DiaRectangle rect;
-  gint i;
+  int i;
   GList *tmp;
-  real min_dist = G_MAXFLOAT, dist = G_MAXFLOAT;
+  double min_dist = G_MAXFLOAT, dist = G_MAXFLOAT;
 
   if (!arr) {
     arr = g_array_new (FALSE, FALSE, sizeof(Point));
   }
+
   if (!barr) {
     barr = g_array_new (FALSE, FALSE, sizeof(BezPoint));
   }
@@ -722,10 +727,12 @@ custom_distance_from (Custom *custom, Point *point)
     if (min_dist == 0.0)
       break;
   }
+
   if (custom->info->has_text && min_dist != 0.0) {
-    dist = text_distance_from(custom->text, point);
-    min_dist = MIN(min_dist, dist);
+    dist = text_distance_from (custom->text, point);
+    min_dist = MIN (min_dist, dist);
   }
+
   return min_dist;
 }
 
@@ -1742,6 +1749,7 @@ custom_create(Point *startpoint,
     p = *startpoint;
     p.x += elem->width / 2.0;
     p.y += elem->height / 2.0 + font_height / 2;
+
     custom->text = new_text("", font, font_height, &p, &custom->border_color,
                             info->text_align);
     g_clear_object (&font);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]