Merge pull request #20 from grendello/fix_array_usage
Fix System.Array usage in {List,Tree}Store
This commit is contained in:
commit
be3214dd29
5 changed files with 43 additions and 4 deletions
35
gtk/ArrayExtensions.cs
Normal file
35
gtk/ArrayExtensions.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Gtk.TreeStore.cs - Gtk TreeStore class customizations
|
||||
//
|
||||
// Authors: Marek Habersack <grendel@twistedcode.net>
|
||||
//
|
||||
// Copyright (c) 2016 Marek Habersack
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the Lesser GNU General
|
||||
// Public License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
namespace Gtk {
|
||||
using System;
|
||||
|
||||
static class ArrayExtensions
|
||||
{
|
||||
public static object[] Explode (this Array arr)
|
||||
{
|
||||
if (arr == null)
|
||||
return null;
|
||||
var ret = new object [arr.Length];
|
||||
arr.CopyTo (ret, 0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,7 +110,7 @@ namespace Gtk {
|
|||
public Gtk.TreeIter AppendValues (Array values)
|
||||
{
|
||||
Gtk.TreeIter iter = Append();
|
||||
SetValues (iter, values);
|
||||
SetValues (iter, values.Explode ());
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ sources = \
|
|||
ActionGroup.cs \
|
||||
Adjustment.cs \
|
||||
Application.cs \
|
||||
ArrayExtensions.cs \
|
||||
Bin.cs \
|
||||
BindingAttribute.cs \
|
||||
Builder.cs \
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace Gtk {
|
|||
|
||||
public Gtk.TreeIter AppendValues (Gtk.TreeIter parent, Array values) {
|
||||
Gtk.TreeIter iter = AppendNode (parent);
|
||||
SetValues (iter, values);
|
||||
SetValues (iter, values.Explode ());
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
@ -212,12 +212,14 @@ namespace Gtk {
|
|||
|
||||
public Gtk.TreeIter AppendValues (Array values) {
|
||||
Gtk.TreeIter iter = AppendNode ();
|
||||
SetValues (iter, values);
|
||||
SetValues (iter, values.Explode ());
|
||||
return iter;
|
||||
}
|
||||
|
||||
public Gtk.TreeIter AppendValues (params object[] values) {
|
||||
return AppendValues ((Array) values);
|
||||
Gtk.TreeIter iter = AppendNode ();
|
||||
SetValues (iter, values);
|
||||
return iter;
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
<Compile Include="Widget.cs" />
|
||||
<Compile Include="Window.cs" />
|
||||
<Compile Include="RadioAction.cs" />
|
||||
<Compile Include="ArrayExtensions.cs" />
|
||||
<Compile Include="generated\Gtk\AboutDialog.cs" />
|
||||
<Compile Include="generated\Gtk\Accel.cs" />
|
||||
<Compile Include="generated\Gtk\AccelActivateHandler.cs" />
|
||||
|
|
Loading…
Reference in a new issue