mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 05:35:28 +00:00
TreePath improvements (#235)
* TreePath(int[]) constructor is now using one API call instead of many. * Indices property is now using one API call instead of two.
This commit is contained in:
parent
2e7297b22e
commit
8ac2892938
|
@ -50,7 +50,9 @@
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='GetToggledTags']" name="hidden">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTextIter']/method[@name='GetToggledTags']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreeIter']/method[@name='Copy']" name="deprecated">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreeIter']/method[@name='Copy']" name="deprecated">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/constructor[@cname='gtk_tree_path_new_from_indices']" name="hidden">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/constructor[@cname='gtk_tree_path_new_from_indices']" name="hidden">1</attr>
|
||||||
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/constructor[@cname='gtk_tree_path_new_from_indicesv']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='GetIndices']" name="hidden">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='GetIndices']" name="hidden">1</attr>
|
||||||
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='GetIndicesWithDepth']" name="hidden">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='Free']" name="deprecated">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreePath']/method[@name='Free']" name="deprecated">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreeRowReference']/method[@name='Free']" name="deprecated">1</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreeRowReference']/method[@name='Free']" name="deprecated">1</attr>
|
||||||
<attr path="/api/namespace/boxed[@cname='GtkTreeRowReference']/method[@name='GetPath']/return-type" name="owned">true</attr>
|
<attr path="/api/namespace/boxed[@cname='GtkTreeRowReference']/method[@name='GetPath']/return-type" name="owned">true</attr>
|
||||||
|
|
|
@ -20,24 +20,27 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class TreePath {
|
public partial class TreePath {
|
||||||
|
|
||||||
// Patch submitted by malte on bug #49518
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
delegate IntPtr d_gtk_tree_path_get_indices(IntPtr raw);
|
delegate IntPtr d_gtk_tree_path_get_indices_with_depth(IntPtr raw, out int depth);
|
||||||
static d_gtk_tree_path_get_indices gtk_tree_path_get_indices = FuncLoader.LoadFunction<d_gtk_tree_path_get_indices>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_path_get_indices"));
|
static d_gtk_tree_path_get_indices_with_depth gtk_tree_path_get_indices_with_depth = FuncLoader.LoadFunction<d_gtk_tree_path_get_indices_with_depth>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_path_get_indices_with_depth"));
|
||||||
|
|
||||||
public int [] Indices {
|
public int [] Indices {
|
||||||
get {
|
get {
|
||||||
IntPtr ptr = gtk_tree_path_get_indices(Handle);
|
IntPtr arrPtr = gtk_tree_path_get_indices_with_depth(Handle, out int depth);
|
||||||
int [] arr = new int [Depth];
|
int[] arr = new int[depth];
|
||||||
Marshal.Copy (ptr, arr, 0, Depth);
|
if (arrPtr != IntPtr.Zero)
|
||||||
|
Marshal.Copy(arrPtr, arr, 0, depth);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreePath (int[] indices) : this ()
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
delegate IntPtr d_gtk_tree_path_new_from_indicesv(int[] indices, UIntPtr length);
|
||||||
|
static d_gtk_tree_path_new_from_indicesv gtk_tree_path_new_from_indicesv = FuncLoader.LoadFunction<d_gtk_tree_path_new_from_indicesv>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_tree_path_new_from_indicesv"));
|
||||||
|
|
||||||
|
public TreePath (int[] indices)
|
||||||
{
|
{
|
||||||
foreach (int i in indices)
|
Raw = gtk_tree_path_new_from_indicesv(indices, (UIntPtr)indices.Length);
|
||||||
AppendIndex (i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals (object o)
|
public override bool Equals (object o)
|
||||||
|
|
Loading…
Reference in a new issue