diff --git a/ChangeLog b/ChangeLog index 44bbd7555..9b70e03c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,50 @@ +2005-05-04 Dan Winship + + * generator/Parameters.cs (Parameters.Validate): If the parameters + end with "callback, gpointer, GDestroyNotify", then mark the + callback as having "notified" Scope. + (Parameters.IsHidden): Hide user_data and GDestroyNotify after a + callback. + (Parameter.Scope): make this settable + (Parameter.IsDestroyNotify): new test + + * generator/MethodBody.cs (Initialize): Handle "notified" callback + scope (using a GCHandle and GLib.DestroyHelper.NotifyHandler) + + * generator/CallbackGen.cs (GenWrapper): Add a static + "GetManagedDelegate" method to the wrapper type, to translate a + native delegate back to its corresponding managed delegate. + (FromNative): use GetManagedDelegate. + + * generator/ReturnValue.cs (Validate): We handle callback return + values now + + * generator/SymbolTable.cs: marshal GDestroyNotify as + GLib.DestroyNotify + + * glib/DestroyNotify.cs: Moved from gtk + + * gtk/Gtk.metadata: globally change GtkDestroyNotify to + GDestroyNotify, but then change back the ones that are exposed in + the API. Un-hide lots of methods we can correctly autogenerate + now. + + * gtk/DestroyHelper.cs: moved to glib + + * gtk/*.custom: remove methods that are autogenerated now, add + Obsolete wrappers where needed, replace Gtk.DestroyHelper usage + with GLib.DestroyHelper. + + * gdk/Gdk.metadata: + * gnome/Gnome.metadata: Turn Gdk.Drawable.SetData and + Gnome.IconList.SetIconDataFull's GDestroyNotify args into + gpointers so the generated API stays the same as it used to be. + + * rsvg/Handle.custom: implement deprecated SetSizeCallback + + * sample/GtkDemo/DemoIconView.cs (CreateSort): update for API + changes + 2005-05-03 Mike Kestner * parser/gapi2xml.pl : parse const * const * Foo () properly. diff --git a/doc/ChangeLog b/doc/ChangeLog index b7a1704d7..7e41887d4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,12 @@ +2005-05-03 Dan Winship + + * document new callback properties / deprecate some old + callback-setting methods + + * updater/updater.cs (Update): close the writer when we're done. + (Compare): don't write "updates" to a file if its FullName is + wrong. + 2005-04-24 Dan Winship * en/Pango/Attribute.xml, etc: document new Attribute stuff. diff --git a/doc/en/GLib/DestroyHelper.xml b/doc/en/GLib/DestroyHelper.xml new file mode 100644 index 000000000..d3ce4579a --- /dev/null +++ b/doc/en/GLib/DestroyHelper.xml @@ -0,0 +1,35 @@ + + + + glib-sharp + [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4] + 2.0.0.0 + neutral + + + Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. + + Helper methods for unmanaged memory + + + + System.Object + + + + + + + Property + + GLib.DestroyNotify + + + + A that frees a . + a + + + + + \ No newline at end of file diff --git a/doc/en/GLib/DestroyNotify.xml b/doc/en/GLib/DestroyNotify.xml new file mode 100644 index 000000000..3fd1e4299 --- /dev/null +++ b/doc/en/GLib/DestroyNotify.xml @@ -0,0 +1,34 @@ + + + + glib-sharp + [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4] + 2.0.0.0 + neutral + + + Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. + + A callback invoked to free user-provided data. + This is mostly for internal use. You should not need to use it unless you are binding additional unmanaged API. + + + System.Delegate + + + + System.ICloneable + + + System.Runtime.Serialization.ISerializable + + + + + + System.Void + + + + + \ No newline at end of file diff --git a/doc/en/Gtk/AboutDialog.xml b/doc/en/Gtk/AboutDialog.xml index 837280add..99d11afa4 100644 --- a/doc/en/Gtk/AboutDialog.xml +++ b/doc/en/Gtk/AboutDialog.xml @@ -226,5 +226,37 @@ To be added + + + Method + + Gtk.AboutDialogActivateLinkFunc + + + + + + To be added + a + a + To be added + + + + + Method + + Gtk.AboutDialogActivateLinkFunc + + + + + + To be added + a + a + To be added + + \ No newline at end of file diff --git a/doc/en/Gtk/ActionGroup.xml b/doc/en/Gtk/ActionGroup.xml index db55b4e88..53ae358d3 100644 --- a/doc/en/Gtk/ActionGroup.xml +++ b/doc/en/Gtk/ActionGroup.xml @@ -422,18 +422,15 @@ Therefore you must either set the accel path yourself with event. - - - Method + + + Property - System.Void + Gtk.TranslateFunc - - - - Sets a function to be used for translating the label and tooltip of GtkActionGroupEntrys added by . - a + Function to be used for translating the label and tooltip of GtkActionGroupEntrys added by . + a If you are using gettext(), it is enough to set the translation domain with . diff --git a/doc/en/Gtk/CellLayout.xml b/doc/en/Gtk/CellLayout.xml index d173dd5cd..b5b247873 100644 --- a/doc/en/Gtk/CellLayout.xml +++ b/doc/en/Gtk/CellLayout.xml @@ -144,18 +144,18 @@ - + Method System.Void - + Sets up a data function for this layout. - a + a a The data function is used instead of the standard attributes mapping for setting the @@ -178,8 +178,8 @@ Sets the attribute to model column bindings for a renderer. a a - The array should consist of pairs of attribute names and column indices. + The array should consist of pairs of attribute names and column indices. - + \ No newline at end of file diff --git a/doc/en/Gtk/CellView.xml b/doc/en/Gtk/CellView.xml index 1273e7ee2..7d049dcc7 100644 --- a/doc/en/Gtk/CellView.xml +++ b/doc/en/Gtk/CellView.xml @@ -322,18 +322,18 @@ - + Method System.Void - + Sets a data function to use for the cell layout. - a + a a The data function @@ -388,4 +388,4 @@ - + \ No newline at end of file diff --git a/doc/en/Gtk/ComboBox.xml b/doc/en/Gtk/ComboBox.xml index 52faf00f7..5c6e27833 100644 --- a/doc/en/Gtk/ComboBox.xml +++ b/doc/en/Gtk/ComboBox.xml @@ -377,18 +377,18 @@ class ComboBoxSample - + Method System.Void - + Sets a data function to use for the combo box. - a + a a The data function @@ -660,23 +660,17 @@ Default value: 0 To be added - - - Method + + + Property - System.Void + Gtk.TreeViewRowSeparatorFunc - - - - - + - To be added - a - a - a - To be added + Callback function to indicate whether or not a given row of the combo box should be rendered as a separator. + a + diff --git a/doc/en/Gtk/EntryCompletion.xml b/doc/en/Gtk/EntryCompletion.xml index 02c502f4b..bd670bed9 100644 --- a/doc/en/Gtk/EntryCompletion.xml +++ b/doc/en/Gtk/EntryCompletion.xml @@ -452,18 +452,18 @@ public class DemoEntryCompletion : Window - + Method System.Void - + Sets up a data function for this layout. - a + a a The data function is used instead of the standard attributes mapping for setting the @@ -502,18 +502,15 @@ public class DemoEntryCompletion : Window The array should be pairs of attribute names and column indexes. - - - Method + + + Property - System.Void + Gtk.EntryCompletionMatchFunc - - - - Sets the matching function. - a + The matching function + a The match function is used to determine if a row should or should not be in the completion list. diff --git a/doc/en/Gtk/ItemFactory.xml b/doc/en/Gtk/ItemFactory.xml index 7d65f6166..50faa7306 100644 --- a/doc/en/Gtk/ItemFactory.xml +++ b/doc/en/Gtk/ItemFactory.xml @@ -290,7 +290,7 @@ - + Method @@ -306,7 +306,19 @@ The delegate to be used to traslate path elements. ignored ignored - This overload is obsolete. New code should use the single parameter overload instead. + This method is obsolete. New code should use the property instead. + + + + + Property + + Gtk.TranslateFunc + + + The method to be used for translating the path elements before they are displayed. + a + @@ -541,20 +553,5 @@ FIXME: See bugzilla 70887. - - - Method - - System.Void - - - - - - Sets a method to be used for translating the path elements before they are displayed. - The delegate to be used to translate path elements. - - - - + \ No newline at end of file diff --git a/doc/en/Gtk/ListStore.xml b/doc/en/Gtk/ListStore.xml index 865805a8b..2ce668797 100644 --- a/doc/en/Gtk/ListStore.xml +++ b/doc/en/Gtk/ListStore.xml @@ -136,7 +136,7 @@ This overload is obsolete. The two parameter overload is preferred for new code. - + Method @@ -152,7 +152,19 @@ A ignored ignored - This overload is obsolete. The single parameter overload is preferred for new code. + This method is obsolete. The property is preferred for new code. + + + + + Property + + Gtk.TreeIterCompareFunc + + + The function that will be used by default to sort columns. + a + @@ -1062,7 +1074,7 @@ The above example creates a new three columns list store. The types of the colum Find out whether this ListStore has a default sort function. a , true if there is a default sort function. - To set a default sort function, use . + To set a default sort function, use the property. @@ -1090,10 +1102,8 @@ The above example creates a new three columns list store. The types of the colum This property is meant primarily for classes that inherit from , and should - only be used when constructing a new . It will not function after a - row has been added or after a method on the interface has been called. + only be used when constructing a new . It will not function after a + row has been added or after a method on the interface has been called. @@ -1465,21 +1475,6 @@ The above example creates a new three columns list store. The types of the colum - - - Method - - System.Void - - - - - - Set the function that will be used by default to sort columns. - A - - - Method diff --git a/doc/en/Gtk/TreeModelFilter.xml b/doc/en/Gtk/TreeModelFilter.xml index 47322b5ec..9e34ef42c 100644 --- a/doc/en/Gtk/TreeModelFilter.xml +++ b/doc/en/Gtk/TreeModelFilter.xml @@ -92,31 +92,6 @@ in a for display. - - - Method - - System.Void - - - - - - - - Sets the visible function used when filtering to be . - a - a - a - - Note: this overload of the function is obsolete and requires you to manage the persistence - of func manually so it isn't garbage collected. The method has been replaced by a single parameter - overload which manages delegate persistence internally. - The function should return TRUE if the given row should be visible and - FALSE otherwise. - - - Method @@ -1081,21 +1056,16 @@ in a for display. - - - Method + + + Property - System.Void + Gtk.TreeModelFilterVisibleFunc - - - - Sets the visible function used when filtering to be . - a - - The function should return if the given row should be visible. - + The function used to determine whether or not a row should be visible + a + diff --git a/doc/en/Gtk/TreeModelSort.xml b/doc/en/Gtk/TreeModelSort.xml index c1352a2a8..771d0e395 100644 --- a/doc/en/Gtk/TreeModelSort.xml +++ b/doc/en/Gtk/TreeModelSort.xml @@ -115,7 +115,7 @@ node is always the parent. This overload is obsolete. The two parameter overload is preferred for new code. - + Method @@ -131,7 +131,19 @@ node is always the parent. A , the function to use for sorting ignored ignored - This overload is obsolete. The single parameter overload is preferred for new code. + This method is obsolete. The property is preferred for new code. + + + + + Property + + Gtk.TreeIterCompareFunc + + + The function to sort columns not otherwise specified by . + a + This property is meant to be used together with . @@ -865,7 +877,7 @@ node is always the parent. Return whether this TreeModel has a default sort function or not. a , true if a default sort function exists. - See to set a default sort function. + See to set a default sort function. @@ -1173,20 +1185,5 @@ node is always the parent. This method is meant to be used together with . - - - Method - - System.Void - - - - - - Sets a function to sort columns by default if not otherwise specified by . - A , the function to use for sorting - This method is meant to be used together with . - - - + \ No newline at end of file diff --git a/doc/en/Gtk/TreeSelection.xml b/doc/en/Gtk/TreeSelection.xml index c566393ca..4c6a85756 100644 --- a/doc/en/Gtk/TreeSelection.xml +++ b/doc/en/Gtk/TreeSelection.xml @@ -285,7 +285,7 @@ class TreeSelectionSample - + Method @@ -301,7 +301,21 @@ class TreeSelectionSample A delegate to invoke before a node is (un)selected. ignored ignored - This overload is obsolete. New code should use the single parameter overload. + This method is obsolete. New code should use the property. + + + + + Property + + Gtk.TreeSelectionFunc + + + A hook into selection and unselection + a + + If set, is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return if the state of the node may be toggled, and if the state of the node should be left unchanged. + @@ -538,22 +552,5 @@ class TreeSelectionSample - - - Method - - System.Void - - - - - - Add a hook into selection and unselection. - A delegate to invoke before a node is (un)selected. - - If set, is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return if the state of the node may be toggled, and if the state of the node should be left unchanged. - - - \ No newline at end of file diff --git a/doc/en/Gtk/TreeSortable.xml b/doc/en/Gtk/TreeSortable.xml index 59d193d08..48787b5e0 100644 --- a/doc/en/Gtk/TreeSortable.xml +++ b/doc/en/Gtk/TreeSortable.xml @@ -71,7 +71,7 @@ This overloaded method is obsolete. It is replaced by the SetSortFunc (int, TreeIterCompareFunc) overload." />. - + Method @@ -87,7 +87,19 @@ A , the function to use for sorting ignored ignored - This overload of SetDefaultSortFunc is obsolete. The replacement is a single parameter overload. The and paramaters to this method are ignored. + This method is obsolete. It is replaced by the property. + + + + + Property + + Gtk.TreeIterCompareFunc + + + Function to sort columns by default if not otherwise specified by . + a + This method is meant to be used together with @@ -133,21 +145,6 @@ See to set a default sort function. - - - Method - - System.Void - - - - - - Sets a function to sort columns by default if not otherwise specified by . - A , the function to use for sorting - This method is meant to be used together with - - Method diff --git a/doc/en/Gtk/TreeStore.xml b/doc/en/Gtk/TreeStore.xml index 6c155589b..5b372c321 100644 --- a/doc/en/Gtk/TreeStore.xml +++ b/doc/en/Gtk/TreeStore.xml @@ -154,7 +154,7 @@ This overload is obsolete. The two parameter is preferred for new code. - + Method @@ -170,7 +170,19 @@ A , the function to use for sorting ignored ignored - This overload is obsolete. The single parameter overload is preferred for new code. + This method is obsolete. The property is preferred for new code. + + + + + Property + + Gtk.TreeIterCompareFunc + + + The function that should be used to be sort columns by default if not otherwise specified by . + a + This property is meant to be used together with . @@ -1205,7 +1217,7 @@ store = new TreeStore (typeof (int), typeof (string)); Find out whether this TreeStore has a default sort function. a , true if there is a default sort function. - To set a default sort function, use . + To set a default sort function, use . @@ -1785,20 +1797,5 @@ store = new TreeStore (typeof (int), typeof (string)); This method is meant to be used together with - - - Method - - System.Void - - - - - - Sets a function that should be used to be sort columns by default if not otherwise specified by . - A , the function to use for sorting - This method is meant to be used together with . - - \ No newline at end of file diff --git a/doc/en/Gtk/TreeView.xml b/doc/en/Gtk/TreeView.xml index f7cb6f79f..50a7d86ff 100644 --- a/doc/en/Gtk/TreeView.xml +++ b/doc/en/Gtk/TreeView.xml @@ -261,7 +261,7 @@ For a example how to handle selection events see - + Method @@ -277,7 +277,19 @@ For a example how to handle selection events see an object of type ignored ignored - This overload is obsolete. New code should use the single parameter overload. + This method is obsolete. New code should use the property. + + + + + Property + + Gtk.TreeViewColumnDropFunc + + + The function for determining where a column may be dropped when dragged. + a + This function is called on every column pair in turn at the beginning of a column drag to determine where a drop can take place. If the property is set to be , then reverts to the default behavior of allowing all columns to be dropped everywhere. @@ -446,7 +458,7 @@ For a example how to handle selection events see - + Method @@ -465,7 +477,19 @@ For a example how to handle selection events see It is meant for private use by Atk for determining the number of visible children that are removed when the user collapses a row, or a row is deleted. - + + + Property + + Gtk.TreeDestroyCountFunc + + + This property should almost never be used. It is meant for private use by ATK for determining the number of visible children that are removed when the user collapses a row, or a row is deleted. + a + It is meant for private use by Atk for determining the number of visible children that are removed when the user collapses a row, or a row is deleted. + + + Method @@ -481,7 +505,20 @@ For a example how to handle selection events see The to invoke. ignored ignored - This overload is obsolete. New code should use the single parameter overload. + This method is obsolete. New code should use the property. + + + + + Property + + Gtk.TreeViewSearchEqualFunc + + + + The compare function for the interactive search capabilities. + a + @@ -1826,53 +1863,6 @@ tree_view.AppendColumn ("title", text, "text", 0); 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. - - - Method - - System.Void - - - - - - Sets the compare function for the interactive search capabilities. - The to invoke. - - - - - - - - Method - - System.Void - - - - - - This function should almost never be used. It is meant for private use by ATK for determining the number of visible children that are removed when the user collapses a row, or a row is deleted. - an object of type - It is meant for private use by Atk for determining the number of visible children that are removed when the user collapses a row, or a row is deleted. - - - - - Method - - System.Void - - - - - - Sets a user function for determining where a column may be dropped when dragged. - an object of type - This function is called on every column pair in turn at the beginning of a column drag to determine where a drop can take place. If is set to be , then reverts to the default behavior of allowing all columns to be dropped everywhere. - - Property @@ -1899,24 +1889,18 @@ tree_view.AppendColumn ("title", text, "text", 0); To be added - - - Method + + + Property - System.Void + Gtk.TreeViewRowSeparatorFunc - - - - - + - To be added - a - a - a - To be added + Callback function to indicate whether or not a given row of the tree view should be rendered as a separator. + a + - + \ No newline at end of file diff --git a/doc/en/Gtk/TreeViewColumn.xml b/doc/en/Gtk/TreeViewColumn.xml index 0efaec44e..cefbde622 100644 --- a/doc/en/Gtk/TreeViewColumn.xml +++ b/doc/en/Gtk/TreeViewColumn.xml @@ -403,20 +403,20 @@ - + Method System.Void - + 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. + 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. @@ -733,4 +733,4 @@ - + \ No newline at end of file diff --git a/doc/en/Pango/FcFontMap.xml b/doc/en/Pango/FcFontMap.xml index 6c6d565cc..26c8bf2b0 100644 --- a/doc/en/Pango/FcFontMap.xml +++ b/doc/en/Pango/FcFontMap.xml @@ -91,21 +91,17 @@ - + Method System.Void - - To be added a - a - a To be added diff --git a/doc/en/Rsvg/Handle.xml b/doc/en/Rsvg/Handle.xml index 510e34a42..14f5a49cf 100644 --- a/doc/en/Rsvg/Handle.xml +++ b/doc/en/Rsvg/Handle.xml @@ -173,7 +173,7 @@ To be added - + Method @@ -192,5 +192,17 @@ To be added + + + Property + + Rsvg.SizeFunc + + + To be added + a + To be added + + - + \ No newline at end of file diff --git a/doc/updater/updater.cs b/doc/updater/updater.cs index f77082519..cb1cd24bc 100644 --- a/doc/updater/updater.cs +++ b/doc/updater/updater.cs @@ -141,7 +141,7 @@ class Updater { XmlTextWriter writer = new XmlTextWriter (filename, Encoding.ASCII); writer.Formatting = Formatting.Indented; doc.WriteContentTo (writer); - writer.Flush (); + writer.Close (); Console.WriteLine (type.FullName); return true; } @@ -150,6 +150,10 @@ class Updater { { bool changed = false; + XmlNode node = doc.SelectSingleNode ("/Type/@FullName"); + if (node == null || node.InnerText != t.FullName) + return false; + if (!t.IsAbstract && typeof (System.Delegate).IsAssignableFrom (t)) return CompareDelegate (t, doc); diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index 0c6a62573..1c5eae5b8 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -65,6 +65,7 @@ 1 1 out + gpointer 1 1 1 diff --git a/generator/CallbackGen.cs b/generator/CallbackGen.cs index 9a2492af3..9ba3d7258 100644 --- a/generator/CallbackGen.cs +++ b/generator/CallbackGen.cs @@ -50,9 +50,9 @@ namespace GtkSharp.Generation { return var_name + ".NativeDelegate"; } - public override string FromNative(string var) + public override string FromNative (string var) { - return var; + return NS + "Sharp." + Name + "Wrapper.GetManagedDelegate (" + var + ")"; } public string GenWrapper (string ns, GenerationInfo gen_info) @@ -146,6 +146,16 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t\tif (managed != null)"); sw.WriteLine ("\t\t\t\tNativeDelegate = new " + wrapper + " (NativeCallback);"); sw.WriteLine ("\t\t}"); + sw.WriteLine (); + sw.WriteLine ("\t\tpublic static " + NS + "." + Name + " GetManagedDelegate (" + wrapper + " native)"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\tif (native == null)"); + sw.WriteLine ("\t\t\t\treturn null;"); + sw.WriteLine ("\t\t\t" + Name + "Wrapper wrapper = (" + Name + "Wrapper) native.Target;"); + sw.WriteLine ("\t\t\tif (wrapper == null)"); + sw.WriteLine ("\t\t\t\treturn null;"); + sw.WriteLine ("\t\t\treturn wrapper.managed;"); + sw.WriteLine ("\t\t}"); sw.WriteLine ("\t}"); sw.WriteLine ("#endregion"); sw.WriteLine ("}"); diff --git a/generator/MethodBody.cs b/generator/MethodBody.cs index c30a5a8f7..73b1522d1 100644 --- a/generator/MethodBody.cs +++ b/generator/MethodBody.cs @@ -140,6 +140,22 @@ namespace GtkSharp.Generation { CallbackGen cbgen = gen as CallbackGen; string wrapper = cbgen.GenWrapper(impl_ns, gen_info); switch (p.Scope) { + case "notified": + sw.WriteLine (indent + "\t\t\t{0} {1}_wrapper;", wrapper, name); + sw.WriteLine (indent + "\t\t\tIntPtr {0};", parameters [i + 1].Name); + sw.WriteLine (indent + "\t\t\t{0} {1};", parameters [i + 2].CSType, parameters [i + 2].Name); + sw.WriteLine (indent + "\t\t\tif ({0} == null) {{", name); + sw.WriteLine (indent + "\t\t\t\t{0}_wrapper = null;", name); + sw.WriteLine (indent + "\t\t\t\t{0} = IntPtr.Zero;", parameters [i + 1].Name); + sw.WriteLine (indent + "\t\t\t\t{0} = null;", parameters [i + 2].Name); + sw.WriteLine (indent + "\t\t\t} else {"); + + sw.WriteLine (indent + "\t\t\t\t{0}_wrapper = new {1} ({0});", name, wrapper); + sw.WriteLine (indent + "\t\t\t\t{0} = (IntPtr) GCHandle.Alloc ({1}_wrapper);", parameters [i + 1].Name, name); + sw.WriteLine (indent + "\t\t\t\t{0} = new {1} (GLib.DestroyHelper.NotifyHandler);", parameters [i + 2].Name, parameters [i + 2].CSType); + sw.WriteLine (indent + "\t\t\t}"); + break; + case "call": default: if (p.Scope == String.Empty) diff --git a/generator/Parameters.cs b/generator/Parameters.cs index d9a93bccb..6c6d4db99 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -98,6 +98,12 @@ namespace GtkSharp.Generation { } } + public bool IsDestroyNotify { + get { + return CType == "GDestroyNotify"; + } + } + public bool IsLength { get { @@ -176,9 +182,15 @@ namespace GtkSharp.Generation { } } + string scope; public string Scope { get { - return elem.GetAttribute ("scope"); + if (scope == null) + scope = elem.GetAttribute ("scope"); + return scope; + } + set { + scope = value; } } @@ -269,6 +281,12 @@ namespace GtkSharp.Generation { if (HasCB || HideData) { if (p.IsUserData && (idx == Count - 1)) return true; + if (p.IsUserData && (idx == Count - 2) && + this [idx + 1].IsDestroyNotify) + return true; + if (p.IsDestroyNotify && (idx == Count - 1) && + this [idx - 1].IsUserData) + return true; } return false; @@ -309,7 +327,8 @@ namespace GtkSharp.Generation { if (cleared) return false; - foreach (Parameter p in param_list) { + for (int i = 0; i < param_list.Count; i++) { + Parameter p = this [i]; if (p.IsEllipsis) { Console.Write("Ellipsis parameter "); @@ -325,8 +344,13 @@ namespace GtkSharp.Generation { return false; } - if (p.Generatable is CallbackGen) + if (p.Generatable is CallbackGen) { has_cb = true; + if (i == Count - 3 && + this [i + 1].IsUserData && + this [i + 2].IsDestroyNotify) + p.Scope = "notified"; + } } return true; diff --git a/generator/ReturnValue.cs b/generator/ReturnValue.cs index b89542c31..7f0db32e0 100644 --- a/generator/ReturnValue.cs +++ b/generator/ReturnValue.cs @@ -109,11 +109,6 @@ namespace GtkSharp.Generation { public bool Validate () { - // FIXME: implement callback return values. - if (IGen is CallbackGen) { - Console.Write ("Callback rettype " + CSType); - return false; - } if (MarshalType == "" || CSType == "") { Console.Write("rettype: " + CType); return false; diff --git a/generator/SymbolTable.cs b/generator/SymbolTable.cs index ed0ae6e89..5a587a463 100644 --- a/generator/SymbolTable.cs +++ b/generator/SymbolTable.cs @@ -102,6 +102,7 @@ namespace GtkSharp.Generation { AddType (new MarshalGen ("GString", "string", "IntPtr", "new GLib.GString ({0}).Handle", "GLib.GString.PtrToString ({0})")); AddType (new MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})")); AddType (new ByRefGen ("GValue", "GLib.Value")); + AddType (new SimpleGen ("GDestroyNotify", "GLib.DestroyNotify")); // FIXME: These ought to be handled properly. AddType (new SimpleGen ("GC", "IntPtr")); @@ -113,14 +114,12 @@ namespace GtkSharp.Generation { AddType (new SimpleGen ("GArray", "IntPtr")); AddType (new SimpleGen ("GByteArray", "IntPtr")); AddType (new SimpleGen ("GData", "IntPtr")); - AddType (new SimpleGen ("GDestroyNotify", "IntPtr")); AddType (new SimpleGen ("GIOChannel", "IntPtr")); AddType (new SimpleGen ("GTypeModule", "GLib.Object")); AddType (new SimpleGen ("GHashTable", "System.IntPtr")); AddType (new SimpleGen ("va_list", "IntPtr")); AddType (new SimpleGen ("GParamSpec", "IntPtr")); AddType (new SimpleGen ("gconstpointer", "IntPtr")); - AddType (new SimpleGen ("GDestroyNotify", "IntPtr")); } public void AddType (IGeneratable gen) diff --git a/gtk/DestroyHelper.cs b/glib/DestroyNotify.cs similarity index 76% rename from gtk/DestroyHelper.cs rename to glib/DestroyNotify.cs index 3c8a385fc..0f09ee13e 100644 --- a/gtk/DestroyHelper.cs +++ b/glib/DestroyNotify.cs @@ -1,4 +1,4 @@ -// Gtk.DestroyHelper.cs - internal DestroyNotify helper +// GLib.DestroyNotify.cs - internal DestroyNotify helper // // Author: Mike Kestner // @@ -18,14 +18,14 @@ // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. -namespace Gtk { +namespace GLib { using System; using System.Runtime.InteropServices; - internal delegate void NativeDestroyNotify (IntPtr data); + public delegate void DestroyNotify (IntPtr data); - internal class DestroyHelper { + public class DestroyHelper { private DestroyHelper () {} @@ -37,12 +37,12 @@ namespace Gtk { gch.Free (); } - static NativeDestroyNotify release_gchandle; + static DestroyNotify release_gchandle; - internal static NativeDestroyNotify NotifyHandler { + public static DestroyNotify NotifyHandler { get { if (release_gchandle == null) - release_gchandle = new NativeDestroyNotify (ReleaseGCHandle); + release_gchandle = new DestroyNotify (ReleaseGCHandle); return release_gchandle; } } diff --git a/glib/Makefile.am b/glib/Makefile.am index c1b79799e..74c768f1e 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -17,6 +17,7 @@ sources = \ ConnectBeforeAttribute.cs \ DefaultSignalHandlerAttribute.cs \ DelegateWrapper.cs \ + DestroyNotify.cs \ EnumWrapper.cs \ FileUtils.cs \ GException.cs \ diff --git a/gnome/Gnome.metadata b/gnome/Gnome.metadata index 3284d6f2d..2cb268301 100644 --- a/gnome/Gnome.metadata +++ b/gnome/Gnome.metadata @@ -92,6 +92,7 @@ 1 1 1 + gpointer IconFocused IconSelected IconUnselected diff --git a/gtk/ActionGroup.custom b/gtk/ActionGroup.custom index 7375649f5..2a1a0f2ab 100644 --- a/gtk/ActionGroup.custom +++ b/gtk/ActionGroup.custom @@ -84,17 +84,3 @@ result [i] = list [i] as Gtk.Action; return result; } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_action_group_set_translate_func (IntPtr raw, GtkSharp.TranslateFuncNative func, IntPtr data, NativeDestroyNotify notify); - - public void SetTranslateFunc (Gtk.TranslateFunc func) - { - if (func == null) { - gtk_action_group_set_translate_func (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TranslateFuncWrapper func_wrapper = new GtkSharp.TranslateFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_action_group_set_translate_func (Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } diff --git a/gtk/CellLayout.custom b/gtk/CellLayout.custom index eaeb35132..f3b5f75f4 100644 --- a/gtk/CellLayout.custom +++ b/gtk/CellLayout.custom @@ -19,6 +19,5 @@ // 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 index b36261414..c86f1a84e 100644 --- a/gtk/CellView.custom +++ b/gtk/CellView.custom @@ -31,19 +31,3 @@ 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, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, NativeDestroyNotify destroy); - - public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) - { - if (func == null) { - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/ComboBox.custom b/gtk/ComboBox.custom index f8ee6f483..bd5d8d8c6 100644 --- a/gtk/ComboBox.custom +++ b/gtk/ComboBox.custom @@ -31,19 +31,3 @@ 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, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, NativeDestroyNotify destroy); - - public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) - { - if (func == null) { - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/EntryCompletion.custom b/gtk/EntryCompletion.custom index 2b77ba8bf..1352800ed 100644 --- a/gtk/EntryCompletion.custom +++ b/gtk/EntryCompletion.custom @@ -31,34 +31,3 @@ 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, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, NativeDestroyNotify destroy); - - public void SetCellDataFunc (CellRenderer renderer, CellLayoutDataFunc func) - { - if (func == null) { - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_cell_layout_set_cell_data_func (Handle, renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_entry_completion_set_match_func (IntPtr raw, GtkSharp.EntryCompletionMatchFuncNative func, IntPtr func_data, NativeDestroyNotify func_notify); - - public void SetMatchFunc (EntryCompletionMatchFunc func) - { - if (func == null) { - gtk_entry_completion_set_match_func (Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.EntryCompletionMatchFuncWrapper func_wrapper = new GtkSharp.EntryCompletionMatchFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_entry_completion_set_match_func (Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/FileFilter.custom b/gtk/FileFilter.custom deleted file mode 100644 index bb3bfdf6a..000000000 --- a/gtk/FileFilter.custom +++ /dev/null @@ -1,35 +0,0 @@ -// Gtk.FileFilter.custom - Gtk FileFilter class 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. - - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_file_filter_add_custom(IntPtr raw, int needed, GtkSharp.FileFilterFuncNative func, IntPtr data, NativeDestroyNotify notify); - - public void AddCustom (Gtk.FileFilterFlags needed, Gtk.FileFilterFunc func) - { - if (func == null) { - gtk_file_filter_add_custom (Handle, (int) needed, null, IntPtr.Zero, null); - return; - } - GtkSharp.FileFilterFuncWrapper func_wrapper = new GtkSharp.FileFilterFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_file_filter_add_custom(Handle, (int) needed, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 362780906..35e135681 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -1,5 +1,6 @@ + GDestroyNotify GdkKey Key GdkModifierType @@ -73,7 +74,6 @@ FinishEditing WidgetRemoved 1 - 1 GetIsEditable ref SetIsEditable @@ -100,8 +100,6 @@ EmitRowHasChildToggled EmitRowInserted EmitRowsReordered - 1 - 1 ChangeSortColumn label Activated @@ -128,7 +126,6 @@ 1 1 Remove - 1 action_group action proxy @@ -177,7 +174,7 @@ 1 1 1 - out + out 1 call @@ -185,6 +182,7 @@ call call call + GtkDestroyNotify 1 1 1 @@ -205,12 +203,10 @@ ClipboardCopied ClipboardCut ClipboardPasted - 1 PrefixInserted 1 1 1 - 1 1 GObject Activated @@ -246,7 +242,7 @@ 1 GetItem GetWidget - 1 + GtkDestroyNotify Deselected Selected Toggled @@ -285,6 +281,10 @@ 1 1 1 + GtkDestroyNotify + GtkDestroyNotify + GtkDestroyNotify + GtkDestroyNotify Destroyed 1 1 @@ -372,7 +372,6 @@ TooltipSet out out - 1 1 model out @@ -380,7 +379,6 @@ out 1 call - 1 1 1 1 @@ -400,7 +398,6 @@ 1 1 1 - 1 1 1 out @@ -413,15 +410,11 @@ out out 1 - 1 1 1 call ActivateRow GetRowExpanded - 1 - 1 - 1 ScrollAdjustmentsSet 1 1 diff --git a/gtk/Input.custom b/gtk/Input.custom index c3d81cd87..34788fb21 100644 --- a/gtk/Input.custom +++ b/gtk/Input.custom @@ -20,7 +20,7 @@ [DllImport("libgtk-win32-2.0-0.dll")] - static extern uint gtk_input_add_full(int source, int condition, InputFunctionNative function, GtkSharp.CallbackMarshalNative marshal, IntPtr data, NativeDestroyNotify destroy); + static extern uint gtk_input_add_full(int source, int condition, InputFunctionNative function, GtkSharp.CallbackMarshalNative marshal, IntPtr data, GLib.DestroyNotify destroy); [GLib.CDeclCallback] delegate void InputFunctionNative(IntPtr data, int source, int condition); @@ -52,7 +52,7 @@ GtkSharp.CallbackMarshalWrapper marshal; IntPtr data; DestroyNotify destroy; - NativeDestroyNotify handler; + GLib.DestroyNotify handler; public InputProxy (InputFunctionWrapper function, GtkSharp.CallbackMarshalWrapper marshal, IntPtr data, DestroyNotify destroy) { @@ -60,7 +60,7 @@ this.function = function; this.destroy = destroy; this.data = data; - handler = new NativeDestroyNotify (OnDestroy); + handler = new GLib.DestroyNotify (OnDestroy); } void OnDestroy (IntPtr data) @@ -72,7 +72,7 @@ gch.Free (); } - public NativeDestroyNotify Handler { + public GLib.DestroyNotify Handler { get { return handler; } diff --git a/gtk/ItemFactory.custom b/gtk/ItemFactory.custom index 061544576..28b8f13d0 100644 --- a/gtk/ItemFactory.custom +++ b/gtk/ItemFactory.custom @@ -36,23 +36,8 @@ GLib.Marshaller.Free (native); } - [DllImport ("libgtk-win32-2.0-0.dll")] - static extern void gtk_item_factory_set_translate_func (IntPtr raw, GtkSharp.TranslateFuncNative func, IntPtr data, NativeDestroyNotify notify); - - [Obsolete ("Replaced by SetTranslateFunc (TranslateFunc) overload.")] + [Obsolete ("Replaced by TranslateFunc property.")] public void SetTranslateFunc (TranslateFunc func, IntPtr data, DestroyNotify notify) { - SetTranslateFunc (func); + TranslateFunc = func; } - - public void SetTranslateFunc (TranslateFunc func) - { - if (func == null) { - gtk_item_factory_set_translate_func (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TranslateFuncWrapper func_wrapper = new GtkSharp.TranslateFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_item_factory_set_translate_func (Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/ListStore.custom b/gtk/ListStore.custom index 045aa8461..6c5cc6eff 100644 --- a/gtk/ListStore.custom +++ b/gtk/ListStore.custom @@ -156,45 +156,14 @@ return ret; } - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_sort_func(IntPtr raw, int col_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - [Obsolete ("Replaced by SetSortFunc (int, TreeIterCompareFunc) overload.")] public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { SetSortFunc (sort_column_id, sort_func); } - public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_sort_func (Handle, sort_column_id, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_sort_func(Handle, sort_column_id, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_default_sort_func(IntPtr raw, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetDefaultSortFunc (TreeIterCompareFunc) overload.")] + [Obsolete ("Replaced by DefaultSortFunc property.")] public void SetDefaultSortFunc (TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { - SetDefaultSortFunc (sort_func); + DefaultSortFunc = sort_func; } - - public void SetDefaultSortFunc (TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_default_sort_func (Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_default_sort_func(Handle, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 0df621cc7..b5ec986d5 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -14,7 +14,6 @@ sources = \ Application.cs \ BindingAttribute.cs \ ChildPropertyAttribute.cs \ - DestroyHelper.cs \ ITreeNode.cs \ NodeCellDataFunc.cs \ NodeSelection.cs \ @@ -53,7 +52,6 @@ customs = \ EntryCompletion.custom \ FileChooserDialog.custom \ FileChooserWidget.custom \ - FileFilter.custom \ FileSelection.custom \ FileSystemModel.custom \ Frame.custom \ diff --git a/gtk/Quit.custom b/gtk/Quit.custom index 33696f095..eedc6590b 100644 --- a/gtk/Quit.custom +++ b/gtk/Quit.custom @@ -25,7 +25,7 @@ GtkSharp.CallbackMarshalWrapper marshal; IntPtr data; DestroyNotify destroy; - NativeDestroyNotify handler; + GLib.DestroyNotify handler; public QuitProxy (GtkSharp.FunctionWrapper function, GtkSharp.CallbackMarshalWrapper marshal, IntPtr data, DestroyNotify destroy) { @@ -33,7 +33,7 @@ this.function = function; this.destroy = destroy; this.data = data; - handler = new NativeDestroyNotify (OnDestroy); + handler = new GLib.DestroyNotify (OnDestroy); } void OnDestroy (IntPtr data) @@ -45,7 +45,7 @@ gch.Free (); } - public NativeDestroyNotify Handler { + public GLib.DestroyNotify Handler { get { return handler; } @@ -53,7 +53,7 @@ } [DllImport("libgtk-win32-2.0-0.dll")] - static extern uint gtk_quit_add_full(uint main_level, GtkSharp.FunctionNative function, GtkSharp.CallbackMarshalNative marshal, IntPtr data, NativeDestroyNotify destroy); + static extern uint gtk_quit_add_full(uint main_level, GtkSharp.FunctionNative function, GtkSharp.CallbackMarshalNative marshal, IntPtr data, GLib.DestroyNotify destroy); [Obsolete ("Replaced by Add method")] public static uint AddFull (uint main_level, Function function, CallbackMarshal marshal, IntPtr data, DestroyNotify destroy) @@ -69,6 +69,6 @@ { GtkSharp.FunctionWrapper function_wrapper = new GtkSharp.FunctionWrapper (function); GCHandle gch = GCHandle.Alloc (function_wrapper); - return gtk_quit_add_full (main_level, function_wrapper.NativeDelegate, null, (IntPtr) gch, DestroyHelper.NotifyHandler); + return gtk_quit_add_full (main_level, function_wrapper.NativeDelegate, null, (IntPtr) gch, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler)); } diff --git a/gtk/TreeModelFilter.custom b/gtk/TreeModelFilter.custom index 49075ba58..4038c7708 100644 --- a/gtk/TreeModelFilter.custom +++ b/gtk/TreeModelFilter.custom @@ -58,27 +58,14 @@ return ret; } - [Obsolete ("Replaced by SetVisibleFunc (TreeModelFilterVisibleFunc) overload.")] - public void SetVisibleFunc (TreeModelFilterVisibleFunc func, IntPtr data, Gtk.DestroyNotify destroy) + [Obsolete ("Replaced by VisibleFunc property.")] + public void SetVisibleFunc (TreeModelFilterVisibleFunc func, IntPtr data, Gtk.DestroyNotify destroy) { - SetVisibleFunc (func); + VisibleFunc = func; } [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_model_filter_set_visible_func (IntPtr raw, GtkSharp.TreeModelFilterVisibleFuncNative func, IntPtr data, NativeDestroyNotify destroy); - public void SetVisibleFunc (TreeModelFilterVisibleFunc func) - { - if (func == null) { - gtk_tree_model_filter_set_visible_func (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TreeModelFilterVisibleFuncWrapper func_wrapper = new GtkSharp.TreeModelFilterVisibleFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_tree_model_filter_set_visible_func (Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_model_filter_set_modify_func(IntPtr raw, int n_columns, IntPtr[] types, GtkSharp.TreeModelFilterModifyFuncNative func, IntPtr data, NativeDestroyNotify destroy); + static extern void gtk_tree_model_filter_set_modify_func(IntPtr raw, int n_columns, IntPtr[] types, GtkSharp.TreeModelFilterModifyFuncNative func, IntPtr data, GLib.DestroyNotify destroy); public void SetModifyFunc (int n_columns, GLib.GType[] types, TreeModelFilterModifyFunc func) { @@ -87,6 +74,6 @@ for (int i = 0; i < types.Length; i++) native_types [i] = types [i].Val; GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_tree_model_filter_set_modify_func (Handle, n_columns, native_types, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); + gtk_tree_model_filter_set_modify_func (Handle, n_columns, native_types, func_wrapper.NativeDelegate, (IntPtr) gch, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler)); } diff --git a/gtk/TreeModelSort.custom b/gtk/TreeModelSort.custom index c2a788d8d..2ae5d2499 100644 --- a/gtk/TreeModelSort.custom +++ b/gtk/TreeModelSort.custom @@ -85,45 +85,14 @@ return ret; } - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_sort_func(IntPtr raw, int col_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - [Obsolete ("Replaced by SetSortFunc (int, TreeIterCompareFunc) overload.")] public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { SetSortFunc (sort_column_id, sort_func); } - public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_sort_func (Handle, sort_column_id, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_sort_func(Handle, sort_column_id, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_default_sort_func(IntPtr raw, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetDefaultSortFunc (TreeIterCompareFunc) overload.")] + [Obsolete ("Replaced by DefaultSortFunc property.")] public void SetDefaultSortFunc (TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { - SetDefaultSortFunc (sort_func); + DefaultSortFunc = sort_func; } - - public void SetDefaultSortFunc (TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_default_sort_func (Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_default_sort_func(Handle, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/TreeSelection.custom b/gtk/TreeSelection.custom index 55c962759..aecfe6db9 100644 --- a/gtk/TreeSelection.custom +++ b/gtk/TreeSelection.custom @@ -53,23 +53,8 @@ return result; } - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_selection_set_select_function (IntPtr raw, GtkSharp.TreeSelectionFuncNative func, IntPtr data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetSelectFunction (TreeSelectionFunc) overload.")] + [Obsolete ("Replaced by SelectFunction property.")] public void SetSelectFunction (Gtk.TreeSelectionFunc func, IntPtr data, Gtk.DestroyNotify destroy) { - SetSelectFunction (func); + SelectFunction = func; } - - public void SetSelectFunction (Gtk.TreeSelectionFunc func) - { - if (func == null) { - gtk_tree_selection_set_select_function(Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TreeSelectionFuncWrapper func_wrapper = new GtkSharp.TreeSelectionFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_tree_selection_set_select_function(Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/TreeSortable.custom b/gtk/TreeSortable.custom index 95252dd46..d476da7fd 100644 --- a/gtk/TreeSortable.custom +++ b/gtk/TreeSortable.custom @@ -23,10 +23,6 @@ [Obsolete ("Replaced by SetDefaultSortFunc (TreeIterCompareFunc) overload.")] void SetDefaultSortFunc (TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy); - void SetDefaultSortFunc (TreeIterCompareFunc sort_func); - [Obsolete ("Replaced by SetSortFunc (int, TreeIterCompareFunc) overload.")] void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy); - void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func); - diff --git a/gtk/TreeStore.custom b/gtk/TreeStore.custom index 3195f563c..5b439a993 100644 --- a/gtk/TreeStore.custom +++ b/gtk/TreeStore.custom @@ -331,45 +331,14 @@ return ret; } - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_sort_func(IntPtr raw, int col_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - [Obsolete ("Replaced by SetSortFunc (int, TreeIterCompareFunc) overload.")] public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { SetSortFunc (sort_column_id, sort_func); } - public void SetSortFunc (int sort_column_id, TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_sort_func (Handle, sort_column_id, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_sort_func(Handle, sort_column_id, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_sortable_set_default_sort_func(IntPtr raw, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetDefaultSortFunc (TreeIterCompareFunc) overload.")] + [Obsolete ("Replaced by DefaultSortFunc property.")] public void SetDefaultSortFunc (TreeIterCompareFunc sort_func, IntPtr user_data, Gtk.DestroyNotify destroy) { - SetDefaultSortFunc (sort_func); + DefaultSortFunc = sort_func; } - - public void SetDefaultSortFunc (TreeIterCompareFunc sort_func) - { - if (sort_func == null) { - gtk_tree_sortable_set_default_sort_func (Handle, null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func); - GCHandle gch = GCHandle.Alloc (sort_func_wrapper); - gtk_tree_sortable_set_default_sort_func(Handle, sort_func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/TreeView.custom b/gtk/TreeView.custom index af279884b..5c2af394e 100644 --- a/gtk/TreeView.custom +++ b/gtk/TreeView.custom @@ -162,63 +162,20 @@ return InsertColumn (col, pos); } - [DllImport ("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_view_set_search_equal_func (IntPtr raw, GtkSharp.TreeViewSearchEqualFuncNative search_equal_func, IntPtr search_user_data, NativeDestroyNotify search_destroy); - - [Obsolete ("Replaced by SetSearchEqualFunc (TreeViewSearchEqualFunc) overload.")] + [Obsolete ("Replaced by SearchEqualFunc property.")] public void SetSearchEqualFunc (TreeViewSearchEqualFunc search_equal_func, IntPtr search_user_data, DestroyNotify search_destroy) { - SetSearchEqualFunc (search_equal_func); + SearchEqualFunc = search_equal_func; } - public void SetSearchEqualFunc (TreeViewSearchEqualFunc search_equal_func) - { - if (search_equal_func == null) { - gtk_tree_view_set_search_equal_func (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TreeViewSearchEqualFuncWrapper wrapper = new GtkSharp.TreeViewSearchEqualFuncWrapper (search_equal_func); - GCHandle gch = GCHandle.Alloc (wrapper); - gtk_tree_view_set_search_equal_func (Handle, wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport ("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_view_set_destroy_count_func (IntPtr raw, GtkSharp.TreeDestroyCountFuncNative func, IntPtr data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetDestroyCountFunc (TreeDestroyCountFunc) overload.")] + [Obsolete ("Replaced by DestroyCountFunc property.")] public void SetDestroyCountFunc (TreeDestroyCountFunc func, IntPtr data, DestroyNotify destroy) { - SetDestroyCountFunc (func); + DestroyCountFunc = func; } - public void SetDestroyCountFunc (TreeDestroyCountFunc func) - { - if (func == null) { - gtk_tree_view_set_destroy_count_func (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TreeDestroyCountFuncWrapper wrapper = new GtkSharp.TreeDestroyCountFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (wrapper); - gtk_tree_view_set_destroy_count_func (Handle, wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - [DllImport ("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_view_set_column_drag_function (IntPtr raw, GtkSharp.TreeViewColumnDropFuncNative func, IntPtr user_data, NativeDestroyNotify destroy); - - [Obsolete ("Replaced by SetColumnDragFunction (TreeViewColumnDropFunc) overload.")] + [Obsolete ("Replaced by ColumnDragFunction property.")] public void SetColumnDragFunction (TreeViewColumnDropFunc func, IntPtr user_data, DestroyNotify destroy) { - SetColumnDragFunction (func); + ColumnDragFunction = func; } - - public void SetColumnDragFunction (TreeViewColumnDropFunc func) - { - if (func == null) { - gtk_tree_view_set_column_drag_function (Handle, null, IntPtr.Zero, null); - return; - } - GtkSharp.TreeViewColumnDropFuncWrapper wrapper = new GtkSharp.TreeViewColumnDropFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (wrapper); - gtk_tree_view_set_column_drag_function (Handle, wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - diff --git a/gtk/TreeViewColumn.custom b/gtk/TreeViewColumn.custom index be8098baa..581ff2633 100644 --- a/gtk/TreeViewColumn.custom +++ b/gtk/TreeViewColumn.custom @@ -66,36 +66,6 @@ } } - [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, NativeDestroyNotify destroy); - - [DllImport("libgtk-win32-2.0-0.dll")] - static extern void gtk_tree_view_column_set_cell_data_func (IntPtr raw, IntPtr cell_renderer, GtkSharp.CellLayoutDataFuncNative func, IntPtr func_data, NativeDestroyNotify destroy); - - public void SetCellDataFunc (CellRenderer cell_renderer, TreeCellDataFunc func) - { - if (func == null) { - gtk_tree_view_column_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, (GtkSharp.TreeCellDataFuncNative) null, IntPtr.Zero, null); - return; - } - - GtkSharp.TreeCellDataFuncWrapper wrapper = new GtkSharp.TreeCellDataFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (wrapper); - gtk_tree_view_column_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - - public void SetCellDataFunc (CellRenderer cell_renderer, CellLayoutDataFunc func) - { - if (func == null) { - gtk_tree_view_column_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, (GtkSharp.TreeCellDataFuncNative) null, IntPtr.Zero, null); - return; - } - - GtkSharp.CellLayoutDataFuncWrapper func_wrapper = new GtkSharp.CellLayoutDataFuncWrapper (func); - GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_tree_view_column_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); - } - public void SetCellDataFunc (CellRenderer cell_renderer, NodeCellDataFunc func) { if (func == null) { @@ -105,7 +75,7 @@ NodeCellDataFuncWrapper func_wrapper = new NodeCellDataFuncWrapper (func); GCHandle gch = GCHandle.Alloc (func_wrapper); - gtk_tree_view_column_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, DestroyHelper.NotifyHandler); + gtk_cell_layout_set_cell_data_func (Handle, cell_renderer == null ? IntPtr.Zero : cell_renderer.Handle, func_wrapper.NativeDelegate, (IntPtr) gch, new GLib.DestroyNotify (GLib.DestroyHelper.NotifyHandler)); } [Obsolete ("Replaced by SetCellDataFunc (CellRenderer, TreeCellDataFunc) overload")] diff --git a/rsvg/Handle.custom b/rsvg/Handle.custom new file mode 100644 index 000000000..439fe5b71 --- /dev/null +++ b/rsvg/Handle.custom @@ -0,0 +1,25 @@ +// Rsvg.Handle.custom - Rsvg Handle class customizations +// +// Copyright (C) 2005 Novell, Inc. +// +// This code is inserted after the automatically generated code. +// +// 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. + +[Obsolete ("Replaced by SizeCallback property")] +public void SetSizeCallback (Rsvg.SizeFunc size_func, IntPtr user_data, IntPtr user_data_destroy) +{ + SizeCallback = size_func; +} diff --git a/rsvg/Makefile.am b/rsvg/Makefile.am index 3595cc6f2..90d412659 100644 --- a/rsvg/Makefile.am +++ b/rsvg/Makefile.am @@ -14,7 +14,9 @@ references = ../glib/glib-sharp.dll ../pango/pango-sharp.dll ../atk/atk-sharp.dl sources = \ Tool.cs -customs = Pixbuf.custom +customs = \ + Handle.custom \ + Pixbuf.custom add_dist = rsvg-sharp-2.0.pc.in diff --git a/sample/GtkDemo/DemoIconView.cs b/sample/GtkDemo/DemoIconView.cs index 4a79f04a2..457e17380 100644 --- a/sample/GtkDemo/DemoIconView.cs +++ b/sample/GtkDemo/DemoIconView.cs @@ -76,7 +76,7 @@ namespace GtkDemo ListStore store = new ListStore (GLib.GType.String, GLib.GType.String, Gdk.Pixbuf.GType, GLib.GType.Boolean); // Set sort column and function - store.SetDefaultSortFunc (SortFunc); + store.DefaultSortFunc = SortFunc; store.SetSortColumnId (COL_DISPLAY_NAME, SortType.Ascending); return store;