GNode patch.
- From: jrb redhat com
- To: gtk-devel-list gnome org
- Subject: GNode patch.
- Date: Fri, 29 Sep 2000 12:56:45 -0400
Hi,
Here is a small patch to add g_node_insert_after. If no one
complains, I'd like to commit it. However, I am a little confused by
the behavior of g_node_insert_before. If you pass in NULL as the
sibling, it will effectively do a g_node_append (in fact,
g_node_append is implemented this way.) I guess my gut instict is to
have g_node_insert_before do a g_node_prepend if sibling is NULL, and
g_node_insert_after do a g_node_append if sibling is NULL. This would
probably break a lot of code, though.
Thoughts?
-Jonathan
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/ChangeLog,v
retrieving revision 1.483
diff -u -u -r1.483 ChangeLog
--- ChangeLog 2000/09/29 13:37:01 1.483
+++ ChangeLog 2000/09/29 16:36:36
@@ -1,3 +1,8 @@
+2000-09-29 Jonathan Blandford <jrb redhat com>
+
+ * gnode.c (g_node_insert_after): Added function to keep symmetry
+ with g_node_insert_before.
+
2000-09-29 Martin Baulig <baulig suse de>
Several minor ANSI C fixes.
Index: glib.h
===================================================================
RCS file: /cvs/gnome/glib/glib.h,v
retrieving revision 1.203
diff -u -u -r1.203 glib.h
--- glib.h 2000/09/29 13:10:41 1.203
+++ glib.h 2000/09/29 16:36:36
@@ -1267,6 +1267,9 @@
GNode* g_node_insert_before (GNode *parent,
GNode *sibling,
GNode *node);
+GNode* g_node_insert_after (GNode *parent,
+ GNode *sibling,
+ GNode *node);
GNode* g_node_prepend (GNode *parent,
GNode *node);
guint g_node_n_nodes (GNode *root,
Index: gnode.c
===================================================================
RCS file: /cvs/gnome/glib/gnode.c,v
retrieving revision 1.14
diff -u -u -r1.14 gnode.c
--- gnode.c 2000/07/26 11:01:59 1.14
+++ gnode.c 2000/09/29 16:36:36
@@ -281,6 +281,46 @@
}
GNode*
+g_node_insert_after (GNode *parent,
+ GNode *sibling,
+ GNode *node)
+{
+ g_return_val_if_fail (parent != NULL, node);
+ g_return_val_if_fail (node != NULL, node);
+ g_return_val_if_fail (G_NODE_IS_ROOT (node), node);
+ if (sibling)
+ g_return_val_if_fail (sibling->parent == parent, node);
+
+ node->parent = parent;
+
+ if (sibling)
+ {
+ if (sibling->next)
+ {
+ sibling->next->prev = node;
+ }
+ node->next = sibling->next;
+ node->prev = sibling;
+ sibling->next = node;
+ }
+ else
+ {
+ if (parent->children)
+ {
+ sibling = parent->children;
+ while (sibling->next)
+ sibling = sibling->next;
+ node->prev = sibling;
+ sibling->next = node;
+ }
+ else
+ node->parent->children = node;
+ }
+
+ return node;
+}
+
+GNode*
g_node_prepend (GNode *parent,
GNode *node)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]