summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2007-12-04 23:18:43 +0100
committerGuillaume Seguin <guillaume@segu.in>2007-12-04 23:18:43 +0100
commit76d6f35f7995f9fe6670d8d4ab2ad18508dd4ef6 (patch)
treed3e0a317772ba56cf0ec975fafdb211938c0fd2e
parentc967d8ecf9df4717d12f9b9f8f22602b4f1b1cd7 (diff)
downloadgmathlib-76d6f35f7995f9fe6670d8d4ab2ad18508dd4ef6.tar.gz
gmathlib-76d6f35f7995f9fe6670d8d4ab2ad18508dd4ef6.tar.bz2
* Add gmathboxed_find_symbol to recursively find the boxed for a symbol
-rw-r--r--cairo/gmathboxed.c26
-rw-r--r--include/gmathcairo.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/cairo/gmathboxed.c b/cairo/gmathboxed.c
index 4d8cdc7..e1a3395 100644
--- a/cairo/gmathboxed.c
+++ b/cairo/gmathboxed.c
@@ -180,3 +180,29 @@ gmathboxed_find_smallest_container (GMathBoxed *boxed,
return boxed;
}
+
+/* Find the boxed struct for a given symbol */
+GMathBoxed*
+gmathboxed_find_symbol (GMathBoxed *boxed, GMathSymbol *symbol)
+{
+ GMathBoxed *child, *temp;
+ GSList *list;
+
+ if (!boxed || !symbol)
+ return NULL;
+
+ if (boxed->symbol == symbol)
+ return boxed;
+
+ list = boxed->children;
+ while (list)
+ {
+ child = (GMathBoxed *) list->data;
+ temp = gmathboxed_find_symbol (child, symbol);
+ if (temp)
+ return temp;
+ list = list->next;
+ }
+
+ return NULL;
+}
diff --git a/include/gmathcairo.h b/include/gmathcairo.h
index 34556af..8017ef1 100644
--- a/include/gmathcairo.h
+++ b/include/gmathcairo.h
@@ -173,6 +173,8 @@ GMathBoxed*
gmathboxed_find_smallest_container (GMathBoxed *boxed,
int x, int y, int width, int height);
+GMathBoxed*
+gmathboxed_find_symbol (GMathBoxed *boxed, GMathSymbol *symbol);
/* Internal methods */
void