X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=plugins%2FLoadProgress.cs;h=d6355731480aead7ecb51440cd2bc7248a3ca304;hb=fc831a2ef0ae342cc73dee301e051bcfbbbeb82c;hp=9dc68383e9adf9ec5793d6d55a7b27569d84fbe2;hpb=1bff29702cf8ce8c1952d22243e4dc7a9df74105;p=WebThing.git diff --git a/plugins/LoadProgress.cs b/plugins/LoadProgress.cs index 9dc6838..d635573 100644 --- a/plugins/LoadProgress.cs +++ b/plugins/LoadProgress.cs @@ -16,14 +16,16 @@ public class LoadThrobber : Gtk.DrawingArea { public LoadThrobber(WebThing wt) { LoadState = Mode.LoadStarted; - wt.WebView.LoadStarted += WebView_LoadStarted; - wt.WebView.LoadCommitted += WebView_LoadCommitted; - wt.WebView.LoadProgressChanged += WebView_LoadProgressChanged; - wt.WebView.LoadFinished += WebView_LoadFinished; - SetSizeRequest(64, 64); } + public void AttachSignals(WebView wv) { + wv.LoadStarted += WebView_LoadStarted; + wv.LoadCommitted += WebView_LoadCommitted; + wv.LoadProgressChanged += WebView_LoadProgressChanged; + wv.LoadFinished += WebView_LoadFinished; + } + protected override bool OnExposeEvent(Gdk.EventExpose e) { Gdk.Window w = e.Window; Gdk.GC gc = new Gdk.GC(w); @@ -50,7 +52,7 @@ public class LoadThrobber : Gtk.DrawingArea { void WebView_LoadStarted(object o, LoadStartedArgs e) { this.Show(); - Console.WriteLine("Loading Started"); + //Console.WriteLine("Loading Started"); LoadState = Mode.LoadStarted; idletimer = GLib.Timeout.Add(100, delegate { QueueDraw(); @@ -59,7 +61,7 @@ public class LoadThrobber : Gtk.DrawingArea { } void WebView_LoadCommitted(object o, LoadCommittedArgs e) { - Console.WriteLine("Loading Committed"); + //Console.WriteLine("Loading Committed"); LoadState = Mode.LoadInProgress; GLib.Source.Remove(idletimer); r = 0; @@ -67,21 +69,27 @@ public class LoadThrobber : Gtk.DrawingArea { } void WebView_LoadProgressChanged(object o, LoadProgressChangedArgs e) { - Console.WriteLine("Loading Progress: {0}", e.Progress); + //Console.WriteLine("Loading Progress: {0}", e.Progress); r = (int) ((e.Progress / 100.0) * 360); QueueDraw(); } void WebView_LoadFinished(object o, LoadFinishedArgs e) { - Console.WriteLine("Loading Finished"); + //Console.WriteLine("Loading Finished"); LoadState = Mode.LoadFinished; this.Hide(); } } -public class Plugin { - public Plugin(WebThing wt) { - LoadThrobber lt = new LoadThrobber(wt); - wt.AttachWidget(lt, CompassDirection.Interior); +public class LoadThrobberPlugin : WebThingPlugin { + LoadThrobber lt; + + public override void Init(WebThing wt) { + lt = new LoadThrobber(wt); + wt.AttachWidget(lt, AttachPoint.Interior); + } + + public override void InitWebView(WebView wv) { + lt.AttachSignals(wv); } }