* 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. svn path=/trunk/gtk-sharp/; revision=41805
This commit is contained in:
parent
6a6e89d67e
commit
e957a84316
3 changed files with 46 additions and 13 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-03-14 Dan Winship <danw@novell.com>
|
||||||
|
|
||||||
|
* 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 <mkestner@novell.com>
|
2005-03-12 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* glade/Glade.metadata : mark the XMLCustomWidgetHandler string params
|
* glade/Glade.metadata : mark the XMLCustomWidgetHandler string params
|
||||||
|
|
|
@ -317,8 +317,6 @@ namespace Gtk {
|
||||||
private void changed_cb (object o, EventArgs args)
|
private void changed_cb (object o, EventArgs args)
|
||||||
{
|
{
|
||||||
ITreeNode node = o as ITreeNode;
|
ITreeNode node = o as ITreeNode;
|
||||||
node_hash [node.ID] = node;
|
|
||||||
|
|
||||||
gtksharp_node_store_emit_row_changed (Handle, get_path_cb (node.ID), node.ID);
|
gtksharp_node_store_emit_row_changed (Handle, get_path_cb (node.ID), node.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +325,7 @@ namespace Gtk {
|
||||||
|
|
||||||
private void child_added_cb (object o, ITreeNode child)
|
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);
|
gtksharp_node_store_emit_row_inserted (Handle, get_path_cb (child.ID), child.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,6 +335,13 @@ namespace Gtk {
|
||||||
[DllImport("gtksharpglue-2")]
|
[DllImport("gtksharpglue-2")]
|
||||||
static extern void gtksharp_node_store_emit_row_has_child_toggled (IntPtr handle, IntPtr path, int node_idx);
|
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)
|
private void child_deleted_cb (object o, int idx)
|
||||||
{
|
{
|
||||||
ITreeNode node = o as ITreeNode;
|
ITreeNode node = o as ITreeNode;
|
||||||
|
@ -346,28 +350,39 @@ namespace Gtk {
|
||||||
TreePath child_path = path.Copy ();
|
TreePath child_path = path.Copy ();
|
||||||
child_path.AppendIndex (idx);
|
child_path.AppendIndex (idx);
|
||||||
|
|
||||||
|
ITreeNode child = GetNodeAtPath (child_path);
|
||||||
|
RemoveNodeInternal (child);
|
||||||
|
|
||||||
gtksharp_node_store_emit_row_deleted (Handle, child_path.Handle);
|
gtksharp_node_store_emit_row_deleted (Handle, child_path.Handle);
|
||||||
|
|
||||||
if (node.ChildCount <= 0) {
|
if (node.ChildCount <= 0)
|
||||||
node_hash [node.ID] = node;
|
gtksharp_node_store_emit_row_has_child_toggled (Handle, get_path_cb (node.ID), node.ID);
|
||||||
gtksharp_node_store_emit_row_has_child_toggled (Handle, path.Handle, node.ID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConnectNode (ITreeNode node)
|
private void AddNodeInternal (ITreeNode node)
|
||||||
{
|
{
|
||||||
|
node_hash [node.ID] = node;
|
||||||
|
|
||||||
node.Changed += new EventHandler (changed_cb);
|
node.Changed += new EventHandler (changed_cb);
|
||||||
node.ChildAdded += new TreeNodeAddedHandler (child_added_cb);
|
node.ChildAdded += new TreeNodeAddedHandler (child_added_cb);
|
||||||
node.ChildRemoved += new TreeNodeRemovedHandler (child_deleted_cb);
|
node.ChildRemoved += new TreeNodeRemovedHandler (child_deleted_cb);
|
||||||
|
|
||||||
|
for (int i = 0; i < node.ChildCount; i++)
|
||||||
|
AddNodeInternal (node [i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddNode (ITreeNode node)
|
public void AddNode (ITreeNode node)
|
||||||
{
|
{
|
||||||
nodes.Add (node);
|
nodes.Add (node);
|
||||||
node_hash [node.ID] = node;
|
AddNodeInternal (node);
|
||||||
ConnectNode (node);
|
|
||||||
for (int i = 0; i < node.ChildCount; i++)
|
gtksharp_node_store_emit_row_inserted (Handle, get_path_cb (node.ID), node.ID);
|
||||||
ConnectNode (node [i]);
|
}
|
||||||
|
|
||||||
|
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);
|
gtksharp_node_store_emit_row_inserted (Handle, get_path_cb (node.ID), node.ID);
|
||||||
}
|
}
|
||||||
|
@ -378,6 +393,7 @@ namespace Gtk {
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return;
|
return;
|
||||||
nodes.Remove (node);
|
nodes.Remove (node);
|
||||||
|
RemoveNodeInternal (node);
|
||||||
|
|
||||||
TreePath path = new TreePath ();
|
TreePath path = new TreePath ();
|
||||||
path.AppendIndex (idx);
|
path.AppendIndex (idx);
|
||||||
|
|
|
@ -111,6 +111,13 @@ namespace Gtk {
|
||||||
OnChildAdded (child);
|
OnChildAdded (child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddChild (TreeNode child, int position)
|
||||||
|
{
|
||||||
|
children.Insert (position, child);
|
||||||
|
child.SetParent (this);
|
||||||
|
OnChildAdded (child);
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveChild (TreeNode child)
|
public void RemoveChild (TreeNode child)
|
||||||
{
|
{
|
||||||
int idx = children.IndexOf (child);
|
int idx = children.IndexOf (child);
|
||||||
|
|
Loading…
Add table
Reference in a new issue