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

gEDA-cvs: CVS update: g_hook.c



  User: cnieves 
  Date: 06/09/30 07:30:26

  Modified:    .        g_hook.c g_register.c gschem.c x_window.c
  Log:
  Added a new scheme function to get the objects in a page.
  
  Improved the new-page-hook in system-gschemrc so it only adds
  
  the titleblock if the page has no objects.
  
  
  
  
  Revision  Changes    Path
  1.8       +40 -9     eda/geda/gaf/gschem/src/g_hook.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_hook.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_hook.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- g_hook.c	28 Sep 2006 18:00:31 -0000	1.7
  +++ g_hook.c	30 Sep 2006 11:30:26 -0000	1.8
  @@ -477,8 +477,9 @@
     gchar *comp_name, *clib;
     int x, y, angle;
     GSList *clibs = NULL;
  +  OBJECT *new_object;
   
  -  /* Get w_current and o_current */
  +  /* Get w_current and the page */
     SCM_ASSERT (g_get_data_from_page_smob (page_smob, &w_current, &page),
   	      page_smob, SCM_ARG1, "add-component");
     /* Check the arguments */
  @@ -518,8 +519,8 @@
       }
       clib = (gchar*)clibs->data;
   
  -    page->object_tail = o_complex_add(w_current, 
  -				      page->object_head, 'C', 
  +    new_object = o_complex_add(w_current, 
  +			       page->object_tail, 'C', 
   				      WHITE, 
   				      x, y, 
   				      angle, mirror,
  @@ -527,10 +528,40 @@
   
       /* Now the new component should be added to the object's list and 
          drawn in the screen */
  -    o_redraw_single(w_current, page->object_tail);
  +    o_redraw_single(w_current, new_object);
   
       return SCM_BOOL_T;        
     }
   
     return SCM_BOOL_F;    
   }
  +
  +/*! \brief Return the objects in a page.
  + *  \par Function Description
  + *  Returns an object smob list with all the objects in the given page.
  + *  \param [in] page_smob Page to look at.
  + *  \return the object smob list with the objects in the page.
  + *
  + */
  +SCM g_get_objects_in_page(SCM page_smob) {
  +
  +  TOPLEVEL *w_current;
  +  PAGE *page;
  +  OBJECT *object;
  +  SCM return_list=SCM_EOL;
  +
  +  /* Get w_current and the page */
  +  SCM_ASSERT (g_get_data_from_page_smob (page_smob, &w_current, &page),
  +	      page_smob, SCM_ARG1, "add-component");
  +
  +  if (page && page->object_head && page->object_head->next) {
  +    object = page->object_head->next;
  +    while (object) {
  +      return_list = scm_cons (g_make_object_smob(w_current, object),
  +			      return_list);
  +      object = object->next;
  +    }
  +  }
  +
  +  return return_list;
  +} 
  
  
  
  1.46      +1 -0      eda/geda/gaf/gschem/src/g_register.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: g_register.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_register.c,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -b -r1.45 -r1.46
  --- g_register.c	28 Sep 2006 18:00:32 -0000	1.45
  +++ g_register.c	30 Sep 2006 11:30:26 -0000	1.46
  @@ -340,6 +340,7 @@
     scm_c_define_gsubr ("set-attribute-text-properties!", 7, 0, 0, g_set_attrib_text_properties);
     scm_c_define_gsubr ("set-attribute-value!", 2, 0, 0, g_set_attrib_value_x);
     scm_c_define_gsubr ("add-component", 7, 0, 0, g_add_component);
  +  scm_c_define_gsubr ("get-objects-in-page", 1, 0, 0, g_get_objects_in_page);
   
     add_component_hook  = scm_create_hook ("add-component-hook", 1);
     add_component_object_hook  = scm_create_hook ("add-component-object-hook", 
  
  
  
  1.37      +16 -18    eda/geda/gaf/gschem/src/gschem.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: gschem.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/gschem.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -b -r1.36 -r1.37
  --- gschem.c	28 Sep 2006 18:00:32 -0000	1.36
  +++ gschem.c	30 Sep 2006 11:30:26 -0000	1.37
  @@ -258,11 +258,6 @@
         i_set_filename(w_current,
                        w_current->page_current->page_filename);
   
  -      a_zoom_extents(w_current,
  -                     w_current->page_current->object_head,
  -                     A_PAN_DONT_REDRAW);
  -      o_undo_savestate(w_current, UNDO_ALL);
  -
         first_page = 0;
       } else {
         /* Much simpler	*/
  @@ -277,22 +272,10 @@
                    filename);
           }
           
  -	/* Run the new page hook */
  -	if (scm_hook_empty_p(new_page_hook) == SCM_BOOL_F &&
  -	    page != NULL) {
  -	  scm_run_hook(new_page_hook,
  -		       scm_cons(g_make_page_smob(w_current, page),
  -				SCM_EOL));
  -	}
  -  
           f_open(w_current,
                  w_current->page_current->page_filename);
           i_set_filename(w_current,
                          w_current->page_current->page_filename);
  -        a_zoom_extents(w_current,
  -                       w_current->page_current->object_head,
  -                       A_PAN_DONT_REDRAW);
  -        o_undo_savestate(w_current, UNDO_ALL);
         }
       }
       i++;
  @@ -328,6 +311,21 @@
                      w_current->page_current->page_filename);
     }
   
  +  /* Run the new page hook */
  +  if (scm_hook_empty_p(new_page_hook) == SCM_BOOL_F &&
  +      w_current->page_current != NULL) {
  +    scm_run_hook(new_page_hook,
  +		 scm_cons(g_make_page_smob(w_current, 
  +					   w_current->page_current),
  +			  SCM_EOL));
  +  }
  +
  +  a_zoom_extents(w_current,
  +		 w_current->page_current->object_head,
  +		 A_PAN_DONT_REDRAW);
  +  o_undo_savestate(w_current, UNDO_ALL);
  +  
  +  
     x_scrollbars_update(w_current);
     o_redraw_all_fast(w_current);
   
  
  
  
  1.45      +0 -8      eda/geda/gaf/gschem/src/x_window.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_window.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_window.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -b -r1.44 -r1.45
  --- x_window.c	28 Sep 2006 18:00:32 -0000	1.44
  +++ x_window.c	30 Sep 2006 11:30:26 -0000	1.45
  @@ -166,14 +166,6 @@
     page = s_page_new (toplevel, "unknown");
     s_page_goto (toplevel, page);
   
  -  /* Run the new page hook */
  -  if (scm_hook_empty_p(new_page_hook) == SCM_BOOL_F &&
  -      page != NULL) {
  -    scm_run_hook(new_page_hook,
  -		 scm_cons(g_make_page_smob(toplevel, page),
  -			  SCM_EOL));
  -  }
  -
     /* Do a zoom extents */
     a_zoom_extents(toplevel, toplevel->page_current->object_head, 0);
     
  
  
  


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