4 using bytex64.WebThing;
6 public class LoadThrobber : Gtk.DrawingArea {
12 public Mode LoadState;
16 public LoadThrobber(WebThing wt) {
17 LoadState = Mode.LoadStarted;
19 wt.WebView.LoadStarted += WebView_LoadStarted;
20 wt.WebView.LoadCommitted += WebView_LoadCommitted;
21 wt.WebView.LoadProgressChanged += WebView_LoadProgressChanged;
22 wt.WebView.LoadFinished += WebView_LoadFinished;
24 SetSizeRequest(64, 64);
27 protected override bool OnExposeEvent(Gdk.EventExpose e) {
28 Gdk.Window w = e.Window;
29 Gdk.GC gc = new Gdk.GC(w);
31 w.GetSize(out width, out height);
33 gc.Foreground = new Gdk.Color(0, 0, 0);
34 gc.SetLineAttributes(3, Gdk.LineStyle.Solid, Gdk.CapStyle.Butt, Gdk.JoinStyle.Round);
38 case Mode.LoadStarted:
39 w.DrawArc(gc, false, 4, 4, width-8, width-8, -r*64, 90*64);
40 w.DrawArc(gc, false, 4, 4, width-8, width-8, -r*64 + 180*64, 90*64);
43 case Mode.LoadInProgress:
44 case Mode.LoadFinished:
45 w.DrawArc(gc, false, 4, 4, width-8, width-8, 90*64, -r*64);
51 void WebView_LoadStarted(object o, LoadStartedArgs e) {
53 Console.WriteLine("Loading Started");
54 LoadState = Mode.LoadStarted;
55 idletimer = GLib.Timeout.Add(100, delegate {
61 void WebView_LoadCommitted(object o, LoadCommittedArgs e) {
62 Console.WriteLine("Loading Committed");
63 LoadState = Mode.LoadInProgress;
64 GLib.Source.Remove(idletimer);
69 void WebView_LoadProgressChanged(object o, LoadProgressChangedArgs e) {
70 Console.WriteLine("Loading Progress: {0}", e.Progress);
71 r = (int) ((e.Progress / 100.0) * 360);
75 void WebView_LoadFinished(object o, LoadFinishedArgs e) {
76 Console.WriteLine("Loading Finished");
77 LoadState = Mode.LoadFinished;
82 public class LoadThrobberPlugin : WebThingPlugin {
83 public void Init(WebThing wt) {
84 LoadThrobber lt = new LoadThrobber(wt);
85 wt.AttachWidget(lt, CompassDirection.Interior);