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

gEDA-cvs: CVS update: g_hook.c



  User: cnieves 
  Date: 06/09/28 14:00:32

  Modified:    .        g_hook.c g_register.c globals.c gschem.c
                        i_callbacks.c x_window.c
  Log:
  Added a new page hook, a new add-component function for scheme,
  
  and some lines in the system-gschemrc file (commented by default),  
  
  so gschem can add automatically a symbol when creating a new page.  
  
  Commenting out these lines can solven bug #1443806 (gschem   
  
  zoomed out way to much on startup).
  
  
  
  
  Revision  Changes    Path
  1.7       +80 -0     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.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- g_hook.c	26 Jul 2006 20:11:50 -0000	1.6
  +++ g_hook.c	28 Sep 2006 18:00:31 -0000	1.7
  @@ -454,3 +454,83 @@
     
     return (returned);
   }
  +
  +/*! \brief Add a component to the page.
  + *  \par Function Description
  + *  Adds a component <B>scm_comp_name</B> to the schematic, at 
  + *  position (<B>scm_x</B>, <B>scm_y</B>), with some properties set by 
  + *  the parameters:
  + *  \param [in] scm_x Coordinate X of the symbol.
  + *  \param [in] scm_y Coordinate Y of the symbol.
  + *  \param [in] angle Angle of rotation of the symbol. 
  + *  \param [in] selectable True if the symbol is selectable, false otherwise.
  + *  \param [in] mirror True if the symbol is mirrored, false otherwise.
  + *  \return TRUE if the component was added, FALSE otherwise.
  + *
  + */
  +SCM g_add_component(SCM page_smob, SCM scm_comp_name, SCM scm_x, SCM scm_y, 
  +		    SCM scm_angle, SCM scm_selectable, SCM scm_mirror)
  +{
  +  TOPLEVEL *w_current;
  +  PAGE *page;
  +  gboolean selectable, mirror;
  +  gchar *comp_name, *clib;
  +  int x, y, angle;
  +  GSList *clibs = NULL;
  +
  +  /* Get w_current and o_current */
  +  SCM_ASSERT (g_get_data_from_page_smob (page_smob, &w_current, &page),
  +	      page_smob, SCM_ARG1, "add-component");
  +  /* Check the arguments */
  +  SCM_ASSERT (SCM_STRINGP(scm_comp_name), scm_comp_name,
  +	      SCM_ARG2, "add-component");
  +  SCM_ASSERT ( SCM_INUMP(scm_x), scm_x, 
  +               SCM_ARG3, "add-component");
  +  SCM_ASSERT ( SCM_INUMP(scm_y), scm_y, 
  +               SCM_ARG4, "add-component");
  +  SCM_ASSERT ( SCM_INUMP(scm_angle), scm_angle, 
  +               SCM_ARG5, "add-component");
  +  SCM_ASSERT ( scm_boolean_p(scm_selectable), scm_selectable,
  +	       SCM_ARG6, "add-component");
  +  SCM_ASSERT ( scm_boolean_p(scm_mirror), scm_mirror,
  +	       SCM_ARG7, "add-component");
  +
  +  /* Get the parameters */
  +  comp_name = SCM_STRING_CHARS(scm_comp_name);
  +  x = SCM_INUM(scm_y);
  +  y = SCM_INUM(scm_y);
  +  angle = SCM_INUM(scm_angle);  
  +  selectable = SCM_NFALSEP(scm_selectable);
  +  mirror = SCM_NFALSEP(scm_mirror);
  +
  +  clibs = (GSList *) s_clib_search_basename (comp_name);
  +  if (clibs == NULL) {
  +    /* Component not found */
  +    s_log_message ("add-component: Component with name [%s] not found.\n",
  +		   comp_name);
  +    return SCM_BOOL_F;    
  +  } else {
  +    if (g_slist_next (clibs)) {
  +      s_log_message ("add-component: More than one component found with name [%s]\n",
  +		     comp_name);
  +      /* PB: for now, use the first directory in clibs */
  +      /* PB: maybe open a dialog to select the right one? */
  +    }
  +    clib = (gchar*)clibs->data;
  +
  +    page->object_tail = o_complex_add(w_current, 
  +				      page->object_head, 'C', 
  +				      WHITE, 
  +				      x, y, 
  +				      angle, mirror,
  +				      clib, comp_name, selectable, FALSE);
  +
  +    /* 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);
  +
  +    return SCM_BOOL_T;        
  +  }
  +
  +  return SCM_BOOL_F;    
  +}
  
  
  
  1.45      +3 -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.44
  retrieving revision 1.45
  diff -u -b -r1.44 -r1.45
  --- g_register.c	30 Aug 2006 11:06:16 -0000	1.44
  +++ g_register.c	28 Sep 2006 18:00:32 -0000	1.45
  @@ -329,6 +329,7 @@
   
     g_init_attrib_smob ();
     g_init_object_smob ();
  +  g_init_page_smob ();
   
     /* Hook stuff */
     scm_c_define_gsubr ("add-attribute-to-object", 5, 0, 0, g_add_attrib);
  @@ -338,6 +339,7 @@
     scm_c_define_gsubr ("get-pin-ends", 1, 0, 0, g_get_pin_ends);
     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);
   
     add_component_hook  = scm_create_hook ("add-component-hook", 1);
     add_component_object_hook  = scm_create_hook ("add-component-object-hook", 
  @@ -358,5 +360,6 @@
     mirror_pin_hook = scm_create_hook ("mirror-pin-hook", 1);
     rotate_pin_hook = scm_create_hook ("rotate-pin-hook", 1);
     add_attribute_hook = scm_create_hook ("add-attribute-hook", 1);
  +  new_page_hook = scm_create_hook ("new-page-hook", 1);
   
   }
  
  
  
  1.18      +1 -0      eda/geda/gaf/gschem/src/globals.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: globals.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/globals.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -b -r1.17 -r1.18
  --- globals.c	6 Aug 2006 16:45:29 -0000	1.17
  +++ globals.c	28 Sep 2006 18:00:32 -0000	1.18
  @@ -92,3 +92,4 @@
   SCM deselect_all_hook;
   SCM select_component_hook;
   SCM select_net_hook;
  +SCM new_page_hook;
  
  
  
  1.36      +8 -0      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.35
  retrieving revision 1.36
  diff -u -b -r1.35 -r1.36
  --- gschem.c	7 Sep 2006 02:41:28 -0000	1.35
  +++ gschem.c	28 Sep 2006 18:00:32 -0000	1.36
  @@ -277,6 +277,14 @@
                    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,
  
  
  
  1.65      +20 -0     eda/geda/gaf/gschem/src/i_callbacks.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: i_callbacks.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_callbacks.c,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -b -r1.64 -r1.65
  --- i_callbacks.c	23 Sep 2006 09:01:06 -0000	1.64
  +++ i_callbacks.c	28 Sep 2006 18:00:32 -0000	1.65
  @@ -206,6 +206,14 @@
     s_log_message (_("New page created [%s]\n"),
                    toplevel->page_current->page_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(toplevel, page),
  +			  SCM_EOL));
  +  }
  +  
     x_pagesel_update (toplevel);
     i_update_menus (toplevel);
     i_set_filename (toplevel, toplevel->page_current->page_filename);
  @@ -213,6 +221,7 @@
     x_hscrollbar_update (toplevel);
     x_vscrollbar_update (toplevel);
     x_repaint_background (toplevel);
  +  a_zoom_extents(toplevel, toplevel->page_current->object_head, 0);
     o_undo_savestate (toplevel, UNDO_ALL);
     
   }
  @@ -1776,6 +1785,17 @@
     s_log_message(_("New Page created [%s]\n"),
                   toplevel->page_current->page_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(toplevel, page),
  +			  SCM_EOL));
  +  }
  +  
  +  /* Do a zoom extents */
  +  a_zoom_extents(toplevel, toplevel->page_current->object_head, 0);
  +  
     x_pagesel_update (toplevel);
     i_update_menus (toplevel);
     i_set_filename (toplevel, toplevel->page_current->page_filename);
  
  
  
  1.44      +11 -0     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.43
  retrieving revision 1.44
  diff -u -b -r1.43 -r1.44
  --- x_window.c	23 Sep 2006 09:01:06 -0000	1.43
  +++ x_window.c	28 Sep 2006 18:00:32 -0000	1.44
  @@ -166,6 +166,17 @@
     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);
  +  
     o_undo_savestate(toplevel, UNDO_ALL);
     i_update_menus(toplevel);
   
  
  
  


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