diff --git a/gtk/IconTheme.cs b/gtk/IconTheme.cs index 524cfd7e2..e8581ab1e 100644 --- a/gtk/IconTheme.cs +++ b/gtk/IconTheme.cs @@ -23,7 +23,7 @@ namespace Gtk { using System; - using System.Collections; + using System.Collections.Generic; using System.Runtime.InteropServices; public partial class IconTheme { @@ -117,7 +117,7 @@ namespace Gtk { { IntPtr icon_name_as_native = GLib.Marshaller.StringToPtrGStrdup (icon_name); IntPtr raw_ret = gtk_icon_theme_get_icon_sizes(Handle, icon_name_as_native); - ArrayList result = new ArrayList (); + var result = new List (); int offset = 0; int size = Marshal.ReadInt32 (raw_ret, offset); while (size != 0) { @@ -127,7 +127,7 @@ namespace Gtk { } GLib.Marshaller.Free (icon_name_as_native); GLib.Marshaller.Free (raw_ret); - return (int[]) result.ToArray (typeof (int)); + return result.ToArray (); } } } diff --git a/gtk/Image.cs b/gtk/Image.cs index 8c85ae905..79f33c78c 100644 --- a/gtk/Image.cs +++ b/gtk/Image.cs @@ -22,7 +22,7 @@ namespace Gtk { using System; - using System.Collections; + using System.Collections.Generic; using System.Runtime.InteropServices; public partial class Image { @@ -33,13 +33,13 @@ namespace Gtk { public Image (Gtk.IconSet icon_set, Gtk.IconSize size) : base (IntPtr.Zero) { if (GetType () != typeof (Image)) { - ArrayList vals = new ArrayList(); - ArrayList names = new ArrayList(); + var vals = new List (); + var names = new List (); names.Add ("icon_set"); vals.Add (new GLib.Value (icon_set)); names.Add ("icon_size"); vals.Add (new GLib.Value ((int)size)); - CreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value))); + CreateNativeObject (names.ToArray (), vals.ToArray ()); return; } Raw = gtk_image_new_from_icon_set(icon_set.Handle, (int) size); @@ -51,13 +51,13 @@ namespace Gtk { public Image (string stock_id, Gtk.IconSize size) : base (IntPtr.Zero) { if (GetType () != typeof (Image)) { - ArrayList vals = new ArrayList(); - ArrayList names = new ArrayList(); + var vals = new List (); + var names = new List (); names.Add ("stock"); vals.Add (new GLib.Value (stock_id)); names.Add ("icon_size"); vals.Add (new GLib.Value ((int)size)); - CreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value))); + CreateNativeObject (names.ToArray (), vals.ToArray ()); return; } IntPtr native = GLib.Marshaller.StringToPtrGStrdup (stock_id); diff --git a/gtk/NodeStore.cs b/gtk/NodeStore.cs index 308db171f..db249191d 100644 --- a/gtk/NodeStore.cs +++ b/gtk/NodeStore.cs @@ -24,6 +24,7 @@ namespace Gtk { using System; using System.Collections; + using System.Collections.Generic; using System.Reflection; using System.Runtime.InteropServices; @@ -107,7 +108,7 @@ namespace Gtk { if (tna != null) list_only = tna.ListOnly; - ArrayList minfos = new ArrayList (); + var minfos = new List (); foreach (PropertyInfo pi in type.GetProperties ()) foreach (TreeNodeValueAttribute attr in pi.GetCustomAttributes (typeof (TreeNodeValueAttribute), false)) @@ -199,12 +200,12 @@ namespace Gtk { #endregion #region Gtk.TreeIter handling - ArrayList gc_handles = new ArrayList (); + IList gc_handles = new List (); protected override void Dispose (bool disposing) { // Free all the GCHandles pointing to the iters since they won't be garbage collected - foreach (System.Runtime.InteropServices.GCHandle handle in gc_handles) + foreach (GCHandle handle in gc_handles) handle.Free (); base.Dispose (disposing); diff --git a/gtk/Widget.cs b/gtk/Widget.cs index c34896135..fef270712 100644 --- a/gtk/Widget.cs +++ b/gtk/Widget.cs @@ -24,7 +24,7 @@ namespace Gtk { using System; - using System.Collections; + using System.Collections.Generic; using System.Runtime.InteropServices; public partial class Widget { @@ -134,10 +134,11 @@ namespace Gtk { } } - /* As gtk_binding_entry_add_signall only allows passing long, double and string parameters to the specified signal, we cannot pass a pointer to the BindingInvoker directly - * to the signal. Instead, the signal takes the index of the BindingInvoker in binding_invokers. - */ - static ArrayList binding_invokers; + /* As gtk_binding_entry_add_signall only allows passing long, double and string parameters + * to the specified signal, we cannot pass a pointer to the BindingInvoker directly to the signal. + * Instead, the signal takes the index of the BindingInvoker in binding_invokers. + */ + static IList binding_invokers; static void BindingMarshal_cb (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) { @@ -148,7 +149,7 @@ namespace Gtk { inst_and_params [idx] = (GLib.Value) Marshal.PtrToStructure (new IntPtr (param_values.ToInt64 () + idx * gvalue_size), typeof (GLib.Value)); Widget w = inst_and_params [0].Val as Widget; - BindingInvoker invoker = binding_invokers [(int) (long) inst_and_params [1]] as BindingInvoker; + BindingInvoker invoker = binding_invokers [(int) (long) inst_and_params [1]]; invoker.Invoke (w); } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException (e, false); @@ -197,7 +198,7 @@ namespace Gtk { RegisterSignal (signame, gtype, GLib.Signal.Flags.RunLast | GLib.Signal.Flags.Action, GLib.GType.None, new GLib.GType[] {GLib.GType.Long}, BindingDelegate); if (binding_invokers == null) - binding_invokers = new ArrayList (); + binding_invokers = new List (); foreach (BindingAttribute attr in attrs) { System.Reflection.MethodInfo mi = t.GetMethod (attr.Handler, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public); @@ -206,7 +207,10 @@ namespace Gtk { GtkBindingArg arg = new GtkBindingArg (); arg.arg_type = GLib.GType.Long.Val; - int binding_invoker_idx = binding_invokers.Add (new BindingInvoker (mi, attr.Parms)); + + var bi = new BindingInvoker (mi, attr.Parms); + binding_invokers.Add (bi); + int binding_invoker_idx = binding_invokers.IndexOf (bi); #if WIN64LONGS arg.data.long_data = binding_invoker_idx; #else @@ -296,15 +300,11 @@ namespace Gtk { Path (out len, out path, out path_reversed); } - -// Code from custom code for Gtk.Object in 2.x -// Object is gone in 3.x - - static Hashtable destroy_handlers; - static Hashtable DestroyHandlers { + static IDictionary destroy_handlers; + static IDictionary DestroyHandlers { get { if (destroy_handlers == null) - destroy_handlers = new Hashtable (); + destroy_handlers = new Dictionary (); return destroy_handlers; } } @@ -320,7 +320,7 @@ namespace Gtk { [GLib.DefaultSignalHandler(Type=typeof(Gtk.Widget), ConnectionMethod="OverrideDestroyed")] protected virtual void OnDestroyed () { - if (DestroyHandlers.Contains (Handle)) { + if (DestroyHandlers.ContainsKey (Handle)) { EventHandler handler = (EventHandler) DestroyHandlers [Handle]; handler (this, EventArgs.Empty); DestroyHandlers.Remove (Handle);