2003-11-18 Peter Williams <peter@newton.cx>

* gtk/NodeStore.cs (GetNode): New public function. Patch refactored
	a bit to eliminate code duplication with get_node_cb.

svn path=/trunk/gtk-sharp/; revision=20188
This commit is contained in:
Mike Kestner 2003-11-18 20:13:39 +00:00
parent e71f1cda17
commit 4c24cd0747
4 changed files with 57 additions and 12 deletions

View file

@ -1,3 +1,8 @@
2003-11-18 Peter Williams <peter@newton.cx>
* gtk/NodeStore.cs (GetNode): New public function. Patch refactored
a bit to eliminate code duplication with get_node_cb.
2003-11-18 John Luke <jluke@cfl.rr.com>
* configure.in: test for gtkhtml3

View file

@ -1,3 +1,7 @@
2003-11-18 Peter Williams <peter@newton.cx>
* en/Gtk/NodeStore.xml: Document new GetNode functions.
2003-11-17 John Luke <jluke@cfl.rr.com>
* en/Gtk/Socket.xml: documented

View file

@ -42,6 +42,24 @@
</remarks>
</Docs>
</Member>
<Member MemberName="GetNode">
<MemberSignature Language="C#" Value="public Gtk.ITreeNode GetNode (Gtk.TreePath path);" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>Gtk.ITreeNode</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="path" Type="Gtk.TreePath" />
</Parameters>
<Docs>
<summary>Returns a node given a <see cref="T:Gtk.TreePath" />.</summary>
<param name="path">The path to look up.</param>
<remarks>
Looks up the node corresponding to <paramref name="path" /> and returns it,
or null if the node cannot be found.
</remarks>
</Docs>
</Member>
<Member MemberName="RemoveNode">
<MemberSignature Language="C#" Value="public void RemoveNode (Gtk.ITreeNode node);" />
<MemberType>Method</MemberType>

View file

@ -89,23 +89,15 @@ namespace Gtk {
bool get_node_cb (out int node_idx, IntPtr path)
{
if (path == IntPtr.Zero)
Console.WriteLine ("Got a null path in get_node");
throw new ArgumentNullException ("path");
TreePath treepath = new TreePath (path);
node_idx = -1;
int[] indices = treepath.Indices;
if (indices[0] >= Nodes.Count)
ITreeNode node = GetNodeAtPath (treepath);
if (node == null)
return false;
ITreeNode node = Nodes [indices [0]] as ITreeNode;
int i;
for (i = 1; i < treepath.Depth; i++) {
if (indices [i] >= node.ChildCount)
return false;
node = node [indices [i]];
}
node_idx = node.ID;
node_hash [node.ID] = node;
return true;
@ -410,5 +402,31 @@ namespace Gtk {
gtksharp_node_store_emit_row_deleted (Handle, path.Handle);
}
private ITreeNode GetNodeAtPath (TreePath path)
{
int[] indices = path.Indices;
if (indices[0] >= Nodes.Count)
return null;
ITreeNode node = Nodes [indices [0]] as ITreeNode;
int i;
for (i = 1; i < path.Depth; i++) {
if (indices [i] >= node.ChildCount)
return null;
node = node [indices [i]];
}
return node;
}
public ITreeNode GetNode (TreePath path) {
if (path == null)
throw new ArgumentNullException ();
return GetNodeAtPath (path);
}
}
}