-//
-using System;
-using System.Text;
-using System.IO;
-using System.Collections;
-using Gecko;
-using Gtk;
-#if USE_GTKHTML_PRINT
-using Gnome;
-#endif
-
-namespace Monodoc {
-public class GeckoHtmlRender : IHtmlRender {
-
- //Images are cached in a temporal directory
- Hashtable cache_imgs;
- string tmpPath;
-
- WebControl html_panel;
- Viewport panel;
- public Widget HtmlPanel {
- get { return (Widget) panel; }
- }
-
- string url;
- public string Url {
- get { return url; }
- }
- RootTree help_tree;
-
- public event EventHandler OnUrl;
- public event EventHandler UrlClicked;
-
- public GeckoHtmlRender (RootTree help_tree)
- {
- this.help_tree = help_tree;
- }
-
- public bool Initialize ()
- {
- tmpPath = Path.Combine (Path.GetTempPath (), "monodoc");
- try {
- string mozHome = System.Environment.GetEnvironmentVariable ("MOZILLA_HOME");
- if (mozHome != null)
- WebControl.CompPath = mozHome;
- html_panel = new WebControl (tmpPath, "MonodocGecko");
- }
- catch (Exception ex) {
- Console.WriteLine (ex.Message);
- Console.WriteLine (ex.StackTrace);
- return false;
- }
-
- html_panel.Show(); //due to Gecko bug
- html_panel.OpenUri += OnOpenUri;
- html_panel.LinkMsg += OnLinkMsg;
- panel = new Viewport();
- panel.Add (html_panel);
- cache_imgs = new Hashtable();
- return true;
- }
-
- public Capabilities Capabilities
- {
- get { return Capabilities.Css | Capabilities.Fonts; }
- }
-
- public string Name
- {
- get { return "Gecko"; }
- }
-
-
- protected void OnOpenUri (object o, OpenUriArgs args)
- {
- url = CheckUrl (args.AURI);
- // if the file is cached on disk, return
- if (url.StartsWith ("file:///") || url.StartsWith("javascript:", StringComparison.InvariantCultureIgnoreCase))
- return;
-
- if (UrlClicked != null)
- UrlClicked (this, new EventArgs());
- args.RetVal = true; //this prevents Gecko to continue processing
- }
-
- protected void OnLinkMsg (object o, EventArgs args)
- {
- url = CheckUrl (html_panel.LinkMessage);
- if (OnUrl != null)
- OnUrl (this, args);
- }
-
- // URL like T:System.Activator are lower cased by gecko to t.;System.Activator
- // so we revert that
- string CheckUrl (string u)
- {
- if (u.IndexOf (':') == 1)
- return Char.ToUpper (u[0]) + u.Substring (1);
- return u;
- }
-
- /* NOT ALREADY IMPLEMENTED */
- public void JumpToAnchor (string anchor_name)
- {
- }
-
- /* NOT ALREADY IMPLEMENTED */
- public void Copy() {}
-
- /* NOT ALREADY IMPLEMENTED */
- public void SelectAll() {}
-
- static int tmp_file = 0;
- public void Render (string html_code)
- {
- string r = ProcessImages (html_code);
- // if the html code is too big, write it down to a tmp file
- if (((uint) r.Length) > 50000) {
- string filename = (tmp_file++) + ".html";
- string filepath = Path.Combine (tmpPath, filename);
- using (FileStream file = new FileStream (filepath, FileMode.Create)) {
- StreamWriter sw = new StreamWriter (file);
- sw.Write (r);
- sw.Close ();
- }
- html_panel.LoadUrl (filepath);
- } else {
- html_panel.OpenStream ("file:///", "text/html");
- html_panel.AppendData (r);
- html_panel.CloseStream ();
- }
-
- }
-
- // Substitute the src of the images with the appropriate path
- string ProcessImages (string html_code)
- {
- //If there are no Images return fast
- int pos = html_code.IndexOf ("
-//
-using System;
-using Gtk;
-using System.IO;
-using System.Reflection;
-
-namespace Monodoc {
-class GtkHtmlHtmlRender : IHtmlRender {
-
- HTML html_panel;
- public Widget HtmlPanel {
- get { return (Widget) html_panel; }
- }
-
- string url;
- public string Url {
- get { return url; }
- }
-
- RootTree help_tree;
- public event EventHandler OnUrl;
- public event EventHandler UrlClicked;
-
-
- public GtkHtmlHtmlRender (RootTree help_tree)
- {
- this.help_tree = help_tree;
- }
-
- protected void LinkClicked (object o, LinkClickedArgs args)
- {
- url = FixUrl (args.Url);
- if (UrlClicked != null)
- UrlClicked (this, new EventArgs());
- }
-
- static string FixUrl (string url)
- {
- if (url == null)
- return url;
- return url.Replace ("<", "<").Replace (">", ">");
- }
-
- protected void OnUrlMouseOver (object o, OnUrlArgs args)
- {
- url = FixUrl (args.Url);
- if (OnUrl != null)
- OnUrl (this, args);
- }
-
- public void JumpToAnchor (string anchor)
- {
- html_panel.JumpToAnchor(anchor);
- }
-
- public void Copy ()
- {
- html_panel.Copy();
- }
-
- public void SelectAll ()
- {
- html_panel.SelectAll();
- }
-
- public void Render (string html_code)
- {
- Gtk.HTMLStream stream = html_panel.Begin ("text/html");
- stream.Write(html_code);
- html_panel.End (stream, HTMLStreamStatus.Ok);
- }
-
- static Stream GetBrowserResourceImage (string name)
- {
- Assembly assembly = typeof (RootTree).Assembly;
- System.IO.Stream s = assembly.GetManifestResourceStream (name);
-
- return s;
- }
-
- protected void UrlRequested (object sender, UrlRequestedArgs args)
- {
- Stream s = help_tree.GetImage (args.Url);
-
- if (s == null)
- s = GetBrowserResourceImage ("monodoc.png");
- byte [] buffer = new byte [8192];
- int n, m;
- m=0;
- while ((n = s.Read (buffer, 0, 8192)) != 0) {
- args.Handle.Write (buffer, n);
- m += n;
- }
- args.Handle.Close (HTMLStreamStatus.Ok);
- }
-
- public void Print (string Html) {
-#if !MACOS
- if (Html == null) {
- Console.WriteLine ("empty print");
- return;
- }
-
- PrintManager.Print (Html);
-#endif
- }
-
- public bool Initialize ()
- {
- try {
- html_panel = new HTML ();
- }
- catch (Exception ex) {
- Console.WriteLine (ex.Message);
- Console.WriteLine (ex.StackTrace);
- return false;
- }
- html_panel.Show ();
- html_panel.LinkClicked += new LinkClickedHandler (LinkClicked);
- html_panel.OnUrl += new OnUrlHandler (OnUrlMouseOver);
- html_panel.UrlRequested += new UrlRequestedHandler (UrlRequested);
- return true;
-
- }
-
- public Capabilities Capabilities
- {
- get { return Capabilities.None; }
- }
-
- public string Name
- {
- get { return "GtkHtml"; }
- }
-
-}
-}
diff --git a/docbrowser/IndexBrowser.cs b/docbrowser/IndexBrowser.cs
new file mode 100644
index 000000000..8d071f389
--- /dev/null
+++ b/docbrowser/IndexBrowser.cs
@@ -0,0 +1,344 @@
+using Gtk;
+using System;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using System.Collections;
+using System.Collections.Generic;
+using System.Web.Services.Protocols;
+using System.Xml;
+
+using Mono.Options;
+
+#if MACOS
+using OSXIntegration.Framework;
+#endif
+
+namespace Monodoc {
+class IndexBrowser {
+ Browser browser;
+
+ IndexReader index_reader;
+ public BigList index_list;
+ public MatchModel match_model;
+ public BigList match_list;
+ IndexEntry current_entry = null;
+
+
+ public static IndexBrowser MakeIndexBrowser (Browser browser)
+ {
+ IndexReader ir = browser.help_tree.GetIndex ();
+ if (ir == null) {
+ return new IndexBrowser (browser);
+ }
+
+ return new IndexBrowser (browser, ir);
+ }
+
+ ProgressPanel ppanel;
+ IndexBrowser (Browser parent)
+ {
+ browser = parent;
+ ppanel = new ProgressPanel ("No index found", "Generate", RootTree.MakeIndex, NewIndexCreated);
+ browser.index_vbox.Add (ppanel);
+ browser.index_vbox.Show ();
+ }
+
+ void NewIndexCreated ()
+ {
+ index_reader = browser.help_tree.GetIndex ();
+ //restore widgets
+ browser.index_vbox.Remove (ppanel);
+ CreateWidget ();
+ browser.index_vbox.ShowAll ();
+ }
+
+ IndexBrowser (Browser parent, IndexReader ir)
+ {
+ browser = parent;
+ index_reader = ir;
+
+ CreateWidget ();
+ }
+
+ void CreateWidget () {
+ //
+ // Create the widget
+ //
+ Frame frame1 = new Frame ();
+ VBox vbox1 = new VBox (false, 0);
+ frame1.Add (vbox1);
+
+ // title
+ HBox hbox1 = new HBox (false, 3);
+ hbox1.BorderWidth = 3;
+ Image icon = new Image (Stock.Index, IconSize.Menu);
+ Label look_for_label = new Label ("Look for:");
+ look_for_label.Justify = Justification.Left;
+ look_for_label.Xalign = 0;
+ hbox1.PackEnd (look_for_label, true, true, 0);
+ hbox1.PackEnd (icon, false, true, 0);
+ hbox1.ShowAll ();
+ vbox1.PackStart (hbox1, false, true, 0);
+
+ // entry
+ vbox1.PackStart (new HSeparator (), false, true, 0);
+ browser.index_entry = new Entry ();
+ browser.index_entry.Activated += browser.OnIndexEntryActivated;
+ browser.index_entry.Changed += browser.OnIndexEntryChanged;
+ browser.index_entry.FocusInEvent += browser.OnIndexEntryFocused;
+ browser.index_entry.KeyPressEvent += browser.OnIndexEntryKeyPress;
+ vbox1.PackStart (browser.index_entry, false, true, 0);
+ vbox1.PackStart (new HSeparator (), false, true, 0);
+
+ //search results
+ browser.search_box = new VBox ();
+ vbox1.PackStart (browser.search_box, true, true, 0);
+ vbox1.ShowAll ();
+
+
+ //
+ // Setup the widget
+ //
+ index_list = new BigList (index_reader);
+ //index_list.SetSizeRequest (100, 400);
+
+ index_list.ItemSelected += new ItemSelected (OnIndexSelected);
+ index_list.ItemActivated += new ItemActivated (OnIndexActivated);
+ HBox box = new HBox (false, 0);
+ box.PackStart (index_list, true, true, 0);
+ Scrollbar scroll = new VScrollbar (index_list.Adjustment);
+ box.PackEnd (scroll, false, false, 0);
+
+ browser.search_box.PackStart (box, true, true, 0);
+ box.ShowAll ();
+
+ //
+ // Setup the matches.
+ //
+ browser.matches = new Frame ();
+ match_model = new MatchModel (this);
+ browser.matches.Hide ();
+ match_list = new BigList (match_model);
+ match_list.ItemSelected += new ItemSelected (OnMatchSelected);
+ match_list.ItemActivated += new ItemActivated (OnMatchActivated);
+ HBox box2 = new HBox (false, 0);
+ box2.PackStart (match_list, true, true, 0);
+ Scrollbar scroll2 = new VScrollbar (match_list.Adjustment);
+ box2.PackEnd (scroll2, false, false, 0);
+ box2.ShowAll ();
+
+ browser.matches.Add (box2);
+ index_list.SetSizeRequest (100, 200);
+
+ browser.index_vbox.PackStart (frame1, true, true, 0);
+ browser.index_vbox.PackEnd (browser.matches, true, true, 0);
+ }
+
+ //
+ // This class is used as an implementation of the IListModel
+ // for the matches for a given entry.
+ //
+ public class MatchModel : IListModel {
+ IndexBrowser index_browser;
+ Browser browser;
+
+ public MatchModel (IndexBrowser parent)
+ {
+ index_browser = parent;
+ browser = parent.browser;
+ }
+
+ public int Rows {
+ get {
+ if (index_browser.current_entry != null)
+ return index_browser.current_entry.Count;
+ else
+ return 0;
+ }
+ }
+
+ public string GetValue (int row)
+ {
+ Topic t = index_browser.current_entry [row];
+
+ // Names from the ECMA provider are somewhat
+ // ambigious (you have like a million ToString
+ // methods), so lets give the user the full name
+
+ // Filter out non-ecma
+ if (t.Url [1] != ':')
+ return t.Caption;
+
+ switch (t.Url [0]) {
+ case 'C': return t.Url.Substring (2) + " constructor";
+ case 'M': return t.Url.Substring (2) + " method";
+ case 'P': return t.Url.Substring (2) + " property";
+ case 'F': return t.Url.Substring (2) + " field";
+ case 'E': return t.Url.Substring (2) + " event";
+ default:
+ return t.Caption;
+ }
+ }
+
+ public string GetDescription (int row)
+ {
+ return GetValue (row);
+ }
+
+ }
+
+ void ConfigureIndex (int index)
+ {
+ current_entry = index_reader.GetIndexEntry (index);
+
+ if (current_entry.Count > 1){
+ browser.matches.Show ();
+ match_list.Reload ();
+ match_list.Refresh ();
+ } else {
+ browser.matches.Hide ();
+ }
+ }
+
+ //
+ // When an item is selected from the main index list
+ //
+ void OnIndexSelected (int index)
+ {
+ ConfigureIndex (index);
+ if (browser.matches.Visible == true)
+ match_list.Selected = 0;
+ }
+
+ void OnIndexActivated (int index)
+ {
+ if (browser.matches.Visible == false)
+ browser.LoadUrl (current_entry [0].Url);
+ }
+
+ void OnMatchSelected (int index)
+ {
+ }
+
+ void OnMatchActivated (int index)
+ {
+ browser.LoadUrl (current_entry [index].Url);
+ }
+
+ int FindClosest (string text)
+ {
+ int low = 0;
+ int top = index_reader.Rows-1;
+ int high = top;
+ bool found = false;
+ int best_rate_idx = Int32.MaxValue, best_rate = -1;
+
+ while (low <= high){
+ int mid = (high + low) / 2;
+
+ //Console.WriteLine ("[{0}, {1}] -> {2}", low, high, mid);
+
+ string s;
+ int p = mid;
+ for (s = index_reader.GetValue (mid); s [0] == ' ';){
+ if (p == high){
+ if (p == low){
+ if (best_rate_idx != Int32.MaxValue){
+ //Console.WriteLine ("Bestrated: "+best_rate_idx);
+ //Console.WriteLine ("Bestrated: "+index_reader.GetValue(best_rate_idx));
+ return best_rate_idx;
+ } else {
+ //Console.WriteLine ("Returning P="+p);
+ return p;
+ }
+ }
+
+ high = mid;
+ break;
+ }
+
+ if (p < 0)
+ return 0;
+
+ s = index_reader.GetValue (++p);
+ //Console.WriteLine (" Advancing to ->"+p);
+ }
+ if (s [0] == ' ')
+ continue;
+
+ int c, rate;
+ c = Rate (text, s, out rate);
+ //Console.WriteLine ("[{0}] Text: {1} at {2}", text, s, p);
+ //Console.WriteLine (" Rate: {0} at {1}", rate, p);
+ //Console.WriteLine (" Best: {0} at {1}", best_rate, best_rate_idx);
+ //Console.WriteLine (" {0} - {1}", best_rate, best_rate_idx);
+ if (rate >= best_rate){
+ best_rate = rate;
+ best_rate_idx = p;
+ }
+ if (c == 0)
+ return mid;
+
+ if (low == high){
+ //Console.WriteLine ("THISPATH");
+ if (best_rate_idx != Int32.MaxValue)
+ return best_rate_idx;
+ else
+ return low;
+ }
+
+ if (c < 0){
+ high = mid;
+ } else {
+ if (low == mid)
+ low = high;
+ else
+ low = mid;
+ }
+ }
+
+ // Console.WriteLine ("Another");
+ if (best_rate_idx != Int32.MaxValue)
+ return best_rate_idx;
+ else
+ return high;
+
+ }
+
+ int Rate (string user_text, string db_text, out int rate)
+ {
+ int c = String.Compare (user_text, db_text, true);
+ if (c == 0){
+ rate = 0;
+ return 0;
+ }
+
+ int i;
+ for (i = 0; i < user_text.Length; i++){
+ if (db_text [i] != user_text [i]){
+ rate = i;
+ return c;
+ }
+ }
+ rate = i;
+ return c;
+ }
+
+ public void SearchClosest (string text)
+ {
+ index_list.Selected = FindClosest (text);
+ }
+
+ public void LoadSelected ()
+ {
+ if (browser.matches.Visible == true) {
+ if (match_list.Selected != -1)
+ OnMatchActivated (match_list.Selected);
+ } else {
+ if (index_list.Selected != -1)
+ OnIndexActivated (index_list.Selected);
+ }
+ }
+}
+}
diff --git a/docbrowser/Lookup.glade b/docbrowser/Lookup.glade
new file mode 100644
index 000000000..0def0612b
--- /dev/null
+++ b/docbrowser/Lookup.glade
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
diff --git a/docbrowser/Makefile.am b/docbrowser/Makefile.am
index 2f2ecf55d..1b3fae297 100644
--- a/docbrowser/Makefile.am
+++ b/docbrowser/Makefile.am
@@ -1,5 +1,8 @@
monodocdir=$(prefix)/lib/monodoc
+# HACK: Temporarily bypass build system requiring older GTK and WK
+# -pkg:gtk-sharp-3.0
+
if DMCS_PRESENT
COMPILER=$(MCS)
else
@@ -8,28 +11,14 @@ endif
SUBDIRS=theme-icons
-if ENABLE_GTKHTML
-noinst_DATA = admin.exe
-endif
-
-
-if ENABLE_GECKO
-GECKO_TARGET=GeckoHtmlRender.dll
-endif
-if ENABLE_GTKHTML
-GECKO_PRINTING_DEF="-d:USE_GTKHTML_PRINT"
-
-GTKHTML_TARGET=GtkHtmlHtmlRender.dll
-endif
-if ENABLE_WEBKIT
+#if ENABLE_WEBKIT
WEBKIT_TARGET=WebKitHtmlRender.dll
-endif
-if ENABLE_MONOWEBBROWSER
-MONOWEBBROWSER_TARGET=MonoWebBrowserHtmlRender.dll
-endif
+#endif
+
+DUMMY_TARGET=DummyHtmlRender.dll
-CLEANFILES = browser.exe browser.exe.mdb admin.exe admin.exe.mdb $(GECKO_TARGET) $(GECKO_TARGET).mdb $(GTKHTML_TARGET) $(GTKHTML_TARGET).mdb $(WEBKIT_TARGET) $(WEBKIT_TARGET).mdb $(MONOWEBBROWSER_TARGET) $(MONOWEBBROWSER_TARGET).mdb monodoc.desktop Options.cs
-monodoc_DATA = browser.exe $(GECKO_TARGET) $(GTKHTML_TARGET) $(WEBKIT_TARGET) $(MONOWEBBROWSER_TARGET)
+CLEANFILES = browser.exe browser.exe.mdb $(WEBKIT_TARGET) $(WEBKIT_TARGET).mdb $(DUMMY_TARGET) $(DUMMY_TARGET).mdb monodoc.desktop Options.cs
+monodoc_DATA = browser.exe $(WEBKIT_TARGET) $(DUMMY_TARGET)
DISTCLEANFILES = AssemblyInfo.cs monodoc.desktop monodoc
@@ -40,77 +29,49 @@ browser_sources = \
$(srcdir)/list.cs \
$(srcdir)/elabel.cs \
$(srcdir)/history.cs \
- $(srcdir)/editing.cs \
- $(srcdir)/Contributions.cs \
- $(srcdir)/XmlNodeWriter.cs \
$(srcdir)/IHtmlRender.cs \
$(srcdir)/BookmarkManager.cs \
- $(srcdir)/ProgressPanel.cs
+ $(srcdir)/ProgressPanel.cs \
+ $(srcdir)/Driver.cs \
+ $(srcdir)/Tab.cs \
+ $(srcdir)/IndexBrowser.cs \
+ $(srcdir)/TreeBrowser.cs
browser_built_sources = AssemblyInfo.cs Options.cs
-geckorender_sources = \
- $(srcdir)/PrintManager.cs \
- $(srcdir)/GeckoHtmlRender.cs
-
-gtkhtmlrender_sources = \
- $(srcdir)/PrintManager.cs \
- $(srcdir)/GtkHtmlHtmlRender.cs
-
webkitrender_sources = \
$(srcdir)/WebKitHtmlRender.cs
-monowebbrowserrender_sources = \
- $(srcdir)/BrowserWidget.cs \
- $(srcdir)/MonoWebBrowserHtmlRender.cs
-
-admin_sources = \
- $(srcdir)/admin.cs \
- $(srcdir)/Contributions.cs
-
-browser_assemblies = $(GTK_SHARP_LIBS) $(MONODOC_LIBS) $(GNOME_SHARP_LIBS) -r:System.Web.Services -r:System.Web
-# we insert gtkhtml libs if we have them for printing
-geckorender_assemblies = $(GTK_SHARP_LIBS) $(GTKHTML_SHARP_LIBS) $(GECKO_SHARP_LIBS) $(GNOME_SHARP_LIBS) $(MONODOC_LIBS) -r:browser.exe
-gtkhtmlrender_assemblies = $(GTK_SHARP_LIBS) $(GTKHTML_SHARP_LIBS) $(GNOME_SHARP_LIBS) $(MONODOC_LIBS) -r:browser.exe
-
-webkitrender_assemblies = $(GTK_SHARP_LIBS) $(WEBKIT_SHARP_LIBS) $(MONODOC_LIBS) -r:browser.exe
+dummyrender_sources = \
+ $(srcdir)/DummyHtmlRender.cs
-monowebbrowserrender_assemblies = $(GTK_SHARP_LIBS) $(GNOME_SHARP_LIBS) $(MONOWEBBROWSER_LIBS) $(MONODOC_LIBS) -r:browser.exe -r:Mono.WebBrowser.dll
+#browser_assemblies = $(GTK_SHARP_LIBS) $(MONODOC_LIBS) $(GNOME_SHARP_LIBS) -r:System.Web.Services -r:System.Web
+browser_assemblies = -pkg:gtk-sharp-3.0 $(MONODOC_LIBS) -r:System.Web.Services -r:System.Web
+# webkitrender_assemblies = $(GTK_SHARP_LIBS) $(WEBKIT_SHARP_LIBS) $(MONODOC_LIBS) -r:browser.exe
+webkitrender_assemblies = -pkg:gtk-sharp-3.0 -pkg:webkit2-sharp-4.0 $(MONODOC_LIBS) -r:browser.exe
+# dummyrender_assemblies = $(GTK_SHARP_LIBS) $(MONODOC_LIBS) -r:browser.exe
+dummyrender_assemblies = -pkg:gtk-sharp-3.0 $(MONODOC_LIBS) -r:browser.exe
EXTRA_DIST = \
$(browser_sources) \
- $(geckorender_sources) \
- $(gtkhtmlrender_sources) \
- $(monowebbrowserrender_sources) \
$(webkitrender_sources) \
monodoc.desktop.in \
- admin.cs \
- admin.glade \
- browser.glade \
+ AddBookmarkDialog.glade \
+ BookmarksManager.glade \
+ Browser.glade \
+ Lookup.glade \
monodoc.png \
AssemblyInfo.cs.in \
README.ADMIN
-# admin hardcodes GTKHTML for now.
-if ENABLE_GTKHTML
-admin.exe: $(admin_sources) $(srcdir)/admin.glade
- $(COMPILER) -debug -out:admin.exe $(admin_sources) -resource:$(srcdir)/admin.glade,admin.glade $(browser_assemblies) $(GTKHTML_SHARP_LIBS) -r:System.Drawing
-endif
-
browser.exe: $(browser_sources) $(browser_built_sources) $(srcdir)/browser.glade $(srcdir)/monodoc.png
$(COMPILER) -debug -out:browser.exe $(browser_sources) $(browser_built_sources) -resource:$(srcdir)/monodoc.png,monodoc.png -resource:$(srcdir)/browser.glade,browser.glade $(browser_assemblies) $(CSHARP_FLAGS)
-GeckoHtmlRender.dll : $(geckorender_sources) browser.exe
- $(COMPILER) -debug -target:library -out:$@ $(geckorender_sources) $(geckorender_assemblies) $(GECKO_PRINTING_DEF) $(CSHARP_FLAGS)
-
-GtkHtmlHtmlRender.dll : $(gtkhtmlrender_sources) browser.exe
- $(COMPILER) -debug -target:library -out:$@ $(gtkhtmlrender_sources) $(gtkhtmlrender_assemblies) $(CSHARP_FLAGS)
-
WebKitHtmlRender.dll : $(webkitrender_sources) browser.exe
$(COMPILER) -debug -target:library -out:$@ $(webkitrender_sources) $(webkitrender_assemblies) $(CSHARP_FLAGS)
-MonoWebBrowserHtmlRender.dll : $(monowebbrowserrender_sources) browser.exe
- $(COMPILER) -debug -target:library -out:$@ $(monowebbrowserrender_sources) $(monowebbrowserrender_assemblies) $(CSHARP_FLAGS)
+DummyHtmlRender.dll : $(dummyrender_sources) browser.exe
+ $(COMPILER) -debug -target:library -out:$@ $(dummyrender_sources) $(dummyrender_assemblies) $(CSHARP_FLAGS)
Options.cs:
cp `pkg-config --variable=Sources mono-options` .
@@ -118,9 +79,6 @@ Options.cs:
b: browser.exe
MONO_PATH=. $(RUNTIME) --debug browser.exe
-c: admin.exe
- MONO_PATH=. $(RUNTIME) --debug admin.exe
-
desktopdir = $(datadir)/applications
desktop_DATA = monodoc.desktop
diff --git a/docbrowser/MonoWebBrowserHtmlRender.cs b/docbrowser/MonoWebBrowserHtmlRender.cs
deleted file mode 100755
index f0fa9c8e7..000000000
--- a/docbrowser/MonoWebBrowserHtmlRender.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-//Permission is hereby granted, free of charge, to any person obtaining
-//a copy of this software and associated documentation files (the
-//"Software"), to deal in the Software without restriction, including
-//without limitation the rights to use, copy, modify, merge, publish,
-//distribute, sublicense, and/or sell copies of the Software, and to
-//permit persons to whom the Software is furnished to do so, subject to
-//the following conditions:
-//
-//The above copyright notice and this permission notice shall be
-//included in all copies or substantial portions of the Software.
-//
-//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-//EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-//MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-//NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-//LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-//OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-//WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-//Copyright (c) 2008 Novell, Inc.
-//
-//Authors:
-// Andreia Gaita (avidigal@novell.com)
-//
-
-using System;
-using Mono.WebBrowser;
-using Gtk;
-using System.IO;
-using System.Text;
-using System.Collections;
-
-namespace Monodoc
-{
- public class MonoWebBrowserHtmlRender : IHtmlRender
- {
- BrowserWidget html_panel;
- RootTree help_tree;
-
- public MonoWebBrowserHtmlRender (RootTree help_tree)
- {
- this.help_tree = help_tree;
- }
-
- public event EventHandler OnUrl;
- public event EventHandler UrlClicked;
-
- // Jump to an anchor of the form
- public void JumpToAnchor (string anchor_name)
- {
- }
-
- //Copy to the clipboard the selcted text
- public void Copy ()
- {
- }
-
- //Select all the text
- public void SelectAll ()
- {
- }
-
- // Variable that handles the info encessary for the events
- // As every implementation of HtmlRender will have differents events
- // we try to homogenize them with the variabel
- string url;
- public string Url {
- get {return url; }
- }
-
- public Widget HtmlPanel {
- get { return (Widget)html_panel; }
- }
-
- public void Print (string Html)
- {
- html_panel.browser.ExecuteScript ("print();");
- return;
- }
-
- LoadFinishedEventHandler loadEvent;
- public bool Initialize ()
- {
- html_panel = new BrowserWidget ();
- html_panel.Realized += delegate (object sender, EventArgs e) {
- html_panel.browser.NavigationRequested += delegate (object sender1, NavigationRequestedEventArgs e1) {
-
- url = CheckUrl (e1.Uri);
- // if the file is cached on disk, return
- if (url.StartsWith ("file:///") || url.StartsWith("javascript:", StringComparison.InvariantCultureIgnoreCase))
- return;
-
- if (UrlClicked != null)
- UrlClicked (this, new EventArgs());
- e1.Cancel = true;
- };
- html_panel.browser.StatusChanged += delegate (object sender1, StatusChangedEventArgs e1) {
- url = e1.Message;
- if (OnUrl != null)
- OnUrl (this, new EventArgs ());
- };
- };
- cache_imgs = new Hashtable();
- tmpPath = Path.Combine (Path.GetTempPath (), "monodoc");
- return html_panel.browser.Initialized;
- }
-
- // URL like T:System.Activator are lower cased by gecko to t.;System.Activator
- // so we revert that
- string CheckUrl (string u)
- {
- if (u.IndexOf (':') == 1)
- return Char.ToUpper (u[0]) + u.Substring (1);
- return u;
- }
-
- static int tmp_file = 0;
- string tmpPath;
- Hashtable cache_imgs;
-
- public void Render (string html_code)
- {
- string r = ProcessImages (html_code);
- // if the html code is too big, write it down to a tmp file
- if (((uint) r.Length) > 50000) {
- string filename = (tmp_file++) + ".html";
- string filepath = Path.Combine (tmpPath, filename);
- using (FileStream file = new FileStream (filepath, FileMode.Create)) {
- StreamWriter sw = new StreamWriter (file);
- sw.Write (r);
- sw.Close ();
- }
- html_panel.browser.Navigation.Go (filepath);
- } else {
- html_panel.browser.Render (r);
- }
-
- }
-
- // Substitute the src of the images with the appropriate path
- string ProcessImages (string html_code)
- {
- //If there are no Images return fast
- int pos = html_code.IndexOf ("
-
-
-
-
-
-
-
-
-
- Here as you can see the configuration file is made to point to
- the various directories that I have checkout from CVS.
-
-Policies
-========
-
- People contribute many kinds of changes, and we do not
- necessarily want all of those changes, changes that are
- typically OK:
-
- * Completing missing documentation.
-
- * Providing illustrative examples.
-
- * Copy/pasting documentation from the ECMA
- specification. The ECMA specification has been
- updated and the license allows us to incorporate
- those changes.
-
- We have sadly not automated this process and hence
- the documentation that we have reflects the first
- ECMA release, not the latest one.
-
- * Pointing out alternative APIs that might be better
- suited for a particular task, limitations in an API.
-
- Changes that are not OK:
-
- * Long explanations in the summary line that should be
- instead in the Remarks section.
-
- * Sample code in languages other than C#. People
- have been picking samples in Boo, Visual Basic,
- Jscript and IronPython, but considering that we do
- even have complete C# coverage, it is better to keep
- all samples in C#.
-
- * Documentation that has been copy/pasted from
- Microsoft documentation. This means that for every
- change that affects the Microsoft stack
- documentation an editor must verify that the text
- for the equivalent class is not the same.
-
- This can be a very time consuming operation, and it
- is best to not approve a change if you have not
- explicitly verified that this is not a copy.
-
- * Opinions, these should be kept out of the
- documentation, this is a technical document and we
- should not be passing value judgments on it.
-
-
-Using the Tool
-==============
-
- Once you have configured the tool, run the `make c' command in
- this directory. This will bring up the administration tool.
- Click on "Check Server Updates to get updates from the
- server".
-
- Many of the early applications are pending review or have some
- problems but we have not cleared them out yet, so its best to
- start at the higher numbered contributions which are the
- freshest.
-
- Click on a contribution, it will show you the actual change.
- The rendering is not perfect, if you want to get further
- information click [Diff], that will provide a rendering before
- and after that you can more easily examine.
-
- When you like a change, click on [Apply], and commit the code
- properly giving credit on the commit message to the person
- that made the contribution (you must do this from a separate
- window where you run svn commit). [Yes, this could be improved]
-
- If the contribution is large, also add the contribution to the
- AUTHORS for that particular bit of documentation.
-
- Once a contribution has been applied and there is nothing left
- to use (either because it has been applied, or the
- contribution has been deemed as invalid) click the [Flag as
- Done] button that will remove the contribution from the list
-
-Samples in Other Languages
-==========================
-
- The reality is that we probably need a better system to handle
- examples, keep those examples off-line so that people can
- contribute alternative implementations, but at this point we
- do not have a mechanism to do this.
diff --git a/docbrowser/Tab.cs b/docbrowser/Tab.cs
new file mode 100644
index 000000000..2842ba95e
--- /dev/null
+++ b/docbrowser/Tab.cs
@@ -0,0 +1,203 @@
+using Gtk;
+using System;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using System.Collections;
+using System.Collections.Generic;
+using System.Web.Services.Protocols;
+using System.Xml;
+
+using Mono.Options;
+
+#if MACOS
+using OSXIntegration.Framework;
+#endif
+
+namespace Monodoc {
+//
+// A Tab is a Notebok with two pages, one for editing and one for visualizing
+//
+public class Tab : Notebook {
+ // Where we render the contents
+ public IHtmlRender html;
+
+ public History history;
+ private Browser browser;
+ private Label titleLabel;
+ public HBox TabLabel;
+
+ public string Title {
+ get { return titleLabel.Text; }
+ set { titleLabel.Text = value; }
+ }
+
+ public Node CurrentNode;
+
+ void FocusOut (object sender, FocusOutEventArgs args)
+ {
+ }
+
+
+ private static IHtmlRender LoadRenderer (string dll, Browser browser) {
+ if (!System.IO.File.Exists (dll))
+ return null;
+
+ try {
+ Assembly ass = Assembly.LoadFile (dll);
+ System.Type type = ass.GetType ("Monodoc." + ass.GetName ().Name, false, false);
+ if (type == null)
+ return null;
+ return (IHtmlRender) Activator.CreateInstance (type, new object[1] { browser.help_tree });
+ } catch (Exception ex) {
+ Console.Error.WriteLine (ex);
+ }
+ return null;
+ }
+
+ public static IHtmlRender GetRenderer (string engine, Browser browser)
+ {
+ IHtmlRender renderer = LoadRenderer (System.IO.Path.Combine (AppDomain.CurrentDomain.BaseDirectory, engine + "HtmlRender.dll"), browser);
+ if (renderer != null) {
+ try {
+ if (renderer.Initialize ()) {
+ Console.WriteLine ("using " + renderer.Name);
+ return renderer;
+ }
+ } catch (Exception ex) {
+ Console.Error.WriteLine (ex);
+ }
+ }
+
+ foreach (string backend in Driver.engines) {
+ if (backend != engine) {
+ renderer = LoadRenderer (System.IO.Path.Combine (AppDomain.CurrentDomain.BaseDirectory, backend + "HtmlRender.dll"), browser);
+ if (renderer != null) {
+ try {
+ if (renderer.Initialize ()) {
+ Console.WriteLine ("using " + renderer.Name);
+ return renderer;
+ }
+ } catch (Exception ex) {
+ Console.Error.WriteLine (ex);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public Tab(Browser br)
+ {
+ browser = br;
+ CurrentNode = br.help_tree;
+ ShowTabs = false;
+ ShowBorder = false;
+ //TabBorder = 0;
+ //TabHborder = 0;
+ history = new History (browser.back_button, browser.forward_button);
+
+ //
+ // First Page
+ //
+ ScrolledWindow html_container = new ScrolledWindow();
+ html_container.Show();
+
+ //
+ // Setup the HTML rendering and preview area
+ //
+
+ html = GetRenderer (browser.engine, browser);
+ if (html == null)
+ throw new Exception ("Couldn't find html renderer!");
+
+ browser.capabilities = html.Capabilities;
+
+ HelpSource.FullHtml = false;
+ HelpSource.UseWebdocCache = true;
+ if ((html.Capabilities & Capabilities.Css) != 0)
+ HelpSource.use_css = true;
+
+ //Prepare Font for css (TODO: use GConf?)
+ if ((html.Capabilities & Capabilities.Fonts) != 0 && SettingsHandler.Settings.preferred_font_size == 0) {
+ Pango.FontDescription font_desc = Pango.FontDescription.FromString ("Sans 12");
+ SettingsHandler.Settings.preferred_font_family = font_desc.Family;
+ SettingsHandler.Settings.preferred_font_size = 100; //size: 100%
+ }
+
+ html_container.Add (html.HtmlPanel);
+ html.UrlClicked += new EventHandler (browser.LinkClicked);
+ html.OnUrl += new EventHandler (browser.OnUrlMouseOver);
+ browser.context_id = browser.statusbar.GetContextId ("");
+
+ AppendPage(html_container, new Label("Html"));
+
+ //
+ //Create the Label for the Tab
+ //
+ TabLabel = new HBox(false, 2);
+
+ titleLabel = new Label("");
+
+ //Close Tab button
+ Button tabClose = new Button();
+ Image img = new Image(Stock.Close, IconSize.SmallToolbar);
+ tabClose.Add(img);
+ tabClose.Relief = Gtk.ReliefStyle.None;
+ tabClose.SetSizeRequest (18, 18);
+ tabClose.Clicked += new EventHandler (browser.OnCloseTab);
+
+ TabLabel.PackStart (titleLabel, true, true, 0);
+ TabLabel.PackStart (tabClose, false, false, 2);
+
+ // needed, otherwise even calling show_all on the notebook won't
+ // make the hbox contents appear.
+ TabLabel.ShowAll();
+
+ }
+
+ public static string GetNiceUrl (Node node) {
+ if (node.Element.StartsWith("N:"))
+ return node.Element;
+ string name, full;
+ int bk_pos = node.Caption.IndexOf (' ');
+ // node from an overview
+ if (bk_pos != -1) {
+ name = node.Caption.Substring (0, bk_pos);
+ full = node.Parent.Caption + "." + name.Replace ('.', '+');
+ return "T:" + full;
+ }
+ // node that lists constructors, methods, fields, ...
+ if ((node.Caption == "Constructors") || (node.Caption == "Fields") || (node.Caption == "Events")
+ || (node.Caption == "Members") || (node.Caption == "Properties") || (node.Caption == "Methods")
+ || (node.Caption == "Operators")) {
+ bk_pos = node.Parent.Caption.IndexOf (' ');
+ name = node.Parent.Caption.Substring (0, bk_pos);
+ full = node.Parent.Parent.Caption + "." + name.Replace ('.', '+');
+ return "T:" + full + "/" + node.Element;
+ }
+ int pr_pos = node.Caption.IndexOf ('(');
+ // node from a constructor
+ if (node.Parent.Element == "C") {
+ name = node.Parent.Parent.Parent.Caption;
+ int idx = node.PublicUrl.IndexOf ('/');
+ return node.PublicUrl[idx+1] + ":" + name + "." + node.Caption.Replace ('.', '+');
+ // node from a method with one signature, field, property, operator
+ } else if (pr_pos == -1) {
+ bk_pos = node.Parent.Parent.Caption.IndexOf (' ');
+ name = node.Parent.Parent.Caption.Substring (0, bk_pos);
+ full = node.Parent.Parent.Parent.Caption + "." + name.Replace ('.', '+');
+ int idx = node.PublicUrl.IndexOf ('/');
+ return node.PublicUrl[idx+1] + ":" + full + "." + node.Caption;
+ // node from a method with several signatures
+ } else {
+ bk_pos = node.Parent.Parent.Parent.Caption.IndexOf (' ');
+ name = node.Parent.Parent.Parent.Caption.Substring (0, bk_pos);
+ full = node.Parent.Parent.Parent.Parent.Caption + "." + name.Replace ('.', '+');
+ int idx = node.PublicUrl.IndexOf ('/');
+ return node.PublicUrl[idx+1] + ":" + full + "." + node.Caption;
+ }
+ }
+}
+}
diff --git a/docbrowser/TreeBrowser.cs b/docbrowser/TreeBrowser.cs
new file mode 100644
index 000000000..3082e6978
--- /dev/null
+++ b/docbrowser/TreeBrowser.cs
@@ -0,0 +1,264 @@
+using Gtk;
+using System;
+using System.IO;
+using System.Reflection;
+using System.Threading;
+using System.Collections;
+using System.Collections.Generic;
+using System.Web.Services.Protocols;
+using System.Xml;
+
+using Mono.Options;
+
+#if MACOS
+using OSXIntegration.Framework;
+#endif
+
+namespace Monodoc {
+//
+// This class implements the tree browser
+//
+public class TreeBrowser {
+ Browser browser;
+
+ TreeView tree_view;
+
+ TreeStore store;
+ RootTree help_tree;
+ TreeIter root_iter;
+
+ //
+ // This hashtable maps an iter to its node.
+ //
+ Hashtable iter_to_node;
+
+ //
+ // This hashtable maps the node to its iter
+ //
+ Hashtable node_to_iter;
+
+ //
+ // Maps a node to its TreeIter parent
+ //
+ Hashtable node_parent;
+
+ public TreeBrowser (RootTree help_tree, TreeView reference_tree, Browser browser)
+ {
+ this.browser = browser;
+ tree_view = reference_tree;
+ iter_to_node = new Hashtable ();
+ node_to_iter = new Hashtable ();
+ node_parent = new Hashtable ();
+
+ // Setup the TreeView
+ tree_view.AppendColumn ("name_col", new CellRendererText (), "text", 0);
+
+ // Bind events
+ tree_view.RowExpanded += new Gtk.RowExpandedHandler (RowExpanded);
+ tree_view.Selection.Changed += new EventHandler (RowActivated);
+ tree_view.RowActivated += new Gtk.RowActivatedHandler (RowClicked);
+
+ // Setup the model
+ this.help_tree = help_tree;
+ store = new TreeStore (typeof (string));
+
+ root_iter = store.AppendValues ("Mono Documentation");
+ iter_to_node [root_iter] = help_tree;
+ node_to_iter [help_tree] = root_iter;
+ PopulateNode (help_tree, root_iter);
+
+ reference_tree.Model = store;
+ }
+
+ void PopulateNode (Node node, TreeIter parent)
+ {
+ if (node.Nodes == null)
+ return;
+
+ TreeIter iter;
+ foreach (Node n in node.Nodes){
+ iter = store.AppendValues (parent, n.Caption);
+ iter_to_node [iter] = n;
+ node_to_iter [n] = iter;
+ }
+ }
+
+ Hashtable populated = new Hashtable ();
+
+ void RowExpanded (object o, Gtk.RowExpandedArgs args)
+ {
+ Node result = iter_to_node [args.Iter] as Node;
+
+ Open (result);
+ }
+
+ void RowClicked (object o, Gtk.RowActivatedArgs args)
+ {
+ ITreeModel model;
+ Gtk.TreeIter iter;
+ Gtk.TreePath path = args.Path;
+
+ tree_view.Selection.GetSelected (out model, out iter);
+
+ Node result = iter_to_node [iter] as Node;
+
+ if (!tree_view.GetRowExpanded (path)) {
+ tree_view.ExpandRow (path, false);
+ Open (result);
+ } else {
+ tree_view.CollapseRow (path);
+ }
+
+ }
+
+ void Open (Node node)
+ {
+ if (node == null){
+ Console.Error.WriteLine ("Expanding something that I do not know about");
+ return;
+ }
+
+ if (populated.Contains (node))
+ return;
+
+ //
+ // We need to populate data on a second level
+ //
+ if (node.Nodes == null)
+ return;
+
+ foreach (Node n in node.Nodes){
+ PopulateNode (n, (TreeIter) node_to_iter [n]);
+ }
+ populated [node] = true;
+ }
+
+ void PopulateTreeFor (Node n)
+ {
+ if (populated [n] == null){
+ if (n.Parent != null) {
+ OpenTree (n.Parent);
+ }
+ }
+ Open (n);
+ }
+
+ public void OpenTree (Node n)
+ {
+ PopulateTreeFor (n);
+
+ TreeIter iter = (TreeIter) node_to_iter [n];
+ TreePath path = store.GetPath (iter);
+ }
+
+ public Node SelectedNode
+ {
+ get {
+ Gtk.TreeIter iter;
+ ITreeModel model;
+
+ if (tree_view.Selection.GetSelected (out model, out iter))
+ return (Node) iter_to_node [iter];
+ else
+ return null;
+ }
+ }
+
+ public void ShowNode (Node n)
+ {
+ if (node_to_iter [n] == null){
+ OpenTree (n);
+ if (node_to_iter [n] == null){
+ Console.Error.WriteLine ("Internal error: no node to iter mapping");
+ return;
+ }
+ }
+
+ TreeIter iter = (TreeIter) node_to_iter [n];
+ TreePath path = store.GetPath (iter);
+
+ tree_view.ExpandToPath (path);
+
+ IgnoreRowActivated = true;
+ tree_view.Selection.SelectPath (path);
+ IgnoreRowActivated = false;
+ tree_view.ScrollToCell (path, null, false, 0.5f, 0.0f);
+ }
+
+ class NodePageVisit : PageVisit {
+ Browser browser;
+ Node n;
+ string url;
+
+ public NodePageVisit (Browser browser, Node n, string url)
+ {
+ if (n == null)
+ throw new Exception ("N is null");
+
+ this.browser = browser;
+ this.n = n;
+ this.url = url;
+ }
+
+ public override void Go ()
+ {
+ string res = Browser.GetHtml (url, n.tree.HelpSource, browser.help_tree);
+ browser.Render (res, n, url);
+ }
+ }
+
+ bool IgnoreRowActivated = false;
+
+ //
+ // This has to handle two kinds of urls: those encoded in the tree
+ // file, which are used to quickly lookup information precisely
+ // (things like "ecma:0"), and if that fails, it uses the more expensive
+ // mechanism that walks trees to find matches
+ //
+ void RowActivated (object sender, EventArgs a)
+ {
+
+ //browser.CurrentTab.SetMode (Mode.Viewer);
+
+ if (IgnoreRowActivated)
+ return;
+
+ Gtk.TreeIter iter;
+ ITreeModel model;
+
+ if (tree_view.Selection.GetSelected (out model, out iter)){
+ Node n = (Node) iter_to_node [iter];
+
+ string url = n.PublicUrl;
+ Node match;
+ string s;
+
+ if (n.tree.HelpSource != null)
+ {
+ //
+ // Try the tree-based urls first.
+ //
+
+ s = Browser.GetHtml (url, n.tree.HelpSource, help_tree);
+ if (s != null){
+ ((Browser)browser).Render (s, n, url);
+ browser.CurrentTab.history.AppendHistory (new NodePageVisit (browser, n, url));
+ return;
+ }
+ }
+
+ //
+ // Try the url resolver next
+ //
+ s = Browser.GetHtml (url, null, help_tree);
+ if (s != null){
+ ((Browser)browser).Render (s, n, url);
+ browser.CurrentTab.history.AppendHistory (new Browser.LinkPageVisit (browser, url));
+ return;
+ }
+
+ ((Browser)browser).Render ("Unhandled URL
" + "Functionality to view the resource " + n.PublicUrl + " is not available on your system or has not yet been implemented.
", null, url);
+ }
+ }
+}
+}
diff --git a/docbrowser/WebKitHtmlRender.cs b/docbrowser/WebKitHtmlRender.cs
index d698b0619..c0f6a90a9 100644
--- a/docbrowser/WebKitHtmlRender.cs
+++ b/docbrowser/WebKitHtmlRender.cs
@@ -7,7 +7,7 @@
using System;
using System.IO;
using Gtk;
-using WebKit;
+using WebKit2;
namespace Monodoc {
public class WebKitHtmlRender : IHtmlRender {
@@ -30,16 +30,19 @@ public WebKitHtmlRender (RootTree help_tree)
{
web_view = new WebView ();
web_view.Show ();
- web_view.NavigationRequested += delegate (object sender, NavigationRequestedArgs e) {
+ web_view.ResourceLoadStarted += delegate (object sender, ResourceLoadStartedArgs e) {
if (e.Request.Uri == "about:blank")
return;
url = e.Request.Uri;
+ // TODO: I don't see a way to stop the request from the event;
+ // so we try this; sometimes it doesn't happen though, and we have a race
+ web_view.StopLoading ();
if (UrlClicked != null)
UrlClicked (this, new EventArgs());
- e.RetVal = NavigationResponse.Ignore;
+ //e.RetVal = NavigationResponse.Ignore;
};
- web_view.HoveringOverLink += delegate (object sender, HoveringOverLinkArgs e) {
- url = e.Link;
+ web_view.MouseTargetChanged += delegate (object sender, MouseTargetChangedArgs e) {
+ url = e?.HitTestResult?.LinkUri;
if (OnUrl != null)
OnUrl (this, new EventArgs ());
};
@@ -48,27 +51,29 @@ public WebKitHtmlRender (RootTree help_tree)
public void JumpToAnchor (string anchor)
{
- web_view.Open ("#" + anchor);
+ web_view.LoadUri ("#" + anchor);
}
+ // TODO: Reimplement for WebKit2
+
public void Copy ()
{
- web_view.CopyClipboard ();
+ //web_view.CopyClipboard ();
}
public void SelectAll ()
{
- web_view.SelectAll ();
+ //web_view.SelectAll ();
}
public void Render (string html)
{
- web_view.LoadHtmlString (html, null);
+ web_view.LoadHtml (html);
}
public void Print (string html)
{
- web_view.ExecuteScript ("print();");
+ //web_view.ExecuteScript ("print();");
}
public bool Initialize ()
diff --git a/docbrowser/XmlNodeWriter.cs b/docbrowser/XmlNodeWriter.cs
deleted file mode 100644
index ce726f045..000000000
--- a/docbrowser/XmlNodeWriter.cs
+++ /dev/null
@@ -1,367 +0,0 @@
-//
-// Mono.Xml.XmlNodeWriter
-//
-// Author:
-// Atsushi Enomoto (ginga@kit.hi-ho.ne.jp)
-//
-// (C)2003 Atsushi Enomoto
-//
-using System;
-using System.Xml;
-
-namespace Monodoc
-{
- public class CopyXmlNodeWriter : XmlWriter
- {
- public CopyXmlNodeWriter () : this (true)
- {
- }
-
- // It should be public after some tests are done :-)
- public CopyXmlNodeWriter (bool isDocumentEntity)
- {
- doc = new XmlDocument ();
- state = XmlNodeType.None;
- this.isDocumentEntity = isDocumentEntity;
- if (!isDocumentEntity)
- current = fragment = doc.CreateDocumentFragment ();
- }
-
- XmlDocument doc;
- bool isClosed;
- // If it is not null, then we are now inside the element.
- XmlNode current;
- // If it is not null, then we are now inside the attribute.
- XmlAttribute attribute;
- // If it is false, then allow to contain multiple document elements.
- bool isDocumentEntity;
- XmlDocumentFragment fragment;
-
- // None: started or closed.
- // XmlDeclaration: after xmldecl. Never allow xmldecl.
- // DocumentType: after doctype. Never allow xmldecl and doctype.
- // Element: inside document element.
- //
- XmlNodeType state;
-
- // Properties
- public XmlNode Document {
- get { return isDocumentEntity ? (XmlNode)doc : (XmlNode)fragment; }
- }
-
- public override WriteState WriteState {
- get {
- if (isClosed)
- return WriteState.Closed;
- if (attribute != null)
- return WriteState.Attribute;
-
- switch (state) {
- case XmlNodeType.None:
- return WriteState.Start;
- case XmlNodeType.XmlDeclaration:
- return WriteState.Prolog;
- case XmlNodeType.DocumentType:
- return WriteState.Element;
- default:
- return WriteState.Content;
- }
- }
- }
-
- public override string XmlLang {
- get {
- for (XmlElement n = current as XmlElement; n != null; n = n.ParentNode as XmlElement)
- if (n.HasAttribute ("xml:lang"))
- return n.GetAttribute ("xml:lang");
- return String.Empty;
- }
- }
-
- public override XmlSpace XmlSpace {
- get {
- for (XmlElement n = current as XmlElement; n != null; n = n.ParentNode as XmlElement) {
- string xs = n.GetAttribute ("xml:space");
- switch (xs) {
- case "preserve":
- return XmlSpace.Preserve;
- case "default":
- return XmlSpace.Default;
- case "":
- continue;
- default:
- throw new InvalidOperationException (String.Format ("Invalid xml:space {0}.", xs));
- }
- }
- return XmlSpace.None;
- }
- }
-
- // Private Methods
-
- private void CheckState ()
- {
- if (isClosed)
- throw new InvalidOperationException ();
-
- }
-
- private void WritePossiblyTopLevelNode (XmlNode n, bool possiblyAttribute)
- {
- CheckState ();
- if (!possiblyAttribute && attribute != null)
- throw new InvalidOperationException (String.Format ("Current state is not acceptable for {0}.", n.NodeType));
-
- if (state != XmlNodeType.Element)
- Document.AppendChild (n);
- else if (attribute != null)
- attribute.AppendChild (n);
- else
- current.AppendChild (n);
- if (state == XmlNodeType.None)
- state = XmlNodeType.XmlDeclaration;
- }
-
- // Public Methods
-
- public override void Close ()
- {
- CheckState ();
- isClosed = true;
- }
-
- public override void Flush ()
- {
- }
-
- public override string LookupPrefix (string ns)
- {
- CheckState ();
- if (current == null)
- throw new InvalidOperationException ();
- return current.GetPrefixOfNamespace (ns);
- }
-
- // StartDocument
-
- public override void WriteStartDocument ()
- {
- WriteStartDocument (null);
- }
-
- public override void WriteStartDocument (bool standalone)
- {
- WriteStartDocument (standalone ? "yes" : "no");
- }
-
- private void WriteStartDocument (string sddecl)
- {
- CheckState ();
- if (state != XmlNodeType.None)
- throw new InvalidOperationException ("Current state is not acceptable for xmldecl.");
-
- doc.AppendChild (doc.CreateXmlDeclaration ("1.0", null, sddecl));
- state = XmlNodeType.XmlDeclaration;
- }
-
- // EndDocument
-
- public override void WriteEndDocument ()
- {
- CheckState ();
-
- isClosed = true;
- }
-
- // DocumentType
- public override void WriteDocType (string name, string publicId, string systemId, string internalSubset)
- {
- CheckState ();
- switch (state) {
- case XmlNodeType.None:
- case XmlNodeType.XmlDeclaration:
- doc.AppendChild (doc.CreateDocumentType (name, publicId, systemId, internalSubset));
- state = XmlNodeType.DocumentType;
- break;
- default:
- throw new InvalidOperationException ("Current state is not acceptable for doctype.");
- }
- }
-
- // StartElement
-
- public override void WriteStartElement (string prefix, string name, string ns)
- {
- CheckState ();
- if (isDocumentEntity && state == XmlNodeType.EndElement && doc.DocumentElement != null)
- throw new InvalidOperationException ("Current state is not acceptable for startElement.");
-
- XmlElement el = doc.CreateElement (prefix, name, ns);
- if (current == null) {
- Document.AppendChild (el);
- state = XmlNodeType.Element;
- } else {
- current.AppendChild (el);
- state = XmlNodeType.Element;
- }
-
- current = el;
- }
-
- // EndElement
-
- public override void WriteEndElement ()
- {
- WriteEndElementInternal (false);
- }
-
- public override void WriteFullEndElement ()
- {
- WriteEndElementInternal (true);
- }
-
- private void WriteEndElementInternal (bool forceFull)
- {
- CheckState ();
- if (current == null)
- throw new InvalidOperationException ("Current state is not acceptable for endElement.");
-
- if (!forceFull && current.FirstChild == null)
- ((XmlElement) current).IsEmpty = true;
-
- if (isDocumentEntity && current.ParentNode == doc)
- state = XmlNodeType.EndElement;
- else
- current = current.ParentNode;
- }
-
- // StartAttribute
-
- public override void WriteStartAttribute (string prefix, string name, string ns)
- {
- CheckState ();
- if (attribute != null)
- throw new InvalidOperationException ("There is an open attribute.");
- if (!(current is XmlElement))
- throw new InvalidOperationException ("Current state is not acceptable for startAttribute.");
-
- attribute = doc.CreateAttribute (prefix, name, ns);
- ((XmlElement)current).SetAttributeNode (attribute);
- }
-
- public override void WriteEndAttribute ()
- {
- CheckState ();
- if (attribute == null)
- throw new InvalidOperationException ("Current state is not acceptable for startAttribute.");
-
- attribute = null;
- }
-
- public override void WriteCData (string data)
- {
- CheckState ();
- if (current == null)
- throw new InvalidOperationException ("Current state is not acceptable for CDATAsection.");
-
- current.AppendChild (doc.CreateCDataSection (data));
- }
-
- public override void WriteComment (string comment)
- {
- WritePossiblyTopLevelNode (doc.CreateComment (comment), false);
- }
-
- public override void WriteProcessingInstruction (string name, string value)
- {
- WritePossiblyTopLevelNode (
- doc.CreateProcessingInstruction (name, value), false);
- }
-
- public override void WriteEntityRef (string name)
- {
- WritePossiblyTopLevelNode (doc.CreateEntityReference (name), true);
- }
-
- public override void WriteCharEntity (char c)
- {
- WritePossiblyTopLevelNode (doc.CreateTextNode (new string (new char [] {c}, 0, 1)), true);
- }
-
- public override void WriteWhitespace (string ws)
- {
- WritePossiblyTopLevelNode (doc.CreateWhitespace (ws), true);
- }
-
- public override void WriteString (string data)
- {
- CheckState ();
- if (current == null)
- throw new InvalidOperationException ("Current state is not acceptable for Text.");
-
- if (attribute != null)
- attribute.AppendChild (doc.CreateTextNode (data));
- else {
- XmlText last = current.LastChild as XmlText;
- if (last == null)
- current.AppendChild(doc.CreateTextNode(data));
- else
- last.AppendData(data);
- }
- }
-
- public override void WriteName (string name)
- {
- WriteString (name);
- }
-
- public override void WriteNmToken (string nmtoken)
- {
- WriteString (nmtoken);
- }
-
- public override void WriteQualifiedName (string name, string ns)
- {
- string prefix = LookupPrefix (ns);
- if (prefix == null)
- throw new ArgumentException (String.Format ("Invalid namespace {0}", ns));
- if (prefix != String.Empty)
- WriteString (name);
- else
- WriteString (prefix + ":" + name);
- }
-
- public override void WriteChars (char [] chars, int start, int len)
- {
- WriteString (new string (chars, start, len));
- }
-
- public override void WriteRaw (string data)
- {
- // It never supports raw string.
- WriteString (data);
- }
-
- public override void WriteRaw (char [] chars, int start, int len)
- {
- // It never supports raw string.
- WriteChars (chars, start, len);
- }
-
- public override void WriteBase64 (byte [] data, int start, int len)
- {
- // It never supports raw string.
- WriteString (Convert.ToBase64String (data, start, len));
- }
-
- public override void WriteBinHex (byte [] data, int start, int len)
- {
- throw new NotImplementedException ();
- }
-
- public override void WriteSurrogateCharEntity (char c1, char c2)
- {
- throw new NotImplementedException ();
- }
- }
-}
diff --git a/docbrowser/admin.cs b/docbrowser/admin.cs
deleted file mode 100644
index 4afad514a..000000000
--- a/docbrowser/admin.cs
+++ /dev/null
@@ -1,494 +0,0 @@
-//
-// admin.cs: Mono collaborative documentation adminsitration tool.
-//
-// Author:
-// Miguel de Icaza
-//
-// (C) 2003 Novell, Inc.
-//
-using Gtk;
-using GtkSharp;
-using Glade;
-using System;
-using System.IO;
-using System.Xml;
-using System.Collections;
-using System.Xml.Serialization;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace Monodoc {
-class AdminDriver {
- static int Main (string [] args)
- {
- bool real_server = true;
-
- if (Environment.GetEnvironmentVariable ("MONODOCTESTING") != null)
- real_server = false;
-
- Settings.RunningGUI = true;
- Application.Init ();
- Admin admin = new Admin (real_server);
- Application.Run ();
- return 0;
- }
-}
-
-
-
-class Admin {
- Glade.XML ui;
- [Widget] Window main_window;
- [Widget] ScrolledWindow container, review_container;
- [Widget] Statusbar statusbar;
- [Widget] Notebook notebook;
- [Widget] TextView text_ondisk;
- [Widget] TextView text_diff;
- [Widget] TextView text_current;
- uint contextid;
-
- HTML html, html_review;
-
- Contributions d;
- string login = SettingsHandler.Settings.Email;
- string pass = SettingsHandler.Settings.Key;
- PendingChange [] changes;
-
- public Admin (bool real_server)
- {
- LoadProviders ();
- ui = new Glade.XML (null, "admin.glade", "main_window", null);
- ui.Autoconnect (this);
- contextid = statusbar.GetContextId ("");
-
- main_window.DeleteEvent += new DeleteEventHandler (OnDeleteEvent);
- d = new Contributions ();
- if (real_server)
- d.Url = "http://www.go-mono.com/docs/server.asmx";
-
- html = new HTML ();
- html.LinkClicked += new LinkClickedHandler (LinkClicked);
- html.Show ();
- html.SetSizeRequest (700, 500);
- container.Add (html);
-
- html_review = new HTML ();
- html_review.LinkClicked += new LinkClickedHandler (ReviewLinkClicked);
- html_review.Show ();
- review_container.Add (html_review);
- }
-
- bool Decouple (string prefix, string url, out int id, out int serial)
- {
- if (!url.StartsWith (prefix)){
- id = 0;
- serial = 0;
- return false;
- }
-
- string rest = url.Substring (prefix.Length);
- int p = rest.IndexOf ('$');
- string sid = rest.Substring (0, p);
- string sserial = rest.Substring (p+1);
-
- id = int.Parse (sid);
- serial = int.Parse (sserial);
-
- return true;
- }
-
- void LinkClicked (object o, LinkClickedArgs args)
- {
- string url = args.Url;
- int id, serial;
-
- Console.WriteLine ("Got: " + url);
- if (Decouple ("review:", url, out id, out serial)){
- RenderReview (id, serial);
- return;
- }
-
- Console.WriteLine ("Unhandled url: " + url);
- }
-
- class FileAction {
- public GlobalChangeset globalset;
- public DocSetChangeset docset;
- public FileChangeset fileset;
-
- public FileAction (GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs)
- {
- globalset = gs;
- docset = ds;
- fileset = fs;
- }
- }
-
- class ItemAction {
- public GlobalChangeset globalset;
- public DocSetChangeset docset;
- public FileChangeset fileset;
- public Change change;
-
- public ItemAction (GlobalChangeset gs, DocSetChangeset ds, FileChangeset fs, Change c)
- {
- globalset = gs;
- docset = ds;
- fileset = fs;
- change = c;
- }
- }
-
- void ApplyFile (FileAction fa)
- {
- XmlDocument d = LoadDocument (fa.docset, fa.fileset.RealFile);
-
- foreach (Change c in fa.fileset.Changes){
- XmlNode old = d.SelectSingleNode (c.XPath);
- if (old != null)
- old.ParentNode.ReplaceChild (d.ImportNode (c.NewNode, true), old);
-
- }
- SaveDocument (d, fa.docset, fa.fileset);
- }
-
- void ApplyItem (ItemAction fa)
- {
- XmlDocument d = LoadDocument (fa.docset, fa.fileset.RealFile);
-
- XmlNode old = d.SelectSingleNode (fa.change.XPath);
- if (old != null)
- old.ParentNode.ReplaceChild (d.ImportNode (fa.change.NewNode, true), old);
-
- SaveDocument (d, fa.docset, fa.fileset);
- }
-
- static void WriteNode (string file, string str)
- {
- using (FileStream s = File.Create (file)){
- using (StreamWriter sw = new StreamWriter (s)){
- sw.Write (str);
- }
- }
- }
-
- void DiffChangeItem (ItemAction fa)
- {
- XmlDocument d = LoadDocument (fa.docset, fa.fileset.RealFile);
-
- XmlNode orig = d.SelectSingleNode (fa.change.XPath);
- XmlNode newn = fa.change.NewNode;
-
- text_ondisk.Buffer.Text = orig.InnerXml;
- text_current.Buffer.Text = newn.InnerXml;
-
- WriteNode ("/tmp/file-1", orig.InnerXml);
- WriteNode ("/tmp/file-2", newn.InnerXml);
-
- Process diffp = new Process ();
- diffp.StartInfo.FileName = "diff";
- diffp.StartInfo.Arguments = "-uw /tmp/file-1 /tmp/file-2";
- diffp.StartInfo.UseShellExecute = false;
- diffp.StartInfo.RedirectStandardOutput = true;
- diffp.Start ();
-
- text_diff.Buffer.Text = "=" + diffp.StandardOutput.ReadToEnd ();
- diffp.WaitForExit ();
- }
-
- void SaveDocument (XmlDocument d, DocSetChangeset docset, FileChangeset fileset)
- {
- string basedir = (string) providers [docset.DocSet];
- string file = basedir + "/" + fileset.RealFile;
-
- d.Save (file);
- RenderReview (current_id, current_serial);
- }
-
- void ReviewLinkClicked (object o, LinkClickedArgs args)
- {
- string url = args.Url;
- int id, serial;
-
- if (Decouple ("flag-done:", url, out id, out serial)){
- d.UpdateStatus (login, pass, id, serial, 1);
- notebook.Page = 0;
- return;
- }
-
- if (url.StartsWith ("apply-file:")){
- string rest = url.Substring (11);
-
- ApplyFile ((FileAction) action_map [Int32.Parse (rest)]);
- return;
- }
-
- if (url.StartsWith ("apply-change:")){
- string rest = url.Substring (13);
-
- ApplyItem ((ItemAction) action_map [Int32.Parse (rest)]);
- return;
- }
-
- if (url.StartsWith ("diff-change:")){
- string rest = url.Substring (12);
- DiffChangeItem ((ItemAction) action_map [Int32.Parse (rest)]);
-
- notebook.Page = 2;
- }
-
- Console.WriteLine ("Unhandled url: " + url);
- }
-
- Hashtable cache = new Hashtable ();
-
- GlobalChangeset LoadReview (int id, int serial)
- {
- string key = String.Format ("{0}:{1}", id, serial);
- if (cache [key] != null)
- return (GlobalChangeset) cache [key];
-
- //
- // Download contribution
- //
- XmlNode n = d.FetchContribution (login, pass, id, serial);
-
- //
- // Parse into GlobalChangeset
- //
- XmlDocument doc = new XmlDocument ();
- doc.AppendChild (doc.ImportNode (n, true));
- XmlNodeReader r = new XmlNodeReader (doc);
- GlobalChangeset s;
- try {
- s = (GlobalChangeset) GlobalChangeset.serializer.Deserialize (r);
- } catch (Exception e) {
- Console.WriteLine ("Error: " + e);
- Status = "Invalid contribution obtained from server: " + key;
- return null;
- }
-
- cache [key] = s;
- return s;
- }
-
- Hashtable action_map;
- int current_id, current_serial;
-
- //
- // Renders the id/serial representation for review by the administrator.
- //
- void RenderReview (int id, int serial)
- {
- current_id = id;
- current_serial = serial;
-
- notebook.Page = 1;
-
- GlobalChangeset globalset;
- globalset = LoadReview (id, serial);
-
- HTMLStream s = html_review.Begin ("text/html");
- s.Write ("");
- if (globalset == null){
- s.Write ("No data found");
- html_review.End (s, HTMLStreamStatus.Ok);
- return;
- }
-
- int key = 0;
- action_map = new Hashtable ();
-
- //
- // First make sure we dont have sources that we dont know about,
- // so a contribution can not be flagged as done by accident
- //
- bool allow_flag_as_done = true;
- foreach (DocSetChangeset docset in globalset.DocSetChangesets){
- if (!providers.Contains (docset.DocSet)){
- s.Write (String.Format ("Warning: Skipping {0}", docset.DocSet));
- allow_flag_as_done = false;
- continue;
- }
- }
-
- if (allow_flag_as_done)
- s.Write (String.Format ("", id, serial));
-
- foreach (DocSetChangeset docset in globalset.DocSetChangesets){
- if (!providers.Contains (docset.DocSet))
- continue;
-
- if (docset == null){
- s.Write ("Null?");
- continue;
- }
- string ds;
-
- ds = String.Format ("", docset.DocSet);
- foreach (FileChangeset fileset in docset.FileChangesets){
- string fs, es = null;
-
- fs = String.Format ("[Apply] File: {1}
",
- key, fileset.RealFile);
-
- action_map [key++] = new FileAction (globalset, docset, fileset);
-
- if (fileset.RealFile == null){
- s.Write (String.Format ("Warning: invalid contribution, its missing filename"));
- continue;
- }
- XmlDocument d = LoadDocument (docset, fileset.RealFile);
-
- foreach (Change c in fileset.Changes){
- XmlNode orig = d.SelectSingleNode (c.XPath);
- XmlNode newn = c.NewNode;
-
- if (orig == null){
- s.Write (String.Format ("Warning, node {0} does not exist", c.XPath));
- continue;
- }
-
- if (ds != null) { s.Write (ds); ds = null; }
- if (fs != null) { s.Write (fs); fs = null; es = "
"; }
-
- string original_text = orig.InnerXml;
- string new_text = c.NewNode.InnerXml;
-
- if (original_text == new_text){
- //s.Write ("Applied
");
- continue;
- }
-
- int p = c.XPath.LastIndexOf ("/");
- s.Write (String.Format ("[Diff]", key));
- s.Write (String.Format ("[Apply]: {1} ", key, c.XPath));
- if (c.FromVersion != RootTree.MonodocVersion)
- s.Write ("FROM OLD VERSION");
- action_map [key++] = new ItemAction (globalset, docset, fileset, c);
- s.Write ("
Current | New | ");
-
- s.Write ("
");
- s.Write (String.Format ("{0} | ", Htmlize (original_text)));
-
- s.Write ("");
- s.Write (Htmlize (new_text));
- s.Write (" |
");
- s.Write ("
");
- }
- if (es != null) s.Write (es);
- }
- }
- s.Write ("");
- html_review.End (s, HTMLStreamStatus.Ok);
- }
-
- //
- // Colorizes the ECMA XML documentation into some pretty HTML
- //
- string Htmlize (string s)
- {
- string r = s.Replace ("<", "<").Replace (">", ">").Replace ("<", "<").Replace
- ("/para>", "para>");
- return r;
- }
-
- //
- // Loads the `file' from a DocSetChangeset
- //
- XmlDocument LoadDocument (DocSetChangeset ds, string file)
- {
- XmlDocument d = new XmlDocument ();
- string basedir = (string) providers [ds.DocSet];
- d.Load (basedir + "/" + file);
- return d;
- }
-
- void OnDeleteEvent (object o, DeleteEventArgs args)
- {
- Application.Quit ();
- }
-
- void RenderChanges ()
- {
- notebook.Page = 0;
- HTMLStream s = html.Begin ("text/html");
- if (changes != null){
- s.Write ("
Pending Changes
");
- int i = 0;
- foreach (PendingChange ch in changes){
- s.Write (String.Format ("{3}: {2}
", ch.ID, ch.Serial, ch.Login, i++));
- }
- } else {
- s.Write ("No pending changes on the server
");
- }
- html.End (s, HTMLStreamStatus.Ok);
- }
-
- void OnCheckUpdatesClicked (object o, EventArgs args)
- {
- Status = "Loading";
- try {
- changes = d.GetPendingChanges (login, pass);
- if (changes == null)
- Status = "No changes available";
- else
- Status = "Changes loaded: " + changes.Length + " contributions";
- RenderChanges ();
- } catch (Exception e){
- Status = "There was a failure trying to fetch the status from the server";
- Console.WriteLine (e);
- }
- }
-
- string Status {
- set {
- statusbar.Pop (contextid);
- statusbar.Push (contextid, value);
- }
- }
-
- Hashtable providers = new Hashtable ();
- public void LoadProviders ()
- {
- string config_dir = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
- string monodoc_dir = System.IO.Path.Combine (config_dir, "monodoc");
- string settings_file = System.IO.Path.Combine (monodoc_dir, "providers.xml");
-
- XmlSerializer ser = new XmlSerializer (typeof (Providers));
- Providers p;
- if (File.Exists (settings_file))
- p = (Providers) ser.Deserialize (new XmlTextReader (settings_file));
- else {
- Console.WriteLine ("File {0} does not exist", settings_file);
- Console.WriteLine ("Format is:");
- Console.WriteLine (@"
-
-
-");
-
-
- Environment.Exit (1);
- return;
- }
-
- for (int i = 0; i < p.Locations.Length; i++){
- providers [p.Locations [i].Name] = p.Locations [i].Path;
- }
- }
-}
-
-///
-/// Configuration Loading
-///
-public class ProviderLocation {
- [XmlAttribute] public string Name;
- [XmlAttribute] public string Path;
-}
-
-public class Providers {
- [XmlElement ("Location", typeof (ProviderLocation))]
- public ProviderLocation [] Locations;
-}
-
-}
diff --git a/docbrowser/admin.glade b/docbrowser/admin.glade
deleted file mode 100644
index d2e795fa1..000000000
--- a/docbrowser/admin.glade
+++ /dev/null
@@ -1,450 +0,0 @@
-
-
-
-
-
-
- True
- Monodoc Admin Tool.
- GTK_WINDOW_TOPLEVEL
- GTK_WIN_POS_NONE
- False
- True
- False
- True
- False
- False
- GDK_WINDOW_TYPE_HINT_NORMAL
- GDK_GRAVITY_NORTH_WEST
-
-
-
- True
- False
- 0
-
-
-
- True
- False
- 0
-
-
-
- True
- True
- Check Server Updates.
- True
- GTK_RELIEF_NORMAL
- True
-
-
-
- 0
- False
- False
-
-
-
-
-
-
-
-
-
-
-
-
- 0
- False
- False
-
-
-
-
-
- True
- True
- True
- False
- GTK_POS_TOP
- False
- False
-
-
-
- True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
- GTK_SHADOW_NONE
- GTK_CORNER_TOP_LEFT
-
-
-
-
-
-
- False
- True
-
-
-
-
-
- True
- Pending
- False
- False
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- tab
-
-
-
-
-
- True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
- GTK_SHADOW_NONE
- GTK_CORNER_TOP_LEFT
-
-
-
-
-
-
- False
- True
-
-
-
-
-
- True
- Contribution
- False
- False
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- tab
-
-
-
-
-
- True
- False
- 0
-
-
-
- True
- False
- 0
-
-
-
- True
- 0
- 0.5
- GTK_SHADOW_NONE
-
-
-
- True
- 0.5
- 0.5
- 1
- 1
- 0
- 0
- 12
- 0
-
-
-
- True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
- GTK_SHADOW_NONE
- GTK_CORNER_TOP_LEFT
-
-
-
- True
- True
- True
- False
- True
- GTK_JUSTIFY_LEFT
- GTK_WRAP_WORD
- True
- 0
- 0
- 0
- 0
- 0
- 0
-
-
-
-
-
-
-
-
-
-
- True
- <b>On Disk</b>
- False
- True
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- label_item
-
-
-
-
- 0
- True
- True
-
-
-
-
-
- True
- 0
- 0.5
- GTK_SHADOW_NONE
-
-
-
- True
- 0.5
- 0.5
- 1
- 1
- 0
- 0
- 12
- 0
-
-
-
- True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
- GTK_SHADOW_NONE
- GTK_CORNER_TOP_LEFT
-
-
-
- True
- True
- True
- False
- True
- GTK_JUSTIFY_LEFT
- GTK_WRAP_WORD
- True
- 0
- 0
- 0
- 0
- 0
- 0
-
-
-
-
-
-
-
-
-
-
- True
- <b>Diff</b>
- False
- True
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- label_item
-
-
-
-
- 0
- True
- True
-
-
-
-
- 0
- True
- True
-
-
-
-
-
- True
- 0
- 0.5
- GTK_SHADOW_NONE
-
-
-
- True
- 0.5
- 0.5
- 1
- 1
- 0
- 0
- 12
- 0
-
-
-
- True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
- GTK_SHADOW_NONE
- GTK_CORNER_TOP_LEFT
-
-
-
- True
- True
- True
- False
- True
- GTK_JUSTIFY_LEFT
- GTK_WRAP_WORD
- True
- 0
- 0
- 0
- 0
- 0
- 0
-
-
-
-
-
-
-
-
-
-
- True
- <b>Current</b>
- False
- True
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- label_item
-
-
-
-
- 0
- True
- True
-
-
-
-
- False
- True
-
-
-
-
-
- True
- Viewer
- False
- False
- GTK_JUSTIFY_LEFT
- False
- False
- 0.5
- 0.5
- 0
- 0
-
-
- tab
-
-
-
-
- 0
- True
- True
-
-
-
-
-
- True
- True
-
-
- 0
- False
- False
-
-
-
-
-
-
-
diff --git a/docbrowser/browser.cs b/docbrowser/browser.cs
index b9eb66f84..79c36f3bb 100644
--- a/docbrowser/browser.cs
+++ b/docbrowser/browser.cs
@@ -9,7 +9,6 @@
// TODO:
//
using Gtk;
-using Glade;
using System;
using System.IO;
using System.Reflection;
@@ -26,219 +25,36 @@
#endif
namespace Monodoc {
-class Driver {
-
- public static string[] engines = {"WebKit", "MonoWebBrowser", "Gecko", "GtkHtml"};
-
- static int Main (string [] args)
- {
- string topic = null;
- bool remote_mode = false;
-
- string engine = engines[0];
- string basedir = null;
- string mergeConfigFile = null;
- bool show_help = false, show_version = false;
- bool show_gui = true;
- var sources = new List ();
-
- int r = 0;
-
- var p = new OptionSet () {
- { "docrootdir=",
- "Load documentation tree & sources from {DIR}. The default directory is $libdir/monodoc.",
- v => {
- basedir = v != null && v.Length > 0 ? v : null;
- string md;
- if (basedir != null && !File.Exists (Path.Combine (basedir, "monodoc.xml"))) {
- Error ("Missing required file monodoc.xml.");
- r = 1;
- }
- } },
- { "docdir=",
- "Load documentation from {DIR}.",
- v => sources.Add (v) },
- { "edit=",
- "Edit mdoc(5) XML documentation found within {PATH}.",
- v => RootTree.AddUncompiledSource (v) },
- { "engine=",
- "Specify which HTML rendering {ENGINE} to use:\n" +
- " " + string.Join ("\n ", engines) + "\n" +
- "If the chosen engine isn't available " +
- "(or you\nhaven't chosen one), monodoc will fallback to the next " +
- "one on the list until one is found.",
- v => engine = v },
- { "html=",
- "Write to stdout the HTML documentation for {CREF}.",
- v => {
- show_gui = false;
- Node n;
- RootTree help_tree = LoadTree (basedir, sources);
- string res = help_tree.RenderUrl (v, out n);
- if (res != null)
- Console.WriteLine (res);
- else {
- Error ("Could not find topic: {0}", v);
- r = 1;
- }
- } },
- { "make-index",
- "Generate a documentation index. Requires write permission to $libdir/monodoc.",
- v => {
- show_gui = false;
- RootTree.MakeIndex ();
- } },
- { "make-search-index",
- "Generate a search index. Requires write permission to $libdir/monodoc.",
- v => {
- show_gui = false;
- RootTree.MakeSearchIndex () ;
- } },
- { "merge-changes=",
- "Merge documentation changes found within {FILE} and target directories.",
- v => {
- show_gui = false;
- if (v != null)
- mergeConfigFile = v;
- else {
- Error ("Missing config file for --merge-changes.");
- r = 1;
- }
- } },
- { "remote-mode",
- "Accept CREFs from stdin to display in the browser.\n" +
- "For MonoDevelop integration.",
- v => remote_mode = v != null },
- { "about|version",
- "Write version information and exit.",
- v => show_version = v != null },
- { "h|?|help",
- "Show this message and exit.",
- v => show_help = v != null },
- };
-
- List topics = p.Parse (args);
-
- if (basedir == null)
- basedir = Directory.GetParent (System.Reflection.Assembly.GetExecutingAssembly ().Location).FullName;
-
- if (show_version) {
- Console.WriteLine ("Mono Documentation Browser");
- Version ver = Assembly.GetExecutingAssembly ().GetName ().Version;
- if (ver != null)
- Console.WriteLine (ver.ToString ());
- return r;
- }
- if (show_help) {
- Console.WriteLine ("usage: monodoc [--html TOPIC] [--make-index] [--make-search-index] [--merge-changes CHANGE_FILE TARGET_DIR+] [--about] [--edit path] [--remote-mode] [--engine engine] [TOPIC]");
- p.WriteOptionDescriptions (Console.Out);
- return r;
- }
-
- /*if (mergeConfigFile != null) {
- ArrayList targetDirs = new ArrayList ();
-
- for (int i = 0; i < topics.Count; i++)
- targetDirs.Add (topics [i]);
-
- EditMerger e = new EditMerger (
- GlobalChangeset.LoadFromFile (mergeConfigFile),
- targetDirs
- );
-
- e.Merge ();
- return 0;
- }*/
-
- if (r != 0 || !show_gui)
- return r;
-
- SettingsHandler.CheckUpgrade ();
-
- Settings.RunningGUI = true;
- Application.Init ();
- Browser browser = new Browser (basedir, sources, engine);
-
- if (topic != null)
- browser.LoadUrl (topic);
-
- Thread in_thread = null;
- if (remote_mode) {
- in_thread = new Thread (delegate () {
- while (true) {
- string url = Console.ReadLine ();
- if (url == null)
- return;
-
- Gtk.Application.Invoke (delegate {
- browser.LoadUrl (url);
- browser.MainWindow.Present ();
- });
- }
- });
-
- in_thread.Start ();
- }
-
- Application.Run ();
- if (in_thread != null)
- in_thread.Abort ();
-
- return 0;
- }
-
- static void Error (string format, params object[] args)
- {
- Console.Error.Write("monodoc: ");
- Console.Error.WriteLine (format, args);
- }
-
- public static RootTree LoadTree (string basedir, IEnumerable sourcedirs)
- {
- var root = RootTree.LoadTree (basedir);
- foreach (var s in sourcedirs)
- root.AddSource (s);
- return root;
- }
-}
-
public class Browser {
- Glade.XML ui;
+ Builder ui;
public Gtk.Window MainWindow;
- Style bar_style;
- [Glade.Widget] public Window window1;
- [Glade.Widget] TreeView reference_tree;
- [Glade.Widget] TreeView bookmark_tree;
- [Glade.Widget] public Statusbar statusbar;
- [Glade.Widget] public Button back_button, forward_button;
+ public Window window1;
+ TreeView reference_tree;
+ public Statusbar statusbar;
+ public Button back_button, forward_button;
public Entry index_entry;
- [Glade.Widget] CheckMenuItem editing1;
- [Glade.Widget] CheckMenuItem showinheritedmembers;
- [Glade.Widget] CheckMenuItem comments1;
- [Glade.Widget] MenuItem postcomment;
- [Glade.Widget] public MenuItem cut1;
- [Glade.Widget] public MenuItem paste1;
- [Glade.Widget] public MenuItem print;
- [Glade.Widget] public MenuItem close_tab;
+ CheckMenuItem showinheritedmembers;
+ public MenuItem print;
+ public MenuItem close_tab;
public Notebook tabs_nb;
public Tab CurrentTab;
bool HoldCtrl;
public string engine;
- [Glade.Widget] public MenuItem bookmarksMenu;
- [Glade.Widget] MenuItem view1;
+ public MenuItem bookmarksMenu;
+ MenuItem view1;
MenuItem textLarger;
MenuItem textSmaller;
MenuItem textNormal;
- [Glade.Widget] VBox help_container;
+ VBox help_container;
- [Glade.Widget] EventBox bar_eb, index_eb;
- [Glade.Widget] Label subtitle_label;
- [Glade.Widget] Notebook nb;
+ EventBox bar_eb, index_eb;
+ Label subtitle_label;
+ Notebook nb;
- [Glade.Widget] Box title_label_box;
+ Box title_label_box;
ELabel title_label;
// Bookmark Manager
@@ -249,7 +65,7 @@ public class Browser {
//
internal VBox search_box;
internal Frame matches;
- [Glade.Widget] internal VBox index_vbox;
+ internal VBox index_vbox;
Gdk.Pixbuf monodoc_pixbuf;
@@ -262,7 +78,7 @@ public class Browser {
SearchableIndex search_index;
ArrayList searchResults = new ArrayList (20);
string highlight_text;
- [Glade.Widget] VBox search_vbox;
+ VBox search_vbox;
ProgressPanel ppanel;
//
@@ -304,10 +120,33 @@ public Browser (string basedir, IEnumerable sources, string engine)
#endif
this.engine = engine;
- ui = new Glade.XML (null, "browser.glade", "window1", null);
+ ui = new Builder();
+ ui.AddFromFile("Browser.glade");
ui.Autoconnect (this);
- MainWindow = (Gtk.Window) ui["window1"];
+ MainWindow = (Gtk.Window) ui.GetObject("window1");
+ window1 = MainWindow;
+
+ // Glade did this via attribs, Builder doesn't; we need to initialize everything
+ help_container = (Gtk.VBox) ui.GetObject("help_container");
+ search_vbox = (Gtk.VBox) ui.GetObject("search_vbox");
+ index_vbox = (Gtk.VBox) ui.GetObject("index_vbox");
+ title_label_box = (Gtk.Box) ui.GetObject("title_label_box");
+ bar_eb = (Gtk.EventBox) ui.GetObject("bar_eb");
+ index_eb = (Gtk.EventBox) ui.GetObject("index_eb");
+ back_button = (Button) ui.GetObject("back_button");
+ forward_button = (Button) ui.GetObject("forward_button");
+ reference_tree = (TreeView) ui.GetObject("reference_tree");
+ subtitle_label = (Label) ui.GetObject("subtitle_label");
+ nb = (Notebook) ui.GetObject("nb");
+ statusbar = (Statusbar) ui.GetObject("statusbar");
+ showinheritedmembers = (CheckMenuItem) ui.GetObject("showinheritedmembers");
+ print = (MenuItem) ui.GetObject("print");
+ view1 = (MenuItem) ui.GetObject("view1");
+ close_tab = (MenuItem) ui.GetObject("close_tab");
+ bookmarksMenu = (MenuItem) ui.GetObject("bookmarksMenu");
+ bookmarksMenu.Submenu = new Menu(); // sigh; null now...
+
MainWindow.DeleteEvent += new DeleteEventHandler (delete_event_cb);
MainWindow.KeyPressEvent += new KeyPressEventHandler (keypress_event_cb);
@@ -329,12 +168,6 @@ public Browser (string basedir, IEnumerable sources, string engine)
title_label.Layout.FontDescription = fd;
title_label_box.Add (title_label);
title_label.Show ();
-
- //colour the bar according to the current style
- bar_style = bar_eb.Style.Copy ();
- bar_eb.Style = bar_style;
- MainWindow.StyleSet += new StyleSetHandler (BarStyleSet);
- BarStyleSet (null, null);
help_tree = Driver.LoadTree (basedir, sources);
tree_browser = new TreeBrowser (help_tree, reference_tree, this);
@@ -384,14 +217,6 @@ public Browser (string basedir, IEnumerable sources, string engine)
textNormal.AddAccelerator ("activate", accel, ak);
}
- // restore the editing setting
- editing1.Active = SettingsHandler.Settings.EnableEditing;
-
- comments1.Active = SettingsHandler.Settings.ShowComments;
-
- cut1.Sensitive = false;
- paste1.Sensitive = false;
-
//
// Other bits
//
@@ -475,7 +300,7 @@ void CreateSearchPanel ()
// Create the search panel
//
VBox vbox1 = new VBox (false, 0);
- search_vbox.PackStart (vbox1);
+ search_vbox.PackStart (vbox1, true, true, 0);
// title
HBox hbox1 = new HBox (false, 3);
@@ -555,14 +380,7 @@ void ChangeTab(object o, SwitchPageArgs args)
//Activate the new history
CurrentTab.history.Active = true;
- if (CurrentTab.Tab_mode == Mode.Viewer) {
- CurrentTab.history.ActivateCurrent();
- paste1.Sensitive = false;
- print.Sensitive = true;
- } else {
- paste1.Sensitive = true;
- print.Sensitive = false;
- }
+ CurrentTab.history.ActivateCurrent();
if (tree_browser.SelectedNode != CurrentTab.CurrentNode)
tree_browser.ShowNode (CurrentTab.CurrentNode);
@@ -613,10 +431,8 @@ void LostFocus(object sender, FocusOutEventArgs a)
//
void ShowSearchResult (object sender, EventArgs a)
{
- CurrentTab.SetMode (Mode.Viewer);
-
Gtk.TreeIter iter;
- Gtk.TreeModel model;
+ Gtk.ITreeModel model;
bool selected = search_tree.Selection.GetSelected (out model, out iter);
if (!selected)
@@ -672,11 +488,6 @@ void TextNormal (object obj, EventArgs args)
SettingsHandler.Save ();
}
- void BarStyleSet (object obj, StyleSetArgs args)
- {
- bar_style.SetBackgroundGC (StateType.Normal, MainWindow.Style.BackgroundGCs[1]);
- }
-
public Stream GetResourceImage (string name)
{
Assembly assembly = System.Reflection.Assembly.GetCallingAssembly ();
@@ -714,9 +525,6 @@ public void LinkClicked (object o, EventArgs args)
LoadUrl (url);
}
- private System.Xml.XmlNode edit_node;
- private string edit_url;
-
public void LoadUrl (string url)
{
if (url.StartsWith("#"))
@@ -725,16 +533,6 @@ public void LoadUrl (string url)
CurrentTab.html.JumpToAnchor(url.Substring(1));
return;
}
-
- if (url.StartsWith ("edit:"))
- {
- Console.WriteLine ("Node is: " + url);
- CurrentTab.edit_node = EditingUtils.GetNodeFromUrl (url, help_tree);
- CurrentTab.edit_url = url;
- CurrentTab.SetMode (Mode.Editor);
- CurrentTab.text_editor.Buffer.Text = CurrentTab.edit_node.InnerXml;
- return;
- }
Node node;
@@ -1015,17 +813,6 @@ public static string GetHtml (string url, HelpSource help_source, RootTree help_
html.Write ("