X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=WebThing.cs;h=c1e180687d7e038427c2307ec4b1822f2334f749;hb=6c50b11e5b8e72781db4195d8472bb7d542c1d3c;hp=6f8a16482c459d36a05c8d4e61a0013e05fcbd05;hpb=85b244419aec2552d114990aa86900aeac83a7e0;p=WebThing.git diff --git a/WebThing.cs b/WebThing.cs index 6f8a164..c1e1806 100644 --- a/WebThing.cs +++ b/WebThing.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Reflection; using System.IO; using System.Text.RegularExpressions; using System.Runtime.InteropServices; @@ -9,7 +8,7 @@ using GtkSharp; using WebKit; namespace bytex64.WebThing { - public enum CompassDirection { + public enum AttachPoint { N, E, S, W, Interior } @@ -44,14 +43,13 @@ namespace bytex64.WebThing { private Gtk.Table WidgetGrid; private Gtk.Alignment InteriorOverlay; - public Dictionary Plugins; + public PluginManager Plugins; [DllImport ("SoupSettings.dll")] private static extern void soup_settings(); public void Run() { Application.Init(); - Plugins = new Dictionary(); Config.ParseCommandLine(); Config.Load(); @@ -69,6 +67,7 @@ namespace bytex64.WebThing { _Tabs = new Gtk.Notebook(); _Tabs.ShowBorder = false; + _Tabs.Scrollable = true; _Tabs.SwitchPage += Tabs_SwitchPage; WidgetGrid.Attach(_Tabs, 1, 2, 1, 2); @@ -79,61 +78,41 @@ namespace bytex64.WebThing { WebThingView newview = NewWebThingView(); - // TODO: Conf.Get("plugins") instead of hard-coded path? - using (TextReader f = new StreamReader("plugins.conf")) { - string line; - while ((line = f.ReadLine()) != null) { - line = line.Trim(); - LoadPlugin(line); - } - } - - WebViewSetupPlugins(newview.WebView); + Plugins = new PluginManager(this); + Plugins.Load(); + Plugins.WebViewSetup(newview.WebView); newview.WebView.GrabFocus(); Application.Run(); } - public void LoadPlugin(string assemblyname) { - Assembly a = Assembly.LoadFile("plugins/" + assemblyname + ".dll"); - Type[] types = a.GetTypes(); - foreach (Type t in types) { - if (t.IsSubclassOf(typeof(WebThingPlugin))) { - WebThingPlugin p = (WebThingPlugin) a.CreateInstance(t.FullName, false, BindingFlags.ExactBinding, null, null, null, null); - p.Init(this); - Plugins[t.FullName] = p; - Console.WriteLine("Successfully loaded {0}", t.FullName); - } - } - } - - public void AttachWidget(Gtk.Widget widget, CompassDirection direction, AttachOptions xoptions, AttachOptions yoptions) { + public void AttachWidget(Gtk.Widget widget, AttachPoint direction, AttachOptions xoptions, AttachOptions yoptions) { switch(direction) { - case CompassDirection.N: + case AttachPoint.N: WidgetGrid.Attach(widget, 0, 3, 0, 1, xoptions, yoptions, 0, 0); break; - case CompassDirection.E: + case AttachPoint.E: WidgetGrid.Attach(widget, 2, 3, 1, 2, xoptions, yoptions, 0, 0); break; - case CompassDirection.S: + case AttachPoint.S: WidgetGrid.Attach(widget, 0, 3, 2, 3, xoptions, yoptions, 0, 0); break; - case CompassDirection.W: + case AttachPoint.W: WidgetGrid.Attach(widget, 0, 1, 1, 2, xoptions, yoptions, 0, 0); break; - case CompassDirection.Interior: + case AttachPoint.Interior: InteriorOverlay.Add(widget); break; } } - public void AttachWidget(Gtk.Widget widget, CompassDirection direction) { + public void AttachWidget(Gtk.Widget widget, AttachPoint direction) { AttachWidget(widget, direction, 0, 0); } public WebView NewTab() { WebThingView newview = NewWebThingView(); - WebViewSetupPlugins(newview.WebView); + Plugins.WebViewSetup(newview.WebView); return newview.WebView; } @@ -149,12 +128,6 @@ namespace bytex64.WebThing { return newview; } - private void WebViewSetupPlugins(WebView view) { - foreach (string key in Plugins.Keys) { - Plugins[key].InitWebView(view); - } - } - public void CloseTab() { CloseTab(_Tabs.Page); }