mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
[Manticore]
Save Page As dialog stuff, beginning to enhance Toolbar generation code NOT PART OF BUILD.
This commit is contained in:
parent
e4b1dd3230
commit
1ba2c50430
@ -1,7 +1,7 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.0.9254"
|
||||
ProductVersion = "7.0.9372"
|
||||
SchemaVersion = "1.0"
|
||||
ProjectGuid = "{B40F4C31-96AF-4E5F-A088-546389BC78C4}"
|
||||
>
|
||||
@ -15,7 +15,6 @@
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
NoStandardLibraries = "true"
|
||||
OutputType = "WinExe"
|
||||
RootNamespace = "Silverstone.Manticore"
|
||||
StartupObject = ""
|
||||
@ -58,22 +57,6 @@
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "MSHTML"
|
||||
AssemblyName = "MSHTML"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AxSHDocVw"
|
||||
AssemblyName = "AxSHDocVw"
|
||||
/>
|
||||
<Reference
|
||||
Name = "MOZILLACONTROLLib"
|
||||
AssemblyName = "MOZILLACONTROLLib"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AxMOZILLACONTROLLib"
|
||||
AssemblyName = "AxMOZILLACONTROLLib"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
@ -94,6 +77,30 @@
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AxComCtl3"
|
||||
AssemblyName = "AxComCtl3"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AxMOZILLACONTROLLib"
|
||||
AssemblyName = "AxMOZILLACONTROLLib"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AxSHDocVw"
|
||||
AssemblyName = "AxSHDocVw"
|
||||
/>
|
||||
<Reference
|
||||
Name = "ComCtl3"
|
||||
AssemblyName = "ComCtl3"
|
||||
/>
|
||||
<Reference
|
||||
Name = "MOZILLACONTROLLib"
|
||||
AssemblyName = "MOZILLACONTROLLib"
|
||||
/>
|
||||
<Reference
|
||||
Name = "SHDocVw"
|
||||
AssemblyName = "SHDocVw"
|
||||
/>
|
||||
<Reference
|
||||
Name = "mscorlib"
|
||||
AssemblyName = "mscorlib"
|
||||
@ -107,10 +114,6 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "licenses.licx"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "makefile.win"
|
||||
BuildAction = "None"
|
||||
@ -291,6 +294,10 @@
|
||||
RelPath = "resources\bookmark-folder-open.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "resources\manticore.exe.manifest"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "resources\manticore.png"
|
||||
BuildAction = "Content"
|
||||
|
@ -1,13 +1,15 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP>
|
||||
<Build>
|
||||
<Settings ReferencePath = "C:\WINNT\Microsoft.NET\Framework\v1.0.2914;C:\builds\mozilla\extensions\manticore;" >
|
||||
<Settings ReferencePath = "C:\WINNT\Microsoft.NET\Framework\v1.0.2914;C:\builds\mozilla\extensions\manticore;D:\builds\mozilla\extensions\manticore\;D:\builds\trunk\mozilla\extensions\manticore\" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
@ -22,6 +24,8 @@
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
|
@ -3,14 +3,20 @@
|
||||
<toolbox id="mainToolbox"
|
||||
xmlns="http://www.silverstone.net.nz/2001/manticore/uidl">
|
||||
<toolstrip>
|
||||
<toolbar id="navigation-toolbar" label="" visible="true" description="Navigation Toolbar">
|
||||
<toolbarbutton label="Back" command="view-go-back"/>
|
||||
<toolbarbutton label="Forward" command="view-go-forward"/>
|
||||
<toolbarbutton label="Stop" command="view-stop"/>
|
||||
<toolbarbutton label="Reload" command="view-reload"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton label="Home" command="view-go-home"/>
|
||||
</toolbar>
|
||||
<toolbar id="command-toolbar" label="" visible="true" description="Command Toolbar">
|
||||
<toolbarbutton label="Back" command="view-go-back"/>
|
||||
<toolbarbutton label="Forward" command="view-go-forward"/>
|
||||
<toolbarbutton label="Stop" command="view-stop"/>
|
||||
<toolbarbutton label="Reload" command="view-reload"/>
|
||||
<toolbarseparator/>
|
||||
<toolbarbutton label="Home" command="view-go-home"/>
|
||||
</toolbar>
|
||||
</toolstrip>
|
||||
<toolstrip>
|
||||
<toolbar id="navigation-toolbar" label="Location:" visible="true" description="Navigation Toolbar">
|
||||
<locationbar/>
|
||||
<toolbarbutton label="Go" command="go-to-url"/>
|
||||
</toolbar>
|
||||
</toolstrip>
|
||||
</toolbox>
|
||||
|
||||
|
@ -38,6 +38,9 @@ namespace Silverstone.Manticore.Browser
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Net;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
using Silverstone.Manticore.Core;
|
||||
using Silverstone.Manticore.App;
|
||||
@ -123,7 +126,6 @@ namespace Silverstone.Manticore.Browser
|
||||
this.Controls.Add(mStatusBar);
|
||||
|
||||
mToolbarBuilder = new BrowserToolbarBuilder("browser\\browser-toolbar.xml", this);
|
||||
mToolbarBuilder.Build();
|
||||
|
||||
// Start Page handler
|
||||
this.VisibleChanged += new EventHandler(LoadStartPage);
|
||||
@ -187,6 +189,56 @@ namespace Silverstone.Manticore.Browser
|
||||
mWebBrowser.LoadURL(dlg.URL, false);
|
||||
}
|
||||
|
||||
public void SavePageAs()
|
||||
{
|
||||
SaveFileDialog dlg = new SaveFileDialog();
|
||||
dlg.AddExtension = true;
|
||||
dlg.DefaultExt = "html";
|
||||
dlg.FileName = "untitled";
|
||||
dlg.InitialDirectory = FileLocator.GetFolderPath(FileLocator.SpecialFolders.ssfPERSONAL); // XXX persist this.
|
||||
dlg.Title = "Save Page As...";
|
||||
dlg.ValidateNames = true;
|
||||
dlg.OverwritePrompt = true;
|
||||
|
||||
WebRequest req = WebRequest.Create(mWebBrowser.URL);
|
||||
WebResponse resp = req.GetResponse();
|
||||
string contentType = resp.ContentType;
|
||||
switch (contentType)
|
||||
{
|
||||
case "text/html":
|
||||
case "text/xhtml":
|
||||
dlg.Filter = "Web Page, complete (*.htm;*.html)|*.htm*|Web Page, HTML only (*.htm;*.html)|*.htm*|Text only (*.txt)|*.txt";
|
||||
break;
|
||||
default:
|
||||
// XXX factor this into a separate MIME service.
|
||||
RegistryKey clsRoot = Registry.ClassesRoot;
|
||||
string extFromMIMEDBKey = "MIME\\Database\\Content Type\\" + contentType;
|
||||
RegistryKey extensionKey = clsRoot.OpenSubKey(extFromMIMEDBKey);
|
||||
string extension = extensionKey.GetValue("Extension") as String;
|
||||
RegistryKey handlerKey = clsRoot.OpenSubKey(extension);
|
||||
string handler = handlerKey.GetValue("") as String;
|
||||
RegistryKey descriptionKey = clsRoot.OpenSubKey(handler);
|
||||
string description = descriptionKey.GetValue("") as String;
|
||||
if (description == "")
|
||||
description = extension.ToUpper() + "file";
|
||||
description += " (*" + extension + ")";
|
||||
dlg.Filter = description + "|*" + extension + "|All Files (*.*)|*.*";
|
||||
break;
|
||||
}
|
||||
|
||||
dlg.FileOk += new CancelEventHandler(OnSavePageAsOK);
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
|
||||
public void OnSavePageAsOK(Object sender, CancelEventArgs e)
|
||||
{
|
||||
if (e.Cancel != true)
|
||||
{
|
||||
SaveFileDialog dlg = sender as SaveFileDialog;
|
||||
Console.WriteLine("{0}", dlg.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
ManticoreApp app = ServiceManager.App;
|
||||
@ -257,6 +309,9 @@ namespace Silverstone.Manticore.Browser
|
||||
case "file-open":
|
||||
Open();
|
||||
break;
|
||||
case "file-save-as":
|
||||
SavePageAs();
|
||||
break;
|
||||
case "file-exit":
|
||||
Quit();
|
||||
break;
|
||||
|
@ -43,7 +43,6 @@ namespace Silverstone.Manticore.Layout
|
||||
|
||||
// Trident
|
||||
using AxSHDocVw;
|
||||
using MSHTML;
|
||||
|
||||
// Gecko
|
||||
using AxMOZILLACONTROLLib;
|
||||
@ -115,7 +114,7 @@ namespace Silverstone.Manticore.Layout
|
||||
{
|
||||
String layoutEngine = ServiceManager.Preferences.GetStringPref("browser.layoutengine");
|
||||
if (layoutEngine == "")
|
||||
layoutEngine = "gecko";
|
||||
layoutEngine = "trident";
|
||||
SwitchLayoutEngine(layoutEngine);
|
||||
}
|
||||
}
|
||||
@ -190,6 +189,7 @@ namespace Silverstone.Manticore.Layout
|
||||
// made to support ignore-cache and ignore-history.
|
||||
// This will require modification to the ActiveX
|
||||
// control.
|
||||
|
||||
RealizeLayoutEngine();
|
||||
Object o = null;
|
||||
if (gecko != null)
|
||||
|
@ -100,6 +100,7 @@ bindings:
|
||||
echo $(_WINDIR)\system32\shdocvw.dll
|
||||
aximp $(_WINDIR)\system32\shdocvw.dll
|
||||
aximp $(MOZ_SRC)\mozilla\dist\$(SUBDIR)\bin\mozctl.dll
|
||||
aximp $(_WINDIR)\system32\comct332.ocx
|
||||
|
||||
# XXX fix me
|
||||
clean:
|
||||
|
@ -77,10 +77,5 @@ namespace Silverstone.Manticore.Toolkit
|
||||
WindowMediator wm = ServiceManager.WindowMediator;
|
||||
wm.SetMostRecentWindow(this);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,29 +44,46 @@ namespace Silverstone.Manticore.Toolkit
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
using AxComCtl3;
|
||||
using ComCtl3;
|
||||
|
||||
public abstract class ToolbarBuilder
|
||||
{
|
||||
private String mToolbarFile;
|
||||
private ToolBar mCurrentToolbar;
|
||||
|
||||
protected String mToolbarFile;
|
||||
protected AxCoolBar mCoolBar;
|
||||
protected Form mForm;
|
||||
|
||||
public Hashtable mItems;
|
||||
|
||||
public ToolbarBuilder(String file, Form form)
|
||||
public ToolbarBuilder(String aToolbarFile, Form aForm)
|
||||
{
|
||||
mToolbarFile = file;
|
||||
mForm = form;
|
||||
mToolbarFile = aToolbarFile;
|
||||
mForm = aForm;
|
||||
mItems = new Hashtable();
|
||||
|
||||
// Initialize CoolBar
|
||||
mCoolBar = new AxCoolBar();
|
||||
AxHost host = mCoolBar as AxHost;
|
||||
host.BeginInit();
|
||||
host.Dock = DockStyle.Top;
|
||||
host.EndInit();
|
||||
mForm.Controls.Add(host);
|
||||
|
||||
// We can't build the CoolBar until after the window is visible
|
||||
mForm.VisibleChanged += new EventHandler(Build);
|
||||
}
|
||||
|
||||
public void Build()
|
||||
public void Build(Object sender, EventArgs e)
|
||||
{
|
||||
XmlTextReader reader;
|
||||
reader = new XmlTextReader(mToolbarFile);
|
||||
reader.WhitespaceHandling = WhitespaceHandling.None;
|
||||
reader.MoveToContent();
|
||||
|
||||
bool shouldBuildNewRow = true;
|
||||
|
||||
ToolBar currToolbar = null;
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
@ -75,9 +92,9 @@ namespace Silverstone.Manticore.Toolkit
|
||||
{
|
||||
case "toolstrip":
|
||||
// The next <toolbar/> we encounter should be created on a new row.
|
||||
shouldBuildNewRow = true;
|
||||
break;
|
||||
case "toolbar":
|
||||
//
|
||||
String[] tbvalues = new String[4] {"", "", "", ""};
|
||||
String[] tbnames = new String[4] {"id", "label", "description", "visible"};
|
||||
for (int i = 0; i < tbnames.Length; ++i)
|
||||
@ -90,38 +107,46 @@ namespace Silverstone.Manticore.Toolkit
|
||||
|
||||
String key = tbvalues[0];
|
||||
String label = tbvalues[1];
|
||||
String visible = tbvalues[3];
|
||||
bool visible = tbvalues[3] == "true";
|
||||
|
||||
// Create and add a new toolbar.
|
||||
mCurrentToolbar = new ToolBar();
|
||||
mCurrentToolbar.Dock = DockStyle.Top;
|
||||
mCurrentToolbar.Appearance = ToolBarAppearance.Flat;
|
||||
mForm.Controls.Add(mCurrentToolbar);
|
||||
currToolbar = new ToolBar();
|
||||
currToolbar.Appearance = ToolBarAppearance.Flat;
|
||||
currToolbar.ButtonClick += new ToolBarButtonClickEventHandler(this.OnCommand);
|
||||
mForm.Controls.Add(currToolbar);
|
||||
|
||||
//mCoolBar.Bands.Add(-1, key, label, new Object(), true, currToolbar, true);
|
||||
|
||||
mCurrentToolbar.ButtonClick += new ToolBarButtonClickEventHandler(this.OnCommand);
|
||||
shouldBuildNewRow = false;
|
||||
break;
|
||||
case "toolbarseparator":
|
||||
{
|
||||
ToolBarButton button = new ToolBarButton();
|
||||
button.Style = ToolBarButtonStyle.Separator;
|
||||
mCurrentToolbar.Buttons.Add(button);
|
||||
if (currToolbar != null)
|
||||
{
|
||||
ToolBarButton button = new ToolBarButton();
|
||||
button.Style = ToolBarButtonStyle.Separator;
|
||||
currToolbar.Buttons.Add(button);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "toolbarbutton":
|
||||
{
|
||||
String[] tbbvalues = new String[2] {"", ""};
|
||||
String[] tbbnames = new String[2] {"label", "command"};
|
||||
for (int i = 0; i < tbbnames.Length; ++i)
|
||||
if (currToolbar != null)
|
||||
{
|
||||
if (reader.MoveToAttribute(tbbnames[i]) &&
|
||||
reader.ReadAttributeValue())
|
||||
tbbvalues[i] = reader.Value; // XXX need to handle entities
|
||||
reader.MoveToElement();
|
||||
String[] tbbvalues = new String[3] {"", "", ""};
|
||||
String[] tbbnames = new String[3] {"label", "icon", "command"};
|
||||
for (int i = 0; i < tbbnames.Length; ++i)
|
||||
{
|
||||
if (reader.MoveToAttribute(tbbnames[i]) &&
|
||||
reader.ReadAttributeValue())
|
||||
tbbvalues[i] = reader.Value; // XXX need to handle entities
|
||||
reader.MoveToElement();
|
||||
}
|
||||
|
||||
ToolBarButton button = new CommandButtonItem(tbbvalues[1]);
|
||||
button.Text = tbbvalues[0];
|
||||
currToolbar.Buttons.Add(button);
|
||||
}
|
||||
|
||||
ToolBarButton button = new CommandButtonItem(tbbvalues[1]);
|
||||
button.Text = tbbvalues[0];
|
||||
mCurrentToolbar.Buttons.Add(button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user