Commit graph

4034 commits

Author SHA1 Message Date
Stephan Sundermann 8e0de299e4 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.
2014-08-10 18:35:19 +02:00
Stephan Sundermann 961b9ef348 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.
2014-08-10 18:20:32 +02:00
Bertrand Lorentz fe0be81892 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.
2014-08-10 18:20:01 +02:00
Stephan Sundermann 280087e431 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.
2014-08-10 15:36:40 +02:00
Stephan Sundermann 1fab57eeac 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.
2014-08-10 15:33:50 +02:00
Bertrand Lorentz 7ea0c4afaf 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.
2014-07-05 16:16:58 +02:00
Bertrand Lorentz f5211acb74 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.
2014-07-05 16:07:39 +02:00
Bertrand Lorentz 813f56e00a 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.
2014-07-05 16:07:28 +02:00
Bertrand Lorentz 11920f2add 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.
2014-07-05 13:00:50 +02:00
Bertrand Lorentz 83b602320a Merge pull request #109 from bl8/master
Variant: Fix crash when casting a Variant to string
2014-06-17 21:34:04 +02:00
Xavier Claessens 9559f579e6 Variant: Fix crash when casting a Variant to string
If we don't pass NULL to the length argument it makes C
code write the length at random places in memory and bad
things happens.
2014-06-17 21:16:38 +02:00
Bertrand Lorentz a1636d306b Variant: Add a NewArray (Variant[] children) convenience method
This allows you to avoid ugly calls like "NewArray (null, some_array)"
when you want the child type to be determined by the first element of
the children array.

Also throw specific exceptions when both type and children parameters
would be null.
2014-06-13 13:10:48 +02:00
Bertrand Lorentz b605b42540 Variant: Small code formatting fix 2014-06-13 13:10:02 +02:00
Xavier Claessens c271fe235b VariantType: Fix typo 2014-06-12 16:57:42 -04:00
Xavier Claessens 4158bc99f8 Variant: Add Type property 2014-06-12 16:48:03 -04:00
Xavier Claessens dc0f50729a Variant: Add ToArray() and ToAsv() helpers 2014-06-12 16:08:36 -04:00
Xavier Claessens 4c72b23216 Add Variant sample 2014-06-12 13:22:44 -04:00
Xavier Claessens 893703018f Variant: Add wrapper to construct "a{sv}" variant 2014-06-12 13:22:44 -04:00
Xavier Claessens cef9b13d72 Variant: Add wrapper for g_variant_new_dict_entry() 2014-06-12 13:22:44 -04:00
Xavier Claessens 58fb7aa378 Variant: Add wrapper for g_variant_new_array() 2014-06-12 13:22:43 -04:00
Xavier Claessens 24f8cede19 Variant: Add wrapper for g_variant_new_tuple() 2014-06-12 13:22:43 -04:00
Xavier Claessens b5062a8c7d Variant: Add wrapper for g_variant_new_variant() 2014-06-12 13:22:43 -04:00
Xavier Claessens b357aaef84 Variant: Add wrapper for g_variant_new_strv() 2014-06-12 12:30:29 -04:00
Xavier Claessens c1fbe27b32 Variant: Add wrapper for g_variant_print() 2014-06-12 12:05:35 -04:00
Bertrand Lorentz bc40506cab Merge pull request #107 from xDarkice/ambiguousmatch
glib.Value: Make GetMethod more specific to avoid ambiguous matches
2014-06-10 18:32:06 +02:00
Stephan Sundermann 839a32d797 Value: Make GetMethod more specific to avoid ambigous matches
This patch prevents GetMethod from throwing an AmbiguousMatchException because several constructors were found.
2014-06-10 15:25:39 +02:00
Bertrand Lorentz 3c54b8d78e release: Fix indentation of NEWS 2014-06-06 15:48:07 +02:00
Bertrand Lorentz 9c2e74d826 release: Update NEWS for 2.99.3 release 2014-06-06 15:45:11 +02:00
Bertrand Lorentz 34400a254b cairo: Remove FormatStrideForWidth and PathExtents methods from Context
Those methods are not in Mono.Cairo, and are not necessary for Gtk#, so
I'm assuming they are not really needed.

The idea is to have the same API as Mono.Cairo shipped with mono, so if
you need those methods, get them first in Mono.Cairo available at
https://github.com/mono/mono

Also move the HasCurrentPoint property to its logical place in the
source, next to CurrentPoint.
2014-05-30 16:21:53 +02:00
Bertrand Lorentz ae624a0048 GtkDemo: Add demo for theming style classes
This also demonstrates the use of Gtk.Builder to load .ui files.

Also simplify handling of resources in GtkDemo build: we don't need to
make a distinction between images and other resources.
2014-05-30 14:42:32 +02:00
Bertrand Lorentz f6003f94a4 GtkDemo: Add a CssBasics demo to demonstrate CSS theming
The main difference with the C demo is that we can't use GResource, as
it's only in gio 2.32 and later, so '@import url("resource://...' won't
work. Instead, we use a separate CssProvider to apply reset.css.
2014-05-29 21:44:49 +02:00
Bertrand Lorentz c15a1d18b5 GtkDemo: Add a Spinner demo
As the other samples in GtkDemo, this is straight translation of the C
demos in the GTK+ source tree under demos/gtk-demo/.
2014-05-29 18:25:42 +02:00
Andrés G. Aragoneses e52ff66c9d .gitignore: add autotools' compile
Since automake 1.14, autotools now generate a symbolic link named
`compile` in the root of the repository when running, so let's include
it in .gitignore to achieve a clean `git status` after compiling (or
avoid breaking the build via `git clean -fd`).

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-05-29 17:34:22 +02:00
Stephan Sundermann f38daf0d49 glib: Add GVariant to fundamental types
GVariant is a fundamental type since 2.26, this commit adds it to the
fundamental type list and adds operators to construct and convert from
and to a GValue.

https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#G-TYPE-VARIANT:CAPS

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-05-29 17:11:47 +02:00
Bertrand Lorentz b6e95af4a3 sample: Fix GtkDemo/DemoImages progressive update with recent gtk+ 2014-05-25 17:20:11 +02:00
Bertrand Lorentz c9c2d099ba Update the Windows installer infrastructure for GTK+ 3
Port the current installer infrastructure from the gtk-sharp-2-12
branch, adapting it as needed. Credits go to Duncan Mak for
maintaining the 2.12 installer in the past few years.

When building on Windows, if the WiX toolset is available, the msi is
generated automatically at the end of the build.
2014-05-24 17:30:18 +02:00
Bertrand Lorentz 233614e18b sample: Fix GtkDemo/DemoImages.cs on Windows
Calling .PeekChar on a binary stream can cause an ArgumentException
because it tries to decode the byte.
2014-05-24 17:25:42 +02:00
Bertrand Lorentz a6c9634748 build: Fix opaquetest build on Windows
Create 2 makefile variable to facilitate build on Windows:
GENERATED_SOURCES_FILES to match files created by the code generator,
and GENERATED_SOURCES_OPTION for the corresponding option to be passed
to the compiler.

Also adapt the makefile for the valtest sample to use these variables.
2014-05-24 17:25:39 +02:00
Andrés G. Aragoneses 3495ca286d configure: use canonical paths when comparing prefixes
A user reported in the mailing list [1] to be advised to use
`/usr/lib64/pkgconfig/../..` as a prefix. This path is too
convoluted, could give problems, and also shouldn't be the
one to be compared against the prefix flag used, so use
readlink -m to follow '..' subfolders to transform it, in
this example, to simply `/usr`

[1] http://lists.ximian.com/pipermail/gtk-sharp-list/2014-May/011436.html
2014-05-24 16:19:10 +02:00
Bertrand Lorentz b1215d430a build: Make libtoolize quiet, it's not that interesting 2014-05-24 15:42:08 +02:00
Bertrand Lorentz f719b82ede build: Tell libtoolize to put its m4 files in the m4 directory
Also have git ignore that m4 directory, as its content is generated by
autogen.sh.
2014-05-24 15:40:26 +02:00
Bertrand Lorentz 30f758d984 gdk: Fix dll name and use a const for all DllImports in custom code
In Windows builds of GTK+ 3.x, the dll filename for GDK is
libgdk-3-0.dll.

We use this opportunity to use a common const in the DllImport for all
custom code.
2014-05-04 17:30:26 +02:00
Stephan Sundermann 016891bb7a generator: Fix generation of SetGValue method
Some types need special methods to convert an object to a GLib.Value.
The type system will look for a SetGValue method with a "ref GLib.Value"
parameter and invoke it.

A special case in the generation is needed because this is a non-static
method with the Handle being passed as the second parameter and the
GLib.Value as the first. Without this fix, the generator would generate
the Handle for the first parameter and then the GLib.Value.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-27 15:15:15 +02:00
Marcin Kolny dee590926a build: Add a pkg-config file for gdk-sharp-3.0
This allows consumers to specifically require gdk-sharp-3.0 without
having to pull in the full gtk-sharp-3.0.

Closes issue #101.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-21 21:36:57 +02:00
Stephan Sundermann 40b90d2407 generator: Add new keyword to GType property if it hides parent
If the parent already has a GType property, add a "new" keywords to hide
it.

This eliminates a lot of warnings when using classes derived from
Opaque. Closes issue #100.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-21 20:50:18 +02:00
Stephan Sundermann 0563af1c25 generator: Fix handle being passed when type is a struct
A static getter method would always generate a Handle parameter even
though some types do not have a Handle, for example structs.

Closes issue #99.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-21 18:23:48 +02:00
Stephan Sundermann 06b966beef generator: Add support for fixed length arrays as method parameters
Fixed length arrays are available in gobject introspection and are
already converted by the bindinator tool. The array_len attribute was
only used in structs.

This adds support for them as method parameters, generating the correct
code for them. Fixes issue #98.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-21 17:23:32 +02:00
Bertrand Lorentz 87275786b7 gapi.xsd: Fix type of array_len attribute in fieldType 2014-04-21 17:22:54 +02:00
Gankov Andrey 1da92bdd62 gtk: Add ListStore.SetValue overload for long type
Without that change, using ListStore.SetValue with a long would use the
float overload, which might not be expected and cause some issues.

Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
2014-04-21 16:50:21 +02:00
Bertrand Lorentz 80485a464d build: Fix Makefile of valtest and opaquetest samples
Some parts were not taking into account the fact that the generated code
is now in a subfolder.
2014-04-21 16:24:08 +02:00