4 using bytex64.WebThing;
6 public class LoadThrobber : Gtk.DrawingArea {
12 public Mode LoadState;
16 public LoadThrobber(WebThing wt) {
17 LoadState = Mode.LoadStarted;
19 SetSizeRequest(64, 64);
22 public void AttachSignals(WebView wv) {
23 wv.LoadStarted += WebView_LoadStarted;
24 wv.LoadCommitted += WebView_LoadCommitted;
25 wv.LoadProgressChanged += WebView_LoadProgressChanged;
26 wv.LoadFinished += WebView_LoadFinished;
29 protected override bool OnExposeEvent(Gdk.EventExpose e) {
30 Gdk.Window w = e.Window;
31 Gdk.GC gc = new Gdk.GC(w);
33 w.GetSize(out width, out height);
35 gc.Foreground = new Gdk.Color(0, 0, 0);
36 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
40 case Mode.LoadStarted:
41 w.DrawArc(gc, false, 4, 4, width-8, width-8, -r*64, 90*64);
42 w.DrawArc(gc, false, 4, 4, width-8, width-8, -r*64 + 180*64, 90*64);
45 case Mode.LoadInProgress:
46 case Mode.LoadFinished:
47 w.DrawArc(gc, false, 4, 4, width-8, width-8, 90*64, -r*64);
53 void WebView_LoadStarted(object o, LoadStartedArgs e) {
55 Console.WriteLine("Loading Started");
56 LoadState = Mode.LoadStarted;
57 idletimer = GLib.Timeout.Add(100, delegate {
63 void WebView_LoadCommitted(object o, LoadCommittedArgs e) {
64 Console.WriteLine("Loading Committed");
65 LoadState = Mode.LoadInProgress;
66 GLib.Source.Remove(idletimer);
71 void WebView_LoadProgressChanged(object o, LoadProgressChangedArgs e) {
72 Console.WriteLine("Loading Progress: {0}", e.Progress);
73 r = (int) ((e.Progress / 100.0) * 360);
77 void WebView_LoadFinished(object o, LoadFinishedArgs e) {
78 Console.WriteLine("Loading Finished");
79 LoadState = Mode.LoadFinished;
84 public class LoadThrobberPlugin : WebThingPlugin {
87 public override void Init(WebThing wt) {
88 lt = new LoadThrobber(wt);
89 wt.AttachWidget(lt, CompassDirection.Interior);
92 public override void InitWebView(WebView wv) {