diff --git a/ChangeLog b/ChangeLog index 781a5b990..9a9609c19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-16 Eskil Bylund + + * gtk/ListStore.custom: + * gtk/TreeStore.custom: Implement InsertWithValues. + * gtk/Gtk.metadata: Deprecate the old generated method. + [Fixes #325040] + 2007-11-12 Mike Kestner * sample/TreeModelDemo.cs: lt/gt typo bugfix [Fixes #333653] diff --git a/doc/en/Gtk/ListStore.xml b/doc/en/Gtk/ListStore.xml index e22c15af2..cf01ff4e9 100644 --- a/doc/en/Gtk/ListStore.xml +++ b/doc/en/Gtk/ListStore.xml @@ -1581,5 +1581,30 @@ The above example creates a new three columns list store. The types of the colum + + + Method + + Gtk.TreeIter + + + + + + + System.ParamArray + + + + + + Insert position. + An array of column values to set. + Inserts a row into the store at a given position with column values. + An iter pointing to the inserted row. + The values provided should be in column order. + + + diff --git a/doc/en/Gtk/TreeStore.xml b/doc/en/Gtk/TreeStore.xml index c5d39bcbe..362bb7f52 100644 --- a/doc/en/Gtk/TreeStore.xml +++ b/doc/en/Gtk/TreeStore.xml @@ -1852,5 +1852,57 @@ store = new TreeStore (typeof (int), typeof (string)); + + + Method + + Gtk.TreeIter + + + + + + + + System.ParamArray + + + + + + Iter of the node to insert into. + Insert position. + An array of column values. + Inserts a child row into a node with values. + An iter pointing to the added row. + The column values provided should be in column order. + + + + + + Method + + Gtk.TreeIter + + + + + + + System.ParamArray + + + + + + Insert position. + An array of column values. + Inserts a row into the Root node of the store with values. + An iter pointing to the added row. + The column values provided should be in column order. + + + diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index e4c599dcb..1e588e0ad 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -415,6 +415,8 @@ out out out + 1 + 1 out ref 1 @@ -618,6 +620,7 @@ 1 1 1 + 1 1 1 1 diff --git a/gtk/ListStore.custom b/gtk/ListStore.custom index cb5b35b93..810f38753 100644 --- a/gtk/ListStore.custom +++ b/gtk/ListStore.custom @@ -117,6 +117,32 @@ return AppendValues ((Array) values); } + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_list_store_insert_with_valuesv(IntPtr raw, out TreeIter iter, int position, int[] columns, GLib.Value[] values, int n_values); + + public TreeIter InsertWithValues (int position, params object[] values) + { + int[] columns = new int[values.Length]; + GLib.Value[] vals = new GLib.Value[values.Length]; + int n_values = 0; + + for (int i = 0; i < values.Length; i++) { + if (values[i] != null) { + columns[n_values] = i; + vals[n_values] = new GLib.Value (values[i]); + n_values++; + } + } + + TreeIter iter; + gtk_list_store_insert_with_valuesv (Handle, out iter, position, columns, vals, n_values); + + for (int i = 0; i < n_values; i++) + vals[i].Dispose (); + + return iter; + } + public ListStore (params GLib.GType[] types) : base (IntPtr.Zero) { CreateNativeObject (new string [0], new GLib.Value [0]); diff --git a/gtk/TreeStore.custom b/gtk/TreeStore.custom index a40eb210c..42acc72e9 100644 --- a/gtk/TreeStore.custom +++ b/gtk/TreeStore.custom @@ -293,6 +293,48 @@ return AppendValues ((Array) values); } + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_tree_store_insert_with_valuesv(IntPtr raw, out TreeIter iter, IntPtr parent, int position, int[] columns, GLib.Value[] values, int n_values); + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_tree_store_insert_with_valuesv(IntPtr raw, out TreeIter iter, ref TreeIter parent, int position, int[] columns, GLib.Value[] values, int n_values); + + public TreeIter InsertWithValues (int position, params object[] values) + { + return InsertWithValues(false, TreeIter.Zero, position, values); + } + + public TreeIter InsertWithValues (TreeIter parent, int position, params object[] values) + { + return InsertWithValues(true, parent, position, values); + } + + private TreeIter InsertWithValues (bool hasParent, TreeIter parent, int position, params object[] values) + { + int[] columns = new int[values.Length]; + GLib.Value[] vals = new GLib.Value[values.Length]; + int n_values = 0; + + for (int i = 0; i < values.Length; i++) { + if (values[i] != null) { + columns[n_values] = i; + vals[n_values] = new GLib.Value (values[i]); + n_values++; + } + } + + TreeIter iter; + if (hasParent) + gtk_tree_store_insert_with_valuesv (Handle, out iter, ref parent, position, columns, vals, n_values); + else + gtk_tree_store_insert_with_valuesv (Handle, out iter, IntPtr.Zero, position, columns, vals, n_values); + + for (int i = 0; i < n_values; i++) + vals[i].Dispose (); + + return iter; + } + public TreeStore (params GLib.GType[] types) : base (IntPtr.Zero) { CreateNativeObject (new string [0], new GLib.Value [0]);