Fix scrolling functionality
[WebThing.git] / plugins / LoadProgress.cs
index a4be542..d635573 100644 (file)
@@ -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 LoadThrobberPlugin : WebThingPlugin {
-    public void Init(WebThing wt) {
-        LoadThrobber lt = new LoadThrobber(wt);
-        wt.AttachWidget(lt, CompassDirection.Interior);
+    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);
     }
 }