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

gEDA-cvs: gaf.git: branch: master updated (1.6.1-20100214-173-gf665979)



The branch, master has been updated
       via  f66597934bf8c88519396956637792533ba3a151 (commit)
       via  4a2272be60b5e728a1e656dae1845f475fb44491 (commit)
       via  3d7719ca26bd4a77bce4f3ce3100c72d93d5e933 (commit)
       via  b87d7edc2be45dab1e7cab8ec81cce2631377b4f (commit)
       via  0b94d2379a5bd5d14690f941690e0df761df13c9 (commit)
       via  a33839adef1f8c7239e5b291baef667b9046d91f (commit)
       via  e883ed4bf0681db9e67da5e176d2caa6d8876f4c (commit)
       via  3abdca2a4ee088184e976822c444069d67e20a20 (commit)
       via  4a3a3d9e4cc72fa94165306c5b8d411d47812d45 (commit)
       via  c26ed9d5b126f7e2b67285e465438aa9b5ee4ffd (commit)
      from  63cd6d754fce280800eac55c6cafa21888942f96 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gattrib/src/s_toplevel.c            |    3 +-
 gattrib/src/x_fileselect.c          |    2 +-
 gnetlist/src/gnetlist.c             |   12 +-
 gnetlist/src/s_hierarchy.c          |    7 +-
 gschem/src/g_funcs.c                |   16 +++-
 gschem/src/gschem.c                 |    4 +-
 gschem/src/i_callbacks.c            |   36 +++----
 gschem/src/o_misc.c                 |   22 +++--
 gschem/src/o_undo.c                 |    6 +-
 gschem/src/x_autonumber.c           |    4 +-
 gschem/src/x_image.c                |    2 +-
 gschem/src/x_preview.c              |    3 +-
 gschem/src/x_print.c                |    8 +-
 gschem/src/x_script.c               |    2 +-
 gschem/src/x_window.c               |    4 +-
 gsymcheck/src/gsymcheck.c           |    1 +
 libgeda/include/libgeda/prototype.h |   21 ++--
 libgeda/include/prototype_priv.h    |    2 +-
 libgeda/src/a_basic.c               |   13 ---
 libgeda/src/f_basic.c               |   38 ++++----
 libgeda/src/f_print.c               |   44 +++++----
 libgeda/src/g_basic.c               |    4 +-
 libgeda/src/g_rc.c                  |    2 +-
 libgeda/src/o_attrib.c              |    4 -
 libgeda/src/o_net_basic.c           |   37 +++----
 libgeda/src/s_hierarchy.c           |  186 ++++++++++++++++++-----------------
 libgeda/src/s_page.c                |   21 +---
 utils/gschlas/gschlas.c             |    3 +-
 28 files changed, 251 insertions(+), 256 deletions(-)


=================
 Commit Messages
=================

commit f66597934bf8c88519396956637792533ba3a151
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Don't use page_current in hierarchy traversal.
    
    With this patch, the only remaining functions in libgeda which care
    about the "current page" are:
    
    - o_get_page_compat() [deprecated]
    - s_page_goto()
    - s_page_delete()
    - s_page_delete_list()
    - s_toplevel_new()

:100644 100644 7b8f07a... fbbfc09... M	gnetlist/src/s_hierarchy.c
:100644 100644 d985e77... 6520721... M	gschem/src/i_callbacks.c
:100644 100644 1cb5b81... 0d7896b... M	gschem/src/o_misc.c
:100644 100644 073f916... a6193df... M	gschem/src/x_autonumber.c
:100644 100644 d260ed2... 09cf151... M	libgeda/include/libgeda/prototype.h
:100644 100644 eaf8e29... 37d3296... M	libgeda/src/s_hierarchy.c

commit 4a2272be60b5e728a1e656dae1845f475fb44491
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Pre-refactor cosmetic changes.
    
    This patch cleans up whitespace in s_hierarchy.c, and changes some
    constructs of the form:
    
      for (x; y; z) {
        if (!foo) {
          if (!bar) {
            /* Lots of stuff */
          }
        }
      }
    
    to:
    
      for (x; y; z) {
        if (foo) continue;
        if (bar) continue;
        /* Lots of stuff */
      }

:100644 100644 994a7a2... eaf8e29... M	libgeda/src/s_hierarchy.c

commit 3d7719ca26bd4a77bce4f3ce3100c72d93d5e933
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Add PAGE argument to o_net_consolidate().

:100644 100644 b90d237... 14f1442... M	gschem/src/o_undo.c
:100644 100644 38ec6ac... d260ed2... M	libgeda/include/libgeda/prototype.h
:100644 100644 0c47b71... de3fb69... M	libgeda/src/o_net_basic.c

commit b87d7edc2be45dab1e7cab8ec81cce2631377b4f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Remove some more uses of page_current.
    
    Removes some uses of TOPLEVEL.page_current which were missed in
    a33839adef1f.

:100644 100644 21206dd... 3c7d16d... M	libgeda/src/f_basic.c

commit a33839adef1f8c7239e5b291baef667b9046d91f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Get rid of some uses of page_current.
    
    Remove some uses of page_current from functions used only by libgeda.
    This will make it more painless to remove page_current completely.

:100644 100644 ba3c216... 21206dd... M	libgeda/src/f_basic.c
:100644 100644 c839597... 640debb... M	libgeda/src/o_attrib.c
:100644 100644 fa7019e... 0c47b71... M	libgeda/src/o_net_basic.c

commit e883ed4bf0681db9e67da5e176d2caa6d8876f4c
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Remove o_save_curr_page().

:100644 100644 08c3fb3... 2890bff... M	gschem/src/o_misc.c
:100644 100644 51d0820... 794aeca... M	gschem/src/o_undo.c
:100644 100644 55b1e5a... c7d9707... M	libgeda/include/libgeda/prototype.h
:100644 100644 38d347c... bc9553c... M	libgeda/src/a_basic.c
:100644 100644 f85d090... ba3c216... M	libgeda/src/f_basic.c

commit 3abdca2a4ee088184e976822c444069d67e20a20
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Add PAGE argument to file load/save functions.

:100644 100644 e8babd9... 53c971a... M	gattrib/src/s_toplevel.c
:100644 100644 5b734a9... da35a7b... M	gattrib/src/x_fileselect.c
:100644 100644 352684c... 3471b97... M	gnetlist/src/gnetlist.c
:100644 100644 deb3aee... 51d0820... M	gschem/src/o_undo.c
:100644 100644 47bab5c... bd892ff... M	gschem/src/x_preview.c
:100644 100644 07beb6e... c44fa12... M	gschem/src/x_window.c
:100644 100644 75e1f49... da8b2d2... M	gsymcheck/src/gsymcheck.c
:100644 100644 d9e60d4... 55b1e5a... M	libgeda/include/libgeda/prototype.h
:100644 100644 afe83c9... f85d090... M	libgeda/src/f_basic.c
:100644 100644 584fc58... 994a7a2... M	libgeda/src/s_hierarchy.c
:100644 100644 3621319... 5665f0b... M	libgeda/src/s_page.c
:100644 100644 b9160aa... 507cfc6... M	utils/gschlas/gschlas.c

commit 4a3a3d9e4cc72fa94165306c5b8d411d47812d45
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Add PAGE argument to print functions.

:100644 100644 ecfc83a... d2035ab... M	gschem/src/g_funcs.c
:100644 100644 aa7b845... 1c94c5b... M	gschem/src/x_image.c
:100644 100644 3de2205... 769190a... M	gschem/src/x_print.c
:100644 100644 6b8b1e4... d9e60d4... M	libgeda/include/libgeda/prototype.h
:100644 100644 f02e9db... 1b62ff7... M	libgeda/include/prototype_priv.h
:100644 100644 5bb9d3d... 5406537... M	libgeda/src/f_print.c

commit c26ed9d5b126f7e2b67285e465438aa9b5ee4ffd
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make g_read_file() take a TOPLEVEL argument.

:100644 100644 faa63e4... 352684c... M	gnetlist/src/gnetlist.c
:100644 100644 b47d503... e5e6ca3... M	gschem/src/gschem.c
:100644 100644 61e0c83... 9d5e00e... M	gschem/src/x_script.c
:100644 100644 47a0fbb... 6b8b1e4... M	libgeda/include/libgeda/prototype.h
:100644 100644 e4d2083... 15dda39... M	libgeda/src/g_basic.c
:100644 100644 f40156e... 5e0bc46... M	libgeda/src/g_rc.c

=========
 Changes
=========

commit f66597934bf8c88519396956637792533ba3a151
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Don't use page_current in hierarchy traversal.
    
    With this patch, the only remaining functions in libgeda which care
    about the "current page" are:
    
    - o_get_page_compat() [deprecated]
    - s_page_goto()
    - s_page_delete()
    - s_page_delete_list()
    - s_toplevel_new()

diff --git a/gnetlist/src/s_hierarchy.c b/gnetlist/src/s_hierarchy.c
index 7b8f07a..fbbfc09 100644
--- a/gnetlist/src/s_hierarchy.c
+++ b/gnetlist/src/s_hierarchy.c
@@ -45,6 +45,7 @@ s_hierarchy_traverse(TOPLEVEL * pr_current, OBJECT * o_current,
     char *attrib;
     int page_control=-1;
     PAGE *p_current;
+    PAGE *child_page;
     int count = 0;
     int pcount = 0;
     int looking_inside = FALSE;
@@ -93,16 +94,18 @@ s_hierarchy_traverse(TOPLEVEL * pr_current, OBJECT * o_current,
 #if DEBUG
 	    printf("Going down %s\n", current_filename);
 #endif
-	    page_control =
+	    child_page =
 		s_hierarchy_down_schematic_single(pr_current,
 						  current_filename,
 						  pr_current->page_current,
 						  page_control,
                                                   HIERARCHY_FORCE_LOAD);
 
-	    if (page_control == -1) {
+	    if (child_page == NULL) {
 		fprintf(stderr, "Could not open [%s]\n", current_filename);
 	    } else {
+              page_control = child_page->page_control;
+              s_page_goto (pr_current, child_page);
 
 		loaded_flag = TRUE;
 
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index d985e77..6520721 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -2829,9 +2829,9 @@ DEFINE_I_CALLBACK(hierarchy_down_schematic)
   OBJECT *object=NULL;
   PAGE *save_first_page=NULL;
   PAGE *parent=NULL;
+  PAGE *child = NULL;
   int loaded_flag=FALSE;
   int page_control = 0;
-  int saved_page_control = 0;
   int pcount = 0;
   int looking_inside=FALSE;
 
@@ -2866,36 +2866,34 @@ DEFINE_I_CALLBACK(hierarchy_down_schematic)
     while(current_filename != NULL) {
 
       s_log_message(_("Searching for source [%s]\n"), current_filename);
-      saved_page_control = page_control;
-      page_control =
-        s_hierarchy_down_schematic_single(w_current->toplevel,
-                                          current_filename,
-                                          parent,
-                                          page_control,
-                                          HIERARCHY_NORMAL_LOAD);
+      child = s_hierarchy_down_schematic_single(w_current->toplevel,
+                                                current_filename,
+                                                parent,
+                                                page_control,
+                                                HIERARCHY_NORMAL_LOAD);
 
       /* s_hierarchy_down_schematic_single() will not zoom the loaded page */
-      if (page_control != -1) {
+      if (child != NULL) {
+        s_page_goto (w_current->toplevel, child);
         a_zoom_extents(w_current,
                        s_page_objects (w_current->toplevel->page_current),
                        A_PAN_DONT_REDRAW);
         o_undo_savestate(w_current, UNDO_ALL);
+        s_page_goto (w_current->toplevel, parent);
       }
 
       /* save the first page */
-      if ( !loaded_flag && page_control > 0 ) {
-        save_first_page = w_current->toplevel->page_current;
+      if ( !loaded_flag && (child != NULL)) {
+        save_first_page = child;
       }
 
       /* now do some error fixing */
-      if (page_control == -1) {
+      if (child == NULL) {
         s_log_message(_("Cannot find source [%s]\n"), current_filename);
-
-        /* restore this for the next page */
-        page_control = saved_page_control;
       } else {
         /* this only signifies that we tried */
         loaded_flag = TRUE;
+        page_control = child->page_control;
       }
 
       g_free(current_filename);
@@ -2932,12 +2930,8 @@ DEFINE_I_CALLBACK(hierarchy_down_schematic)
     }
   }
 
-  if (loaded_flag) {
-
-    if (save_first_page) {
-      w_current->toplevel->page_current = save_first_page;
-    }
-    x_window_set_current_page( w_current, w_current->toplevel->page_current );
+  if (loaded_flag && (save_first_page != NULL)) {
+    x_window_set_current_page (w_current, save_first_page);
   }
 }
 
diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 1cb5b81..0d7896b 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -494,21 +494,23 @@ int o_edit_find_text (GSCHEM_TOPLEVEL *w_current, const GList *o_list,
           pcount = 0;
           current_filename = u_basic_breakup_string(attrib, ',', pcount);
           if (current_filename != NULL) {
-            page_control =
+            PAGE *child_page =
               s_hierarchy_down_schematic_single(toplevel,
                                                 current_filename,
                                                 parent,
                                                 page_control,
                                                 HIERARCHY_NORMAL_LOAD);
-            /* o_invalidate_all (w_current); */
 
-            rv = o_edit_find_text (w_current,
-                                   s_page_objects (toplevel->page_current),
-                                   stext, descend, skiplast);
-            if (!rv) {
-              return 0;
+            if (child_page != NULL) {
+              page_control = child_page->page_control;
+              rv = o_edit_find_text (w_current,
+                                     s_page_objects (child_page),
+                                     stext, descend, skiplast);
+              if (!rv) {
+                s_page_goto( toplevel, child_page );
+                return 0;
+              }
             }
-            s_page_goto( toplevel, parent );
           }
         }
       }
diff --git a/gschem/src/x_autonumber.c b/gschem/src/x_autonumber.c
index 073f916..a6193df 100644
--- a/gschem/src/x_autonumber.c
+++ b/gschem/src/x_autonumber.c
@@ -655,7 +655,9 @@ void autonumber_text_autonumber(AUTONUMBER_TEXT *autotext)
   scope_text = g_list_first(autotext->scope_text)->data;
 
   /* Step1: get all pages of the hierarchy */
-  pages = s_hierarchy_traversepages(w_current->toplevel, HIERARCHY_NODUPS);
+  pages = s_hierarchy_traversepages (w_current->toplevel,
+                                     w_current->toplevel->page_current,
+                                     HIERARCHY_NODUPS);
 
   /*  g_list_foreach(pages, (GFunc) s_hierarchy_print_page, NULL); */
 
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index d260ed2..09cf151 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -331,10 +331,10 @@ void s_cue_output_lowlevel_midpoints(TOPLEVEL *toplevel, OBJECT *object, FILE *f
 void s_cue_output_single(TOPLEVEL *toplevel, OBJECT *object, FILE *fp, int type);
 
 /* s_hierarchy.c */
-int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename, PAGE *parent, int page_control, int flag);
+PAGE *s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename, PAGE *parent, int page_control, int flag);
 void s_hierarchy_down_symbol (TOPLEVEL *toplevel, const CLibSymbol *symbol, PAGE *parent);
 PAGE *s_hierarchy_find_up_page(GedaPageList *page_list, PAGE *current_page);
-GList* s_hierarchy_traversepages(TOPLEVEL *toplevel, gint flags);
+GList* s_hierarchy_traversepages(TOPLEVEL *toplevel, PAGE *p_current, gint flags);
 gint s_hierarchy_print_page(PAGE *p_current, void * data);
 PAGE *s_hierarchy_find_prev_page(GedaPageList *page_list, PAGE *current_page);
 PAGE *s_hierarchy_find_next_page(GedaPageList *page_list, PAGE *current_page);
diff --git a/libgeda/src/s_hierarchy.c b/libgeda/src/s_hierarchy.c
index eaf8e29..37d3296 100644
--- a/libgeda/src/s_hierarchy.c
+++ b/libgeda/src/s_hierarchy.c
@@ -49,7 +49,7 @@ static int page_control_counter=0;
  *  \param [in] parent        The parent page of the schematic.
  *  \param [in] page_control
  *  \param [in] flag
- *  \return The number of pages loaded, -1 otherwise.
+ *  \return The page loaded, or NULL if failed.
  *
  *  \note
  *  This function goes and finds the associated source files and
@@ -59,17 +59,21 @@ static int page_control_counter=0;
  *  flag can either be HIERARCHY_NORMAL_LOAD or HIERARCHY_FORCE_LOAD
  *  flag is mainly used by gnetlist where pushed down schematics MUST be unique
  */
-int
+PAGE *
 s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename,
                                   PAGE *parent, int page_control, int flag)
 {
   gchar *string;
-  PAGE *found;
+  PAGE *found = NULL;
   PAGE *forbear;
 
+  g_return_val_if_fail ((toplevel != NULL), NULL);
+  g_return_val_if_fail ((filename != NULL), NULL);
+  g_return_val_if_fail ((parent != NULL), NULL);
+
   string = s_slib_search_single(filename);
   if (string == NULL) {
-    return -1;
+    return NULL;
   }
 
   switch (flag) {
@@ -89,7 +93,7 @@ s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename,
         if (found->pid == forbear->pid) {
           s_log_message(_("hierarchy loop detected while visiting page:\n"
                           "  \"%s\"\n"), found->page_filename);
-          return -1;  /* error signal */
+          return NULL;  /* error signal */
         }
         s_page_goto (toplevel, found);
         if (page_control != 0) {
@@ -97,11 +101,10 @@ s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename,
         }
         found->up = parent->pid;
         g_free (string);
-        return found->page_control;
+        return found;
       }
 
       found = s_page_new (toplevel, string);
-      s_page_goto (toplevel, found);
 
       f_open (toplevel, found, found->page_filename, NULL);
     }
@@ -109,27 +112,24 @@ s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename,
 
   case HIERARCHY_FORCE_LOAD:
     {
-      PAGE *page = s_page_new (toplevel, string);
-      s_page_goto (toplevel, page);
-      f_open (toplevel, page, page->page_filename, NULL);
+      found = s_page_new (toplevel, string);
+      f_open (toplevel, found, found->page_filename, NULL);
     }
     break;
   }
 
   if (page_control == 0) {
     page_control_counter++;
-    toplevel->page_current->page_control = page_control_counter;
+    found->page_control = page_control_counter;
   } else {
-    toplevel->page_current->page_control = page_control;
+    found->page_control = page_control;
   }
 
-  toplevel->page_current->up = parent->pid;
-
-  s_page_goto(toplevel, toplevel->page_current);
+  found->up = parent->pid;
 
   g_free (string);
 
-  return(page_control_counter);
+  return found;
 }
 
 /*! \todo Finish function documentation!!!
@@ -191,38 +191,40 @@ s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
   return s_page_search_by_page_id (page_list, current_page->up);
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
+/*! \brief Find page hierarchy below a page.
  *  \par Function Description
- *  This function traverses the hierarchy tree of pages and returns a flat
- *  list of pages that are below the current page. There are two
- *  <B>flags</B>: <B>HIERARCHY_NODUPS</B>: returns a list without
- *  duplicate pages
- *  <B>HIERARCHY_POSTORDER</B>: traverses the hierarchy tree and
- *  returns a postorder list instead of preorder.
+ *  This function traverses the hierarchy tree of pages and returns a
+ *  flat list of pages that are below \a p_current. There are two \a
+ *  flags that can be used to control the way that the return value is
+ *  constructed: <B>HIERARCHY_NODUPS</B> returns a list without
+ *  duplicate pages, and <B>HIERARCHY_POSTORDER</B> traverses the
+ *  hierarchy tree and returns a postorder list instead of preorder.
  *
+ *  \param toplevel The TOPLEVEL structure.
+ *  \param p_current The PAGE to traverse hierarchy for.
+ *  \param flags Flags controlling form of return value.
  *  \return A GList of PAGE pointers.
  *
  *  \warning
- *  Call must g_list_free returned GList.
+ *  Caller must destroy returned GList with g_list_free().
  */
 GList *
-s_hierarchy_traversepages (TOPLEVEL *toplevel, gint flags)
+s_hierarchy_traversepages (TOPLEVEL *toplevel, PAGE *p_current, gint flags)
 {
-  PAGE *p_current;
   OBJECT *o_current;
+  PAGE *child_page;
   char *filename = NULL;
-  gint page_control = 0;
   static GList *pages = NULL;
   const GList *iter;
 
+  g_return_val_if_fail ((toplevel != NULL), NULL);
+  g_return_val_if_fail ((p_current != NULL), NULL);
+
   /* init static variables the first time*/
   if (!(flags & HIERARCHY_INNERLOOP)) {
     pages = NULL;
   }
 
-  p_current = toplevel->page_current;
-
   /* preorder traversing */
   if (!(flags & HIERARCHY_POSTORDER)) {
     /* check whether we already visited this page */
@@ -255,13 +257,12 @@ s_hierarchy_traversepages (TOPLEVEL *toplevel, gint flags)
 
     /* we got a schematic source attribute
        lets load the page and dive into it */
-    page_control =
+    child_page =
       s_hierarchy_down_schematic_single (toplevel, filename, p_current, 0,
                                          HIERARCHY_NORMAL_LOAD);
-    if (page_control != -1) {
+    if (child_page != NULL) {
       /* call the recursive function */
-      s_hierarchy_traversepages (toplevel, flags | HIERARCHY_INNERLOOP);
-      s_page_goto(toplevel, p_current);
+      s_hierarchy_traversepages (toplevel, child_page, flags | HIERARCHY_INNERLOOP);
     } else {
       s_log_message (_("ERROR in s_hierarchy_traverse: "
                        "schematic not found: %s\n"),

commit 4a2272be60b5e728a1e656dae1845f475fb44491
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Pre-refactor cosmetic changes.
    
    This patch cleans up whitespace in s_hierarchy.c, and changes some
    constructs of the form:
    
      for (x; y; z) {
        if (!foo) {
          if (!bar) {
            /* Lots of stuff */
          }
        }
      }
    
    to:
    
      for (x; y; z) {
        if (foo) continue;
        if (bar) continue;
        /* Lots of stuff */
      }

diff --git a/libgeda/src/s_hierarchy.c b/libgeda/src/s_hierarchy.c
index 994a7a2..eaf8e29 100644
--- a/libgeda/src/s_hierarchy.c
+++ b/libgeda/src/s_hierarchy.c
@@ -59,9 +59,9 @@ static int page_control_counter=0;
  *  flag can either be HIERARCHY_NORMAL_LOAD or HIERARCHY_FORCE_LOAD
  *  flag is mainly used by gnetlist where pushed down schematics MUST be unique
  */
-int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
-				      const gchar *filename, PAGE *parent,
-				      int page_control, int flag) 
+int
+s_hierarchy_down_schematic_single(TOPLEVEL *toplevel, const gchar *filename,
+                                  PAGE *parent, int page_control, int flag)
 {
   gchar *string;
   PAGE *found;
@@ -73,24 +73,24 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
   }
 
   switch (flag) {
-    case HIERARCHY_NORMAL_LOAD:
+  case HIERARCHY_NORMAL_LOAD:
     {
       gchar *filename = f_normalize_filename (string, NULL);
       found = s_page_search (toplevel, filename);
       g_free (filename);
-      
+
       if (found) {
-	/* check whether this page is in the parents list */
-	for (forbear = parent; 
-	     forbear != NULL && found->pid != forbear->pid && forbear->up >= 0;
-	     forbear = s_page_search_by_page_id (toplevel->pages, forbear->up))
-	  ; /* void */
-
-	if (found->pid == forbear->pid) {
-	  s_log_message(_("hierarchy loop detected while visiting page:\n"
+        /* check whether this page is in the parents list */
+        for (forbear = parent;
+             forbear != NULL && found->pid != forbear->pid && forbear->up >= 0;
+             forbear = s_page_search_by_page_id (toplevel->pages, forbear->up))
+          ; /* void */
+
+        if (found->pid == forbear->pid) {
+          s_log_message(_("hierarchy loop detected while visiting page:\n"
                           "  \"%s\"\n"), found->page_filename);
-	  return -1;  /* error signal */
-	}
+          return -1;  /* error signal */
+        }
         s_page_goto (toplevel, found);
         if (page_control != 0) {
           found->page_control = page_control;
@@ -99,15 +99,15 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
         g_free (string);
         return found->page_control;
       }
-      
+
       found = s_page_new (toplevel, string);
       s_page_goto (toplevel, found);
-      
+
       f_open (toplevel, found, found->page_filename, NULL);
     }
     break;
 
-    case HIERARCHY_FORCE_LOAD:
+  case HIERARCHY_FORCE_LOAD:
     {
       PAGE *page = s_page_new (toplevel, string);
       s_page_goto (toplevel, page);
@@ -137,8 +137,9 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
  *  \par Function Description
  *
  */
-void s_hierarchy_down_symbol (TOPLEVEL *toplevel,
-			      const CLibSymbol *symbol, PAGE *parent)
+void
+s_hierarchy_down_symbol (TOPLEVEL *toplevel, const CLibSymbol *symbol,
+                         PAGE *parent)
 {
   PAGE *page;
   gchar *filename;
@@ -179,7 +180,8 @@ void s_hierarchy_down_symbol (TOPLEVEL *toplevel,
  *  \param [in] current_page The reference page for the search.
  *  \returns A pointer on the page found or NULL if not found.
  */
-PAGE *s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
+PAGE *
+s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
 {
   if (current_page->up < 0) {
     s_log_message(_("There are no schematics above the current one!\n"));
@@ -195,7 +197,7 @@ PAGE *s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
  *  This function traverses the hierarchy tree of pages and returns a flat
  *  list of pages that are below the current page. There are two
  *  <B>flags</B>: <B>HIERARCHY_NODUPS</B>: returns a list without
- *  duplicate pages 
+ *  duplicate pages
  *  <B>HIERARCHY_POSTORDER</B>: traverses the hierarchy tree and
  *  returns a postorder list instead of preorder.
  *
@@ -204,8 +206,8 @@ PAGE *s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
  *  \warning
  *  Call must g_list_free returned GList.
  */
-GList *s_hierarchy_traversepages(TOPLEVEL *toplevel,
-				 gint flags)
+GList *
+s_hierarchy_traversepages (TOPLEVEL *toplevel, gint flags)
 {
   PAGE *p_current;
   OBJECT *o_current;
@@ -213,7 +215,7 @@ GList *s_hierarchy_traversepages(TOPLEVEL *toplevel,
   gint page_control = 0;
   static GList *pages = NULL;
   const GList *iter;
-  
+
   /* init static variables the first time*/
   if (!(flags & HIERARCHY_INNERLOOP)) {
     pages = NULL;
@@ -225,10 +227,10 @@ GList *s_hierarchy_traversepages(TOPLEVEL *toplevel,
   if (!(flags & HIERARCHY_POSTORDER)) {
     /* check whether we already visited this page */
     if ((flags & HIERARCHY_NODUPS)
-	&& (g_list_find(pages, p_current) != NULL)) {
+        && (g_list_find (pages, p_current) != NULL)) {
       return pages;  /* drop the page subtree */
       }
-    pages = g_list_append(pages, p_current);
+    pages = g_list_append (pages, p_current);
   }
 
   /* walk throught the page objects and search for underlaying schematics */
@@ -238,50 +240,46 @@ GList *s_hierarchy_traversepages(TOPLEVEL *toplevel,
     o_current = (OBJECT *)iter->data;
 
     /* only complex things like symbols can contain attributes */
-    if (o_current->type == OBJ_COMPLEX) {
+    if (o_current->type != OBJ_COMPLEX) continue;
+
+    filename =
+      o_attrib_search_attached_attribs_by_name (o_current, "source", 0);
+
+    /* if above is NULL, then look inside symbol */
+    if (filename == NULL) {
       filename =
-        o_attrib_search_attached_attribs_by_name (o_current, "source", 0);
-      
-      /* if above is NULL, then look inside symbol */
-      if (filename == NULL) {
-	filename =
-          o_attrib_search_inherited_attribs_by_name (o_current, "source", 0);
-      }
+        o_attrib_search_inherited_attribs_by_name (o_current, "source", 0);
+    }
 
-      if (filename != NULL) {
-	/* we got a schematic source attribute 
-	   lets load the page and dive into it */
-	page_control =s_hierarchy_down_schematic_single(toplevel,
-							filename,
-							p_current,
-							0,
-							HIERARCHY_NORMAL_LOAD);
-	if (page_control != -1) {
-	  /* call the recursive function */
-	  s_hierarchy_traversepages(toplevel,
-				    flags | HIERARCHY_INNERLOOP);
-	  s_page_goto(toplevel, p_current);
-	}
-	else {
-	  s_log_message(_("ERROR in s_hierarchy_traverse: "
-                          "schematic not found: %s\n"),
-			filename);
-	}
-	
-	g_free(filename);
-	filename = NULL;
-      }
+    if (filename == NULL) continue;
+
+    /* we got a schematic source attribute
+       lets load the page and dive into it */
+    page_control =
+      s_hierarchy_down_schematic_single (toplevel, filename, p_current, 0,
+                                         HIERARCHY_NORMAL_LOAD);
+    if (page_control != -1) {
+      /* call the recursive function */
+      s_hierarchy_traversepages (toplevel, flags | HIERARCHY_INNERLOOP);
+      s_page_goto(toplevel, p_current);
+    } else {
+      s_log_message (_("ERROR in s_hierarchy_traverse: "
+                       "schematic not found: %s\n"),
+                     filename);
     }
+
+    g_free (filename);
+    filename = NULL;
   }
 
   /* postorder traversing */
   if (flags & HIERARCHY_POSTORDER) {
     /* check whether we already visited this page */
     if ((flags & HIERARCHY_NODUPS)
-	&& (g_list_find(pages, p_current) != NULL)) {
+        && (g_list_find (pages, p_current) != NULL)) {
       return pages;  /* don't append it */
     }
-    pages = g_list_append(pages, p_current);
+    pages = g_list_append (pages, p_current);
   }
 
   return pages;
@@ -294,9 +292,10 @@ GList *s_hierarchy_traversepages(TOPLEVEL *toplevel,
  *  \note
  *  Test function which only prints the name of a page and it's number.
  */
-gint s_hierarchy_print_page(PAGE *p_current, void * data)
+gint
+s_hierarchy_print_page (PAGE *p_current, void * data)
 {
-  printf("pagefilename: %s pageid: %d\n", 
+  printf("pagefilename: %s pageid: %d\n",
          p_current->page_filename, p_current->pid);
   return 0;
 }
@@ -316,7 +315,8 @@ gint s_hierarchy_print_page(PAGE *p_current, void * data)
  *  \param [in] current_page The reference page for the search.
  *  \returns A pointer on the page found or NULL if not found.
   */
-PAGE *s_hierarchy_find_prev_page (GedaPageList *page_list, PAGE *current_page)
+PAGE *
+s_hierarchy_find_prev_page (GedaPageList *page_list, PAGE *current_page)
 {
   const GList *iter;
 
@@ -349,7 +349,8 @@ PAGE *s_hierarchy_find_prev_page (GedaPageList *page_list, PAGE *current_page)
  *  \param [in] current_page The reference page for the search.
  *  \returns A pointer on the page found or NULL if not found.
   */
-PAGE *s_hierarchy_find_next_page (GedaPageList *page_list, PAGE *current_page)
+PAGE *
+s_hierarchy_find_next_page (GedaPageList *page_list, PAGE *current_page)
 {
   const GList *iter;
 

commit 3d7719ca26bd4a77bce4f3ce3100c72d93d5e933
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    Add PAGE argument to o_net_consolidate().

diff --git a/gschem/src/o_undo.c b/gschem/src/o_undo.c
index b90d237..14f1442 100644
--- a/gschem/src/o_undo.c
+++ b/gschem/src/o_undo.c
@@ -104,7 +104,7 @@ void o_undo_savestate(GSCHEM_TOPLEVEL *w_current, int flag)
      * triggered before it was removed from o_save_buffer().
      */
     if (toplevel->net_consolidate == TRUE)
-      o_net_consolidate (w_current->toplevel);
+      o_net_consolidate (toplevel, toplevel->page_current);
   }
 
   if (w_current->undo_type == UNDO_DISK && flag == UNDO_ALL) {
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 38ec6ac..d260ed2 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -197,7 +197,7 @@ OBJECT *o_net_copy(TOPLEVEL *toplevel, OBJECT *o_current);
 void o_net_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, int angle, OBJECT *object);
 void o_net_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object);
 int o_net_orientation(OBJECT *object);
-void o_net_consolidate(TOPLEVEL *toplevel);
+void o_net_consolidate(TOPLEVEL *toplevel, PAGE *page);
 void o_net_modify(TOPLEVEL *toplevel, OBJECT *object, int x, int y, int whichone);
 
 /* o_path_basic.c */
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index 0c47b71..de3fb69 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -524,22 +524,16 @@ static int o_net_consolidate_segments (TOPLEVEL *toplevel, OBJECT *object)
   GList *c_current;
   CONN *conn;
   OBJECT *other_object;
-  int changed = 0;
   PAGE *page;
+  int changed = 0;
 
-  if (object == NULL) {
-    return(0);
-  }
-
-  if (object->type != OBJ_NET) {
-    return(0);
-  }
+  g_return_val_if_fail ((toplevel != NULL), 0);
+  g_return_val_if_fail ((object != NULL), 0);
+  g_return_val_if_fail ((object->type == OBJ_NET), 0);
 
-  /* It's meaningless to do anything here without a valid current page. */
-  page = o_get_page_compat (toplevel, object);
-  if (page == NULL) {
-    return (0);
-  }
+  /* It's meaningless to do anything here if the object isn't in a page. */
+  page = o_get_page (toplevel, object);
+  g_return_val_if_fail ((page != NULL), 0);
 
   object_orient = o_net_orientation(object);
 
@@ -598,18 +592,20 @@ static int o_net_consolidate_segments (TOPLEVEL *toplevel, OBJECT *object)
 
 /*! \brief consolidate all net objects
  *  \par Function Description
- *  This function consolidates all net objects until no more consolidations
- *  are posible.
- *
- *  \param toplevel  The TOPLEVEL object
+ *  This function consolidates all net objects in a page until no more
+ *  consolidations are possible.
  *
+ *  \param toplevel  The TOPLEVEL object.
+ *  \param page      The PAGE to consolidate nets in.
  */
-void o_net_consolidate(TOPLEVEL *toplevel)
+void o_net_consolidate(TOPLEVEL *toplevel, PAGE *page)
 {
   OBJECT *o_current;
   const GList *iter;
   int status = 0;
-  PAGE *page = toplevel->page_current;
+
+  g_return_if_fail (toplevel != NULL);
+  g_return_if_fail (page != NULL);
 
   iter = s_page_objects (page);
 

commit b87d7edc2be45dab1e7cab8ec81cce2631377b4f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Remove some more uses of page_current.
    
    Removes some uses of TOPLEVEL.page_current which were missed in
    a33839adef1f.

diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index 21206dd..3c7d16d 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -283,11 +283,11 @@ int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
    * the RC file, it's time to read in the file. */
   if (load_backup_file == 1) {
     /* Load the backup file */
-    s_page_append_list (toplevel, toplevel->page_current,
+    s_page_append_list (toplevel, page,
                         o_read (toplevel, NULL, backup_filename, &tmp_err));
   } else {
     /* Load the original file */
-    s_page_append_list (toplevel, toplevel->page_current,
+    s_page_append_list (toplevel, page,
                         o_read (toplevel, NULL, full_filename, &tmp_err));
   }
 

commit a33839adef1f8c7239e5b291baef667b9046d91f
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Get rid of some uses of page_current.
    
    Remove some uses of page_current from functions used only by libgeda.
    This will make it more painless to remove page_current completely.

diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index ba3c216..21206dd 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -204,7 +204,7 @@ int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
   /* has the head been freed yet? */
   /* probably not hack PAGE */
 
-  set_window(toplevel, toplevel->page_current,
+  set_window(toplevel, page,
              toplevel->init_left, toplevel->init_right,
              toplevel->init_top,  toplevel->init_bottom);
 
@@ -224,9 +224,9 @@ int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
     return 0;
   }
 
-  /* write full, absolute filename into page_current->page_filename */
-  g_free(toplevel->page_current->page_filename);
-  toplevel->page_current->page_filename = g_strdup(full_filename);
+  /* write full, absolute filename into page->page_filename */
+  g_free(page->page_filename);
+  page->page_filename = g_strdup(full_filename);
 
   /* Before we open the page, let's load the corresponding gafrc. */
   /* First cd into file's directory. */
@@ -298,11 +298,11 @@ int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
 
   if (load_backup_file == 0) {
     /* If it's not the backup file */
-    toplevel->page_current->CHANGED=0; /* added 4/7/98 */
+    page->CHANGED=0; /* added 4/7/98 */
   } else {
     /* We are loading the backup file, so gschem should ask
        the user if save it or not when closing the page. */
-    toplevel->page_current->CHANGED=1;
+    page->CHANGED=1;
   }
 
   g_free(full_filename);
@@ -363,7 +363,7 @@ int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename)
   only_filename = g_path_get_basename(real_filename);  
 
   /* Do a backup if it's not an undo file backup and it was never saved. */
-  if (toplevel->page_current->saved_since_first_loaded == 0) {
+  if (page->saved_since_first_loaded == 0) {
     if ( (g_file_test (real_filename, G_FILE_TEST_EXISTS)) && 
 	 (!g_file_test(real_filename, G_FILE_TEST_IS_DIR)) )
     {
@@ -428,12 +428,12 @@ int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename)
   
   if (o_save (toplevel, s_page_objects (page), real_filename)) {
 
-    toplevel->page_current->saved_since_first_loaded = 1;
+    page->saved_since_first_loaded = 1;
 
     /* Reset the last saved timer */
-    g_get_current_time (&toplevel->page_current->last_load_or_save_time);
-    toplevel->page_current->ops_since_last_backup = 0;
-    toplevel->page_current->do_autosave_backup = 0;
+    g_get_current_time (&page->last_load_or_save_time);
+    page->ops_since_last_backup = 0;
+    page->do_autosave_backup = 0;
 
     /* Restore permissions. */
     chmod (real_filename, st.st_mode);
diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index c839597..640debb 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -131,10 +131,6 @@ void o_attrib_attach (TOPLEVEL *toplevel, OBJECT *attrib, OBJECT *object,
 
   if (set_color)
     o_set_color (toplevel, attrib, ATTRIBUTE_COLOR);
-
-  /* can't do this here since just selecting something */
-  /* will cause this to be set */
-  /* toplevel->page_current->CHANGED=1;*/
 }
 
 
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index fa7019e..0c47b71 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -609,8 +609,9 @@ void o_net_consolidate(TOPLEVEL *toplevel)
   OBJECT *o_current;
   const GList *iter;
   int status = 0;
+  PAGE *page = toplevel->page_current;
 
-  iter = s_page_objects (toplevel->page_current);
+  iter = s_page_objects (page);
 
   while (iter != NULL) {
     o_current = (OBJECT *)iter->data;
@@ -620,7 +621,7 @@ void o_net_consolidate(TOPLEVEL *toplevel)
     }
 
     if (status == -1) {
-      iter = s_page_objects (toplevel->page_current);
+      iter = s_page_objects (page);
       status = 0;
     } else {
       iter = g_list_next (iter);

commit e883ed4bf0681db9e67da5e176d2caa6d8876f4c
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Remove o_save_curr_page().

diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 08c3fb3..2890bff 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -830,7 +830,9 @@ void o_autosave_backups(GSCHEM_TOPLEVEL *w_current)
           umask(saved_umask);
         }
 
-        if (o_save_curr_page (toplevel, backup_filename)) {
+        if (o_save (toplevel,
+                    s_page_objects (toplevel->page_current),
+                    backup_filename)) {
 
           p_current->ops_since_last_backup = 0;
                 p_current->do_autosave_backup = 0;
diff --git a/gschem/src/o_undo.c b/gschem/src/o_undo.c
index 51d0820..794aeca 100644
--- a/gschem/src/o_undo.c
+++ b/gschem/src/o_undo.c
@@ -117,7 +117,7 @@ void o_undo_savestate(GSCHEM_TOPLEVEL *w_current, int flag)
     /* f_save manages the creaton of backup copies. 
        This way, f_save is called only when saving a file, and not when
        saving an undo backup copy */
-    o_save_curr_page (toplevel, filename);
+    o_save (toplevel, s_page_objects (toplevel->page_current), filename);
 
   } else if (w_current->undo_type == UNDO_MEMORY && flag == UNDO_ALL) {
     object_list = o_glist_copy_all (toplevel,
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 55b1e5a..c7d9707 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -3,7 +3,6 @@
 const gchar *o_file_format_header();
 gchar *o_save_buffer (TOPLEVEL *toplevel, const GList *object_list);
 int o_save (TOPLEVEL *toplevel, const GList *object_list, const char *filename);
-int o_save_curr_page (TOPLEVEL *toplevel, const char *filename);
 GList *o_read_buffer(TOPLEVEL *toplevel, GList *object_list, char *buffer, const int size, const char *name);
 GList *o_read(TOPLEVEL *toplevel, GList *object_list, char *filename, GError **err);
 void o_scale(TOPLEVEL *toplevel, GList *list, int x_scale, int y_scale);
diff --git a/libgeda/src/a_basic.c b/libgeda/src/a_basic.c
index 38d347c..bc9553c 100644
--- a/libgeda/src/a_basic.c
+++ b/libgeda/src/a_basic.c
@@ -236,19 +236,6 @@ int o_save (TOPLEVEL *toplevel, const GList *object_list,
   return 1;
 }
 
-/*! \brief Save a file
- *  \par Function Description
- *  This function saves the current page in a libgeda format to a file
- *  \param [in] toplevel    The current TOPLEVEL.
- *  \param [in] filename    The filename to save the data to.
- *  \return 1 on success, 0 on failure.
- */
-int o_save_curr_page (TOPLEVEL *toplevel, const char *filename)
-{
-  return o_save (toplevel, s_page_objects (toplevel->page_current),
-                 filename);
-}
-
 /*! \brief Read a memory buffer
  *  \par Function Description
  *  This function reads data in libgeda format from a memory buffer.
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index f85d090..ba3c216 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -426,7 +426,7 @@ int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename)
   g_free (dirname);
   g_free (only_filename);
   
-  if (o_save_curr_page (toplevel, real_filename)) {
+  if (o_save (toplevel, s_page_objects (page), real_filename)) {
 
     toplevel->page_current->saved_since_first_loaded = 1;
 

commit 3abdca2a4ee088184e976822c444069d67e20a20
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Add PAGE argument to file load/save functions.

diff --git a/gattrib/src/s_toplevel.c b/gattrib/src/s_toplevel.c
index e8babd9..53c971a 100644
--- a/gattrib/src/s_toplevel.c
+++ b/gattrib/src/s_toplevel.c
@@ -69,7 +69,8 @@ int s_toplevel_read_page(char *filename)
   pr_current->page_current->page_filename = g_strdup(filename);
   
   /* read in and fill out pr_current using f_open and its callees */
-  file_return_code = f_open(pr_current, filename, &err);
+  file_return_code = f_open(pr_current, pr_current->page_current,
+                            filename, &err);
 
   /* If an error occurred, print message */
   if (err != NULL) {
diff --git a/gattrib/src/x_fileselect.c b/gattrib/src/x_fileselect.c
index 5b734a9..da35a7b 100644
--- a/gattrib/src/x_fileselect.c
+++ b/gattrib/src/x_fileselect.c
@@ -303,7 +303,7 @@ x_fileselect_save (void)
 
     /* try saving current page of toplevel to file filename */
     if (filename != NULL &&
-        f_save (pr_current, filename)) {
+        f_save (pr_current, pr_current->page_current, filename)) {
       s_log_message ("Saved As [%s]\n", filename);
 
       /* replace page filename with new one, do not free filename */
diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index 352684c..3471b97 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -206,7 +206,7 @@ void main_prog(void *closure, int argc, char *argv[])
 
       s_page_goto (pr_current, s_page_new (pr_current, filename));
 
-      if (!f_open (pr_current, filename, &err)) {
+      if (!f_open (pr_current, pr_current->page_current, filename, &err)) {
         g_warning ("%s\n", err->message);
         fprintf (stderr, "%s\n", err->message);
         g_error_free (err);
diff --git a/gschem/src/o_undo.c b/gschem/src/o_undo.c
index deb3aee..51d0820 100644
--- a/gschem/src/o_undo.c
+++ b/gschem/src/o_undo.c
@@ -366,7 +366,7 @@ void o_undo_callback(GSCHEM_TOPLEVEL *w_current, int type)
 
   if (w_current->undo_type == UNDO_DISK && u_current->filename) {
 
-    f_open(toplevel, u_current->filename, NULL);
+    f_open(toplevel, toplevel->page_current, u_current->filename, NULL);
 
     x_manual_resize(w_current);
     toplevel->page_current->page_control = u_current->page_control;
diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index 47bab5c..bd892ff 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -220,7 +220,8 @@ preview_update (Preview *preview)
     g_assert ((preview->filename == NULL) || (preview->buffer == NULL));
     if (preview->filename != NULL) {
       /* open up file in current page */
-      f_open_flags (preview_toplevel, preview->filename,
+      f_open_flags (preview_toplevel, preview_toplevel->page_current,
+                    preview->filename,
                     F_OPEN_RC | F_OPEN_RESTORE_CWD, NULL);
       /* test value returned by f_open... - Fix me */
       /* we should display something if there an error occured - Fix me */
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 07beb6e..c44fa12 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -728,7 +728,7 @@ x_window_open_page (GSCHEM_TOPLEVEL *w_current, const gchar *filename)
     if (!quiet_mode)
       s_log_message (_("Loading schematic [%s]\n"), fn);
 
-    if (!f_open (toplevel, (gchar *) fn, &err)) {
+    if (!f_open (toplevel, page, (gchar *) fn, &err)) {
       GtkWidget *dialog;
 
       g_warning ("%s\n", err->message);
@@ -851,7 +851,7 @@ x_window_save_page (GSCHEM_TOPLEVEL *w_current, PAGE *page, const gchar *filenam
   /* change to page */
   s_page_goto (toplevel, page);
   /* and try saving current page to filename */
-  ret = (gint)f_save (toplevel, filename);
+  ret = (gint)f_save (toplevel, toplevel->page_current, filename);
   if (ret != 1) {
     /* an error occured when saving page to file */
     log_msg   = _("Could NOT save page [%s]\n");
diff --git a/gsymcheck/src/gsymcheck.c b/gsymcheck/src/gsymcheck.c
index 75e1f49..da8b2d2 100644
--- a/gsymcheck/src/gsymcheck.c
+++ b/gsymcheck/src/gsymcheck.c
@@ -99,6 +99,7 @@ main_prog(void *closure, int argc, char *argv[])
                  s_page_new (pr_current, filename));
 
     if (!f_open (pr_current,
+                 pr_current->page_current,
                  pr_current->page_current->page_filename,
                  &err)) {
       /* Not being able to load a file is apparently a fatal error */
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index d9e60d4..55b1e5a 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -11,11 +11,11 @@ void o_scale(TOPLEVEL *toplevel, GList *list, int x_scale, int y_scale);
 /* f_basic.c */
 gchar *f_get_autosave_filename (const gchar *filename);
 gboolean f_has_active_autosave (const gchar *filename, GError **err);
-int f_open(TOPLEVEL *toplevel, const gchar *filename, GError **err);
-int f_open_flags(TOPLEVEL *toplevel, const gchar *filename,
+int f_open(TOPLEVEL *toplevel, PAGE *page, const gchar *filename, GError **err);
+int f_open_flags(TOPLEVEL *toplevel, PAGE *page, const gchar *filename,
                  const gint flags, GError **err);
 void f_close(TOPLEVEL *toplevel);
-int f_save(TOPLEVEL *toplevel, const char *filename);
+int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename);
 gchar *f_normalize_filename (const gchar *filename, GError **error);
 char *follow_symlinks (const gchar *filename, GError **error);
 
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index afe83c9..f85d090 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -162,9 +162,10 @@ gboolean f_has_active_autosave (const gchar *filename, GError **err)
  *
  *  \return 0 on failure, 1 on success.
  */
-int f_open(TOPLEVEL *toplevel, const gchar *filename, GError **err)
+int f_open(TOPLEVEL *toplevel, PAGE *page,
+           const gchar *filename, GError **err)
 {
-  return f_open_flags (toplevel, filename,
+  return f_open_flags (toplevel, page, filename,
                        F_OPEN_RC | F_OPEN_CHECK_BACKUP, err);
 }
 
@@ -187,7 +188,8 @@ int f_open(TOPLEVEL *toplevel, const gchar *filename, GError **err)
  *
  *  \return 0 on failure, 1 on success.
  */
-int f_open_flags(TOPLEVEL *toplevel, const gchar *filename,
+int f_open_flags(TOPLEVEL *toplevel, PAGE *page,
+                 const gchar *filename,
                  const gint flags, GError **err)
 {
   int opened=FALSE;
@@ -339,7 +341,7 @@ void f_close(TOPLEVEL *toplevel)
  *  \param [in]      filename  The file name to save the schematic to.
  *  \return 1 on success, 0 on failure.
  */
-int f_save(TOPLEVEL *toplevel, const char *filename)
+int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename)
 {
   gchar *backup_filename;
   gchar *real_filename;
diff --git a/libgeda/src/s_hierarchy.c b/libgeda/src/s_hierarchy.c
index 584fc58..994a7a2 100644
--- a/libgeda/src/s_hierarchy.c
+++ b/libgeda/src/s_hierarchy.c
@@ -103,7 +103,7 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
       found = s_page_new (toplevel, string);
       s_page_goto (toplevel, found);
       
-      f_open (toplevel, found->page_filename, NULL);
+      f_open (toplevel, found, found->page_filename, NULL);
     }
     break;
 
@@ -111,7 +111,7 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
     {
       PAGE *page = s_page_new (toplevel, string);
       s_page_goto (toplevel, page);
-      f_open (toplevel, page->page_filename, NULL);
+      f_open (toplevel, page, page->page_filename, NULL);
     }
     break;
   }
@@ -157,7 +157,7 @@ void s_hierarchy_down_symbol (TOPLEVEL *toplevel,
 
   s_page_goto (toplevel, page);
 
-  f_open(toplevel, page->page_filename, NULL);
+  f_open(toplevel, page, page->page_filename, NULL);
 
   page->up = parent->pid;
   page_control_counter++;
diff --git a/libgeda/src/s_page.c b/libgeda/src/s_page.c
index 3621319..5665f0b 100644
--- a/libgeda/src/s_page.c
+++ b/libgeda/src/s_page.c
@@ -485,42 +485,31 @@ void s_page_print_all (TOPLEVEL *toplevel)
 gint s_page_save_all (TOPLEVEL *toplevel)
 {
   const GList *iter;
-  PAGE *p_save, *p_current;
+  PAGE *p_current;
   gint status = 0;
 
-  /* save current page */
-  p_save = toplevel->page_current;
-
   for ( iter = geda_list_get_glist( toplevel->pages );
         iter != NULL;
         iter = g_list_next( iter ) ) {
 
     p_current = (PAGE *)iter->data;
 
-    /* make p_current the current page of toplevel */
-    s_page_goto (toplevel, p_current);
-
-    if (f_save (toplevel, p_current->page_filename)) {
+    if (f_save (toplevel, p_current,
+                p_current->page_filename)) {
       s_log_message (_("Saved [%s]\n"),
-                     toplevel->page_current->page_filename);
+                     p_current->page_filename);
       /* reset the CHANGED flag of p_current */
       p_current->CHANGED = 0;
 
     } else {
       s_log_message (_("Could NOT save [%s]\n"),
-                     toplevel->page_current->page_filename);
+                     p_current->page_filename);
       /* increase the error counter */
       status++;
     }
 
   }
 
-  /* restore current page */
-  if (p_save != NULL) 
-  {
-     s_page_goto (toplevel, p_save);
-  }
-
   return status;
 }
 
diff --git a/utils/gschlas/gschlas.c b/utils/gschlas/gschlas.c
index b9160aa..507cfc6 100644
--- a/utils/gschlas/gschlas.c
+++ b/utils/gschlas/gschlas.c
@@ -100,7 +100,8 @@ main_prog(void *closure, int argc, char *argv[])
 
     s_page_goto (pr_current, s_page_new (pr_current, filename));
 
-    if (!f_open (pr_current, pr_current->page_current->page_filename, &err)) {
+    if (!f_open (pr_current, pr_current->page_current,
+                 pr_current->page_current->page_filename, &err)) {
       /* Not being able to load a file is apparently a fatal error */
       logging_dest = STDOUT_TTY;
       g_warning ("%s\n", err->message);

commit 4a3a3d9e4cc72fa94165306c5b8d411d47812d45
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Add PAGE argument to print functions.

diff --git a/gschem/src/g_funcs.c b/gschem/src/g_funcs.c
index ecfc83a..d2035ab 100644
--- a/gschem/src/g_funcs.c
+++ b/gschem/src/g_funcs.c
@@ -45,14 +45,18 @@
  */
 SCM g_funcs_print(SCM filename)
 {
+  TOPLEVEL *toplevel = global_window_current->toplevel;
+  
   SCM_ASSERT (scm_is_string (filename), filename,
               SCM_ARG1, "gschem-print");
 
   if (output_filename) {
-    if (f_print_file (global_window_current->toplevel, output_filename))
+    if (f_print_file (toplevel, toplevel->page_current,
+                      output_filename))
       return SCM_BOOL_F;
   } else  {
-    if (f_print_file (global_window_current->toplevel, SCM_STRING_CHARS (filename)))
+    if (f_print_file (toplevel, toplevel->page_current,
+                      SCM_STRING_CHARS (filename)))
       return SCM_BOOL_F;
   }
   
@@ -66,14 +70,18 @@ SCM g_funcs_print(SCM filename)
  */
 SCM g_funcs_postscript(SCM filename)
 {
+  TOPLEVEL *toplevel = global_window_current->toplevel;
+
   SCM_ASSERT (scm_is_string (filename), filename,
               SCM_ARG1, "gschem-postscript");
 
   if (output_filename) {
-    if (f_print_file (global_window_current->toplevel, output_filename))
+    if (f_print_file (toplevel, toplevel->page_current,
+                      output_filename))
       return SCM_BOOL_F;
   } else  {
-    if (f_print_file (global_window_current->toplevel, SCM_STRING_CHARS (filename)))
+    if (f_print_file (toplevel, toplevel->page_current,
+                      SCM_STRING_CHARS (filename)))
       return SCM_BOOL_F;
   }
   
diff --git a/gschem/src/x_image.c b/gschem/src/x_image.c
index aa7b845..1c94c5b 100644
--- a/gschem/src/x_image.c
+++ b/gschem/src/x_image.c
@@ -291,7 +291,7 @@ void x_image_write_eps(GSCHEM_TOPLEVEL *w_current, const char* filename)
   toplevel->paper_height = 0;
   toplevel->print_orientation = PORTRAIT;
   toplevel->print_output_type = EXTENTS_NOMARGINS;
-  result = f_print_file (toplevel, filename);
+  result = f_print_file (toplevel, toplevel->page_current, filename);
   if (result) {
     s_log_message(_("x_image_lowlevel: Unable to write eps file %s.\n"),
         filename);
diff --git a/gschem/src/x_print.c b/gschem/src/x_print.c
index 3de2205..769190a 100644
--- a/gschem/src/x_print.c
+++ b/gschem/src/x_print.c
@@ -725,13 +725,17 @@ x_print_setup (GSCHEM_TOPLEVEL *w_current, char *filename)
 	/* Print to file */
 	{
 	  destination = filename;
-	  result = f_print_file (toplevel, filename);
+	  result = f_print_file (toplevel,
+                                 toplevel->page_current,
+                                 filename);
 	}
       else if (command[0])
 	/* Print to command and save command for later use. */
 	{
 	  destination = command;
-	  result = f_print_command (toplevel, command);
+	  result = f_print_command (toplevel,
+                                    toplevel->page_current,
+                                    command);
 	  
 	  g_free (w_current->print_command);
 	  w_current->print_command = g_strdup (command);
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 6b8b1e4..d9e60d4 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -20,9 +20,9 @@ gchar *f_normalize_filename (const gchar *filename, GError **error);
 char *follow_symlinks (const gchar *filename, GError **error);
 
 /* f_print.c */
-int f_print_file (TOPLEVEL *toplevel, const char *filename);
-int f_print_command (TOPLEVEL *toplevel, const char *command);
-int f_print_stream(TOPLEVEL *toplevel, FILE *fp);
+int f_print_file (TOPLEVEL *toplevel, PAGE *page, const char *filename);
+int f_print_command (TOPLEVEL *toplevel, PAGE *page, const char *command);
+int f_print_stream(TOPLEVEL *toplevel, PAGE *page, FILE *fp);
 void f_print_set_type(TOPLEVEL *toplevel, int type);
 
 /* g_basic.c */
diff --git a/libgeda/include/prototype_priv.h b/libgeda/include/prototype_priv.h
index f02e9db..1b62ff7 100644
--- a/libgeda/include/prototype_priv.h
+++ b/libgeda/include/prototype_priv.h
@@ -4,7 +4,7 @@ gchar *o_save_objects(const GList *object_list, gboolean save_attribs);
 /* f_print.c */
 void f_print_set_line_width(FILE *fp, int width);
 void f_print_set_color(TOPLEVEL *toplevel, FILE *fp, int color);
-int f_print_header(TOPLEVEL *toplevel, FILE *fp, int paper_size_x, int paper_size_y, int eps);
+int f_print_header(TOPLEVEL *toplevel, PAGE *page, FILE *fp, int paper_size_x, int paper_size_y, int eps);
 void f_print_footer(FILE *fp);
 void f_print_objects(TOPLEVEL *toplevel, FILE *fp, const GList *obj_list, int start_x, int start_y, float scale, int unicode_count, gunichar *unicode_table);
 int f_print_initialize_glyph_table(void);
diff --git a/libgeda/src/f_print.c b/libgeda/src/f_print.c
index 5bb9d3d..5406537 100644
--- a/libgeda/src/f_print.c
+++ b/libgeda/src/f_print.c
@@ -90,14 +90,15 @@ void f_print_set_color(TOPLEVEL *toplevel, FILE *fp, int color)
  *  This function will print a document preamble and header
  *  for a postscript document.
  *
- *  \param [in] toplevel     The TOPLEVEL object to create document for.
+ *  \param [in] toplevel     The TOPLEVEL object.
+ *  \param [in] page          The page to create document for.
  *  \param [in] fp            The postscript document to write to.
  *  \param [in] paper_size_x  The width of the document on paper in inches.
  *  \param [in] paper_size_y  The height of the document on paper in inches.
  *  \param [in] eps           whether to create a eps of a ps document
  *  \return 0 on success, -1 on failure.
  */
-int f_print_header(TOPLEVEL *toplevel, FILE *fp,
+int f_print_header(TOPLEVEL *toplevel, PAGE *page, FILE *fp,
 		   int paper_size_x, int paper_size_y, int eps) 
 {
   char *buf = NULL;
@@ -137,7 +138,7 @@ int f_print_header(TOPLEVEL *toplevel, FILE *fp,
 	  "%%%%BeginProlog\n",
 	  PACKAGE_GIT_VERSION,
 	  ctime(&current_time),
-	  toplevel->page_current->page_filename,
+	  page->page_filename,
 #ifdef HAVE_GETLOGIN
 	  getlogin(),
 #endif
@@ -349,11 +350,12 @@ void f_print_objects (TOPLEVEL *toplevel, FILE *fp, const GList *obj_list,
  *
  *  \par Function Description
  *
- *  \param [in] toplevel  The TOPLEVEL object to print.
+ *  \param [in] toplevel   The TOPLEVEL object.
+ *  \param [in] page       The PAGE to print.
  *  \param [in] filename   The file name of the output postscript document.
  *  \return 0 on success, -1 on failure.
  */
-int f_print_file (TOPLEVEL *toplevel, const char *filename)
+int f_print_file (TOPLEVEL *toplevel, PAGE *page, const char *filename)
 {
   FILE *fp;
   int result;
@@ -367,7 +369,7 @@ int f_print_file (TOPLEVEL *toplevel, const char *filename)
     return -1;
   }
 
-  result = f_print_stream(toplevel, fp);
+  result = f_print_stream(toplevel, page, fp);
   
   if (result != 0) {
     /* If there was an error in f_print_stream, then unlink the output file. */
@@ -382,11 +384,12 @@ int f_print_file (TOPLEVEL *toplevel, const char *filename)
  *
  *  \par Function Description
  *
- *  \param [in] toplevel  The TOPLEVEL object to print.
+ *  \param [in] toplevel   The TOPLEVEL object.
+ *  \param [in] page       The PAGE to print.
  *  \param [in] command    The command to print to.
  *  \return 0 on success, -1 on failure.
  */
-int f_print_command (TOPLEVEL *toplevel, const char *command)
+int f_print_command (TOPLEVEL *toplevel, PAGE *page, const char *command)
 {
   FILE *fp;
   int result;
@@ -401,7 +404,7 @@ int f_print_command (TOPLEVEL *toplevel, const char *command)
       return -1;
     }
 
-  result = f_print_stream (toplevel, fp);
+  result = f_print_stream (toplevel, page, fp);
   pclose (fp);
   return result;
 }
@@ -415,7 +418,7 @@ int f_print_command (TOPLEVEL *toplevel, const char *command)
  *  \return 0 on success, -1 on failure.
  */
 
-int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
+int f_print_stream(TOPLEVEL *toplevel, PAGE *page, FILE *fp)
 {
   int origin_x, origin_y, bottom, right;
   int margin_x, margin_y;
@@ -425,7 +428,6 @@ int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
   gunichar unicode_table [128];  /* to contain the list of unicode
 				    characters that need mapping */
   int eps;
-  
 
   /* Unicode support */
   f_print_initialize_glyph_table();  /* Fill up unicode map */
@@ -433,13 +435,13 @@ int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
   /* Find all the unicode characters */
   unicode_count =
     f_print_get_unicode_chars (toplevel,
-                               s_page_objects (toplevel->page_current),
+                               s_page_objects (page),
                                0, unicode_table);
 
   /*	printf("%d %d\n", toplevel->paper_width, toplevel->paper_height);*/
 
   world_get_object_glist_bounds (toplevel,
-                                 s_page_objects (toplevel->page_current),
+                                 s_page_objects (page),
                                  &origin_x, &origin_y,
                                  &right, &bottom);
 
@@ -459,12 +461,12 @@ int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
     break;
 
   case WINDOW:
-    dx = toplevel->page_current->right - toplevel->page_current->left;
-    dy = toplevel->page_current->bottom - toplevel->page_current->top;
-    origin_x = toplevel->page_current->left;
-    origin_y = toplevel->page_current->top;
-    right = toplevel->page_current->right;
-    bottom = toplevel->page_current->bottom;
+    dx = page->right - page->left;
+    dy = page->bottom - page->top;
+    origin_x = page->left;
+    origin_y = page->top;
+    right = page->right;
+    bottom = page->bottom;
     break;
 
   case EXTENTS_NOMARGINS:
@@ -514,7 +516,7 @@ int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
 #endif  
 
   /* Output the header */
-  if (f_print_header(toplevel, fp,
+  if (f_print_header(toplevel, page, fp,
 		     toplevel->paper_width,
 		     toplevel->paper_height,
 		     eps) != 0) {
@@ -597,7 +599,7 @@ int f_print_stream(TOPLEVEL *toplevel, FILE *fp)
 	  scale, scale);
 
   /* Print the objects */
-  f_print_objects (toplevel, fp, s_page_objects (toplevel->page_current),
+  f_print_objects (toplevel, fp, s_page_objects (page),
                    origin_x, origin_y, scale, unicode_count, unicode_table);
 
   f_print_footer(fp);

commit c26ed9d5b126f7e2b67285e465438aa9b5ee4ffd
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make g_read_file() take a TOPLEVEL argument.

diff --git a/gnetlist/src/gnetlist.c b/gnetlist/src/gnetlist.c
index faa63e4..352684c 100644
--- a/gnetlist/src/gnetlist.c
+++ b/gnetlist/src/gnetlist.c
@@ -174,7 +174,7 @@ void main_prog(void *closure, int argc, char *argv[])
     /* Load the first set of scm files before we load any schematic files */
     list_pnt = pre_backend_list;
     while (list_pnt) {
-      if (g_read_file(list_pnt->data) != -1) {
+      if (g_read_file(pr_current, list_pnt->data) != -1) {
         s_log_message("Read scm file [%s]\n",
                       (char *) list_pnt->data);
       } else {
@@ -238,7 +238,7 @@ void main_prog(void *closure, int argc, char *argv[])
 #endif
 
     filename = g_build_filename (pr_current->scheme_directory, "gnetlist.scm", NULL);
-    if (g_read_file (filename) != -1) {
+    if (g_read_file (pr_current, filename) != -1) {
       s_log_message ("Read init scm file [%s]\n", filename);
     } else {
       s_log_message ("Failed to read init scm file [%s]\n", filename);
@@ -251,7 +251,7 @@ void main_prog(void *closure, int argc, char *argv[])
         str = g_strdup_printf("gnet-%s.scm", guile_proc);
         filename = g_build_filename (pr_current->scheme_directory, str, NULL);
         g_free (str);
-        if (g_read_file (filename) != -1) {
+        if (g_read_file (pr_current, filename) != -1) {
           s_log_message ("Read %s scm file [%s]\n", guile_proc, filename);
         } else {
           s_log_message ("Failed to read %s scm file [%s]\n", guile_proc, filename);
@@ -262,7 +262,7 @@ void main_prog(void *closure, int argc, char *argv[])
         /* Load second set of scm files */
         list_pnt = post_backend_list;
         while (list_pnt) {
-          if (g_read_file(list_pnt->data) != -1) {
+          if (g_read_file(pr_current, list_pnt->data) != -1) {
             s_log_message("Read scm file [%s]\n",
                           (char *) list_pnt->data);
           } else {
@@ -289,7 +289,7 @@ void main_prog(void *closure, int argc, char *argv[])
     g_free(cwd);
 
     filename = g_build_filename (pr_current->scheme_directory, "gnetlist-post.scm", NULL);
-    if (g_read_file (filename) != -1) {
+    if (g_read_file (pr_current, filename) != -1) {
       s_log_message ("Read post traversal scm file [%s]\n", filename);
     } else {
       s_log_message ("Failed to read post traversal scm file [%s]\n", filename);
diff --git a/gschem/src/gschem.c b/gschem/src/gschem.c
index b47d503..e5e6ca3 100644
--- a/gschem/src/gschem.c
+++ b/gschem/src/gschem.c
@@ -248,7 +248,7 @@ void main_prog(void *closure, int argc, char *argv[])
     s_log_message (_("Couldn't find init scm file [%s]\n"), "gschem.scm");
   }
   input_str = scm_to_locale_string (scm_tmp);
-  if (g_read_file(input_str) != -1) {
+  if (g_read_file(w_current->toplevel, input_str) != -1) {
     s_log_message(_("Read init scm file [%s]\n"), input_str);
   } else {
     /*! \todo These two messages are the same. Should be
@@ -323,7 +323,7 @@ void main_prog(void *closure, int argc, char *argv[])
   if (script_filename) {
     s_log_message(_("Executing guile script [%s]\n"),
                   script_filename);
-    g_read_file(script_filename);
+    g_read_file(w_current->toplevel, script_filename);
   }
 
   /* open up log window on startup */
diff --git a/gschem/src/x_script.c b/gschem/src/x_script.c
index 61e0c83..9d5e00e 100644
--- a/gschem/src/x_script.c
+++ b/gschem/src/x_script.c
@@ -64,7 +64,7 @@ void setup_script_selector (GSCHEM_TOPLEVEL *w_current)
 
     if (!(g_file_test(filename, G_FILE_TEST_IS_DIR))) {
       s_log_message(_("Executing guile script [%s]\n"), filename);
-      g_read_file(filename);
+      g_read_file(w_current->toplevel, filename);
     }
     g_free (filename);
   }
diff --git a/libgeda/include/libgeda/prototype.h b/libgeda/include/libgeda/prototype.h
index 47a0fbb..6b8b1e4 100644
--- a/libgeda/include/libgeda/prototype.h
+++ b/libgeda/include/libgeda/prototype.h
@@ -29,7 +29,7 @@ void f_print_set_type(TOPLEVEL *toplevel, int type);
 SCM g_scm_eval_protected (SCM exp, SCM module_or_state);
 SCM g_scm_eval_string_protected (SCM str);
 SCM g_scm_c_eval_string_protected (const gchar *str);
-int g_read_file(const gchar *filename);
+int g_read_file(TOPLEVEL *toplevel, const gchar *filename);
 
 /* g_rc.c */
 SCM g_rc_mode_general(SCM scmmode, const char *rc_name, int *mode_var, 
diff --git a/libgeda/src/g_basic.c b/libgeda/src/g_basic.c
index e4d2083..15dda39 100644
--- a/libgeda/src/g_basic.c
+++ b/libgeda/src/g_basic.c
@@ -235,10 +235,12 @@ SCM g_scm_eval_string_protected (SCM str)
  *  \par Function Description
  *  Start reading a scheme file
  *
+ *  \param [in] toplevel  The TOPLEVEL structure.
  *  \param [in] filename  The file name to start reading from.
  *  \return 0 on success, -1 on failure.
  */
-int g_read_file(const gchar *filename)
+int
+g_read_file(TOPLEVEL *toplevel, const gchar *filename)
 {
 	SCM eval_result = SCM_BOOL_F;
         SCM expr;
diff --git a/libgeda/src/g_rc.c b/libgeda/src/g_rc.c
index f40156e..5e0bc46 100644
--- a/libgeda/src/g_rc.c
+++ b/libgeda/src/g_rc.c
@@ -137,7 +137,7 @@ gint g_rc_parse_general(TOPLEVEL *toplevel,
 
   /* Now try to read in contents of RC file.  */
   if (access (fname, R_OK) == 0) {
-    g_read_file (fname);
+    g_read_file (toplevel, fname);
     found_rc = 1;
     /* Everything was OK.  Now add this file to list of read RC files. */
     toplevel->RC_list = g_list_append (toplevel->RC_list,




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