[Gtk-sharp-list] Hello World help

Guenther Roith groith@tcrz.net
Mon, 11 Nov 2002 17:49:04 +0100


Hello!

This is the wrong solution.
Keep the + and instead, change line

static void Window_Delete(object obj, EventArgs args)

to

static void Window_Delete(object obj, DeleteEventArgs args)

adding the Delete before EventArgs

Johannes


----- Original Message -----
From: Fabian Vargas
To: Gtk# List
Sent: Monday, November 11, 2002 5:36 PM
Subject: [Gtk-sharp-list] Hello World help


Hi Guys
After a lot of struggling, I was finally able to install gtk sharp 0.5 but
when compiling the hello world example, I get the following message:
----
# mcs -r gtk-sharp -r glib-sharp hola.cs
hola.cs(15) error CS0019: Operator + cannot be applied to operands of type
`GtkSharp.DeleteEventHandler' and `System.EventHandler'
Compilation failed: 1 error(s), 0 warnings
---
So this is caused by the line:
win.DeleteEvent += new EventHandler (Window_Delete);
which apparently doesn't work with gtk# 0.5, so I tried installing gtk# 0.4
but it didn't work (and installing 0.5 was not easy so I'd really like it if
it worked).
So I changed the line to :
win.DeleteEvent = new EventHandler (Window_Delete);
and I got the following message:
----
# mcs -r gtk-sharp -r glib-sharp hola.cs
hola.cs(15) error CS0070: The event 'DeleteEvent' can only appear on the
left-side of a += or -= (except when used from within the type 'Gtk.Widget')
Compilation failed: 1 error(s), 0 warnings
----
So I just took the line off and it compiled, but when I run it the following
appears:
-----
mono hola.exe
** ERROR **: No GCHandle support built-in
aborting...
Aborted
----
So now I really don't know what to do, all the examples (button, menu,
conversion) have the same line.
Here's the complete code:
namespace GtkSamples {
 using Gtk;
 using Gdk;
 using GtkSharp;
 using System;
 using System.Drawing;

 public class Hola{
  public static int Main(string[] args)
  {
   Application.Init();
   Gtk.Window win = new Gtk.Window(Gtk.WindowType.Toplevel);
   win.Title = "Gtk# Hola!!!!";
   win.DeleteEvent += new EventHandler (Window_Delete);
   win.ShowAll();
   Application.Run();
   return 0;
  }
  static void Window_Delete(object obj, EventArgs args)
  {
   SignalArgs sa = (SignalArgs) args;
   Application.Quit();
   sa.RetVal = true;
  }
}
This is what I installed (all downloaded Nov 9-10) in the order I did it:
pkgconfig-0.14.0
glib-2.0.7
pango-1.0.5
atk-1.0.3
libxml2-2.4.26
gtk+-2.0.8
mono-0.16
gtk-sharp-0.5
I'm running a SuSE 8 Linux System, the above installation also required some
packages which I installed from SuSE like gcc,libtool,autoconf,bison,X11,
etc
Any help I'd appreciate, I have a mono conference tomorrow and I just want
to run a simple graphic example to demonstrate mono.
Thanks
Fabian