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

gEDA-cvs: CVS update: o_basic.c



  User: cnieves 
  Date: 06/10/21 18:20:39

  Modified:    .        Tag: glist_dev o_basic.c o_complex_basic.c o_list.c
                        o_net_basic.c o_selection.c s_basic.c s_page.c
  Log:
  Convert the SELECTION list into a GList. Added new functions
  
  o_recalc_object_glist and get_object_glist_bounds to handle glists.
  
  
  
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.14.2.2  +24 -0     eda/geda/gaf/libgeda/src/o_basic.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_basic.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_basic.c,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -b -r1.14.2.1 -r1.14.2.2
  --- o_basic.c	21 Oct 2006 21:14:42 -0000	1.14.2.1
  +++ o_basic.c	21 Oct 2006 22:20:35 -0000	1.14.2.2
  @@ -162,6 +162,30 @@
     }
   }
   
  +/*! \brief Recalculate position of a list (GList) of objects.
  + *  \par Function Description
  + *  This function will take a list (GList) of objects and recalculate their
  + *  positions on the screen.
  + *
  + *  \param [in]     w_current    The TOPLEVEL object.
  + *  \param [in,out] object_glist  OBJECT list to recalculate.
  + *
  + */
  +void
  +o_recalc_object_glist(TOPLEVEL *w_current, GList *object_glist)
  +{
  +  GList *list = object_glist;
  +  OBJECT *o_current;
  +
  +  while (list != NULL) {
  +    o_current = (OBJECT *) list->data;
  +    o_recalc_single_object(w_current, o_current);
  +   list = list->next;
  +  }
  +}
  +
  +
  +
   
   /*! \brief Set an #OBJECT's line options.
    *  \par Function Description
  
  
  
  1.27.2.4  +93 -78    eda/geda/gaf/libgeda/src/o_complex_basic.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_complex_basic.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_complex_basic.c,v
  retrieving revision 1.27.2.3
  retrieving revision 1.27.2.4
  diff -u -b -r1.27.2.3 -r1.27.2.4
  --- o_complex_basic.c	21 Oct 2006 20:35:56 -0000	1.27.2.3
  +++ o_complex_basic.c	21 Oct 2006 22:20:35 -0000	1.27.2.4
  @@ -135,7 +135,6 @@
     *bottom = rbottom = 0;
   	
   
  -
     o_current = complex;
   	
     while ( o_current != NULL ) {
  @@ -152,14 +151,19 @@
   
   }
   
  -/*! \brief
  - *  \par Function Description
  - *
  +/*! \brief Return the bounds of the given GList of objects.
  + *  \par Given a list of objects, calcule the bounds coordinates.
  + *  \param [in] w_current The toplevel structure.
  + *  \param [in] complex   The list of objects to look the bounds for.
  + *  \param [out] left   pointer to the left coordinate of the object.
  + *  \param [out] top    pointer to the top coordinate of the object.
  + *  \param [out] right  pointer to the right coordinate of the object.
  + *  \param [out] bottom pointer to the bottom coordinate of the object.
    */
  -void get_complex_bounds_selection(TOPLEVEL *w_current, SELECTION *head, 
  +void get_object_glist_bounds(TOPLEVEL *w_current, GList *head, 
   				  int *left, int *top, int *right, int *bottom)
   {
  -  SELECTION *s_current=NULL;
  +  GList *s_current=NULL;
     OBJECT *o_current=NULL;
     int rleft, rtop, rright, rbottom;
   	
  @@ -172,66 +176,12 @@
   	
     while ( s_current != NULL ) {
   
  -    o_current = s_current->selected_object;
  -
  -    if (!o_current) {
  -      fprintf(stderr, "Got NULL in get_complex_bounds_selection\n");
  -      exit(-1);
  -    }
  -
  -    switch(o_current->type) {
  -      case(OBJ_LINE):
  -        get_line_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_NET):
  -        /* same as a line (diff name)*/
  -        get_net_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_BUS):
  -        /* same as a line (diff name)*/
  -        get_bus_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -	
  -      case(OBJ_BOX):
  -        get_box_bounds(w_current, o_current->box, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_PICTURE):
  -        get_picture_bounds(w_current, o_current->picture, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_CIRCLE):
  -        get_circle_bounds(w_current, o_current->circle, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_COMPLEX):
  -      case(OBJ_PLACEHOLDER):
  -        /* recursive objects ?*/
  -        get_object_list_bounds(w_current, o_current->complex->prim_objs, &rleft, &rtop, &rright, &rbottom);
  -        break;
  -
  -      case(OBJ_TEXT):
  -        /* only do bounding boxes for visible or doing show hidden text */
  -        /* you might lose some attrs though */
  -        if (o_current->visibility == VISIBLE ||
  -            (o_current->visibility == INVISIBLE && w_current->show_hidden_text)) {
  -          get_text_bounds(w_current, o_current, &rleft, &rtop, &rright, &rbottom);
  -        }
  -        break;
  -
  -      case(OBJ_PIN):
  -        get_pin_bounds(w_current, o_current->line, &rleft, &rtop, &rright, &rbottom);
  -        break;
  +    o_current = (OBJECT *) s_current->data;
   
  -      case(OBJ_ARC):
  -        get_arc_bounds(w_current, o_current, &rleft, &rtop, &rright, &rbottom);
  -        break;
  +    g_assert (o_current != NULL);
   
  -      default:
  -        break;
  -    }
  +    get_single_object_bounds(w_current, o_current, &rleft, &rtop, 
  +			     &rright, &rbottom);
   
       if (rleft < *left) *left = rleft;
       if (rtop < *top) *top = rtop;
  @@ -437,7 +387,8 @@
    *  \par Function Description
    *
    */
  -OBJECT *o_complex_add(TOPLEVEL *w_current, OBJECT *object_list, char type,
  +OBJECT *o_complex_add(TOPLEVEL *w_current, OBJECT *object_list, 
  +		      GList **object_glist, char type,
   		      int color, int x, int y, int angle,
   		      int mirror, char *clib,
   		      char *basename, int selectable,
  @@ -449,8 +400,15 @@
     OBJECT *temp_parent=NULL;
     int save_adding_sel = 0;
     int loaded_normally = FALSE;
  -	
  +  gboolean use_object_list;
     char *filename;
  +  GList *glist_ptr;
  +
  +  if (object_list) {
  +    use_object_list = TRUE;
  +  } else {
  +    use_object_list = FALSE;
  +  }
   
     new_node = s_basic_init_object("complex");
     new_node->type = type;
  @@ -627,9 +585,35 @@
   
             /* Isolate tmp completely, now that it's removed from list */
             tmp->next=tmp->prev=NULL;
  -		
  +	  if (use_object_list) {
             object_list = (OBJECT *) s_basic_link_object(tmp, object_list);
             o_attrib_attach (w_current, object_list, tmp, new_node);
  +	  }
  +	  else {
  +	    if (object_glist) {
  +	      *object_glist = g_list_append (*object_glist, tmp);
  +	      
  +	      glist_ptr = *object_glist;
  +	      while (glist_ptr) {
  +		if (glist_ptr->prev == NULL) {
  +		  ((OBJECT *) glist_ptr->data)->prev = NULL;
  +		} else {
  +		  ((OBJECT *) glist_ptr->data)->prev = glist_ptr->prev->data;
  +		}
  +		if (glist_ptr->next == NULL) {
  +		  ((OBJECT *) glist_ptr->data)->next = NULL;
  +		} else {
  +		  ((OBJECT *) glist_ptr->data)->next = glist_ptr->next->data;
  +		}
  +		glist_ptr = glist_ptr->next;
  +	      }
  +	      
  +	      o_attrib_attach (w_current, ((OBJECT *) g_list_last(*object_glist)->data), 
  +			       tmp, new_node);
  +	    } else {
  +	      o_attrib_attach (w_current, NULL, tmp, new_node);
  +	    }
  +	  }
             o_text_translate_world(w_current, x, y, tmp);
   
           } else { /* not promoting now, but deal with floating attribs */
  @@ -652,19 +636,45 @@
     w_current->page_current->object_tail = temp_tail;
     w_current->page_current->object_parent = temp_parent;
   
  +  if (use_object_list) {
     object_list = (OBJECT *) s_basic_link_object(new_node, object_list);
     object_list->complex->prim_objs = prim_objs;
  +  }
  +  else {
  +    new_node->complex->prim_objs = prim_objs;
  +    if (object_glist) {
  +      *object_glist = g_list_append (*object_glist, new_node);
  +
  +      glist_ptr = *object_glist;
  +      while (glist_ptr) {
  +	if (glist_ptr->prev == NULL) {
  +	  ((OBJECT *) glist_ptr->data)->prev = NULL;
  +	} else {
  +	  ((OBJECT *) glist_ptr->data)->prev = glist_ptr->prev->data;
  +	}
  +	if (glist_ptr->next == NULL) {
  +	  ((OBJECT *) glist_ptr->data)->next = NULL;
  +	} else {
  +	  ((OBJECT *) glist_ptr->data)->next = glist_ptr->next->data;
  +	}
  +	glist_ptr = glist_ptr->next;
  +      }
  +      object_list = (OBJECT *) (g_list_last(*object_glist)->data);
  +    } else {
  +      object_list = new_node;
  +    }
   
  +  }
   
     /* do not mirror/rotate/translate/connect the primitive objects if the
      * component was not loaded via o_read 
      */
     if (loaded_normally == TRUE) {
       if (mirror) {
  -      o_complex_mirror_lowlevel(w_current, x, y, object_list);
  +      o_complex_mirror_lowlevel(w_current, x, y, new_node);
       } 
   
  -    o_complex_rotate_lowlevel(w_current, x, y, angle, angle, object_list); 
  +    o_complex_rotate_lowlevel(w_current, x, y, angle, angle, new_node); 
       o_complex_world_translate(w_current, x, y, prim_objs);
   
       if (!w_current->ADDING_SEL) {
  @@ -758,6 +768,7 @@
                   o_current->complex->y,
                   &o_current->complex->screen_x, 
                   &o_current->complex->screen_y);
  +
   }
   
   /*! \brief
  @@ -833,7 +844,7 @@
         clib = (gchar*)clibs->data;
       }
       
  -    object_list = o_complex_add(w_current, object_list, type, 
  +    object_list = o_complex_add(w_current, object_list, NULL, type, 
   				WHITE, 
   				x1, y1, 
   				angle, mirror,
  @@ -1048,6 +1059,10 @@
   {
     int left, right, top, bottom;
   
  +  g_return_if_fail(object != NULL);
  +  g_return_if_fail((object->type == OBJ_COMPLEX) ||
  +		   (object->type == OBJ_PLACEHOLDER));
  +
     object->complex->x = object->complex->x + x1;
     object->complex->y = object->complex->y + y1;
   
  @@ -1094,7 +1109,7 @@
       selectable = FALSE;	
     }
   
  -  new_obj = o_complex_add(w_current, list_tail, o_current->type, color,
  +  new_obj = o_complex_add(w_current, list_tail, NULL, o_current->type, color,
                             o_current->complex->x, o_current->complex->y, 
                             o_current->complex->angle, o_current->complex->mirror,
                             o_current->complex_clib, o_current->complex_basename, 
  
  
  
  1.18.2.1  +4 -4      eda/geda/gaf/libgeda/src/o_list.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_list.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_list.c,v
  retrieving revision 1.18
  retrieving revision 1.18.2.1
  diff -u -b -r1.18 -r1.18.2.1
  --- o_list.c	5 Jul 2006 03:13:38 -0000	1.18
  +++ o_list.c	21 Oct 2006 22:20:35 -0000	1.18.2.1
  @@ -253,10 +253,10 @@
    *  \return OBJECT pointer.
    */
   OBJECT *o_list_copy_all_selection2(TOPLEVEL *w_current,
  -				   SELECTION *src_list_head, 
  +				   GList *src_list_head, 
   				   OBJECT *dest_list_head, int flag)
   {
  -  SELECTION *src;
  +  GList *src;
     OBJECT *object;
     OBJECT *dest;
     OBJECT *temp_parent=NULL;
  @@ -283,7 +283,7 @@
     /* first do all NON text items */
     while(src != NULL) {
   
  -    object = src->selected_object;
  +    object = (OBJECT *) src->data;
   
       /* unselect the object before the copy */
       o_selection_unselect(object);	
  @@ -318,7 +318,7 @@
     /* then do all text items */
     while(src != NULL) {
   
  -    object = src->selected_object;
  +    object = (OBJECT *) src->data;
   
       /* unselect the object before the copy */
       o_selection_unselect(object);	
  
  
  
  1.31.2.1  +5 -4      eda/geda/gaf/libgeda/src/o_net_basic.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_net_basic.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_net_basic.c,v
  retrieving revision 1.31
  retrieving revision 1.31.2.1
  diff -u -b -r1.31 -r1.31.2.1
  --- o_net_basic.c	22 Sep 2006 18:48:07 -0000	1.31
  +++ o_net_basic.c	21 Oct 2006 22:20:37 -0000	1.31.2.1
  @@ -919,16 +919,17 @@
   
             changed++;
             if (other_object->selected == TRUE ) {
  -            o_selection_remove(w_current->page_current->selection2_head, 
  +            o_selection_remove(&(w_current->page_current->selection_list), 
                                  other_object);
               reselect_new=TRUE;
             }
   
             if (reselect_new == TRUE) {
  -            o_selection_remove(w_current->page_current->selection2_head, 
  +            o_selection_remove(&(w_current->page_current->selection_list), 
                                  object);
   
  -            o_selection_add(w_current->page_current->selection2_head, 
  +            w_current->page_current->selection_list = 
  +	      o_selection_add(w_current->page_current->selection_list, 
                               object);
             }
   				
  
  
  
  1.7.2.1   +63 -264   eda/geda/gaf/libgeda/src/o_selection.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_selection.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/o_selection.c,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -b -r1.7 -r1.7.2.1
  --- o_selection.c	15 Jul 2006 17:00:51 -0000	1.7
  +++ o_selection.c	21 Oct 2006 22:20:38 -0000	1.7.2.1
  @@ -46,195 +46,35 @@
   #include <dmalloc.h>
   #endif
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -SELECTION *o_selection_return_tail(SELECTION *head)
  -{
  -  SELECTION *s_current=NULL;
  -  SELECTION *ret_struct=NULL;
  -
  -  s_current = head;
  -  while ( s_current != NULL ) { /* goto end of list */
  -    ret_struct = s_current;
  -    s_current = s_current->next;
  -  }
  -
  -  return(ret_struct);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -SELECTION *o_selection_return_head(SELECTION *tail)
  -{
  -  SELECTION *s_current=NULL;
  -  SELECTION *ret_struct=NULL;
  -
  -  s_current = tail;
  -  while ( s_current != NULL ) { /* goto end of list */
  -    ret_struct = s_current;
  -    s_current = s_current->prev;
  -  }
  -
  -  return(ret_struct);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -SELECTION *o_selection_new_head(void)
  -{
  -  SELECTION *s_new;
  -
  -  s_new = (SELECTION *) g_malloc(sizeof(SELECTION));
  -  s_new->selected_object = NULL;
  -  s_new->prev = NULL;
  -  s_new->next = NULL;
  -
  -  return(s_new);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  +/*! \brief Selects the given object and adds it to the selection list
  + *  \par Selects the given object and does the needed work to make the
  + *  object visually selected.
  + *  \param [in] head Selection list
  + *  \param [in] o_selected Object to select.
  + *  \returns a pointer to the selection list, with the object added.
    */
  -void o_selection_destroy_head(SELECTION *s_head)
  +GList *o_selection_add(GList *head, OBJECT *o_selected)
   {
  -  g_free(s_head);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -/* also does the needed work to make the object visually selected */
  -SELECTION *o_selection_add(SELECTION *head, OBJECT *o_selected)
  -{
  -  SELECTION *tail;
  -  SELECTION *s_new;
  -	
  -  s_new = (SELECTION *) g_malloc(sizeof(SELECTION));
  -
  -  if (o_selected != NULL) {
  -    s_new->selected_object = o_selected;
  -  } else {
  -    fprintf(stderr, "Got NULL passed to o_selection_new\n");
  -  }
  -
     o_selection_select(o_selected, SELECT_COLOR);
  -
  -  if (head == NULL) {
  -    s_new->prev = NULL; /* setup previous link */
  -    s_new->next = NULL;
  -    return(s_new);
  -  } else {
  -    tail = o_selection_return_tail(head);
  -    s_new->prev = tail; /* setup previous link */
  -    s_new->next = NULL;
  -    tail->next = s_new;
  -    return(tail->next);
  -  }
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -/* it's okay to call this with an o_selected which is not necessarily */
  -/* selected */
  -void o_selection_remove(SELECTION *head, OBJECT *o_selected)
  -{
  -  SELECTION *s_current;
  -
  -  if (o_selected == NULL) {
  -    fprintf(stderr, "Got NULL for o_selected in o_selection_remove\n");
  -    return;
  -  }
  -
  -  s_current = head;	
  -
  -  while (s_current != NULL) {
  -    if (s_current->selected_object == o_selected) {
  -      if (s_current->next)
  -        s_current->next->prev = s_current->prev;
  -      else
  -        s_current->next = NULL;
  -
  -      if (s_current->prev)
  -        s_current->prev->next = s_current->next;
  -      else
  -        s_current->prev = NULL;
  -
  -      o_selection_unselect(s_current->selected_object);
  -
  -      s_current->selected_object = NULL;
  -      g_free(s_current);
  -      return;
  -    }
  -    s_current = s_current->next;
  -  }
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -/* removes all but the head node */
  -void o_selection_remove_most(TOPLEVEL *w_current, SELECTION *head)
  -{
  -  SELECTION *s_current;
  -  SELECTION *s_prev;
  -
  -  s_current = o_selection_return_tail(head);
  -
  -  while (s_current != NULL) {
  -    if (s_current->selected_object != NULL) {
  -      s_prev = s_current->prev;	
  -
  -      o_selection_unselect(s_current->selected_object);
  -
  -      o_redraw_single(w_current,  
  -                      s_current->selected_object);
  -	
  -      s_current->selected_object = NULL;
  -      g_free(s_current);
  -      s_current = s_prev;
  -    } else {
  -      break;
  -    }
  -  }
  -
  -  /* clear out any dangling pointers */
  -  head->next=NULL;
  +  return (g_list_append(head, o_selected));
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  +/*! \brief Prints the given selection list.
  + *  \par Prints the given selection list.
  + *  \param [in] head Selection list to print.
    *
    */
  -void o_selection_print_all( SELECTION *head )
  +void o_selection_print_all( GList *head )
   {
  -  SELECTION *s_current;
  +  GList *s_current;
   
     s_current = head;
   
     printf("START printing selection ********************\n");
     while(s_current != NULL) {
  -    if (s_current->selected_object) {
  +    if (s_current->data) {
         printf("Selected object: %d\n", 
  -             s_current->selected_object->sid);
  +	     ( (OBJECT *) s_current->data)->sid);
       }
       s_current = s_current->next;
     }
  @@ -243,32 +83,12 @@
   
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void o_selection_destroy_all(SELECTION *head) 
  -{
  -  SELECTION *s_current;
  -  SELECTION *s_prev;
  -
  -  s_current = o_selection_return_tail(head);
  -
  -  while (s_current != NULL) {
  -    s_prev = s_current->prev;	
  -    s_current->selected_object = NULL;
  -    g_free(s_current);
  -    s_current = s_prev;
  -  }
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  +/*! \brief Selects the given object.
  + *  \par Sets the select flag, saves the color, and then selects the 
  + *  given object
  + *  \param [in] o_selected Object to select.
  + *  \param [in] color color of the selected object.
    */
  -/* this sets the select flag, saves the color, and then sets the color */
   void o_selection_select(OBJECT *object, int color)
   {
     if (object->selected == TRUE) {
  @@ -292,13 +112,12 @@
     }
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  +/*! \brief Unselects the given object.
  + *  \par Unsets the select flag, restores the original color of the
  + *  given object.
  + *  This function should not be called by anybody outside of this file.
  + *  \param [in] object Object to unselect.
    */
  -/* this unsets the select flag and restores the original color */
  -/* this function should not be called by anybody outside of this file */
   void o_selection_unselect(OBJECT *object)
   {
     object->selected = FALSE;
  @@ -307,81 +126,61 @@
     /* grips are erase */
     object->color = object->saved_color;
     if (object->type == OBJ_COMPLEX || object->type == OBJ_PLACEHOLDER) { 
  +    if (!object->complex) {
  +      fprintf(stderr, "o_selection_unselect: Called with NULL object.\n");
  +      return;
  +    }
       o_complex_unset_color(object->complex->prim_objs);
     } else if (object->type == OBJ_TEXT) {
  +    if (!object->text) {
  +      fprintf(stderr, "o_selection_unselect: Called with NULL object.\n");
  +      return;
  +    }
       o_complex_unset_color(object->text->prim_objs);
     }
   
     object->saved_color = -1;
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -OBJECT *o_selection_return_first_object(SELECTION *head) 
  -{
  -  if (!head)
  -  return(NULL);
  -
  -  if (!head->next)  
  -  return(NULL);
  -
  -  if (!head->next->selected_object) 
  -  return(NULL);
  -
  -  return(head->next->selected_object);
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  +/*! \brief Removes the given object from the selection list
  + *  \par Removes the given object from the selection list and does the 
  + *  needed work to make the object visually unselected.
  + *  It's ok to call this function with an object which is not necessarily
  + *  selected.
  + *  \param [in] head Pointer to the selection list
  + *  \param [in] o_selected Object to unselect and remove from the list.
    */
  -/* Nth starts counting a ZERO */
  -/* doesn't consider the head node an object */
  -OBJECT *o_selection_return_nth_object(SELECTION *head, int count) 
  +void
  +o_selection_remove(GList **head, OBJECT *o_selected)
   {
  -  int internal_counter = 0;
  -  SELECTION *s_current;
  -
  -  s_current = head->next;
  -
  -  while (s_current != NULL) {
  -    if (internal_counter == count) {
  -      if (s_current->selected_object) {
  -        return(s_current->selected_object);
  -      }
  +  if (o_selected == NULL) {
  +    fprintf(stderr, "Got NULL for o_selected in o_selection_remove\n");
  +    return;
       }
  -    internal_counter++;
   
  -    s_current = s_current->next;
  +  if (g_list_find(*head, o_selected) != NULL) {
  +    o_selection_unselect(o_selected);
  +    *head = g_list_remove(*head, o_selected);
     }
  -  return(NULL);
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  +/*! \brief Unselects all the objects in the given list.
  + *  \par Unselects all objects in the given list, does the 
  + *  needed work to make the objects visually unselected, and redraw them.
  + *  \param [in] w_current TOPLEVEL struct.
  + *  \param [in] head Pointer to the selection list
    */
  -int o_selection_return_num(SELECTION *head)
  +void
  +o_selection_unselect_list(TOPLEVEL *w_current, GList **head)
   {
  -  int counter = 0;
  -  SELECTION *s_current;
  -
  -  if (!head) {
  -    return 0;
  -  }
  -  
  -  /* skip over head */
  -  s_current = head->next;
  +  GList *list = *head;
   
  -  while (s_current != NULL) {
  -    counter++;
  -    s_current = s_current->next;
  +  while (list != NULL) {
  +    o_selection_unselect((OBJECT *) list->data);
  +    o_redraw_single(w_current, (OBJECT *) list->data);
  +   list = list->next;
     }
     
  -  return(counter);
  +  g_list_free(*head);
  +  *head = NULL;  
   }
  
  
  
  1.24.2.1  +56 -18    eda/geda/gaf/libgeda/src/s_basic.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: s_basic.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/s_basic.c,v
  retrieving revision 1.24
  retrieving revision 1.24.2.1
  diff -u -b -r1.24 -r1.24.2.1
  --- s_basic.c	6 Aug 2006 16:45:31 -0000	1.24
  +++ s_basic.c	21 Oct 2006 22:20:38 -0000	1.24.2.1
  @@ -362,26 +362,10 @@
    *  \par Function Description
    *
    */
  -void s_delete(TOPLEVEL *w_current, OBJECT *o_current)
  +void
  +s_delete_object(TOPLEVEL *w_current, OBJECT *o_current)
   {
     if (o_current != NULL) {
  -
  -
  -#if DEBUG
  -    printf("sdel: %s\n", o_current->name);
  -    printf("sdel: %d\n", o_current->sid);
  -#endif
  -
  -    if (o_current->next) 
  -    o_current->next->prev = o_current->prev;
  -    else
  -    o_current->next = NULL;
  -
  -    if (o_current->prev) 
  -    o_current->prev->next = o_current->next;
  -    else
  -    o_current->prev = NULL;
  -
       s_conn_remove(w_current, o_current);
   	
       /* second half of if is odd that we need it? hack */
  @@ -512,6 +496,36 @@
    *  \par Function Description
    *
    */
  +void
  +s_delete(TOPLEVEL *w_current, OBJECT *o_current)
  +{
  +  if (o_current != NULL) {
  +
  +
  +#if DEBUG
  +    printf("sdel: %s\n", o_current->name);
  +    printf("sdel: %d\n", o_current->sid);
  +#endif
  +
  +    if (o_current->next) 
  +    o_current->next->prev = o_current->prev;
  +    else
  +    o_current->next = NULL;
  +
  +    if (o_current->prev) 
  +    o_current->prev->next = o_current->next;
  +    else
  +    o_current->prev = NULL;
  +    
  +    s_delete_object(w_current, o_current);
  +  }
  +}
  +
  +/*! \todo Finish function documentation!!!
  + *  \brief
  + *  \par Function Description
  + *
  + */
   /* deletes everything include the head */
   void s_delete_list_fromstart(TOPLEVEL *w_current, OBJECT *start)
   {
  @@ -561,6 +575,30 @@
   /*! \todo Finish function documentation!!!
    *  \brief
    *  \par Function Description
  + *
  + */
  +/* deletes everything include the head */
  +void
  +s_delete_object_glist(TOPLEVEL *w_current, GList *list)
  +{
  +  OBJECT *o_current=NULL;
  +  GList *ptr;
  +
  +  ptr = g_list_last(list);
  +
  +  /* do the delete backwards */
  +  while(ptr != NULL) {
  +    o_current = (OBJECT *) ptr->data;
  +    s_delete_object(w_current, o_current);
  +    ptr = ptr->prev;
  +  }
  +
  +}
  +
  +
  +/*! \todo Finish function documentation!!!
  + *  \brief
  + *  \par Function Description
    *  This function removes one object pointed by parameter <B>object</B> from
    *  a list as far as it does not represents a head. If so the function returns
    *  NULL. If not it returns the pointer on the object, i.e. the same as the
  
  
  
  1.25.2.1  +11 -9     eda/geda/gaf/libgeda/src/s_page.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: s_page.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/libgeda/src/s_page.c,v
  retrieving revision 1.25
  retrieving revision 1.25.2.1
  diff -u -b -r1.25 -r1.25.2.1
  --- s_page.c	30 Sep 2006 17:52:00 -0000	1.25
  +++ s_page.c	21 Oct 2006 22:20:38 -0000	1.25.2.1
  @@ -100,15 +100,12 @@
     page->object_head->type = OBJ_HEAD;
   
     /* new selection mechanism */
  -  page->selection2_head = page->selection2_tail = 
  -  o_selection_new_head();
  +  page->selection_list = NULL;
   
     /* net/pin/bus stretch when doing moves */
     page->stretch_head = page->stretch_tail = s_stretch_new_head();
   
  -  page->complex_place_tail = page->complex_place_head = 
  -  s_basic_init_object("complex_place_head");
  -  page->complex_place_tail->type = OBJ_HEAD;
  +  page->complex_place_list = NULL;
   
     /* add p_attrib and p_attached_to */
     page->attrib_place_tail = page->attrib_place_head = 
  @@ -169,6 +166,7 @@
     gchar *real_filename;
     gchar *only_filename;
     gchar *dirname;
  +  int redraw_status=toplevel->DONT_REDRAW;
     
     g_assert (page->pid != -1);
   
  @@ -211,13 +209,17 @@
     }
     g_free(real_filename);
   
  -  /* first delete objects of page */
  +  /* first unselect the objects, without redrawing them */
  +  toplevel->DONT_REDRAW = 1;
  +  o_selection_unselect_list(toplevel, &(page->selection_list));
  +  toplevel->DONT_REDRAW = redraw_status;
  +
  +  /* then delete objects of page */
     s_delete_list_fromstart (toplevel, page->object_head);
     
     toplevel->REMOVING_SEL = 1;
  -  s_delete_list_fromstart (toplevel, page->complex_place_head);
  +  s_delete_object_glist (toplevel, page->complex_place_list);
     s_delete_list_fromstart (toplevel, page->attrib_place_head);
  -  o_selection_destroy_all (page->selection2_head);
     toplevel->REMOVING_SEL = 0;  
   
   #if DEBUG
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs