2 using System.Collections.Generic;
3 using System.Reflection;
9 namespace bytex64.WebThing {
10 public enum CompassDirection {
11 N, NE, E, SE, S, SW, W, NW,
15 public class WebThing {
16 public Gtk.Window Window {
17 get { return _Window; }
21 get { return _Window; }
24 public Gtk.ScrolledWindow ScrolledWindow {
25 get { return _ScrolledWindow; }
28 public Gtk.ScrolledWindow sw {
29 get { return _ScrolledWindow; }
32 public WebKit.WebView WebView {
33 get { return _WebView; }
36 public WebKit.WebView wv {
37 get { return _WebView; }
40 private Gtk.Window _Window;
41 private ScrolledWindow _ScrolledWindow;
42 private WebKit.WebView _WebView;
43 private Gtk.Table WidgetGrid;
44 private Gtk.Alignment InteriorOverlay;
46 public Dictionary<string,object> Plugins;
50 _Window = new Gtk.Window("WebThing");
51 _Window.Destroyed += delegate { Application.Quit(); };
53 WidgetGrid = new Gtk.Table(3, 3, false);
54 _Window.Add(WidgetGrid);
56 _ScrolledWindow = new Gtk.ScrolledWindow();
57 WidgetGrid.Attach(_ScrolledWindow, 1, 2, 1, 2);
59 InteriorOverlay = new Gtk.Alignment(1, 0, 0, 0);
60 WidgetGrid.Attach(InteriorOverlay, 1, 2, 1, 2);
62 _WebView = new WebKit.WebView();
63 _WebView.TitleChanged += delegate(object o, TitleChangedArgs e) {
64 _Window.Title = e.Title + " - WebThing";
66 _ScrolledWindow.Add(_WebView);
70 Plugins = new Dictionary<string, object>();
71 // TODO: Conf.Get("plugins") instead of hard-coded path?
72 using (TextReader f = new StreamReader("plugins.conf")) {
74 while ((line = f.ReadLine()) != null) {
83 public void LoadPlugin(string assemblyname) {
84 Assembly a = Assembly.LoadFile("plugins/" + assemblyname + ".dll");
85 object obj = a.CreateInstance("Plugin", false, BindingFlags.ExactBinding, null, new object[] { this }, null, null);
86 Plugins[assemblyname] = obj;
89 public void AttachWidget(Gtk.Widget widget, CompassDirection direction, AttachOptions xoptions, AttachOptions yoptions) {
91 case CompassDirection.N:
92 WidgetGrid.Attach(widget, 1, 2, 0, 1, xoptions, yoptions, 0, 0);
94 case CompassDirection.NE:
95 WidgetGrid.Attach(widget, 2, 3, 0, 1, xoptions, yoptions, 0, 0);
97 case CompassDirection.E:
98 WidgetGrid.Attach(widget, 2, 3, 1, 2, xoptions, yoptions, 0, 0);
100 case CompassDirection.SE:
101 WidgetGrid.Attach(widget, 2, 3, 2, 3, xoptions, yoptions, 0, 0);
103 case CompassDirection.S:
104 WidgetGrid.Attach(widget, 1, 2, 2, 3, xoptions, yoptions, 0, 0);
106 case CompassDirection.SW:
107 WidgetGrid.Attach(widget, 0, 1, 2, 3, xoptions, yoptions, 0, 0);
109 case CompassDirection.W:
110 WidgetGrid.Attach(widget, 0, 1, 1, 2, xoptions, yoptions, 0, 0);
112 case CompassDirection.NW:
113 WidgetGrid.Attach(widget, 0, 1, 0, 1, xoptions, yoptions, 0, 0);
115 case CompassDirection.Interior:
116 InteriorOverlay.Add(widget);
121 public void AttachWidget(Gtk.Widget widget, CompassDirection direction) {
122 AttachWidget(widget, direction, 0, 0);