Move configuration to Config module
[WebThing.git] / WebThing.cs
index 5e4ca34..6f8a164 100644 (file)
@@ -40,36 +40,11 @@ namespace bytex64.WebThing {
         public Gtk.Notebook Tabs {
             get { return _Tabs; }
         }
-        /*
-        private int _CurrentTab;
-        public int CurrentTab {
-            get { return _CurrentTab; }
-            set {
-                if (value >= _Tabs.Count)
-                    _CurrentTab = _Tabs.Count - 1;
-                else if (value < 0)
-                    _CurrentTab = 0;
-                else
-                    _CurrentTab = value;
-
-                _WebView.Hide();
-                _ScrolledWindow.Remove(_WebView);
-                _WebView = _Tabs[_CurrentTab];
-                _ScrolledWindow.Add(_WebView);
-                foreach (WebView view in Tabs)
-                    Console.WriteLine(view.MainFrame.Uri);
-                _WebView.Show();
-                _WebView.GrabFocus();
-            }
-        }
-        */
 
         private Gtk.Table WidgetGrid;
         private Gtk.Alignment InteriorOverlay;
 
         public Dictionary<string,WebThingPlugin> Plugins;
-        public Dictionary<string,string> Options;
-        public string[] Arguments;
 
         [DllImport ("SoupSettings.dll")]
         private static extern void soup_settings();
@@ -77,7 +52,10 @@ namespace bytex64.WebThing {
         public void Run() {
             Application.Init();
             Plugins = new Dictionary<string,WebThingPlugin>();
-            ParseArgs();
+
+            Config.ParseCommandLine();
+            Config.Load();
+            //Config.DumpOptions();
 
             soup_settings();
 
@@ -116,66 +94,6 @@ namespace bytex64.WebThing {
             Application.Run();
         }
 
-        protected void ParseArgs() {
-            Options = new Dictionary<string,string>();
-            Queue<string> q = new Queue<string>();
-            foreach (string s in System.Environment.GetCommandLineArgs()) {
-                q.Enqueue(s);
-            }
-            q.Dequeue();   // Remove self argument
-
-            Regex SimpleOpt = new Regex(@"^-([a-zA-Z0-9]+)$");
-            Regex LongOpt   = new Regex(@"^--([\w-]+)$");
-            string OptLast = null;
-            List<string> args = new List<string>();
-
-            while (q.Count > 0) {
-                string opt = q.Dequeue();
-                Match m;
-                   
-                m = SimpleOpt.Match(opt);
-                if (m.Success) {
-                    string s = m.Groups[1].Value;
-                    if (s.Length > 1) {
-                        foreach (char c in s) {
-                            Options[c.ToString()] = "";
-                        }
-                        OptLast = null;
-                    } else {
-                        Options[s] = "";
-                        OptLast = s;
-                    }
-                    continue;
-                }
-
-                m = LongOpt.Match(opt);
-                if (m.Success) {
-                    string s = m.Groups[1].Value;
-                    Options[s] = "";
-                    OptLast = s;
-                    continue;
-                }
-
-                // else
-
-                if (OptLast != null) {
-                    Options[OptLast] = opt;
-                    OptLast = null;
-                } else {
-                    args.Add(opt);
-                }
-            }
-            Arguments = args.ToArray();
-
-            /*
-            Console.WriteLine("Options:");
-            foreach (string key in Options.Keys)
-                Console.WriteLine("   {0}\t{1}", key, Options[key]);
-
-            Console.WriteLine("Arguments: {0}", String.Join(" ", Arguments));
-            */
-        }
-
         public void LoadPlugin(string assemblyname) {
             Assembly a = Assembly.LoadFile("plugins/" + assemblyname + ".dll");
             Type[] types = a.GetTypes();