Author: danw
Date: 2005-03-14 16:38:27 -0500 (Mon, 14 Mar 2005)
New Revision: 41805
Modified:
trunk/gtk-sharp/ChangeLog
trunk/gtk-sharp/gtk/NodeStore.cs
trunk/gtk-sharp/gtk/TreeNode.cs
Log:
* gtk/TreeNode.cs (AddNode): add an overload that takes a position
* gtk/NodeStore.cs (AddNode): likewise
(AddNode, child_added_cb): when adding a node, recursively connect
to the node signals on its children
(RemoveNode, child_deleted_cb): when removing a node, recursively
remove its children from node_hash.
Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog 2005-03-14 20:50:19 UTC (rev 41804)
+++ trunk/gtk-sharp/ChangeLog 2005-03-14 21:38:27 UTC (rev 41805)
@@ -1,3 +1,13 @@
+2005-03-14 Dan Winship <[EMAIL PROTECTED]>
+
+ * gtk/TreeNode.cs (AddNode): add an overload that takes a position
+
+ * gtk/NodeStore.cs (AddNode): likewise
+ (AddNode, child_added_cb): when adding a node, recursively connect
+ to the node signals on its children
+ (RemoveNode, child_deleted_cb): when removing a node, recursively
+ remove its children from node_hash.
+
2005-03-12 Mike Kestner <[EMAIL PROTECTED]>
* glade/Glade.metadata : mark the XMLCustomWidgetHandler string params
Modified: trunk/gtk-sharp/gtk/NodeStore.cs
===================================================================
--- trunk/gtk-sharp/gtk/NodeStore.cs 2005-03-14 20:50:19 UTC (rev 41804)
+++ trunk/gtk-sharp/gtk/NodeStore.cs 2005-03-14 21:38:27 UTC (rev 41805)
@@ -317,8 +317,6 @@
private void changed_cb (object o, EventArgs args)
{
ITreeNode node = o as ITreeNode;
- node_hash [node.ID] = node;
-
gtksharp_node_store_emit_row_changed (Handle,
get_path_cb (node.ID), node.ID);
}
@@ -327,8 +325,7 @@
private void child_added_cb (object o, ITreeNode child)
{
- node_hash [child.ID] = child;
-
+ AddNodeInternal (child);
gtksharp_node_store_emit_row_inserted (Handle,
get_path_cb (child.ID), child.ID);
}
@@ -338,6 +335,13 @@
[DllImport("gtksharpglue-2")]
static extern void
gtksharp_node_store_emit_row_has_child_toggled (IntPtr handle, IntPtr path, int
node_idx);
+ private void RemoveNodeInternal (ITreeNode node)
+ {
+ node_hash.Remove (node.ID);
+ for (int i = 0; i < node.ChildCount; i++)
+ RemoveNodeInternal (node [i]);
+ }
+
private void child_deleted_cb (object o, int idx)
{
ITreeNode node = o as ITreeNode;
@@ -346,38 +350,50 @@
TreePath child_path = path.Copy ();
child_path.AppendIndex (idx);
+ ITreeNode child = GetNodeAtPath (child_path);
+ RemoveNodeInternal (child);
+
gtksharp_node_store_emit_row_deleted (Handle,
child_path.Handle);
- if (node.ChildCount <= 0) {
- node_hash [node.ID] = node;
- gtksharp_node_store_emit_row_has_child_toggled
(Handle, path.Handle, node.ID);
- }
+ if (node.ChildCount <= 0)
+ gtksharp_node_store_emit_row_has_child_toggled
(Handle, get_path_cb (node.ID), node.ID);
}
- private void ConnectNode (ITreeNode node)
+ private void AddNodeInternal (ITreeNode node)
{
+ node_hash [node.ID] = node;
+
node.Changed += new EventHandler (changed_cb);
node.ChildAdded += new TreeNodeAddedHandler
(child_added_cb);
node.ChildRemoved += new TreeNodeRemovedHandler
(child_deleted_cb);
+
+ for (int i = 0; i < node.ChildCount; i++)
+ AddNodeInternal (node [i]);
}
public void AddNode (ITreeNode node)
{
nodes.Add (node);
- node_hash [node.ID] = node;
- ConnectNode (node);
- for (int i = 0; i < node.ChildCount; i++)
- ConnectNode (node [i]);
+ AddNodeInternal (node);
gtksharp_node_store_emit_row_inserted (Handle,
get_path_cb (node.ID), node.ID);
}
+ public void AddNode (ITreeNode node, int position)
+ {
+ nodes.Insert (position, node);
+ AddNodeInternal (node);
+
+ gtksharp_node_store_emit_row_inserted (Handle,
get_path_cb (node.ID), node.ID);
+ }
+
public void RemoveNode (ITreeNode node)
{
int idx = nodes.IndexOf (node);
if (idx < 0)
return;
nodes.Remove (node);
+ RemoveNodeInternal (node);
TreePath path = new TreePath ();
path.AppendIndex (idx);
Modified: trunk/gtk-sharp/gtk/TreeNode.cs
===================================================================
--- trunk/gtk-sharp/gtk/TreeNode.cs 2005-03-14 20:50:19 UTC (rev 41804)
+++ trunk/gtk-sharp/gtk/TreeNode.cs 2005-03-14 21:38:27 UTC (rev 41805)
@@ -111,6 +111,13 @@
OnChildAdded (child);
}
+ public void AddChild (TreeNode child, int position)
+ {
+ children.Insert (position, child);
+ child.SetParent (this);
+ OnChildAdded (child);
+ }
+
public void RemoveChild (TreeNode child)
{
int idx = children.IndexOf (child);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches