[dia] uml: fix warnings



commit 54f9ccaa46dc6250abb4c3a04b28ece32ea00ceb
Author: Zander Brown <zbrown gnome org>
Date:   Fri Mar 27 19:06:59 2020 +0000

    uml: fix warnings

 objects/UML/association.c | 274 ++++++++++++++++++++++++++--------------------
 objects/UML/transition.c  | 269 ++++++++++++++++++++++++++-------------------
 2 files changed, 313 insertions(+), 230 deletions(-)
---
diff --git a/objects/UML/association.c b/objects/UML/association.c
index e202b070..a8e1c93e 100644
--- a/objects/UML/association.c
+++ b/objects/UML/association.c
@@ -636,31 +636,36 @@ association_update_data_end(Association *assoc, int endnum)
   end = &assoc->end[endnum];
   end->text_pos = points[fp];
   switch (dir) {
-  case HORIZONTAL:
-    end->text_pos.y -= end->role_descent;
-    if (points[fp].x < points[sp].x) {
-      end->text_align = ALIGN_LEFT;
-      end->text_pos.x += (get_aggregate_pos_diff(end, assoc) + ASSOCIATION_END_SPACE);
-    } else {
-      end->text_align = ALIGN_RIGHT;
-      end->text_pos.x -= (get_aggregate_pos_diff(end, assoc) + ASSOCIATION_END_SPACE);
-    }
-    break;
-  case VERTICAL:
-    if (end->arrow || end->aggregate != AGGREGATE_NONE)
-       end->text_pos.x += ASSOCIATION_DIAMONDWIDTH / 2;
-    end->text_pos.x += ASSOCIATION_END_SPACE;
-
-    end->text_pos.y += end->role_ascent;
-    if (points[fp].y > points[sp].y) {
-      if (end->role!=NULL && *end->role)
+    case HORIZONTAL:
+      end->text_pos.y -= end->role_descent;
+      if (points[fp].x < points[sp].x) {
+        end->text_align = ALIGN_LEFT;
+        end->text_pos.x += (get_aggregate_pos_diff (end, assoc) + ASSOCIATION_END_SPACE);
+      } else {
+        end->text_align = ALIGN_RIGHT;
+        end->text_pos.x -= (get_aggregate_pos_diff (end, assoc) + ASSOCIATION_END_SPACE);
+      }
+      break;
+    case VERTICAL:
+      if (end->arrow || end->aggregate != AGGREGATE_NONE) {
+        end->text_pos.x += ASSOCIATION_DIAMONDWIDTH / 2;
+      }
+      end->text_pos.x += ASSOCIATION_END_SPACE;
+
+      end->text_pos.y += end->role_ascent;
+      if (points[fp].y > points[sp].y) {
+        if (end->role != NULL && *end->role) {
           end->text_pos.y -= assoc->font_height;
-      if (end->multiplicity!=NULL)
+        }
+        if (end->multiplicity != NULL) {
           end->text_pos.y -= assoc->font_height;
-    }
+        }
+      }
 
-    end->text_align = ALIGN_LEFT;
-    break;
+      end->text_align = ALIGN_LEFT;
+      break;
+    default:
+      g_return_if_reached ();
   }
   /* Add the text recangle to the bounding box: */
   rect.left = end->text_pos.x
@@ -741,16 +746,18 @@ association_update_data(Association *assoc)
     dir = VERTICAL;
 
   switch (dir) {
-  case HORIZONTAL:
-    assoc->text_align = ALIGN_CENTER;
-    assoc->text_pos.x = 0.5*(points[i].x+points[i+1].x);
-    assoc->text_pos.y = points[i].y - assoc->descent;
-    break;
-  case VERTICAL:
-    assoc->text_align = ALIGN_LEFT;
-    assoc->text_pos.x = points[i].x + 0.1;
-    assoc->text_pos.y = 0.5*(points[i].y+points[i+1].y) - assoc->descent;
-    break;
+    case HORIZONTAL:
+      assoc->text_align = ALIGN_CENTER;
+      assoc->text_pos.x = 0.5*(points[i].x+points[i+1].x);
+      assoc->text_pos.y = points[i].y - assoc->descent;
+      break;
+    case VERTICAL:
+      assoc->text_align = ALIGN_LEFT;
+      assoc->text_pos.x = points[i].x + 0.1;
+      assoc->text_pos.y = 0.5*(points[i].y+points[i+1].y) - assoc->descent;
+      break;
+    default:
+      g_return_if_reached ();
   }
 
   /* Add the text recangle to the bounding box: */
@@ -767,6 +774,7 @@ association_update_data(Association *assoc)
   association_update_data_end(assoc, 1);
 }
 
+
 static double
 get_aggregate_pos_diff (AssociationEnd *end, const Association *assoc)
 {
@@ -774,22 +782,24 @@ get_aggregate_pos_diff (AssociationEnd *end, const Association *assoc)
   if (end->arrow){
     width = ASSOCIATION_TRIANGLESIZE;
   }
-  switch(end->aggregate){
-  case AGGREGATE_COMPOSITION:
-  case AGGREGATE_NORMAL:
-    if(width!=0) width = MAX(ASSOCIATION_TRIANGLESIZE, ASSOCIATION_DIAMONDLEN);
-    else width = ASSOCIATION_DIAMONDLEN;
-  case AGGREGATE_NONE:
-    break;
+  switch (end->aggregate) {
+    case AGGREGATE_COMPOSITION:
+    case AGGREGATE_NORMAL:
+      if(width!=0) width = MAX(ASSOCIATION_TRIANGLESIZE, ASSOCIATION_DIAMONDLEN);
+      else width = ASSOCIATION_DIAMONDLEN;
+    case AGGREGATE_NONE:
+    default:
+      break;
   }
   return width;
 }
 
+
 static DiaObject *
-association_create(Point *startpoint,
-              void *user_data,
-              Handle **handle1,
-              Handle **handle2)
+association_create (Point   *startpoint,
+                    void    *user_data,
+                    Handle **handle1,
+                    Handle **handle2)
 {
   Association *assoc;
   OrthConn *orth;
@@ -797,7 +807,7 @@ association_create(Point *startpoint,
   int i;
   int user_d;
 
-  assoc = g_malloc0(sizeof(Association));
+  assoc = g_malloc0 (sizeof (Association));
   orth = &assoc->orth;
   obj = &orth->object;
 
@@ -805,20 +815,21 @@ association_create(Point *startpoint,
 
   obj->ops = &association_ops;
 
-  orthconn_init(orth, startpoint);
+  orthconn_init (orth, startpoint);
 
   /* old defaults */
   assoc->font_height = 0.8;
-  assoc->font = dia_font_new_from_style(DIA_FONT_MONOSPACE, assoc->font_height);
+  assoc->font = dia_font_new_from_style (DIA_FONT_MONOSPACE,
+                                         assoc->font_height);
 
   assoc->text_color = color_black;
   assoc->line_width = 0.1; /* old default */
-  assoc->line_color = attributes_get_foreground();
+  assoc->line_color = attributes_get_foreground ();
   assoc->name = NULL;
   assoc->assoc_type = AGGREGATE_NORMAL;
   assoc->direction = ASSOC_RIGHT;
   assoc->show_direction = FALSE;
-  for (i=0;i<2;i++) {
+  for (i = 0; i < 2; i++) {
     assoc->end[i].role = NULL;
     assoc->end[i].multiplicity = NULL;
     assoc->end[i].arrow = FALSE;
@@ -829,19 +840,21 @@ association_create(Point *startpoint,
 
   assoc->text_width = 0.0;
 
-  user_d = GPOINTER_TO_INT(user_data);
+  user_d = GPOINTER_TO_INT (user_data);
   switch (user_d) {
-  case 0:
-    assoc->assoc_type = AGGREGATE_NONE;
-    assoc->show_direction = TRUE;
-    break;
-  case 1:
-    assoc->assoc_type = AGGREGATE_NORMAL;
-    assoc->show_direction = FALSE;
-    break;
+    case 0:
+      assoc->assoc_type = AGGREGATE_NONE;
+      assoc->show_direction = TRUE;
+      break;
+    case 1:
+      assoc->assoc_type = AGGREGATE_NORMAL;
+      assoc->show_direction = FALSE;
+      break;
+    default:
+      g_return_val_if_reached (NULL);
   }
 
-  association_update_data(assoc);
+  association_update_data (assoc);
 
   *handle1 = orth->handles[0];
   *handle2 = orth->handles[orth->numpoints-2];
@@ -849,21 +862,31 @@ association_create(Point *startpoint,
   return &assoc->orth.object;
 }
 
+
 static ObjectChange *
-association_add_segment_callback(DiaObject *obj, Point *clicked, gpointer data)
+association_add_segment_callback (DiaObject *obj,
+                                  Point     *clicked,
+                                  gpointer   data)
 {
   ObjectChange *change;
-  change = orthconn_add_segment((OrthConn *)obj, clicked);
-  association_update_data((Association *)obj);
+
+  change = orthconn_add_segment ((OrthConn *) obj, clicked);
+  association_update_data ((Association *) obj);
+
   return change;
 }
 
+
 static ObjectChange *
-association_delete_segment_callback(DiaObject *obj, Point *clicked, gpointer data)
+association_delete_segment_callback (DiaObject *obj,
+                                     Point     *clicked,
+                                     gpointer   data)
 {
   ObjectChange *change;
-  change = orthconn_delete_segment((OrthConn *)obj, clicked);
-  association_update_data((Association *)obj);
+
+  change = orthconn_delete_segment ((OrthConn *) obj, clicked);
+  association_update_data ((Association *) obj);
+
   return change;
 }
 
@@ -874,43 +897,49 @@ static DiaMenuItem object_menu_items[] = {
   ORTHCONN_COMMON_MENUS,
 };
 
+
 static DiaMenu object_menu = {
   "Association",
-  sizeof(object_menu_items)/sizeof(DiaMenuItem),
+  sizeof (object_menu_items) / sizeof (DiaMenuItem),
   object_menu_items,
   NULL
 };
 
+
 static DiaMenu *
-association_get_object_menu(Association *assoc, Point *clickedpoint)
+association_get_object_menu (Association *assoc, Point *clickedpoint)
 {
   OrthConn *orth;
 
   orth = &assoc->orth;
   /* Set entries sensitive/selected etc here */
-  object_menu_items[0].active = orthconn_can_add_segment(orth, clickedpoint);
-  object_menu_items[1].active = orthconn_can_delete_segment(orth, clickedpoint);
-  orthconn_update_object_menu(orth, clickedpoint, &object_menu_items[2]);
+  object_menu_items[0].active = orthconn_can_add_segment (orth, clickedpoint);
+  object_menu_items[1].active = orthconn_can_delete_segment (orth,
+                                                             clickedpoint);
+  orthconn_update_object_menu (orth, clickedpoint, &object_menu_items[2]);
+
   return &object_menu;
 }
 
+
 static void
-association_destroy(Association *assoc)
+association_destroy (Association *assoc)
 {
   int i;
 
-  orthconn_destroy(&assoc->orth);
+  orthconn_destroy (&assoc->orth);
   g_clear_object (&assoc->font);
-  g_free(assoc->name);
+  g_free (assoc->name);
 
-  for (i=0;i<2;i++) {
-    g_free(assoc->end[i].role);
-    g_free(assoc->end[i].multiplicity);
+  for (i = 0; i < 2; i++) {
+    g_free (assoc->end[i].role);
+    g_free (assoc->end[i].multiplicity);
   }
 }
 
+
 static DiaObject *
-association_copy(Association *assoc)
+association_copy (Association *assoc)
 {
   Association *newassoc;
   OrthConn *orth, *neworth;
@@ -918,12 +947,12 @@ association_copy(Association *assoc)
 
   orth = &assoc->orth;
 
-  newassoc = g_malloc0(sizeof(Association));
+  newassoc = g_malloc0 (sizeof (Association));
   neworth = &newassoc->orth;
 
-  orthconn_copy(orth, neworth);
+  orthconn_copy (orth, neworth);
 
-  newassoc->name = g_strdup(assoc->name);
+  newassoc->name = g_strdup (assoc->name);
   newassoc->direction = assoc->direction;
   newassoc->show_direction = assoc->show_direction;
   newassoc->assoc_type = assoc->assoc_type;
@@ -932,23 +961,26 @@ association_copy(Association *assoc)
   newassoc->text_color = assoc->text_color;
   newassoc->line_width = assoc->line_width;
   newassoc->line_color = assoc->line_color;
-  for (i=0;i<2;i++) {
+  for (i = 0; i < 2; i++) {
     newassoc->end[i] = assoc->end[i];
     newassoc->end[i].role =
-      (assoc->end[i].role != NULL)?g_strdup(assoc->end[i].role):NULL;
+      (assoc->end[i].role != NULL) ? g_strdup (assoc->end[i].role) : NULL;
+
     newassoc->end[i].multiplicity =
-      (assoc->end[i].multiplicity != NULL)?g_strdup(assoc->end[i].multiplicity):NULL;
+      (assoc->end[i].multiplicity != NULL) ?
+        g_strdup (assoc->end[i].multiplicity) : NULL;
   }
 
   newassoc->text_width = assoc->text_width;
 
-  association_update_data(newassoc);
+  association_update_data (newassoc);
 
   return &newassoc->orth.object;
 }
 
+
 static DiaObject *
-association_load(ObjectNode obj_node, int version, DiaContext *ctx)
+association_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
   Association *assoc;
   AttributeNode attr;
@@ -958,73 +990,82 @@ association_load(ObjectNode obj_node, int version, DiaContext *ctx)
   int i;
 
   /* first calls our _create() method */
-  obj = object_load_using_properties(&association_type, obj_node, version, ctx);
-  assoc = (Association *)obj;
+  obj = object_load_using_properties (&association_type,
+                                      obj_node, version, ctx);
+  assoc = (Association *) obj;
   orth = &assoc->orth;
   /* ... butnot orthconn_load()  */
-  if (version < 1)
+  if (version < 1) {
     orth->autorouting = FALSE;
+  }
 
   if (version < 2) {
     /* vesrion 1 used to name it differently */
-    attr = object_find_attribute(obj_node, "autorouting");
-    if (attr != NULL)
-      orth->autorouting = data_boolean(attribute_first_data(attr), ctx);
+    attr = object_find_attribute (obj_node, "autorouting");
+    if (attr != NULL) {
+      orth->autorouting = data_boolean (attribute_first_data (attr), ctx);
+    }
 
-    attr = object_find_attribute(obj_node, "ends");
-    composite = attribute_first_data(attr);
-    for (i=0;i<2;i++) {
+    attr = object_find_attribute (obj_node, "ends");
+    composite = attribute_first_data (attr);
+    for (i = 0; i < 2; i++) {
 
       assoc->end[i].role = NULL;
-      attr = composite_find_attribute(composite, "role");
+      attr = composite_find_attribute (composite, "role");
       if (attr != NULL) {
-        assoc->end[i].role = data_string(attribute_first_data(attr), ctx);
+        assoc->end[i].role = data_string (attribute_first_data (attr), ctx);
       }
       if (   assoc->end[i].role != NULL
-          && 0 == strcmp(assoc->end[i].role, "")) {
-        g_free(assoc->end[i].role);
+          && 0 == strcmp (assoc->end[i].role, "")) {
+        g_free (assoc->end[i].role);
         assoc->end[i].role = NULL;
       }
 
       assoc->end[i].multiplicity = NULL;
-      attr = composite_find_attribute(composite, "multiplicity");
+      attr = composite_find_attribute (composite, "multiplicity");
       if (attr != NULL) {
-        assoc->end[i].multiplicity = data_string(attribute_first_data(attr), ctx);
+        assoc->end[i].multiplicity = data_string (attribute_first_data (attr),
+                                                  ctx);
       }
       if (   assoc->end[i].multiplicity != NULL
-         && 0 == strcmp(assoc->end[i].multiplicity, "")) {
-        g_free(assoc->end[i].multiplicity);
+          && 0 == strcmp (assoc->end[i].multiplicity, "")) {
+        g_free (assoc->end[i].multiplicity);
         assoc->end[i].multiplicity = NULL;
       }
 
       assoc->end[i].arrow = FALSE;
-      attr = composite_find_attribute(composite, "arrow");
-      if (attr != NULL)
-        assoc->end[i].arrow = data_boolean(attribute_first_data(attr), ctx);
+      attr = composite_find_attribute (composite, "arrow");
+      if (attr != NULL) {
+        assoc->end[i].arrow = data_boolean (attribute_first_data (attr), ctx);
+      }
 
       assoc->end[i].aggregate = AGGREGATE_NONE;
-      attr = composite_find_attribute(composite, "aggregate");
-      if (attr != NULL)
-        assoc->end[i].aggregate = data_enum(attribute_first_data(attr), ctx);
+      attr = composite_find_attribute (composite, "aggregate");
+      if (attr != NULL) {
+        assoc->end[i].aggregate = data_enum (attribute_first_data (attr),
+                                             ctx);
+      }
 
       assoc->end[i].visibility = FALSE;
-      attr = composite_find_attribute(composite, "visibility");
-      if (attr != NULL)
-        assoc->end[i].visibility = data_enum(attribute_first_data(attr), ctx);
+      attr = composite_find_attribute (composite, "visibility");
+      if (attr != NULL) {
+        assoc->end[i].visibility = data_enum (attribute_first_data (attr),
+                                              ctx);
+      }
 
       assoc->end[i].text_width = 0.0;
       if (assoc->end[i].role != NULL) {
         assoc->end[i].text_width =
-          dia_font_string_width(assoc->end[i].role, assoc->font,
-                                assoc->font_height);
+          dia_font_string_width (assoc->end[i].role, assoc->font,
+                                 assoc->font_height);
       }
       if (assoc->end[i].multiplicity != NULL) {
         assoc->end[i].text_width =
           MAX(assoc->end[i].text_width,
-              dia_font_string_width(assoc->end[i].multiplicity,
-                                    assoc->font, assoc->font_height) );
+              dia_font_string_width (assoc->end[i].multiplicity,
+                                     assoc->font, assoc->font_height) );
       }
-      composite = data_next(composite);
+      composite = data_next (composite);
     }
     /* derive new members state from ends */
     assoc->show_direction = (assoc->direction != ASSOC_NODIR);
@@ -1043,8 +1084,7 @@ association_load(ObjectNode obj_node, int version, DiaContext *ctx)
     }
   } /* version < 2 */
 
-  association_set_state(assoc, association_get_state(assoc));
+  association_set_state (assoc, association_get_state (assoc));
 
   return &assoc->orth.object;
 }
-
diff --git a/objects/UML/transition.c b/objects/UML/transition.c
index c9320075..214b579a 100644
--- a/objects/UML/transition.c
+++ b/objects/UML/transition.c
@@ -166,6 +166,8 @@ static PropOffset transition_offsets[] = {
 #define TRANSITION_MENU_ADD_SEGMENT_OFFSET 0
 #define TRANSITION_MENU_DEL_SEGMENT_OFFSET 1
 #define TRANSITION_MENU_OFFSET_TO_ORTH_COMMON 2
+
+
 static DiaMenuItem transition_menu_items[] = {
   { N_("Add segment"), transition_add_segment_cb, NULL, 0 } ,
   { N_("Delete segment"), transition_del_segment_cb, NULL, 0 } ,
@@ -175,17 +177,17 @@ static DiaMenuItem transition_menu_items[] = {
 
 static DiaMenu transition_menu = {
   "Transition",
-  sizeof(transition_menu_items)/sizeof(DiaMenuItem),
+  sizeof (transition_menu_items) / sizeof(DiaMenuItem),
   transition_menu_items,
   NULL
 };
 
 
 static DiaObject *
-transition_create(Point *startpoint,
-                  void *user_data,
-                  Handle **handle1,
-                  Handle **handle2)
+transition_create (Point   *startpoint,
+                   void    *user_data,
+                   Handle **handle1,
+                   Handle **handle2)
 {
   Transition *transition;
   OrthConn *orth;
@@ -197,17 +199,17 @@ transition_create(Point *startpoint,
       dia_font_new_from_style (DIA_FONT_SANS, TRANSITION_FONTHEIGHT);
   }
 
-  transition = g_malloc0(sizeof(Transition));
+  transition = g_new0 (Transition, 1);
 
   orth = &transition->orth;
   obj = &orth->object;
   obj->type = &uml_transition_type;
   obj->ops = &uml_transition_ops;
 
-  orthconn_init(orth, startpoint);
+  orthconn_init (orth, startpoint);
 
   transition->text_color = color_black;
-  transition->line_color = attributes_get_foreground();
+  transition->line_color = attributes_get_foreground ();
   /* Prepare the handles for trigger and guard text */
   transition->trigger_text_handle.id = HANDLE_MOVE_TRIGGER_TEXT;
   transition->trigger_text_handle.type = HANDLE_MINOR_CONTROL;
@@ -217,7 +219,7 @@ transition_create(Point *startpoint,
   temp_point.y -= TEXT_HANDLE_DISTANCE_FROM_STARTPOINT;
   transition->trigger_text_pos = temp_point;
   transition->trigger_text_handle.pos = temp_point;
-  object_add_handle(obj, &transition->trigger_text_handle);
+  object_add_handle (obj, &transition->trigger_text_handle);
 
   transition->guard_text_handle.id = HANDLE_MOVE_GUARD_TEXT;
   transition->guard_text_handle.type = HANDLE_MINOR_CONTROL;
@@ -226,111 +228,123 @@ transition_create(Point *startpoint,
   temp_point = *startpoint;
   temp_point.y += TEXT_HANDLE_DISTANCE_FROM_STARTPOINT;
   transition->guard_text_pos = transition->guard_text_handle.pos = temp_point;
-  object_add_handle(obj, &transition->guard_text_handle);
+  object_add_handle (obj, &transition->guard_text_handle);
 
   transition->guard_text = NULL;
   transition->trigger_text = NULL;
   transition->action_text = NULL;
 
-  uml_transition_update_data(transition);
+  uml_transition_update_data (transition);
 
   *handle1 = obj->handles[0];
   *handle2 = obj->handles[1];
   return obj;
 }
 
-static DiaObject *transition_load(ObjectNode obj_node, int version,DiaContext *ctx)
+
+static DiaObject *
+transition_load (ObjectNode obj_node, int version, DiaContext *ctx)
 {
-  DiaObject *obj = object_load_using_properties(&uml_transition_type,
-                                                obj_node,version,ctx);
+  DiaObject *obj = object_load_using_properties (&uml_transition_type,
+                                                 obj_node,version,ctx);
   if (version == 0) {
     AttributeNode attr;
     /* In old objects with no autorouting, set it to false. */
-    attr = object_find_attribute(obj_node, "autorouting");
-    if (attr == NULL)
-      ((OrthConn*)obj)->autorouting = FALSE;
+    attr = object_find_attribute (obj_node, "autorouting");
+    if (attr == NULL) {
+      ((OrthConn*) obj)->autorouting = FALSE;
+    }
   }
   if (version < 2) {
       /* Versions prior to 2 have the arrowheads inverted */
-      ((Transition*)obj)->direction_inverted = TRUE;
+      ((Transition*) obj)->direction_inverted = TRUE;
   }
   return obj;
 }
 
+
 static void
-transition_set_props(Transition *transition, GPtrArray *props)
+transition_set_props (Transition *transition, GPtrArray *props)
 {
-  object_set_props_from_offsets(&transition->orth.object,
-                                transition_offsets, props);
-  uml_transition_update_data(transition);
+  object_set_props_from_offsets (&transition->orth.object,
+                                 transition_offsets, props);
+  uml_transition_update_data (transition);
 }
 
 
 static void
-transition_get_props(Transition *transition, GPtrArray *props)
+transition_get_props (Transition *transition, GPtrArray *props)
 {
-  object_get_props_from_offsets(&transition->orth.object,
-                                transition_offsets, props);
+  object_get_props_from_offsets (&transition->orth.object,
+                                 transition_offsets, props);
 }
 
+
 static PropDescription *
-transition_describe_props(Transition *transition)
+transition_describe_props (Transition *transition)
 {
   if (transition_props[0].quark == 0)
-    prop_desc_list_calculate_quarks(transition_props);
+    prop_desc_list_calculate_quarks (transition_props);
   return transition_props;
 
 }
 
+
 static void
 transition_destroy(Transition* transition)
 {
   g_free (transition->trigger_text);
   g_free (transition->action_text);
   g_free (transition->guard_text);
-  orthconn_destroy(&transition->orth);
+  orthconn_destroy (&transition->orth);
 }
 
+
 static DiaMenu*
-transition_get_object_menu(Transition* transition, Point* clickedpoint)
+transition_get_object_menu (Transition *transition, Point *clickedpoint)
 {
   OrthConn *orth = &transition->orth;
   /* Set/clear the active flag of the add/remove segment according to the
      placement of mouse pointer and placement of the transition and its handles */
   transition_menu_items[TRANSITION_MENU_ADD_SEGMENT_OFFSET].active =
-      orthconn_can_add_segment(orth, clickedpoint);
+      orthconn_can_add_segment (orth, clickedpoint);
   transition_menu_items[TRANSITION_MENU_DEL_SEGMENT_OFFSET].active =
-      orthconn_can_delete_segment(orth, clickedpoint);
+      orthconn_can_delete_segment (orth, clickedpoint);
 
-  orthconn_update_object_menu(orth, clickedpoint,
-             &transition_menu_items[TRANSITION_MENU_OFFSET_TO_ORTH_COMMON]);
+  orthconn_update_object_menu (orth, clickedpoint,
+                               &transition_menu_items[TRANSITION_MENU_OFFSET_TO_ORTH_COMMON]);
   return &transition_menu;
 }
 
-static gchar* create_event_action_text(Transition* transition)
+
+static gchar *
+create_event_action_text (Transition* transition)
 {
   gchar *temp_text;
-  if (transition->action_text && strlen(transition->action_text) != 0)
-  {
-    temp_text = g_strdup_printf("%s/%s", transition->trigger_text,
-                                         transition->action_text);
-  }
-  else
-  {
-         temp_text = g_strdup_printf("%s", transition->trigger_text ? transition->trigger_text : "");
+
+  if (transition->action_text && strlen (transition->action_text) != 0) {
+    temp_text = g_strdup_printf ("%s/%s", transition->trigger_text,
+                                          transition->action_text);
+  } else {
+    temp_text = g_strdup_printf ("%s",
+                                 transition->trigger_text ? transition->trigger_text : "");
   }
+
   return temp_text;
 }
 
-static gchar* create_guard_text(Transition* transition)
+
+static gchar *
+create_guard_text (Transition* transition)
 {
   gchar *temp_text;
-  temp_text = g_strdup_printf("[%s]", transition->guard_text);
+  temp_text = g_strdup_printf ("[%s]", transition->guard_text);
   return temp_text;
 }
 
+
 static void
-transition_draw (Transition* transition, DiaRenderer* renderer)
+transition_draw (Transition *transition, DiaRenderer *renderer)
 {
   Arrow arrow;
   Arrow *start_arrow;
@@ -397,62 +411,64 @@ transition_draw (Transition* transition, DiaRenderer* renderer)
                               &transition->trigger_text_pos,
                               ALIGN_CENTER,
                               &transition->text_color);
-    g_free(text);
+    g_free (text);
   }
 }
 
+
 static real
-transition_distance(Transition* transition, Point* point)
+transition_distance (Transition *transition, Point *point)
 {
-  return orthconn_distance_from(&transition->orth, point, TRANSITION_WIDTH);
+  return orthconn_distance_from (&transition->orth, point, TRANSITION_WIDTH);
 }
 
+
 static void
-transition_select(Transition* transition,
-                  Point* clicked_point,
-                  DiaRenderer* interactive_renderer)
+transition_select (Transition *transition,
+                   Point       *clicked_point,
+                   DiaRenderer *interactive_renderer)
 {
   uml_transition_update_data(transition);
 }
 
+
 static ObjectChange*
-transition_move(Transition* transition, Point* newpos)
+transition_move (Transition* transition, Point* newpos)
 {
   Point delta;
   ObjectChange *change;
 
-
   /* Find a delta in order to move the text handles along with the transition */
   delta = *newpos;
-  point_sub(&delta, &transition->orth.points[0]);
+  point_sub (&delta, &transition->orth.points[0]);
 
-  change = orthconn_move(&transition->orth, newpos);
+  change = orthconn_move (&transition->orth, newpos);
 
   /* Move the text handles */
-  point_add(&transition->trigger_text_pos, &delta);
-  point_add(&transition->guard_text_pos, &delta);
+  point_add (&transition->trigger_text_pos, &delta);
+  point_add (&transition->guard_text_pos, &delta);
 
-  uml_transition_update_data(transition);
+  uml_transition_update_data (transition);
 
   return change;
 }
 
+
 static ObjectChange*
-transition_move_handle(Transition*      transition,
-                       Handle*          handle,
-                       Point*           newpos,
-                       ConnectionPoint* cp,
-                       HandleMoveReason reason,
-                       ModifierKeys     modifiers)
+transition_move_handle (Transition       *transition,
+                        Handle           *handle,
+                        Point            *newpos,
+                        ConnectionPoint  *cp,
+                        HandleMoveReason  reason,
+                        ModifierKeys      modifiers)
 {
   ObjectChange *change = NULL;
 
-  assert(transition != NULL);
-  assert(handle != NULL);
-  assert(newpos != NULL);
+  g_return_val_if_fail (transition != NULL, NULL);
+  g_return_val_if_fail (handle != NULL, NULL);
+  g_return_val_if_fail (newpos != NULL, NULL);
 
-  switch (handle->id)
-  {
+  switch (handle->id) {
     case HANDLE_MOVE_TRIGGER_TEXT:
       /* The trigger text is being moved */
       transition->trigger_text_pos = *newpos;
@@ -463,56 +479,85 @@ transition_move_handle(Transition*      transition,
       transition->guard_text_pos = *newpos;
       break;
 
+    case HANDLE_RESIZE_NW:
+    case HANDLE_RESIZE_N:
+    case HANDLE_RESIZE_NE:
+    case HANDLE_RESIZE_W:
+    case HANDLE_RESIZE_E:
+    case HANDLE_RESIZE_SW:
+    case HANDLE_RESIZE_S:
+    case HANDLE_RESIZE_SE:
+    case HANDLE_MOVE_STARTPOINT:
+    case HANDLE_MOVE_ENDPOINT:
+    case HANDLE_CUSTOM1:
+    case HANDLE_CUSTOM4:
+    case HANDLE_CUSTOM5:
+    case HANDLE_CUSTOM6:
+    case HANDLE_CUSTOM7:
+    case HANDLE_CUSTOM8:
+    case HANDLE_CUSTOM9:
     default:
       {
-        int n = transition->orth.numpoints/2;
+        int n = transition->orth.numpoints / 2;
         Point p1, p2;
-       p1.x = 0.5 * (transition->orth.points[n-1].x + transition->orth.points[n].x);
-       p1.y = 0.5 * (transition->orth.points[n-1].y + transition->orth.points[n].y);
+
+        p1.x = 0.5 * (transition->orth.points[n-1].x + transition->orth.points[n].x);
+        p1.y = 0.5 * (transition->orth.points[n-1].y + transition->orth.points[n].y);
 
         /* Tell the connection that one of its handles is being moved */
-        change = orthconn_move_handle(&transition->orth, handle, newpos, cp, reason, modifiers);
-       /* with auto-routing the number of points may have changed */
-       n = transition->orth.numpoints/2;
-       p2.x = 0.5 * (transition->orth.points[n-1].x + transition->orth.points[n].x);
-       p2.y = 0.5 * (transition->orth.points[n-1].y + transition->orth.points[n].y);
-        point_sub(&p2, &p1);
-
-        point_add(&transition->trigger_text_pos, &p2);
-        point_add(&transition->guard_text_pos, &p2);
+        change = orthconn_move_handle (&transition->orth,
+                                       handle,
+                                       newpos,
+                                       cp,
+                                       reason,
+                                       modifiers);
+        /* with auto-routing the number of points may have changed */
+        n = transition->orth.numpoints/2;
+        p2.x = 0.5 * (transition->orth.points[n-1].x + transition->orth.points[n].x);
+        p2.y = 0.5 * (transition->orth.points[n-1].y + transition->orth.points[n].y);
+        point_sub (&p2, &p1);
+
+        point_add (&transition->trigger_text_pos, &p2);
+        point_add (&transition->guard_text_pos, &p2);
       }
       break;
   }
 
   /* Update ourselves to reflect the new handle position */
-  uml_transition_update_data(transition);
+  uml_transition_update_data (transition);
 
   return change;
 }
 
-static ObjectChange* transition_add_segment_cb(DiaObject *obj,
-                                               Point *clickedpoint,
-                                               gpointer data)
+
+static ObjectChange *
+transition_add_segment_cb (DiaObject *obj,
+                           Point     *clickedpoint,
+                           gpointer   data)
 {
   ObjectChange *change;
-  change = orthconn_add_segment((OrthConn*)obj, clickedpoint);
-  uml_transition_update_data((Transition*)obj);
+
+  change = orthconn_add_segment ((OrthConn *) obj, clickedpoint);
+  uml_transition_update_data ((Transition *) obj);
+
   return change;
 }
 
 
-static ObjectChange* transition_del_segment_cb(DiaObject *obj,
-                                               Point *clickedpoint,
-                                               gpointer data)
+static ObjectChange *
+transition_del_segment_cb (DiaObject *obj,
+                           Point     *clickedpoint,
+                           gpointer   data)
 {
   ObjectChange *change;
-  change = orthconn_delete_segment((OrthConn*)obj, clickedpoint);
-  uml_transition_update_data((Transition*)obj);
+
+  change = orthconn_delete_segment ((OrthConn *) obj, clickedpoint);
+  uml_transition_update_data ((Transition *) obj);
+
   return change;
 }
 
 
-
 static void
 expand_bbox_for_text (DiaRectangle *bbox,
                       Point        *text_pos,
@@ -521,19 +566,19 @@ expand_bbox_for_text (DiaRectangle *bbox,
   DiaRectangle text_box;
   real text_width;
 
-  text_width = dia_font_string_width(text, transition_font,
-                                     TRANSITION_FONTHEIGHT);
+  text_width = dia_font_string_width (text, transition_font,
+                                      TRANSITION_FONTHEIGHT);
   text_box.left = text_pos->x - text_width/2;
   text_box.right = text_box.left + text_width;
-  text_box.top = text_pos->y - dia_font_ascent(text, transition_font,
-                                              TRANSITION_FONTHEIGHT);
+  text_box.top = text_pos->y - dia_font_ascent (text, transition_font,
+                                                TRANSITION_FONTHEIGHT);
   text_box.bottom = text_box.top + TRANSITION_FONTHEIGHT;
-  rectangle_union(bbox, &text_box);
-
+  rectangle_union (bbox, &text_box);
 }
 
+
 static void
-uml_transition_update_data(Transition *transition)
+uml_transition_update_data (Transition *transition)
 {
   gchar *temp_text;
   Point *points;
@@ -550,26 +595,24 @@ uml_transition_update_data(Transition *transition)
   transition->guard_text_handle.pos = transition->guard_text_pos;
 
   /* Update the orthogonal connection to match the new data */
-  orthconn_update_data(orth);
+  orthconn_update_data (orth);
 
   extra->start_long = extra->end_long
                     = extra->middle_trans
                     = TRANSITION_WIDTH/2.0;
   extra->start_trans = extra->end_trans
-                     = MAX(TRANSITION_ARROWLEN, TRANSITION_WIDTH/2.0);
+                     = MAX (TRANSITION_ARROWLEN, TRANSITION_WIDTH/2.0);
 
   /* Update the bounding box to match the new connection data */
-  orthconn_update_boundingbox(orth);
+  orthconn_update_boundingbox (orth);
   /* Update the bounding box to match the new trigger text size and position */
-  temp_text = create_event_action_text(transition);
-  expand_bbox_for_text(&obj->bounding_box, &transition->trigger_text_pos,
-                       temp_text);
-  g_free(temp_text);
+  temp_text = create_event_action_text (transition);
+  expand_bbox_for_text (&obj->bounding_box, &transition->trigger_text_pos,
+                        temp_text);
+  g_free (temp_text);
   /* Update the bounding box to match the new guard text size and position */
-  temp_text = g_strdup_printf("[%s]", transition->guard_text ? transition->guard_text : "");
-  expand_bbox_for_text(&obj->bounding_box, &transition->guard_text_pos,
-                       temp_text);
-  g_free(temp_text);
+  temp_text = g_strdup_printf ("[%s]", transition->guard_text ? transition->guard_text : "");
+  expand_bbox_for_text (&obj->bounding_box, &transition->guard_text_pos,
+                        temp_text);
+  g_free (temp_text);
 }
-
-


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