diff --git a/ChangeLog b/ChangeLog index ab7cf4ce4..15c1189c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-04-05 Mike Kestner + + * gtk/*.custom : persistent delegates for most of the remaining + "interesting" methods. + 2005-04-05 Dan Winship * gdk/PixbufLoader.custom: Fix the new constructors to make sure diff --git a/doc/en/Gtk/ActionGroup.xml b/doc/en/Gtk/ActionGroup.xml index 9501a3e36..63f91ef2b 100644 --- a/doc/en/Gtk/ActionGroup.xml +++ b/doc/en/Gtk/ActionGroup.xml @@ -50,25 +50,6 @@ Accelerators are handled by the Gtk accelerator map. All actions are assigned an - - - Method - - System.Void - - - - - - - - Sets a function to be used for translating the label and tooltip of GtkActionGroupEntrys added by . - a - a - a - If you are using gettext(), it is enough to set the translation domain with . - - Method @@ -441,5 +422,20 @@ Therefore you must either set the accel path yourself with event. + + + Method + + System.Void + + + + + + Sets 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 . + + - \ No newline at end of file + diff --git a/doc/en/Gtk/EntryCompletion.xml b/doc/en/Gtk/EntryCompletion.xml index db50629e9..de34b98e9 100644 --- a/doc/en/Gtk/EntryCompletion.xml +++ b/doc/en/Gtk/EntryCompletion.xml @@ -451,30 +451,6 @@ public class DemoEntryCompletion : Window - - - Method - - System.Void - - - - - - - - - Sets the match function for this entry completion to be . - - a - a - a - - The match function is used to determine if a row should or - should not be in the completion list. - - - Method @@ -523,7 +499,22 @@ public class DemoEntryCompletion : Window Sets the attribute to model column bindings for a renderer. a a - The array should be pairs of attribute names and column indexes. + The array should be pairs of attribute names and column indexes. + + + + + Method + + System.Void + + + + + + Sets 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 a0f17f163..7d65f6166 100644 --- a/doc/en/Gtk/ItemFactory.xml +++ b/doc/en/Gtk/ItemFactory.xml @@ -13,8 +13,8 @@ A factory for menus. To use this class, make an array of - objects which describe a menu, then invoke - to generate the menu. + objects which describe a menu, then invoke + to generate the menu. @@ -304,9 +304,9 @@ Sets a method to be used for translating the path elements before they are displayed. The delegate to be used to traslate path elements. - Data to pass to and . - A delegate to be called when the object is destroyed and when the translation is changed again. - + ignored + ignored + This overload is obsolete. New code should use the single parameter overload instead. @@ -492,12 +492,13 @@ Finds an item factory which has been constructed using the - "<name>" prefix of as the path argument + "<name>" prefix of as the path argument building a new item factory. a - a , or - + a , or + + @@ -514,7 +515,8 @@ Creates menu items from a set of entries. a , the number of entries an array of objects - + + @@ -539,5 +541,20 @@ 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. + + + diff --git a/doc/en/Gtk/TreeSelection.xml b/doc/en/Gtk/TreeSelection.xml index ec25f7ff0..52be9f3fe 100644 --- a/doc/en/Gtk/TreeSelection.xml +++ b/doc/en/Gtk/TreeSelection.xml @@ -299,11 +299,9 @@ class TreeSelectionSample Add a hook into selection and unselection. A delegate to invoke before a node is (un)selected. - Raw data to pass to when it is called. - A delegate to be notified when should be destroyed. Can be . - - 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. - + ignored + ignored + This overload is obsolete. New code should use the single parameter overload. @@ -540,5 +538,22 @@ 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. + + + diff --git a/doc/en/Gtk/TreeView.xml b/doc/en/Gtk/TreeView.xml index 93836cc29..1ac1d3016 100644 --- a/doc/en/Gtk/TreeView.xml +++ b/doc/en/Gtk/TreeView.xml @@ -275,9 +275,9 @@ For a example how to handle selection events see Sets a user function for determining where a column may be dropped when dragged. an object of type - an object of type - 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. + ignored + ignored + This overload is obsolete. New code should use the single parameter overload. @@ -460,8 +460,8 @@ For a example how to handle selection events see 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 - an object of type - an object of type + ignored + ignored 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. @@ -478,11 +478,10 @@ For a example how to handle selection events see Sets the compare function for the interactive search capabilities. - The representing the node - an object of type - an object of type - - + The to invoke. + ignored + ignored + This overload is obsolete. New code should use the single parameter overload. @@ -1830,5 +1829,52 @@ 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. + + - \ No newline at end of file + diff --git a/gtk/ActionGroup.custom b/gtk/ActionGroup.custom index 2a1a0f2ab..7375649f5 100644 --- a/gtk/ActionGroup.custom +++ b/gtk/ActionGroup.custom @@ -84,3 +84,17 @@ 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/EntryCompletion.custom b/gtk/EntryCompletion.custom index ca4121446..2b77ba8bf 100644 --- a/gtk/EntryCompletion.custom +++ b/gtk/EntryCompletion.custom @@ -33,7 +33,7 @@ } [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); + 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) { @@ -47,3 +47,18 @@ 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/Gtk.metadata b/gtk/Gtk.metadata index 26bf89d59..2de6ea423 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -49,8 +49,10 @@ 1 1 1 + 1 1 1 + 1 out out 1 @@ -122,6 +124,7 @@ 1 1 Remove + 1 action_group action proxy @@ -197,6 +200,7 @@ ClipboardCopied ClipboardCut ClipboardPasted + 1 1 1 1 @@ -229,6 +233,7 @@ 1 GetItem GetWidget + 1 Deselected Selected Toggled @@ -243,6 +248,7 @@ out out ref + 1 1 1 1 @@ -359,6 +365,7 @@ out 1 call + 1 1 1 1 @@ -367,6 +374,7 @@ 1 1 ref + 1 1 1 1 @@ -396,6 +404,9 @@ call ActivateRow GetRowExpanded + 1 + 1 + 1 ScrollAdjustmentsSet 1 1 diff --git a/gtk/Input.custom b/gtk/Input.custom new file mode 100644 index 000000000..c3d81cd87 --- /dev/null +++ b/gtk/Input.custom @@ -0,0 +1,90 @@ +// Gtk.Input.custom - Gtk Input 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 uint gtk_input_add_full(int source, int condition, InputFunctionNative function, GtkSharp.CallbackMarshalNative marshal, IntPtr data, NativeDestroyNotify destroy); + + [GLib.CDeclCallback] + delegate void InputFunctionNative(IntPtr data, int source, int condition); + + class InputFunctionWrapper { + + public void NativeCallback (IntPtr data, int source, int condition) + { + IntPtr _arg0 = data; + int _arg1 = source; + Gdk.InputCondition _arg2 = (Gdk.InputCondition) condition; + managed ( _arg0, _arg1, _arg2); + } + + internal InputFunctionNative NativeDelegate; + Gdk.InputFunction managed; + + public InputFunctionWrapper (Gdk.InputFunction managed) + { + this.managed = managed; + if (managed != null) + NativeDelegate = new InputFunctionNative (NativeCallback); + } + } + + class InputProxy { + + InputFunctionWrapper function; + GtkSharp.CallbackMarshalWrapper marshal; + IntPtr data; + DestroyNotify destroy; + NativeDestroyNotify handler; + + public InputProxy (InputFunctionWrapper function, GtkSharp.CallbackMarshalWrapper marshal, IntPtr data, DestroyNotify destroy) + { + this.marshal = marshal; + this.function = function; + this.destroy = destroy; + this.data = data; + handler = new NativeDestroyNotify (OnDestroy); + } + + void OnDestroy (IntPtr data) + { + if (destroy != null) + destroy (); + + GCHandle gch = (GCHandle) data; + gch.Free (); + } + + public NativeDestroyNotify Handler { + get { + return handler; + } + } + } + + [Obsolete] + public static uint AddFull(int source, Gdk.InputCondition condition, Gdk.InputFunction function, Gtk.CallbackMarshal marshal, IntPtr data, Gtk.DestroyNotify destroy) { + InputFunctionWrapper function_wrapper = new InputFunctionWrapper (function); + GtkSharp.CallbackMarshalWrapper marshal_wrapper = new GtkSharp.CallbackMarshalWrapper (marshal); + InputProxy proxy = new InputProxy (function_wrapper, marshal_wrapper, data, destroy); + GCHandle gch = GCHandle.Alloc (proxy); + return gtk_input_add_full (source, (int) condition, function_wrapper.NativeDelegate, marshal_wrapper.NativeDelegate, (IntPtr) gch, proxy.Handler); + } + diff --git a/gtk/ItemFactory.custom b/gtk/ItemFactory.custom index aae5f7013..061544576 100644 --- a/gtk/ItemFactory.custom +++ b/gtk/ItemFactory.custom @@ -36,3 +36,23 @@ 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.")] + public void SetTranslateFunc (TranslateFunc func, IntPtr data, DestroyNotify notify) + { + SetTranslateFunc (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/Makefile.am b/gtk/Makefile.am index 9f8a295f0..1e7d95e0d 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -24,6 +24,7 @@ sources = \ StockManager.cs \ ThreadNotify.cs \ ToggleActionEntry.cs \ + Timeout.cs \ TreeNodeAttribute.cs \ TreeNode.cs \ TreeNodeValueAttribute.cs @@ -63,6 +64,7 @@ customs = \ Image.custom \ ImageMenuItem.custom \ Init.custom \ + Input.custom \ InputDialog.custom \ ItemFactory.custom \ Label.custom \ diff --git a/gtk/Timeout.cs b/gtk/Timeout.cs new file mode 100644 index 000000000..6c5d84f96 --- /dev/null +++ b/gtk/Timeout.cs @@ -0,0 +1,74 @@ +// Gtk.Timeout.cs - Gtk Timeout implementation. +// +// 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. + +namespace Gtk { + + using System; + using System.Runtime.InteropServices; + + [Obsolete ("Replaced by GLib.Timeout")] + public class Timeout { + + [Obsolete ("Replaced by GLib.Source.Remove")] + public static void Remove (uint timeout_handler_id) + { + GLib.Source.Remove (timeout_handler_id); + } + + [Obsolete ("Replaced by GLib.Timeout.Add")] + public static uint AddFull (uint interval, Gtk.Function function, Gtk.CallbackMarshal marshal, IntPtr data, Gtk.DestroyNotify destroy) + { + if (marshal != null || destroy != null) + Console.WriteLine ("marshal, data, and destroy parameters ignored by Gtk.Timeout.AddFull ()."); + return Add (interval, function); + } + + class GTimeoutProxy { + + GLib.TimeoutHandler handler; + Function function; + + public GTimeoutProxy (Gtk.Function function) + { + this.function = function; + handler = new GLib.TimeoutHandler (Invoke); + } + + public GLib.TimeoutHandler Handler { + get { + return handler; + } + } + + bool Invoke () + { + return function (); + } + } + + [Obsolete ("Replaced by GLib.Timeout.Add")] + public static uint Add (uint interval, Gtk.Function function) + { + GTimeoutProxy proxy = new GTimeoutProxy (function); + return GLib.Timeout.Add (interval, proxy.Handler); + } + } +} + diff --git a/gtk/TreeSelection.custom b/gtk/TreeSelection.custom index 34c0f9ece..55c962759 100644 --- a/gtk/TreeSelection.custom +++ b/gtk/TreeSelection.custom @@ -53,3 +53,23 @@ 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.")] + public void SetSelectFunction (Gtk.TreeSelectionFunc func, IntPtr data, Gtk.DestroyNotify destroy) + { + SetSelectFunction (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/TreeView.custom b/gtk/TreeView.custom index 628a501c3..af279884b 100644 --- a/gtk/TreeView.custom +++ b/gtk/TreeView.custom @@ -162,3 +162,63 @@ 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.")] + public void SetSearchEqualFunc (TreeViewSearchEqualFunc search_equal_func, IntPtr search_user_data, DestroyNotify search_destroy) + { + SetSearchEqualFunc (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.")] + public void SetDestroyCountFunc (TreeDestroyCountFunc func, IntPtr data, DestroyNotify destroy) + { + SetDestroyCountFunc (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.")] + public void SetColumnDragFunction (TreeViewColumnDropFunc func, IntPtr user_data, DestroyNotify destroy) + { + SetColumnDragFunction (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); + } +