Moved s_hierarchy_find_page() to libgeda s_page.c and renamed to
s_page_search_by_page_id(). Also added description.
---
 gschem/src/x_pagesel.c      |    4 ++--
 gschem/src/x_window.c       |    2 +-
 libgeda/include/prototype.h |    2 +-
 libgeda/src/s_hierarchy.c   |   26 ++------------------------
 libgeda/src/s_page.c        |   25 +++++++++++++++++++++++++
 5 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/gschem/src/x_pagesel.c b/gschem/src/x_pagesel.c
index 926622b..ef29a6e 100644
--- a/gschem/src/x_pagesel.c
+++ b/gschem/src/x_pagesel.c
@@ -606,8 +606,8 @@ void pagesel_update (Pagesel *pagesel)
     p_current = (PAGE *)iter->data;
     /* find every page that is not a hierarchy-down of another page */
     if (p_current->up < 0 ||
-        s_hierarchy_find_page (toplevel->pages,
-                               p_current->up) == NULL) {
+        s_page_search_by_page_id (toplevel->pages,
+                                  p_current->up) == NULL) {
       add_page (model, NULL, toplevel->pages, p_current);
     }
   }
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 1c8ec6e..814cf1d 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -996,7 +996,7 @@ x_window_close_page (GSCHEM_TOPLEVEL *w_current, PAGE *page)
   if (page == toplevel->page_current) {
     /* as it will delete current page, select new current page */
     /* first look up in page hierarchy */
-    new_current = s_hierarchy_find_page (toplevel->pages, page->up);
+    new_current = s_page_search_by_page_id (toplevel->pages, page->up);
 
     if (new_current == NULL) {
       /* no up in hierarchy, choice is prev, next, new page */
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 7e849c2..66cb893 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -408,7 +408,6 @@ GList* s_hierarchy_traversepages(TOPLEVEL *toplevel, gint 
flags);
 gint s_hierarchy_print_page(PAGE *p_current, void * data);
 PAGE *s_hierarchy_find_prev_page(GedaPageList *page_list, PAGE *current_page, 
int page_control);
 PAGE *s_hierarchy_find_next_page(GedaPageList *page_list, PAGE *current_page, 
int page_control);
-PAGE *s_hierarchy_find_page(GedaPageList *page_list, int pid);
 
 /* s_log.c */
 void s_log_init (const gchar *filename);
@@ -429,6 +428,7 @@ void s_page_delete (TOPLEVEL *toplevel, PAGE *page);
 void s_page_delete_list(TOPLEVEL *toplevel);
 void s_page_goto (TOPLEVEL *toplevel, PAGE *p_new);
 PAGE *s_page_search (TOPLEVEL *toplevel, const gchar *filename);
+PAGE *s_page_search_by_page_id (GedaPageList *list, int pid);
 void s_page_print_all (TOPLEVEL *toplevel);
 gint s_page_save_all (TOPLEVEL *toplevel);
 gboolean s_page_check_changed (GedaPageList *list);
diff --git a/libgeda/src/s_hierarchy.c b/libgeda/src/s_hierarchy.c
index 2d52df6..99528ec 100644
--- a/libgeda/src/s_hierarchy.c
+++ b/libgeda/src/s_hierarchy.c
@@ -83,7 +83,7 @@ int s_hierarchy_down_schematic_single(TOPLEVEL *toplevel,
        /* check whether this page is in the parents list */
        for (forbear = parent; 
             forbear != NULL && found->pid != forbear->pid && forbear->up >= 0;
-            forbear = s_hierarchy_find_page (toplevel->pages, forbear->up))
+            forbear = s_page_search_by_page_id (toplevel->pages, forbear->up))
          ; /* void */
 
        if (found->pid == forbear->pid) {
@@ -179,7 +179,7 @@ void s_hierarchy_up(TOPLEVEL *toplevel, int pid)
     return;
   }
 
-  p_current = s_hierarchy_find_page(toplevel->pages, pid);
+  p_current = s_page_search_by_page_id(toplevel->pages, pid);
 
   if (p_current) {
     s_page_goto(toplevel, p_current);
@@ -344,25 +344,3 @@ PAGE *s_hierarchy_find_next_page (GedaPageList *page_list, 
PAGE *current_page, i
 
   return NULL;
 }
-
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-PAGE *s_hierarchy_find_page (GedaPageList *page_list, int pid)
-{
-  const GList *iter;
-
-  for ( iter = geda_list_get_glist (page_list);
-        iter != NULL;
-        iter = g_list_next (iter) ) {
-
-    PAGE *page = (PAGE *)iter->data;
-    if (page->pid == pid) {
-      return page;
-    }
-  }
-
-  return NULL;
-}
diff --git a/libgeda/src/s_page.c b/libgeda/src/s_page.c
index cdae0a0..cca15c6 100644
--- a/libgeda/src/s_page.c
+++ b/libgeda/src/s_page.c
@@ -298,6 +298,31 @@ PAGE *s_page_search (TOPLEVEL *toplevel, const gchar 
*filename)
   return NULL;
 }
 
+/*! \brief Search for a page given its page id in a page list.
+ *  \par Function Description
+ *  This functions returns the page that have the page id \a pid in
+ *  the list of pages starting at \a page_list, or NULL if there is no
+ *  such page.
+ *
+ *  \param [in] page_list The list of page to search the page in.
+ *  \param [in] pid       The ID of the page to find.
+ *  \returns A pointer on the page found or NULL if not found.
+ */
+PAGE *s_page_search_by_page_id (GedaPageList *list, int pid)
+{
+  const GList *iter;
+
+  for ( iter = geda_list_get_glist (list);
+        iter != NULL;
+        iter = g_list_next (iter) ) {
+    PAGE *page = (PAGE *)iter->data;
+    if (page->pid == pid) {
+      return page;
+    }
+  }
+
+  return NULL;
+}
 
 /*! \brief Print full TOPLEVEL structure.
  *  \par Function Description
-- 
1.5.6




_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to