Renamed s_hierarchy_up() to s_hierarchy_find_up_page() for consistency
and modified it to return a pointer on the page found (as other
hierarchy find functions) instead of changing the current
page. Added description. And finally adapted gschem for this
refactoring.
---
gschem/src/i_callbacks.c | 10 ++++++++--
libgeda/include/prototype.h | 2 +-
libgeda/src/s_hierarchy.c | 30 +++++++++++++++---------------
3 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index e6b0b0a..dcb75fb 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -2939,11 +2939,17 @@ DEFINE_I_CALLBACK(hierarchy_down_symbol)
DEFINE_I_CALLBACK(hierarchy_up)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ PAGE *up_page;
exit_if_null(w_current);
- s_hierarchy_up(w_current->toplevel, w_current->toplevel->page_current->up);
- x_window_set_current_page(w_current, w_current->toplevel->page_current);
+ up_page = s_hierarchy_find_up_page (w_current->toplevel->pages,
+ w_current->toplevel->page_current);
+ if (up_page == NULL) {
+ s_log_message(_("Cannot find any schematics above the current one!\n"));
+ } else {
+ x_window_set_current_page(w_current, up_page);
+ }
}
/*! \todo Finish function documentation!!!
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 7628481..0fb548c 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -403,7 +403,7 @@ 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);
void s_hierarchy_down_symbol (TOPLEVEL *toplevel, const CLibSymbol *symbol,
PAGE *parent);
-void s_hierarchy_up(TOPLEVEL *toplevel, int pid);
+PAGE *s_hierarchy_find_up_page(GedaPageList *page_list, PAGE *current_page);
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);
diff --git a/libgeda/src/s_hierarchy.c b/libgeda/src/s_hierarchy.c
index 102e08c..59b4f97 100644
--- a/libgeda/src/s_hierarchy.c
+++ b/libgeda/src/s_hierarchy.c
@@ -165,28 +165,28 @@ void s_hierarchy_down_symbol (TOPLEVEL *toplevel,
}
-/*! \todo Finish function documentation!!!
- * \brief
+/*! \brief Search for the parent page of a page in hierarchy.
* \par Function Description
+ * This function searches the parent page of page \a page in the
+ * hierarchy. It checks all the pages in the list \a page_list.
+ *
+ * It returns a pointer on the page if found, NULL otherwise.
*
+ * \note
+ * The page \a current_page must be in the list \a page_list.
+ *
+ * \param [in] page_list The list of pages in which to search.
+ * \param [in] current_page The reference page for the search.
+ * \returns A pointer on the page found or NULL if not found.
*/
-void s_hierarchy_up(TOPLEVEL *toplevel, int pid)
+PAGE *s_hierarchy_find_up_page (GedaPageList *page_list, PAGE *current_page)
{
- PAGE *p_current;
-
- if (pid < 0) {
+ if (current_page->up < 0) {
s_log_message(_("There are no schematics above the current one!\n"));
- return;
+ return NULL;
}
- p_current = s_page_search_by_page_id(toplevel->pages, pid);
-
- if (p_current) {
- s_page_goto(toplevel, p_current);
- } else {
- s_log_message(_("Cannot find any schematics above the current one!\n"));
- s_log_message(_("Maybe toplevel schematic page was closed/discarded?\n"));
- }
+ return s_page_search_by_page_id (page_list, current_page->up);
}
/*! \todo Finish function documentation!!!
--
1.5.6
_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev