Hi all,
I'm having a problem with Gtk# 1.9.2 and gecko-sharp 0.6. Using the
two together produces a compile error:
"Cannot convert from 'Gecko.WebControl' to 'Gtk.Widget'"
when I try to add the WebControl to a VBox.
The simplest example of this is compiling the given demo cs file in
the Mono documentation for the WebControl object (also attached). This
demo compiles and works fine when you compile with gtk# 1.x but fails
if you try to compile against gtk# 2 (i.e. with -pkg:gtk-sharp-2.0):
$ mcs GeckoTest.cs -pkg:gtk-sharp-2.0 -pkg:gecko-sharp
GeckoTest.cs(65) error CS1502: The best overloaded match for method
'void Gtk.VBox.PackStart (Gtk.Widget, bool, bool, uint)' has some
invalid arguments
GeckoTest.cs(65) error CS1503: Argument 0: Cannot convert from
'Gecko.WebControl' to 'Gtk.Widget'
GeckoTest.cs(65) error CS1501: No overload for method `PackStart'
takes `4' arguments
Compilation failed: 3 error(s), 0 warnings
$ mcs --version
Mono C# compiler version 1.1.6.0
This is with:
Mono 1.1.6, gtk# 1.0.8 and 1.9.2 installed side-by-side
Mono installed via Gentoo ebuild and gtk from source. This worked fine
with Mono 1.0.6, so this may be a mono problem (maybe the compiler is
more picky?), but gtk# version seems to be the cause of the problem.
Any help would be much appreciated.
Regards,
Mike.
--
"One should not aim at being possible to
understand but at being impossible to
misunderstand." - Quintilian
using System;
using Gtk;
using Gecko;
namespace GeckoTest
{
class GeckoTest
{
WebControl moz;
Entry entry;
string currentUrl;
Statusbar sb;
ProgressBar pb;
static void Main (string[] args)
{
new GeckoTest ();
}
GeckoTest ()
{
Application.Init ();
Window win = new Window ("GeckoTest");
win.SetDefaultSize (800, 600);
win.DeleteEvent += new DeleteEventHandler (window_delete);
VBox vbox = new VBox (false, 1);
win.Add (vbox);
HBox tb = new HBox (true, 1);
Button btnBack = new Button (Gtk.Stock.GoBack);
btnBack.Clicked += new EventHandler (on_btnBack_clicked);
Button btnForward = new Button (Gtk.Stock.GoForward);
btnForward.Clicked += new EventHandler (on_btnForward_clicked);
Button btnStop = new Button (Gtk.Stock.Stop);
btnStop.Clicked += new EventHandler (on_btnStop_clicked);
Button btnRefresh = new Button (Gtk.Stock.Refresh);
btnRefresh.Clicked += new EventHandler (on_btnRefresh_clicked);
tb.Add (btnBack);
tb.Add (btnForward);
tb.Add (btnStop);
tb.Add (btnRefresh);
vbox.PackStart (tb, false, false, 1);
HBox hbox = new HBox (false, 1);
Label label = new Label ("Address:");
entry = new Entry ("URL");
entry.Activated += new EventHandler (entry_activated);
Button button = new Button ("GO!");
button.Clicked += new EventHandler (button_clicked);
hbox.PackStart (label, false, false, 1);
hbox.PackStart (entry, true, true, 1);
hbox.PackStart (button, false, false, 1);
vbox.PackStart (hbox, false, false, 1);
moz = new WebControl ("/tmp/csharp", "GeckoTest");
moz.LinkMsg += new EventHandler(on_moz_linkmessage);
vbox.PackStart(moz, true, true, 1);
HBox hbox2 = new HBox (false, 1);
vbox.PackStart (hbox2, false, false, 1);
sb = new Statusbar ();
sb.Push (1, "Welcome!");
hbox2.Add (sb);
pb = new ProgressBar ();
pb.Orientation = ProgressBarOrientation.LeftToRight;
hbox2.Add (pb);
win.ShowAll ();
Application.Run ();
}
void window_delete (object obj, DeleteEventArgs args)
{
Application.Quit();
}
void button_clicked (object obj, EventArgs args)
{
LoadHtml (entry.Text.Trim());
}
void on_moz_linkmessage (object obj, EventArgs args)
{
sb.Pop (1);
sb.Push (1, moz.LinkMessage);
}
void entry_activated (object obj, EventArgs args)
{
button_clicked (obj, args);
}
void LoadHtml (string URL)
{
moz.LoadUrl (URL);
}
void on_btnBack_clicked (object obj, EventArgs args)
{
moz.GoBack();
}
void on_btnStop_clicked (object obj, EventArgs args)
{
moz.StopLoad();
}
void on_btnForward_clicked (object obj, EventArgs args)
{
moz.GoForward();
}
void on_btnRefresh_clicked (object obj, EventArgs args)
{
moz.Reload(0);
}
}
}