Merge pull request #109 from bl8/master

Variant: Fix crash when casting a Variant to string
glib: Re-organize code in Source for better readability

Move stuff around to have them in a reasonable order: fields, then
constructors, then destructor, then static methods, then instance stuff.
Also remove a commented out method, which would not be correct anyway.

No real code change here, just cosmetic changes.
glib: Refactor Source, Idle and Timeout classes

Turn Source.source_handlers into a private generic Dictionary, and add
the necessary methods to allow Idle and Timeout to add and remove
entries from it.

This improves the encapsulation of the Source class, and factors
into it some code that was previously duplicated in Idle and Timeout.
glib: Have SourceProxy implement the Dispose pattern

Its 2 subclasses, IdleProxy and TimeoutProxy, were already implementing
it, so we factor this implementation into the base class.
glib: Fix native GLib warnings when disposing SourceProxy objects

When an instance of SourceProxy was finalized, we would try to remove
the corresponding source, even if it was already removed. This now
causes native GLib to print out warnings because it can't find the
source ID.

Now Source.Remove only calls g_source_remove if we really had a handler
registered for the ID we're removing.
Value: First try to invoke a constructor with IntPtr, bool

In Cairo there the default constructor does not take a ref to the native
object making the object invalid when trying to access it.

This commit changes the behaviour to search for another constructor that
takes an owner variable which is set to false when invoked to indicate
that the managed side should take a ref.
Value: Don't try to marshal if type has no StructLayout

If the StructLayout is not set, StructureToPtr will throw an exception.
In these cases the type is probably wrapped using a handle and thus
needs no update.
build: Require GLib 2.32 or above

GLib 2.32 has been released in March 2012, so we can now require it a
build and run time. This allows us to remove GLib 2.31 conditionals,
mark the Thread.Init as obsolete, and remove all references to
libgthread.

Please note that the API exposed in glib and gio is still from 2.28, but
we will have some API additions in the future. First example is the next
commit, which brings GBytes, an addition in GLib 2.32.
glib: Add binding for GBytes

This patch adds bindings for GBytes https://developer.gnome.org/glib/stable/glib-Byte-Arrays.html

The code was first generated using gobject-introspection and then
refactored. The new type is also added to the generator SymbolTable.
generator: Set Owned to false when ownership of a parameter changes

This fixes an issue where unref would get called too often because the
ownership has changed when passing an instance to the native side.

See https://github.com/mono/gtk-sharp/pull/112 for more details.
build: Post-release version bump to 2.99.4

Better late than never.
build: Fix distcheck by adding VariantDemo.cs in the tarball
glib: In Value.Update, check if val is null before updating

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
csproj: Fix assembly names and include *.dll.config in output

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
gtk: Use the same behavior in Builder constructor overloads

Each overload needs to call Assembly.GetCallingAssembly () explicitly,
otherwise the calling assembly would end up being gtk-sharp.
gtk: Fix Builder xml definition loading

Gtk.Builder crashes when AddFromString(string) is called with a string
that contains a BOM. Hence, if the buffer contains a BOM, just skip it.

This fixes the crash with the Gtk# 3 project template in MonoDevelop
(robpvn/MonoDevelopGtkSharp3Template).
glib: Check for self-assignment of Opaque.Raw property

This avoids unnecessary work, and prevents the IntPtr from being
freed when assigned to itself.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>