2001-06-27 03:58:39 +04:00
|
|
|
|
|
|
|
namespace Silverstone.Manticore.App
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Collections;
|
|
|
|
|
2001-06-30 05:11:21 +04:00
|
|
|
using Silverstone.Manticore.Browser;
|
|
|
|
using Silverstone.Manticore.Core;
|
|
|
|
using Silverstone.Manticore.Bookmarks;
|
2001-06-27 03:58:39 +04:00
|
|
|
|
|
|
|
public class ManticoreApp
|
|
|
|
{
|
|
|
|
// XXX Need to do something here more similar
|
|
|
|
// to what mozilla does here for parameterized
|
|
|
|
// window types.
|
2001-06-30 10:31:59 +04:00
|
|
|
private Hashtable mBrowserWindows;
|
2001-06-28 04:19:25 +04:00
|
|
|
private Preferences mPreferences;
|
2001-06-30 05:11:21 +04:00
|
|
|
private Bookmarks mBookmarks;
|
2001-06-28 04:19:25 +04:00
|
|
|
|
|
|
|
public Preferences Prefs {
|
|
|
|
get {
|
|
|
|
return mPreferences;
|
|
|
|
}
|
|
|
|
}
|
2001-06-27 03:58:39 +04:00
|
|
|
|
2001-06-30 05:11:21 +04:00
|
|
|
public Bookmarks BM {
|
|
|
|
get {
|
|
|
|
return mBookmarks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-27 03:58:39 +04:00
|
|
|
public ManticoreApp()
|
|
|
|
{
|
2001-06-30 10:31:59 +04:00
|
|
|
mBrowserWindows = new Hashtable();
|
2001-06-28 04:19:25 +04:00
|
|
|
|
|
|
|
// Initialize default and user preferences
|
|
|
|
mPreferences = new Preferences();
|
2001-07-02 11:07:08 +04:00
|
|
|
mPreferences.InitializeDefaults();
|
|
|
|
mPreferences.LoadUserPreferences();
|
2001-06-27 03:58:39 +04:00
|
|
|
|
2001-06-30 05:11:21 +04:00
|
|
|
// Initialize bookmarks
|
|
|
|
mBookmarks = new Bookmarks(this);
|
|
|
|
mBookmarks.LoadBookmarks();
|
|
|
|
|
2001-06-27 03:58:39 +04:00
|
|
|
OpenNewBrowser();
|
|
|
|
|
|
|
|
Application.Run();
|
|
|
|
}
|
|
|
|
|
2001-06-30 10:31:59 +04:00
|
|
|
public void Quit()
|
2001-06-30 05:11:21 +04:00
|
|
|
{
|
|
|
|
// Flush preferences to disk.
|
2001-07-02 11:07:08 +04:00
|
|
|
mPreferences.FlushUserPreferences();
|
2001-06-30 10:31:59 +04:00
|
|
|
|
|
|
|
Application.Exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void WindowClosed(BrowserWindow aWindow)
|
|
|
|
{
|
|
|
|
if (mBrowserWindows.ContainsKey(aWindow.GetHashCode()))
|
|
|
|
mBrowserWindows.Remove(aWindow.GetHashCode());
|
|
|
|
|
|
|
|
// When window count drops to zero, quit.
|
|
|
|
// XXX - a little hacky for now, will eventually reflect
|
|
|
|
// all windows.
|
|
|
|
if (mBrowserWindows.Count == 0)
|
|
|
|
Quit();
|
2001-06-30 05:11:21 +04:00
|
|
|
}
|
|
|
|
|
2001-06-27 03:58:39 +04:00
|
|
|
// Opens and displays a new browser window
|
2001-07-02 11:07:08 +04:00
|
|
|
public BrowserWindow OpenNewBrowser()
|
2001-06-27 03:58:39 +04:00
|
|
|
{
|
|
|
|
BrowserWindow window = new BrowserWindow(this);
|
2001-06-30 10:31:59 +04:00
|
|
|
mBrowserWindows.Add(window.GetHashCode(), window);
|
2001-06-27 03:58:39 +04:00
|
|
|
window.Show();
|
2001-07-02 11:07:08 +04:00
|
|
|
return window;
|
2001-06-27 03:58:39 +04:00
|
|
|
}
|
|
|
|
|
2001-07-03 02:54:41 +04:00
|
|
|
[STAThread]
|
2001-06-27 03:58:39 +04:00
|
|
|
public static void Main(string[] args)
|
|
|
|
{
|
|
|
|
ManticoreApp app = new ManticoreApp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|