diff --git a/gtk/ArrayExtensions.cs b/gtk/ArrayExtensions.cs new file mode 100644 index 000000000..b58db2a8b --- /dev/null +++ b/gtk/ArrayExtensions.cs @@ -0,0 +1,35 @@ +// Gtk.TreeStore.cs - Gtk TreeStore class customizations +// +// Authors: Marek Habersack +// +// 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; + } + } +} diff --git a/gtk/ListStore.cs b/gtk/ListStore.cs index 47c4505e6..585df14dc 100644 --- a/gtk/ListStore.cs +++ b/gtk/ListStore.cs @@ -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; } diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 3a5d45f78..19ecbd148 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -22,6 +22,7 @@ sources = \ ActionGroup.cs \ Adjustment.cs \ Application.cs \ + ArrayExtensions.cs \ Bin.cs \ BindingAttribute.cs \ Builder.cs \ diff --git a/gtk/TreeStore.cs b/gtk/TreeStore.cs index d2f3a4d21..9cfe85b2e 100644 --- a/gtk/TreeStore.cs +++ b/gtk/TreeStore.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)] diff --git a/gtk/gtk.csproj b/gtk/gtk.csproj index 97b284691..83b45c8bb 100644 --- a/gtk/gtk.csproj +++ b/gtk/gtk.csproj @@ -141,6 +141,7 @@ +