diff --git a/ChangeLog b/ChangeLog index 2e983fe08..0b08cbce0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-01-04 Mike Kestner + + * gtk/CellLayout.custom : declare SetAttributes and SetCellDataFunc. + * gtk/CellView.custom : impl SetAttributes and SetCellDataFunc. + * gtk/ComboBox.custom : impl SetAttributes and SetCellDataFunc. + * gtk/EntryCompletion.custom : impl SetAttributes and SetCellDataFunc. + * gtk/Gtk.metadata : hide some methods to be manually implemented. + * gtk/Makefile.am : add new customs. + * gtk/NodeCellDataFunc : use CellLayoutDataFuncNative. + * gtk/TreeView.custom : use CellLayoutDataFunc not TreeCellDataFunc. + * gtk/TreeViewColumn.custom : impl SetAttributes and SetCellDataFunc. + [Fixes #70941] + 2005-01-04 Mike Kestner * gtk/Gtk.metadata : set preferred on CellViewMenuItem.NewWithText. diff --git a/doc/en/Gtk/CellLayout.xml b/doc/en/Gtk/CellLayout.xml index b95f81d94..d173dd5cd 100644 --- a/doc/en/Gtk/CellLayout.xml +++ b/doc/en/Gtk/CellLayout.xml @@ -10,7 +10,7 @@ Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. Manages layout for table cells. - + @@ -31,11 +31,11 @@ - Re-inserts at . + Re-inserts at . a a - Note that has already to be packed + Note that has already to be packed into the cell layout for this to function properly. @@ -52,14 +52,14 @@ - Adds the to the end of the cell layout. + Adds the to the end of the cell layout. a - a , TRUE if is to be given extra space allocated to this cell layout. + a , TRUE if is to be given extra space allocated to this cell layout. - If is FALSE, then the + If is FALSE, then the cell is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is + divided evenly between cells for which is TRUE. @@ -76,14 +76,14 @@ - Packs into the beginning of the cell layout. + Packs into the beginning of the cell layout. a - a , TRUE if is to be given extra space allocated to this cell layout. + a , TRUE if is to be given extra space allocated to this cell layout. - If is FALSE, then the + If is FALSE, then the cell is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is + divided evenly between cells for which is TRUE. @@ -107,11 +107,11 @@ a a - The is the - column of the model to get a value from, and the is the - parameter on to be set from the value. So for example if column 2 + The is the + column of the model to get a value from, and the is the + parameter on to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a - get its values from column 2. + get its values from column 2. @@ -126,9 +126,9 @@ Clears all existing attributes previously set with - . + . a - + @@ -140,33 +140,46 @@ Unsets all the mappings on all renderers for this cell layout. - + - + Method System.Void - + - - Sets up a data function for this layout. - a + a a - a , the user data (FIXME: is this necessary in the Gtk# API?) - a , the destroy notification (FIXME: is this necessary in the Gtk# API?) The data function is used instead of the standard attributes mapping for setting the column value, and should set the value of the layout's cell renderer(s) - as appropriate. may be to remove an older one. + as appropriate. may be to remove an older one. + + + Method + + System.Void + + + + + + + Sets the attribute to model column bindings for a renderer. + a + a + The array should consist of pairs of attribute names and column indices. + + diff --git a/doc/en/Gtk/CellView.xml b/doc/en/Gtk/CellView.xml index 5d2248d35..e3e10cd9e 100644 --- a/doc/en/Gtk/CellView.xml +++ b/doc/en/Gtk/CellView.xml @@ -88,11 +88,12 @@ - Sets the value of 's property to , then resizes and redraws this cell view. + Sets the value of 's property to , then resizes and redraws this cell view. a a a - + + @@ -124,11 +125,11 @@ - Re-inserts at . + Re-inserts at . a a - Note that has already to be packed + Note that has already to be packed into its view for this to function properly. @@ -144,13 +145,13 @@ - Adds the into the end of the cell layout. + Adds the into the end of the cell layout. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -165,13 +166,13 @@ - Packs the into the beginning of the cell layout. + Packs the into the beginning of the cell layout. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -191,13 +192,13 @@ Adds an attribute mapping to the list for this cell layout. a - a , parameter on to be set from the value + a , parameter on to be set from the value a , column of the model to get a value from. - The is the column of the model to get a value from, and the is the - parameter on to be set from the value. So for example if column 2 + The is the column of the model to get a value from, and the is the + parameter on to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a - get its values from column 2. + get its values from column 2. @@ -212,10 +213,8 @@ Clears all existing attributes previously set with - . - a - - + . + a @@ -226,7 +225,8 @@ Unsets all the mappings on all renderers for this cell view. - + + @@ -358,29 +358,42 @@ - + + Method + + System.Void + + + + + + + Sets a data function to use for the cell layout. + a + a + + The data function + is used instead of the standard attributes mapping for setting the + column value, and should set the value of the cell renderer + as appropriate. may be to remove an older one. + + + + + Method System.Void - - - + - Sets a data function to use for the cell layout. + Sets the attribute to model column bindings for a renderer. a - a - a - a - - The data function - is used instead of the standard attributes mapping for setting the - column value, and should set the value of the cell renderer - as appropriate. may be to remove an older one. - + a + The array should consist of pairs of attribute name and column index. diff --git a/doc/en/Gtk/ComboBox.xml b/doc/en/Gtk/ComboBox.xml index f7d041772..03ebce9f5 100644 --- a/doc/en/Gtk/ComboBox.xml +++ b/doc/en/Gtk/ComboBox.xml @@ -220,7 +220,8 @@ class ComboBoxSample Sets the current active item to be the one referenced by iter. a - + + @@ -266,11 +267,11 @@ class ComboBoxSample - Re-inserts at . + Re-inserts at . a a - Note that has already to be packed + Note that has already to be packed into the combo box for this to function properly. i @@ -286,13 +287,13 @@ class ComboBoxSample - Adds the to the end of the combo box. + Adds the to the end of the combo box. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -302,19 +303,18 @@ class ComboBoxSample System.Void - - Packs the into the beginning of the combo box. + Packs the into the beginning of the combo box. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -334,13 +334,13 @@ class ComboBoxSample Adds an attribute mapping to the list in this combo box. a - a , parameter on to be set from the value + a , parameter on to be set from the value a , column of the model to get a value from. - The is the column of the model to get a value from, and the is the - parameter on to be set from the value. So for example if column 2 + The is the column of the model to get a value from, and the is the + parameter on to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a - get its values from column 2. + get its values from column 2. @@ -356,10 +356,11 @@ class ComboBoxSample Clears all existing attributes previously set with - . + . a - + + @@ -371,11 +372,12 @@ class ComboBoxSample Unsets all the mappings on all renderers for this combo box. - + + - + Method System.Void @@ -392,7 +394,7 @@ class ComboBoxSample The data function is used instead of the standard attributes mapping for setting the column value, and should set the value of the cell renderer - as appropriate. may be to remove an older one. + as appropriate. may be to remove an older one. @@ -552,30 +554,21 @@ Default value: 0 - - + + Method System.Void - - - + - Sets a data function to use for the combo box. + Sets the attribute to column bindings for a renderer. a - a - a - a - - The data function - is used instead of the standard attributes mapping for setting the - column value, and should set the value of the cell renderer - as appropriate. may be to remove an older one. - + a + The array should consist of pairs of attribute name and column indexes. diff --git a/doc/en/Gtk/EntryCompletion.xml b/doc/en/Gtk/EntryCompletion.xml index 8c89b1784..db50629e9 100644 --- a/doc/en/Gtk/EntryCompletion.xml +++ b/doc/en/Gtk/EntryCompletion.xml @@ -236,13 +236,13 @@ public class DemoEntryCompletion : Window - Adds the to the end of the entry-completion widget. + Adds the to the end of the entry-completion widget. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -257,13 +257,13 @@ public class DemoEntryCompletion : Window - Packs the into the beginning of the entry-completion widget. + Packs the into the beginning of the entry-completion widget. a a - If is , then the - is allocated no more space than it needs. Any unused space is - divided evenly between cells for which is . + If is , then the + is allocated no more space than it needs. Any unused space is + divided evenly between cells for which is . @@ -283,13 +283,13 @@ public class DemoEntryCompletion : Window Adds an attribute mapping to the list in this entry-completion widget. a - a , parameter on to be set from the value + a , parameter on to be set from the value a , column of the model to get a value from. - The is the column of the model to get a value from, and the is the - parameter on to be set from the value. So for example if column 2 + The is the column of the model to get a value from, and the is the + parameter on to be set from the value. So for example if column 2 of the model contains strings, you could have the "text" attribute of a - get its values from column 2. + get its values from column 2. @@ -305,7 +305,7 @@ public class DemoEntryCompletion : Window Clears all existing attributes previously set with - . + . a @@ -476,23 +476,19 @@ public class DemoEntryCompletion : Window - + Method System.Void - + - - Sets up a data function for this layout. - a + a a - a , the user data (FIXME: is this necessary in the Gtk# API?) - a , the destroy notification (FIXME: is this necessary in the Gtk# API?) The data function is used instead of the standard attributes mapping for setting the column value, and should set the value of the layout's cell renderer(s) @@ -513,5 +509,22 @@ public class DemoEntryCompletion : Window + + + Method + + System.Void + + + + + + + Sets the attribute to model column bindings for a renderer. + a + a + The array should be pairs of attribute names and column indexes. + + diff --git a/doc/en/Gtk/TreeView.xml b/doc/en/Gtk/TreeView.xml index a39bec948..e684baa24 100644 --- a/doc/en/Gtk/TreeView.xml +++ b/doc/en/Gtk/TreeView.xml @@ -1170,7 +1170,7 @@ tree_view.AppendColumn ("title", text, "text", 0); - + Method Gtk.TreeViewColumn @@ -1178,13 +1178,13 @@ tree_view.AppendColumn ("title", text, "text", 0); - + Adds a new to the TreeView and returns it. a a - a + a a This method actually creates the column, rather than relying on a column object to be passed in. There's an alternate invokation form if you'd like to pass in an existing column object. @@ -1769,7 +1769,7 @@ tree_view.AppendColumn ("title", text, "text", 0); - + Method System.Int32 @@ -1778,16 +1778,16 @@ tree_view.AppendColumn ("title", text, "text", 0); - + Convenience function that inserts a new column into the tree view - with the given cell renderer and a to set cell renderer + with the given cell renderer and a to set cell renderer attributes (normally using data from the model). a , the position of the new column (-1 to append, positive numbers to insert) a , the column title a , the renderer object - a , a function for presenting the data + a , a function for presenting the data The number of columns in the tree view after the insertion. See also , . diff --git a/doc/en/Gtk/TreeViewColumn.xml b/doc/en/Gtk/TreeViewColumn.xml index 930c64a19..7f37e6475 100644 --- a/doc/en/Gtk/TreeViewColumn.xml +++ b/doc/en/Gtk/TreeViewColumn.xml @@ -93,7 +93,7 @@ an object of type an object of type an object of type - This function is used instead of the standard attributes mapping for setting the column value, and should set the value of the as appropriate. may be to remove an older one. + This function is used instead of the standard attributes mapping for setting the column value, and should set the value of the as appropriate. may be to remove an older one. @@ -403,19 +403,19 @@ - + Method System.Void - + - Sets the to use for the column. + Sets the to use for a renderer. a - a + a This function is used instead of the standard attributes mapping for setting the column value, and should set the value of the as appropriate. may be to remove an older one. @@ -578,7 +578,8 @@ Whether this column gets share of extra width allocated to the widget. a - + + @@ -592,7 +593,7 @@ - Re-inserts at . + Re-inserts at . a a The given cell must already be packed into the layout for this method to work properly. @@ -680,34 +681,6 @@ - - - Method - - System.Void - - - - - - - - - - Sets the to use for the column. - - a - a - a - a - - This function is used instead of the standard attributes mapping for - setting the column value, and should set the value of this tree view column's - cell renderer as appropriate. may be - to remove an older one. - - - Method @@ -725,5 +698,22 @@ + + + Method + + System.Void + + + + + + + Sets the attribute to model column bindings for a renderer. + a + a + The array should consist of pairs of attribute name and column index. + + diff --git a/gtk/CellLayout.custom b/gtk/CellLayout.custom new file mode 100644 index 000000000..eaeb35132 --- /dev/null +++ b/gtk/CellLayout.custom @@ -0,0 +1,24 @@ +// Gtk.CellLayout.custom - Gtk CellLayout customizations +// +// Author: Mike Kestner +// +// Copyright (c) 2005 Novell, Inc. +// +// 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. + + + void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func); + void SetAttributes (CellRenderer renderer, object[] attrs); + diff --git a/gtk/CellView.custom b/gtk/CellView.custom new file mode 100644 index 000000000..e2f72c852 --- /dev/null +++ b/gtk/CellView.custom @@ -0,0 +1,62 @@ +// Gtk.CellView.custom - Gtk CellView customizations +// +// Authors: Todd Berman +// Mike Kestner +// +// Copyright (c) 2004 Todd Berman +// Copyright (c) 2005 Novell, Inc. +// +// 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. + + + Hashtable datafuncs; + Hashtable DataFuncs { + get { + if (datafuncs == null) + datafuncs = new Hashtable (); + return datafuncs; + } + } + + public void SetAttributes (CellRenderer cell, params object[] attrs) + { + if (attrs.Length % 2 != 0) + throw new ArgumentException ("attrs should contain pairs of attribute/col"); + + ClearAttributes (cell); + for (int i = 0; i < attrs.Length - 1; i += 2) { + AddAttribute (cell, (string) attrs [i], (int) attrs [i + 1]); + } + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, IntPtr func, IntPtr func_data, IntPtr destroy); + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, IntPtr destroy); + + public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) + { + if (func == null) { + DataFuncs [renderer] = null; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); + } else { + + GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func, this); + DataFuncs [renderer] = func_wrapper; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero); + } + } + diff --git a/gtk/ComboBox.custom b/gtk/ComboBox.custom index bc2753c16..fafc87f2f 100644 --- a/gtk/ComboBox.custom +++ b/gtk/ComboBox.custom @@ -1,8 +1,10 @@ // Gtk.ComboBox.custom - Gtk ComboBox customizations // // Authors: Todd Berman +// Mike Kestner // // Copyright (c) 2004 Todd Berman +// Copyright (c) 2005 Novell, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -19,9 +21,42 @@ // Boston, MA 02111-1307, USA. -public void SetCellDataFunc (Gtk.CellRenderer renderer, Gtk.CellLayoutDataFunc func) -{ - GtkSharp.CellLayoutDataFuncWrapper func_wrapper = null; - func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func, this); - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero); -} + Hashtable datafuncs; + Hashtable DataFuncs { + get { + if (datafuncs == null) + datafuncs = new Hashtable (); + return datafuncs; + } + } + + public void SetAttributes (CellRenderer cell, params object[] attrs) + { + if (attrs.Length % 2 != 0) + throw new ArgumentException ("attrs should contain pairs of attribute/col"); + + ClearAttributes (cell); + for (int i = 0; i < attrs.Length - 1; i += 2) { + AddAttribute (cell, (string) attrs [i], (int) attrs [i + 1]); + } + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, IntPtr func, IntPtr func_data, IntPtr destroy); + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, IntPtr destroy); + + public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) + { + if (func == null) { + DataFuncs [renderer] = null; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); + } else { + + GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func, this); + DataFuncs [renderer] = func_wrapper; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero); + } + } + diff --git a/gtk/EntryCompletion.custom b/gtk/EntryCompletion.custom new file mode 100644 index 000000000..6d434961a --- /dev/null +++ b/gtk/EntryCompletion.custom @@ -0,0 +1,62 @@ +// Gtk.EntryCompletion.custom - Gtk EntryCompletion customizations +// +// Authors: Todd Berman +// Mike Kestner +// +// Copyright (c) 2004 Todd Berman +// Copyright (c) 2005 Novell, Inc. +// +// 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. + + + Hashtable datafuncs; + Hashtable DataFuncs { + get { + if (datafuncs == null) + datafuncs = new Hashtable (); + return datafuncs; + } + } + + public void SetAttributes (CellRenderer cell, params object[] attrs) + { + if (attrs.Length % 2 != 0) + throw new ArgumentException ("attrs should contain pairs of attribute/col"); + + ClearAttributes (cell); + for (int i = 0; i < attrs.Length - 1; i += 2) { + AddAttribute (cell, (string) attrs [i], (int) attrs [i + 1]); + } + } + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, IntPtr func, IntPtr func_data, IntPtr destroy); + + [DllImport("libgtk-win32-2.0-0.dll")] + static extern void gtk_cell_layout_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, IntPtr destroy); + + public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) + { + if (func == null) { + DataFuncs [renderer] = null; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); + } else { + + GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func, this); + DataFuncs [renderer] = func_wrapper; + gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero); + } + } + diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 8653264cd..e4fd91cb7 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -66,6 +66,8 @@ 1 FinishEditing WidgetRemoved + 1 + 1 GetIsEditable ref SetIsEditable @@ -124,6 +126,7 @@ 1 1 1 + 1 1 1 1 @@ -336,13 +339,15 @@ out ref 1 + 1 1 1 1 Click + 1 1 1 - 1 + 1 1 1 1 diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 96387cfa5..342c25389 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -45,6 +45,8 @@ customs = \ Button.custom \ Calendar.custom \ CellRenderer.custom \ + CellLayout.custom \ + CellView.custom \ CheckMenuItem.custom \ Clipboard.custom \ ColorSelection.custom \ @@ -54,6 +56,7 @@ customs = \ Container.custom \ Dialog.custom \ Entry.custom \ + EntryCompletion.custom \ FileChooserDialog.custom \ FileChooserWidget.custom \ FileSelection.custom \ diff --git a/gtk/NodeCellDataFunc.cs b/gtk/NodeCellDataFunc.cs index eea01c9e9..a1f8405a4 100644 --- a/gtk/NodeCellDataFunc.cs +++ b/gtk/NodeCellDataFunc.cs @@ -36,12 +36,12 @@ namespace Gtk { managed (col, renderer, store.GetNode (iter)); } - internal GtkSharp.TreeCellDataFuncNative NativeDelegate; + internal GtkSharp.CellLayoutDataFuncNative NativeDelegate; protected NodeCellDataFunc managed; public NodeCellDataFuncWrapper (NodeCellDataFunc managed, object o) : base (o) { - NativeDelegate = new GtkSharp.TreeCellDataFuncNative (NativeCallback); + NativeDelegate = new GtkSharp.CellLayoutDataFuncNative (NativeCallback); this.managed = managed; } } diff --git a/gtk/TreeView.custom b/gtk/TreeView.custom index ecf17def1..377b59eb6 100644 --- a/gtk/TreeView.custom +++ b/gtk/TreeView.custom @@ -120,7 +120,7 @@ return raw_ret; } - public Gtk.TreeViewColumn AppendColumn (string title, Gtk.CellRenderer cell, Gtk.TreeCellDataFunc cell_data) { + public TreeViewColumn AppendColumn (string title, CellRenderer cell, CellLayoutDataFunc cell_data) { Gtk.TreeViewColumn col = new Gtk.TreeViewColumn (); col.Title = title; col.PackStart (cell, true); @@ -136,7 +136,7 @@ return col; } - public int InsertColumn (int pos, string title, CellRenderer cell, TreeCellDataFunc cell_data) + public int InsertColumn (int pos, string title, CellRenderer cell, CellLayoutDataFunc cell_data) { TreeViewColumn col = new TreeViewColumn (); col.Title = title; diff --git a/gtk/TreeViewColumn.custom b/gtk/TreeViewColumn.custom index 713c99f8e..9369b4e35 100644 --- a/gtk/TreeViewColumn.custom +++ b/gtk/TreeViewColumn.custom @@ -21,6 +21,16 @@ // Boston, MA 02111-1307, USA. + public void SetAttributes (CellRenderer cell, params object[] attrs) + { + if (attrs.Length % 2 != 0) + throw new ArgumentException ("attrs should contain pairs of attribute/col"); + + ClearAttributes (cell); + for (int i = 0; i < attrs.Length - 1; i += 2) { + AddAttribute (cell, (string) attrs [i], (int) attrs [i + 1]); + } + } private void _NewWithAttributes (string title, Gtk.CellRenderer cell, Array attrs) { Title = title; @@ -76,16 +86,16 @@ } [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_view_column_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.TreeCellDataFuncNative func, IntPtr func_data, IntPtr destroy); + static extern void gtk_tree_view_column_set_cell_data_func(IntPtr raw, IntPtr cell_renderer, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, IntPtr destroy); - public void SetCellDataFunc (CellRenderer cell_renderer, TreeCellDataFunc func) + public void SetCellDataFunc (CellRenderer cell_renderer, CellLayoutDataFunc func) { if (func == null) { ReleaseDataFunc (cell_renderer); return; } ; - GtkSharp.TreeCellDataFuncWrapper wrapper = new GtkSharp.TreeCellDataFuncWrapper (func, this); + GtkSharp.CellLayoutDataFuncWrapper wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func, this); CellDataFuncs [cell_renderer.Handle] = wrapper; gtk_tree_view_column_set_cell_data_func(Handle, cell_renderer.Handle, wrapper.NativeDelegate, IntPtr.Zero, IntPtr.Zero); }