diff --git a/ChangeLog b/ChangeLog index 7b11a38b2..1fd3ff714 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-10-09 Mike Kestner + + * configure.in.in: kill dead config.in. + * sample/CairoSample.cs: some dispose handling and cleanup. + * sample/cairo-sample.exe.config.in: kill, no pinvoke needed now. + * sample/GException.cs: GException test sample. + * sample/GtkCairo.cs: kill, replaced by Gdk.CairoHelper.Create. + * sample/Makefile.am: cleanup. + 2008-10-08 Mike Gorse * Atk/Makefile.am, Atk/ObjectFactory.custom, Atk/glue/Makefile.am, diff --git a/configure.in.in b/configure.in.in index 287cdc503..2208c2553 100644 --- a/configure.in.in +++ b/configure.in.in @@ -258,7 +258,6 @@ sample/valtest/Makefile sample/valtest/valtest.exe.config sample/opaquetest/Makefile sample/opaquetest/opaquetest.exe.config -sample/cairo-sample.exe.config ]) echo "---" diff --git a/sample/CairoSample.cs b/sample/CairoSample.cs index 78c037ddc..abc39d31f 100644 --- a/sample/CairoSample.cs +++ b/sample/CairoSample.cs @@ -41,19 +41,19 @@ class Knockout : DrawingArea Surface check = cr.Target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE); // draw the check - Context cr2 = new Context (check); - cr2.Operator = Operator.Source; - cr2.Color = new Color (0.4, 0.4, 0.4); - cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE); - cr2.Fill (); + using (Context cr2 = new Context (check)) { + cr2.Operator = Operator.Source; + cr2.Color = new Color (0.4, 0.4, 0.4); + cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE); + cr2.Fill (); - cr2.Color = new Color (0.7, 0.7, 0.7); - cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE); - cr2.Fill (); + cr2.Color = new Color (0.7, 0.7, 0.7); + cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE); + cr2.Fill (); - cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE); - cr2.Fill (); - //cr2.Destroy (); + cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE); + cr2.Fill (); + } // Fill the whole surface with the check SurfacePattern check_pattern = new SurfacePattern (check); @@ -98,33 +98,32 @@ class Knockout : DrawingArea cr.Save (); // Draw a black circle on the overlay - Context cr_overlay = new Context (overlay); - cr_overlay.Color = new Color (0.0, 0.0, 0.0); - OvalPath (cr_overlay, xc, yc, radius, radius); - cr_overlay.Fill (); + using (Context cr_overlay = new Context (overlay)) { + cr_overlay.Color = new Color (0.0, 0.0, 0.0); + OvalPath (cr_overlay, xc, yc, radius, radius); + cr_overlay.Fill (); - // Draw 3 circles to the punch surface, then cut - // that out of the main circle in the overlay - Context cr_tmp = new Context (punch); - Draw3Circles (cr_tmp, xc, yc, radius, 1.0); - //cr_tmp.Destroy (); + // Draw 3 circles to the punch surface, then cut + // that out of the main circle in the overlay + using (Context cr_tmp = new Context (punch)) + Draw3Circles (cr_tmp, xc, yc, radius, 1.0); - cr_overlay.Operator = Operator.DestOut; - cr_overlay.SetSourceSurface (punch, 0, 0); - cr_overlay.Paint (); + cr_overlay.Operator = Operator.DestOut; + cr_overlay.SetSourceSurface (punch, 0, 0); + cr_overlay.Paint (); - // Now draw the 3 circles in a subgroup again - // at half intensity, and use OperatorAdd to join up - // without seams. - Context cr_circles = new Context (circles); - cr_circles.Operator = Operator.Over; - Draw3Circles (cr_circles, xc, yc, radius, 0.5); - // cr_circles.Destroy (); + // Now draw the 3 circles in a subgroup again + // at half intensity, and use OperatorAdd to join up + // without seams. + using (Context cr_circles = new Context (circles)) { + cr_circles.Operator = Operator.Over; + Draw3Circles (cr_circles, xc, yc, radius, 0.5); + } - cr_overlay.Operator = Operator.Add; - cr_overlay.SetSourceSurface (circles, 0, 0); - cr_overlay.Paint (); - // cr_overlay.Destroy (); + cr_overlay.Operator = Operator.Add; + cr_overlay.SetSourceSurface (circles, 0, 0); + cr_overlay.Paint (); + } cr.SetSourceSurface (overlay, 0, 0); cr.Paint (); @@ -136,14 +135,11 @@ class Knockout : DrawingArea protected override bool OnExposeEvent (Gdk.EventExpose e) { - #if GTK_SHARP_2_8 - Context cr = Gdk.CairoHelper.Create (e.Window); - #else - Context cr = Gdk.Graphics.CreateDrawable (e.Window); - #endif - int w, h; - e.Window.GetSize (out w, out h); - Draw (cr, w, h); + using (Context cr = Gdk.CairoHelper.Create (e.Window)) { + int w, h; + e.Window.GetSize (out w, out h); + Draw (cr, w, h); + } return true; } diff --git a/sample/DrawingSample.cs b/sample/DrawingSample.cs index 2db68934c..d5ead7d6e 100644 --- a/sample/DrawingSample.cs +++ b/sample/DrawingSample.cs @@ -1,5 +1,5 @@ // -// Sample program demostrating using Cairo with Gtk# +// Sample program demostrating using System.Drawing with Gtk# // using Gtk; using System; diff --git a/sample/GExceptionTest.cs b/sample/GExceptionTest.cs new file mode 100755 index 000000000..dd069b2fc --- /dev/null +++ b/sample/GExceptionTest.cs @@ -0,0 +1,24 @@ +// HelloWorld.cs - GTK Window class Test implementation +// +// Author: Mike Kestner +// +// (c) 2001-2002 Mike Kestner + +namespace GtkSamples { + + using Gtk; + using Gdk; + using System; + + public class GExceptionTest { + + public static int Main (string[] args) + { + Application.Init (); + Gtk.Window win = new Gtk.Window ("GException"); + win.SetIconFromFile ("this.filename.does.not.exist"); + // Notreached, GException should throw on above call. + return 0; + } + } +} diff --git a/sample/GtkCairo.cs b/sample/GtkCairo.cs deleted file mode 100644 index 14902fbde..000000000 --- a/sample/GtkCairo.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// -// GDK-X11 interface -// - -// -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Reflection; -using System.Runtime.InteropServices; -using Gtk; -using Cairo; - -namespace Gdk -{ - public class Graphics - { - //Use [DllImport("libgdk-win32-2.0-0.dll")] for Win32 - [DllImport("libgdk-x11-2.0.so")] - internal static extern IntPtr gdk_x11_drawable_get_xdisplay (IntPtr raw); - - [DllImport("libgdk-x11-2.0.so")] - internal static extern IntPtr gdk_x11_drawable_get_xid (IntPtr raw); - - [DllImport("libgdk-x11-2.0.so")] - internal static extern IntPtr gdk_drawable_get_visual (IntPtr raw); - - [DllImport("libgdk-x11-2.0.so")] - internal static extern IntPtr gdk_x11_visual_get_xvisual (IntPtr raw); - - [DllImport("libgdk-x11-2.0.so")] - internal static extern IntPtr gdk_cairo_create (IntPtr raw); - - public static Cairo.Context CreateDrawable (Gdk.Drawable drawable) - { - IntPtr x_drawable = IntPtr.Zero; - int x_off = 0, y_off = 0; - - int x, y, w, h, d; - ((Gdk.Window)drawable).GetGeometry(out x, out y, out w, out h, out d); - - bool is_gdk_window = drawable is Gdk.Window; - if (is_gdk_window) - ((Gdk.Window) drawable).GetInternalPaintInfo(out drawable, - out x_off, out y_off); - - x_drawable = drawable.Handle; - IntPtr visual = gdk_drawable_get_visual(x_drawable); - - IntPtr Xdisplay = gdk_x11_drawable_get_xdisplay(x_drawable); - IntPtr Xvisual = gdk_x11_visual_get_xvisual(visual); - IntPtr Xdrawable = gdk_x11_drawable_get_xid (x_drawable); - - Cairo.XlibSurface s = new Cairo.XlibSurface (Xdisplay, - Xdrawable, - Xvisual, - w, h); - - Cairo.Context g = new Cairo.Context (s); - - // this can be safely removed now, just keep it for a bit more - //Cairo.Context g = new Cairo.Context ( - // gdk_cairo_create (x_drawable )); - - if (is_gdk_window) - g.Translate (-(double)x_off,-(double)y_off); - return g; - } - } -} diff --git a/sample/Makefile.am b/sample/Makefile.am index a786ca453..97bc805f5 100755 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -16,7 +16,7 @@ DOTNET_TARGETS= DOTNET_ASSEMBLY= endif -TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe spawn.exe assistant.exe registerprop.exe $(GLADE_TARGETS) $(DOTNET_TARGETS) +TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe spawn.exe assistant.exe registerprop.exe gexceptiontest.exe cairo-sample.exe $(GLADE_TARGETS) $(DOTNET_TARGETS) DEBUGS = $(addsuffix .mdb, $(TARGETS)) @@ -68,8 +68,8 @@ glade-viewer.exe: $(srcdir)/GladeViewer.cs $(assemblies) glade-test.exe: $(srcdir)/GladeTest.cs $(srcdir)/test.glade $(assemblies) $(CSC) /resource:$(srcdir)/test.glade,test.glade /out:glade-test.exe $(references) $(srcdir)/GladeTest.cs -cairo-sample.exe: $(srcdir)/CairoSample.cs $(srcdir)/GtkCairo.cs $(assemblies) - $(CSC) /out:cairo-sample.exe $(references) /r:Mono.Cairo $(srcdir)/CairoSample.cs $(srcdir)/GtkCairo.cs +cairo-sample.exe: $(srcdir)/CairoSample.cs $(assemblies) + $(CSC) /out:cairo-sample.exe $(references) /r:Mono.Cairo $(srcdir)/CairoSample.cs testdnd.exe: $(srcdir)/TestDnd.cs $(assemblies) $(CSC) /debug /unsafe /out:testdnd.exe $(references) $(srcdir)/TestDnd.cs @@ -100,6 +100,9 @@ assistant.exe: $(srcdir)/Assistant.cs $(assemblies) registerprop.exe: $(srcdir)/PropertyRegistration.cs $(assemblies) $(CSC) /out:registerprop.exe $(references) $(srcdir)/PropertyRegistration.cs +gexceptiontest.exe: $(srcdir)/GExceptionTest.cs $(assemblies) + $(CSC) /out:gexceptiontest.exe $(references) $(srcdir)/GExceptionTest.cs + EXTRA_DIST = \ HelloWorld.cs \ Assistant.cs \ @@ -115,6 +118,7 @@ EXTRA_DIST = \ TreeViewDemo.cs \ ManagedTreeViewDemo.cs \ NodeViewDemo.cs \ + GExceptionTest.cs \ GladeViewer.cs \ GladeTest.cs \ test.glade \ @@ -122,7 +126,6 @@ EXTRA_DIST = \ TestDnd.cs \ CustomCellRenderer.cs \ DrawingSample.cs \ - cairo-sample.exe.config \ CustomWidget.cs \ Actions.cs \ PropertyRegistration.cs \ diff --git a/sample/cairo-sample.exe.config.in b/sample/cairo-sample.exe.config.in deleted file mode 100644 index 0924374e0..000000000 --- a/sample/cairo-sample.exe.config.in +++ /dev/null @@ -1,6 +0,0 @@ - - - - - -