diff --git a/configure.in b/configure.in index 28ae426e0..cd994ea53 100644 --- a/configure.in +++ b/configure.in @@ -62,43 +62,6 @@ fi AC_SUBST(GNOME_SHARP_LIBS) AM_CONDITIONAL(ENABLE_GNOME, test "x$enable_gnome" = "xyes") -AC_ARG_ENABLE(gtkhtml, - AC_HELP_STRING([--enable-gtkhtml], [Use GTKHTML Browser]),, - enable_gtkhtml=yes) - -if test "x$enable_gtkhtml" = "xyes" ; then - PKG_CHECK_MODULES([GTKHTML_SHARP], - [gtkhtml-sharp-3.14], - [CSHARP_FLAGS="-d:GTKHTML_SHARP_3_14"], - [ - PKG_CHECK_MODULES([GTKHTML_SHARP], - [gtkhtml-sharp-2.0], - [CSHARP_FLAGS=""], - []) - ] - ) - AC_SUBST(GTKHTML_SHARP_LIBS) - AC_SUBST(CSHARP_FLAGS) -fi - -AM_CONDITIONAL(ENABLE_GTKHTML, test "x$enable_gtkhtml" = "xyes") - -AC_ARG_ENABLE(gecko, - AC_HELP_STRING([--enable-gecko], [Use Gecko / Xulrunner-1.8 browser libs]),, - enable_gecko=yes) - -if test "x$enable_gecko" = "xyes" ; then - PKG_CHECK_MODULES(GECKO_SHARP, gecko-sharp-2.0) - - AC_SUBST(GECKO_SHARP_LIBS) - - # get the mozilla home directory - MOZILLA_HOME="`$PKG_CONFIG --variable=libdir mozilla-gtkmozembed`" - AC_SUBST(MOZILLA_HOME) -fi - -AM_CONDITIONAL(ENABLE_GECKO, test "x$enable_gecko" = "xyes") - AC_ARG_ENABLE(webkit, AC_HELP_STRING([--enable-webkit], [Use Webkit browser]),, enable_webkit=yes) @@ -110,37 +73,9 @@ fi AM_CONDITIONAL(ENABLE_WEBKIT, test "x$enable_webkit" = "xyes") -# PKG_CHECK_MODULES(MONOWEBBROWSER, mono-webbrowser, enable_monowebbrowser=yes, enable_monowebbrowser=no) -# AC_SUBST(MONOWEBBROWSER_LIBS) - -AC_ARG_ENABLE(monowebbrowser, - AC_HELP_STRING([--enable-monowebbrowser], [Use Mono.Webbrowser]),, - enable_monowebbrowser=yes) - -if test "x$enable_monowebbrowser" = "xyes" ; then - AC_MSG_CHECKING([for Mono.WebBrowser]) - if test "x$GACUTIL" = "xno" - then - AC_MSG_RESULT([no]) - if test "x$enable_monowebbrowser" = "x" ; then enable_monowebbrowser=no ; fi - else - if $GACUTIL -l Mono.WebBrowser | grep -q "Mono.WebBrowser" - then - AC_MSG_RESULT([yes]) - enable_monowebbrowser=yes - MONOWEBBROWSER_LIBS=-r:Mono.WebBrowser - else - AC_MSG_RESULT([no]) - enable_monowebbrowser=no - fi - fi -fi - -AM_CONDITIONAL(ENABLE_MONOWEBBROWSER, test "x$enable_monowebbrowser" = "xyes") - -if test "x$enable_gtkhtml$enable_gecko$enable_monowebbrowser$enable_webkit" = "xnononono" ; then - AC_MSG_ERROR([no HTML display found. You need either gtkhtml, gecko, WebKit or Mono.WebBrowser]) -fi +#if test "x$enable_webkit" = "xno" ; then +# AC_MSG_ERROR([no HTML display found. You need WebKit]) +#fi AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], @@ -326,11 +261,7 @@ echo "---" echo "Configuration summary" echo "" echo " * Installation prefix = $prefix" -echo " * Using Gecko = $enable_gecko" -echo " * Using GtkHtml = $enable_gtkhtml" -echo " * Using Mono.WebBrowser = $enable_monowebbrowser" echo " * Using WebKit = $enable_webkit" -echo " * Using Gnome = $enable_gnome" echo "" echo " NOTE: if any of the above say 'no' you may install the" echo " corresponding development packages for them, rerun" diff --git a/docbrowser/AddBookmarkDialog.glade b/docbrowser/AddBookmarkDialog.glade new file mode 100644 index 000000000..5e8e6f05f --- /dev/null +++ b/docbrowser/AddBookmarkDialog.glade @@ -0,0 +1,145 @@ + + + + + + + True + False + Add Bookmark + False + True + center + 60 + 115 + dialog + + + + + + + True + False + 23 + + + True + False + 2 + 22 + + + True + False + 0 + 0 + Name: + 0.5 + 0.5 + + + False + False + 0 + + + + + True + True + * + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 2 + 5 + + + True + False + 0 + 0 + Create in: + 0.5 + 0.5 + + + False + False + 0 + + + + + + + + True + False + 1 + + + + + True + False + 5 + 199 + + + gtk-cancel + True + True + False + True + + + + False + False + 0 + + + + + gtk-add + True + True + False + True + + + + False + False + 1 + + + + + False + True + 4 + 2 + + + + + + diff --git a/docbrowser/BookmarkManager.cs b/docbrowser/BookmarkManager.cs index 5dd64dc76..a290c0826 100644 --- a/docbrowser/BookmarkManager.cs +++ b/docbrowser/BookmarkManager.cs @@ -9,7 +9,6 @@ using System; using Gtk; -using Glade; using System.Collections; using System.Xml.Serialization; using System.Xml; @@ -56,8 +55,8 @@ public Bookmark (string name, string url){ public Bookmark () {} } internal class ManageBookmarkDialog { - [Glade.Widget] Gtk.TreeView bookmarks_treeview; - [Glade.Widget] Gtk.Window manage_bookmarks_dialog; + Gtk.TreeView bookmarks_treeview; + Gtk.Window manage_bookmarks_dialog; BookmarkGroup root_group; Hashtable iter_to_id; string selected_id = string.Empty; @@ -65,8 +64,13 @@ internal class ManageBookmarkDialog { const string UNTITLED = "Untitled"; public ManageBookmarkDialog (BookmarkGroup bookmarks) { - Glade.XML xml = new Glade.XML ("browser.glade","manage_bookmarks_dialog"); - xml.Autoconnect (this); + var ui = new Builder(); + ui.AddFromFile("BookmarksManager.glade"); + ui.Autoconnect (this); + + manage_bookmarks_dialog = (Window) ui.GetObject ("manage_bookmarks_dialog"); + bookmarks_treeview = (TreeView) ui.GetObject ("bookmarks_treeview"); + iter_to_id = new Hashtable (); root_group = bookmarks; bookmarks_treeview.RulesHint = true; @@ -89,7 +93,7 @@ void on_row_expanded (object sender, Gtk.RowExpandedArgs args) { } void on_row_selected (object sender, EventArgs args) { Gtk.TreeIter iter; - Gtk.TreeModel model; + Gtk.ITreeModel model; if (bookmarks_treeview.Selection.GetSelected (out model, out iter)) { selected_id = iter_to_id[iter] as string; @@ -203,32 +207,38 @@ void BuildTreeViewHelper (BookmarkGroup bookmarks, TreeIter iter, TreeStore stor } internal class AddBookmarkDialog { - [Glade.Widget] Gtk.Entry name_entry; - [Glade.Widget] HBox hbox37; - [Glade.Widget] Gtk.Window add_bookmark_dialog; + Gtk.Entry name_entry; + HBox hbox37; + Gtk.Window add_bookmark_dialog; string text, url; BookmarkGroup root; - Combo combo; + Entry combo; Hashtable combo_to_id = new Hashtable (); public AddBookmarkDialog (BookmarkGroup root_group) { - Glade.XML xml = new Glade.XML ("browser.glade","add_bookmark_dialog"); - xml.Autoconnect (this); + var ui = new Builder(); + ui.AddFromFile("AddBookmarkDialog.glade"); + ui.Autoconnect (this); + + add_bookmark_dialog = (Window) ui.GetObject ("add_bookmark_dialog"); + hbox37 = (HBox) ui.GetObject ("hbox37"); + name_entry = (Entry) ui.GetObject ("name_entry"); - combo = new Combo (); + combo = new Entry (); ArrayList list = new ArrayList (); BuildComboList (root_group,list); - combo.PopdownStrings = list.ToArray (typeof (string)) as string[]; - combo.AllowEmpty = false; - combo.Entry.Editable = false; - combo.DisableActivate (); + // TODO: This needs to be a combo box again, but it can't be a Gtk.Combo anymore + //combo.PopdownStrings = list.ToArray (typeof (string)) as string[]; + //combo.AllowEmpty = false; + //combo.Entry.Editable = false; + //combo.DisableActivate (); // pusihing widget into hbox - hbox37.PackEnd (combo); + hbox37.PackEnd (combo, true, true, 0); //combo.Entry.Activated += new EventHandler (on_combo_entry_activated); @@ -259,7 +269,8 @@ public void on_AddBookmark_delete_event (object o, DeleteEventArgs args) public void on_AddButton_clicked (object o, EventArgs args) { - BookmarkManager.AddBookmark (root,combo_to_id [combo.Entry.Text] as string,name_entry.Text,url); +// BookmarkManager.AddBookmark (root,combo_to_id [combo.Entry.Text] as string,name_entry.Text,url); + BookmarkManager.AddBookmark (root,combo_to_id [combo.Text] as string,name_entry.Text,url); add_bookmark_dialog.Hide (); BookmarkManager.Refresh (); } diff --git a/docbrowser/BookmarksManager.glade b/docbrowser/BookmarksManager.glade new file mode 100644 index 000000000..f8d440c1a --- /dev/null +++ b/docbrowser/BookmarksManager.glade @@ -0,0 +1,148 @@ + + + + + + + True + False + Manage Bookmarks + True + center + 375 + 275 + dialog + + + + + + + True + False + + + True + False + + + True + True + 8 + never + in + + + True + True + False + + + + + + + + True + True + 0 + + + + + True + False + 9 + 4 + start + + + gtk-delete + True + True + True + False + True + + + + True + True + 0 + + + + + New Folder + True + True + True + False + True + + + + True + True + 1 + + + + + False + True + end + 1 + + + + + True + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + False + 7 + end + + + gtk-close + True + True + True + False + True + + + + True + True + 0 + + + + + False + True + 2 + + + + + + diff --git a/docbrowser/Browser.glade b/docbrowser/Browser.glade new file mode 100644 index 000000000..92d20f8fa --- /dev/null +++ b/docbrowser/Browser.glade @@ -0,0 +1,529 @@ + + + + + + + True + False + Mono Documentation Library + 640 + 480 + + + + + + True + False + + + True + False + + + True + False + _File + True + + + True + False + + + True + False + New _Tab + True + + + + + + True + False + _Lookup URL... + True + + + + + + True + False + _Print... + True + + + + + + True + False + _Close + True + + + + + + + + + + True + False + _Edit + True + + + True + False + + + True + False + _Copy + True + + + + + + True + False + Select _All + True + + + + + + + + + + True + False + _View + True + + + True + False + + + True + False + _Collapse All + True + + + + + + True + False + Show _Inherited Members + True + + + + + + + + + + True + False + _Bookmarks + True + + + + + False + True + 0 + + + + + True + False + 3 + + + True + False + 3 + 6 + + + True + False + True + + + True + True + False + none + + + True + False + 0.5 + 0.5 + 0 + 0 + left + none + + + + + False + False + 0 + + + + + True + True + False + none + + + True + False + 0.5 + 0.5 + 0 + 0 + none + + + + + False + False + 1 + + + + + False + True + 0 + + + + + True + False + 3 + + + 22 + 22 + True + False + 0.5 + 0.5 + 0 + 0 + gtk-dialog-info + + + False + True + 0 + + + + + True + False + + + + + + True + True + 1 + + + + + True + False + 6 + 0 + n/a + True + right + 1 + 0.5 + + + False + False + 2 + + + + + True + True + 1 + + + + + + + False + True + 1 + + + + + True + False + 3 + + + True + True + 260 + + + True + True + bottom + + + True + True + 3 + always + always + in + + + True + True + False + + + + + + + + + + True + False + 3 + + + True + False + 0.5 + 0.5 + 0 + 0 + gtk-help + 1 + + + True + True + 0 + + + + + True + False + 0 + 0 + _Contents + True + 0.5 + 0.5 + + + False + False + 1 + + + + + False + + + + + True + False + 3 + 3 + + + 1 + + + + + True + False + 3 + + + True + False + 0.5 + 0.5 + 0 + 0 + gtk-index + 1 + + + True + True + 0 + + + + + True + False + 0 + 0 + _Index + True + 0.5 + 0.5 + + + False + False + 1 + + + + + 1 + False + + + + + True + False + 3 + + + 2 + + + + + True + False + 3 + + + True + False + 0.5 + 0.5 + 0 + 0 + gtk-find + 1 + + + True + True + 0 + + + + + True + False + 0 + 0 + _Search + True + 0.5 + 0.5 + + + False + False + 1 + + + + + 2 + False + + + + + False + True + + + + + True + False + + + True + True + + + + + True + True + 0 + + + + + True + False + + + False + True + 1 + + + + + True + True + 2 + + + + + + diff --git a/docbrowser/Contributions.cs b/docbrowser/Contributions.cs deleted file mode 100644 index 9c08137e4..000000000 --- a/docbrowser/Contributions.cs +++ /dev/null @@ -1,238 +0,0 @@ -// ------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Mono Runtime Version: 1.1.4322.2032 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -// -// This source code was auto-generated by Mono Web Services Description Language Utility -// - - -/// -/// -///Web service for the MonoDoc contribution system -/// -[System.Web.Services.WebServiceBinding(Name="ContributionsSoap", Namespace="http://tempuri.org/")] -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.ComponentModel.DesignerCategoryAttribute("code")] -public class Contributions : System.Web.Services.Protocols.SoapHttpClientProtocol { - - public Contributions() { - this.Url = "http://www.go-mono.com/docs/server.asmx"; - } - - /// -///Check the client/server version; 0 means that the server can consume your data -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckVersion", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public int CheckVersion(int version) { - object[] results = this.Invoke("CheckVersion", new object[] { - version}); - return ((int)(results[0])); - } - - public System.IAsyncResult BeginCheckVersion(int version, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("CheckVersion", new object[] { - version}, callback, asyncState); - } - - public int EndCheckVersion(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((int)(results[0])); - } - - /// -///Requests a registration for a login -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Register", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public int Register(string login) { - object[] results = this.Invoke("Register", new object[] { - login}); - return ((int)(results[0])); - } - - public System.IAsyncResult BeginRegister(string login, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("Register", new object[] { - login}, callback, asyncState); - } - - public int EndRegister(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((int)(results[0])); - } - - /// -///Returns the latest serial number used for a change on the server -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetSerial", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public int GetSerial(string login, string password) { - object[] results = this.Invoke("GetSerial", new object[] { - login, - password}); - return ((int)(results[0])); - } - - public System.IAsyncResult BeginGetSerial(string login, string password, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("GetSerial", new object[] { - login, - password}, callback, asyncState); - } - - public int EndGetSerial(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((int)(results[0])); - } - - /// -///Submits a GlobalChangeSet as a contribution -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Submit", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public int Submit(string login, string password, System.Xml.XmlNode node) { - object[] results = this.Invoke("Submit", new object[] { - login, - password, - node}); - return ((int)(results[0])); - } - - public System.IAsyncResult BeginSubmit(string login, string password, System.Xml.XmlNode node, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("Submit", new object[] { - login, - password, - node}, callback, asyncState); - } - - public int EndSubmit(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((int)(results[0])); - } - - /// -///Obtains the list of pending contributions -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetPendingChanges", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public PendingChange[] GetPendingChanges(string login, string password) { - object[] results = this.Invoke("GetPendingChanges", new object[] { - login, - password}); - return ((PendingChange[])(results[0])); - } - - public System.IAsyncResult BeginGetPendingChanges(string login, string password, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("GetPendingChanges", new object[] { - login, - password}, callback, asyncState); - } - - public PendingChange[] EndGetPendingChanges(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((PendingChange[])(results[0])); - } - - /// -///Obtains a change set for a user -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/FetchContribution", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public System.Xml.XmlNode FetchContribution(string login, string password, int person_id, int serial) { - object[] results = this.Invoke("FetchContribution", new object[] { - login, - password, - person_id, - serial}); - return ((System.Xml.XmlNode)(results[0])); - } - - public System.IAsyncResult BeginFetchContribution(string login, string password, int person_id, int serial, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("FetchContribution", new object[] { - login, - password, - person_id, - serial}, callback, asyncState); - } - - public System.Xml.XmlNode EndFetchContribution(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((System.Xml.XmlNode)(results[0])); - } - - /// -///ADMIN: Obtains the number of pending commits -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetStatus", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public Status GetStatus(string login, string password) { - object[] results = this.Invoke("GetStatus", new object[] { - login, - password}); - return ((Status)(results[0])); - } - - public System.IAsyncResult BeginGetStatus(string login, string password, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("GetStatus", new object[] { - login, - password}, callback, asyncState); - } - - public Status EndGetStatus(System.IAsyncResult asyncResult) { - object[] results = this.EndInvoke(asyncResult); - return ((Status)(results[0])); - } - - /// -///ADMIN: Updates the status of a contribution -/// - [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/UpdateStatus", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)] - public void UpdateStatus(string login, string password, int person_id, int contrib_id, int status) { - this.Invoke("UpdateStatus", new object[] { - login, - password, - person_id, - contrib_id, - status}); - } - - public System.IAsyncResult BeginUpdateStatus(string login, string password, int person_id, int contrib_id, int status, System.AsyncCallback callback, object asyncState) { - return this.BeginInvoke("UpdateStatus", new object[] { - login, - password, - person_id, - contrib_id, - status}, callback, asyncState); - } - - public void EndUpdateStatus(System.IAsyncResult asyncResult) { - this.EndInvoke(asyncResult); - } -} - -/// -[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] -public class PendingChange { - - /// - public string Login; - - /// - public int ID; - - /// - public int Serial; -} - -/// -[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://tempuri.org/")] -public class Status { - - /// - public int Contributions; - - /// - public int Commited; - - /// - public int Pending; -} diff --git a/docbrowser/Driver.cs b/docbrowser/Driver.cs new file mode 100644 index 000000000..d4069b565 --- /dev/null +++ b/docbrowser/Driver.cs @@ -0,0 +1,190 @@ +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 Driver { + + public static string[] engines = {"WebKit", "Dummy"}; + + 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) }, + { "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] [--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; + } +} +} diff --git a/docbrowser/DummyHtmlRender.cs b/docbrowser/DummyHtmlRender.cs new file mode 100644 index 000000000..d515b0639 --- /dev/null +++ b/docbrowser/DummyHtmlRender.cs @@ -0,0 +1,70 @@ +// +// DummyHtmlRender.cs: Implementation of IHtmlRender that does nothing +// +// Author: Calvin Buckley +// + +using System; +using System.IO; +using Gtk; + +namespace Monodoc { +public class DummyHtmlRender : IHtmlRender { + + Label web_view; + public Widget HtmlPanel { + get { return (Widget) web_view; } + } + + string url; + public string Url { + get { return url; } + } + + RootTree help_tree; + public event EventHandler OnUrl; + public event EventHandler UrlClicked; + + public DummyHtmlRender (RootTree help_tree) + { + web_view = new Label(); + } + + public void JumpToAnchor (string anchor) + { + } + + public void Copy () + { + } + + public void SelectAll () + { + } + + public void Render (string html) + { + } + + public void Print (string html) + { + } + + public bool Initialize () + { + return true; + } + + public Capabilities Capabilities + { + get { return Capabilities.None; } + } + + public string Name + { + get { return "Dummy"; } + } + + +} +} diff --git a/docbrowser/GeckoHtmlRender.cs b/docbrowser/GeckoHtmlRender.cs deleted file mode 100644 index 1d3cb1731..000000000 --- a/docbrowser/GeckoHtmlRender.cs +++ /dev/null @@ -1,243 +0,0 @@ -// -// GeckoHtmlRender.cs: Implementation of IHtmlRender that uses Gecko -// -// Author: Mario Sopena -// Author: Rafael Ferreira -// -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 @@ + + + + + + + True + False + Lookup URL + + + + + + + True + False + 3 + + + True + False + 0 + 0 + _URL to lookup: + True + True + 0 + 0.5 + + + False + False + 0 + + + + + True + True + True + True + * + True + + + + lookup_entry + + + + + False + False + 2 + 1 + + + + + True + False + + + gtk-ok + True + True + True + True + False + True + + + + True + False + 0 + + + + + False + False + 2 + 2 + + + + + + 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 ("

Changes: [Flag as Done]

", 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: {0}
", 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 (""); - - s.Write (""); - s.Write (String.Format ("", Htmlize (original_text))); - - s.Write (""); - s.Write ("
CurrentNew
{0}"); - s.Write (Htmlize (new_text)); - 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 (""); return html.ToString (); } - - void OnCommentsActivate (object o, EventArgs args) - { - SettingsHandler.Settings.ShowComments = comments1.Active; - - // postcomment.Sensitive = comments1.Active; - - // refresh, so we can see the comments - if (CurrentTab != null && CurrentTab.history != null) // catch the case when we are currently loading - CurrentTab.history.ActivateCurrent (); - } void OnInheritedMembersActivate (object o, EventArgs args) { @@ -1034,15 +821,6 @@ void OnInheritedMembersActivate (object o, EventArgs args) CurrentTab.history.ActivateCurrent (); } - void OnEditingActivate (object o, EventArgs args) - { - SettingsHandler.Settings.EnableEditing = editing1.Active; - - // refresh, so we can see the [edit] things - if (CurrentTab != null && CurrentTab.history != null) // catch the case when we are currently loading - CurrentTab.history.ActivateCurrent (); - } - void OnCollapseActivate (object o, EventArgs args) { reference_tree.CollapseAll (); @@ -1120,1701 +898,95 @@ void OnQuitActivate (object sender, EventArgs a) Application.Quit (); } - // - // Invoked by Edit/Cut menu entry. - // - void OnCutActivate (object sender, EventArgs a) - { - if (CurrentTab.Tab_mode == Mode.Editor) { - Clipboard cb = Clipboard.Get (Gdk.Selection.Clipboard); - CurrentTab.text_editor.Buffer.CutClipboard (cb, true); - } - } - // // Invoked by Edit/Copy menu entry. // void OnCopyActivate (object sender, EventArgs a) { - if (CurrentTab.Tab_mode == Mode.Viewer) - CurrentTab.html.Copy (); - else { - Clipboard cb = Clipboard.Get (Gdk.Selection.Clipboard); - CurrentTab.text_editor.Buffer.CopyClipboard (cb); - } + CurrentTab.html.Copy (); } // - // Invoked by Edit/Paste menu entry. + // Hooked up from Glade // - void OnPasteActivate (object sender, EventArgs a) + void OnAboutActivate (object sender, EventArgs a) { - Clipboard cb = Clipboard.Get (Gdk.Selection.Clipboard); - - if (!cb.WaitIsTextAvailable ()) - return; - - //string text = cb.WaitForText (); - - //CurrentTab.text_editor.Buffer.InsertAtCursor (text); - - CurrentTab.text_editor.Buffer.PasteClipboard (cb); + // TODO: Use a standard Gtk about dialog instead (copy data from old glade file) } - class About { - [Glade.Widget] Window about; - [Glade.Widget] Image logo_image; - [Glade.Widget] Label label_version; - - static About AboutBox; + class Lookup { + Window lookup; + Entry entry; + static Lookup LookupBox; Browser parent; - - About (Browser parent) + + Lookup (Browser browser) { - Glade.XML ui = new Glade.XML (null, "browser.glade", "about", null); + var ui = new Builder(); + ui.AddFromFile("Lookup.glade"); ui.Autoconnect (this); - this.parent = parent; - - about.TransientFor = parent.window1; - Gdk.Pixbuf icon = new Gdk.Pixbuf (null, "monodoc.png"); - - if (icon != null) { - about.Icon = icon; - logo_image.Pixbuf = icon; - } + lookup = (Window) ui.GetObject ("lookup"); + entry = (Entry) ui.GetObject ("entry"); - Assembly assembly = Assembly.GetExecutingAssembly (); - label_version.Markup = String.Format ("Version: {0}", assembly.GetName ().Version.ToString ()); + parent = browser; + lookup.TransientFor = browser.window1; } void OnOkClicked (object sender, EventArgs a) { - about.Hide (); + string text = entry.Text; + if (text != "") + parent.LoadUrl (entry.Text); + lookup.Hide (); } // // Called on the Window delete icon clicked // - void OnDelete (object sender, DeleteEventArgs a) + void OnDelete(object sender, DeleteEventArgs a) { - AboutBox = null; + LookupBox = null; } - static public void Show (Browser parent) + static public void Show (Browser browser) { - if (AboutBox == null) - AboutBox = new About (parent); - AboutBox.about.Show (); + if (LookupBox == null) + LookupBox = new Lookup (browser); + LookupBox.lookup.Show (); } } // - // Hooked up from Glade + // Invoked by File/LookupURL menu entry. // - void OnAboutActivate (object sender, EventArgs a) - { - About.Show (this); - } - - void OnUpload (object sender, EventArgs a) + void OnLookupURL (object sender, EventArgs a) { - string key = SettingsHandler.Settings.Key; - if (key == null || key == "") - ConfigWizard.Run (this); - else - DoUpload (); + Lookup.Show (this); } - void DoUpload () + // + // Invoked by Edit/Select All menu entry. + // + void OnSelectAllActivate (object sender, EventArgs a) { - Upload.Run (this); - } - - class Upload { - enum State { - GetSerial, - PrepareUpload, - SerialError, - VersionError, - SubmitError, - NetworkError, - Done - } - - [Glade.Widget] Dialog upload_dialog; - [Glade.Widget] Label status; - [Glade.Widget] Button cancel; - State state; - ThreadNotify tn; - WebClientAsyncResult war; - Contributions d; - int serial; - - public static void Run (Browser browser) - { - new Upload (browser); - } - - Upload (Browser browser) - { - tn = new ThreadNotify (new ReadyEvent (Update)); - Glade.XML ui = new Glade.XML (null, "browser.glade", "upload_dialog", null); - ui.Autoconnect (this); - d = new Contributions (); - if (Environment.GetEnvironmentVariable ("MONODOCTESTING") == null) - d.Url = "http://www.go-mono.com/docs/server.asmx"; - - status.Text = "Checking Server version"; - war = (WebClientAsyncResult) d.BeginCheckVersion (1, new AsyncCallback (VersionChecked), null); - } - - void Update () - { - Console.WriteLine ("In Update: " + state); - switch (state){ - case State.NetworkError: - status.Text = "A network error ocurred"; - cancel.Label = "Close"; - return; - case State.VersionError: - status.Text = "Server has a different version, upgrade your MonoDoc"; - cancel.Label = "Close"; - return; - case State.GetSerial: - war = (WebClientAsyncResult) d.BeginGetSerial ( - SettingsHandler.Settings.Email, SettingsHandler.Settings.Key, - new AsyncCallback (GetSerialDone), null); - return; - case State.SerialError: - status.Text = "Error obtaining serial number from server for this account"; - cancel.Label = "Close"; - return; - case State.SubmitError: - status.Text = "There was a problem with the documentation uploaded"; - cancel.Label = "Close"; - return; - - case State.PrepareUpload: - GlobalChangeset cs = EditingUtils.GetChangesFrom (serial); - if (cs == null){ - status.Text = "No new contributions"; - cancel.Label = "Close"; - return; - } - - CopyXmlNodeWriter w = new CopyXmlNodeWriter (); - GlobalChangeset.serializer.Serialize (w, cs); - Console.WriteLine ("Uploading..."); - status.Text = String.Format ("Uploading {0} contributions", cs.Count); - XmlDocument dd = (XmlDocument) w.Document; - war = (WebClientAsyncResult) d.BeginSubmit ( - SettingsHandler.Settings.Email, SettingsHandler.Settings.Key, - ((XmlDocument) w.Document).DocumentElement, - new AsyncCallback (UploadDone), null); - return; - case State.Done: - status.Text = "All contributions uploaded"; - cancel.Label = "Close"; - SettingsHandler.Settings.SerialNumber = serial; - SettingsHandler.Save (); - return; - } - } - - void UploadDone (IAsyncResult iar) - { - try { - int result = d.EndSubmit (iar); - war = null; - if (result < 0) - state = State.SubmitError; - else { - state = State.Done; - serial = result; - } - } catch (Exception e) { - state = State.NetworkError; - Console.WriteLine ("Upload: " + e); - } - if (tn != null) - tn.WakeupMain (); - } - - void GetSerialDone (IAsyncResult iar) - { - try { - serial = d.EndGetSerial (iar); - war = null; - if (serial < 0) - state = State.SerialError; - else - state = State.PrepareUpload; - } catch (Exception e) { - Console.WriteLine ("Serial: " + e); - state = State.NetworkError; - } - if (tn != null) - tn.WakeupMain (); - } - - void VersionChecked (IAsyncResult iar) - { - try { - int ver = d.EndCheckVersion (iar); - war = null; - if (ver != 0) - state = State.VersionError; - else - state = State.GetSerial; - } catch (Exception e) { - Console.WriteLine ("Version: " + e); - state = State.NetworkError; - } - if (tn != null) - tn.WakeupMain (); - } - - void Cancel_Clicked (object sender, EventArgs a) - { - if (war != null) - war.Abort (); - war = null; - state = State.Done; - - upload_dialog.Destroy (); - upload_dialog = null; - tn = null; - } + CurrentTab.html.SelectAll (); } - class ConfigWizard { - static ConfigWizard config_wizard; - - [Glade.Widget] Window window_config_wizard; - [Glade.Widget] Notebook notebook; - [Glade.Widget] Button button_email_ok; - [Glade.Widget] Entry entry_email; - [Glade.Widget] Entry entry_password; - - Browser parent; - Contributions d; - WebClientAsyncResult war; - ThreadNotify tn; - int new_page; - - public static void Run (Browser browser) - { - if (config_wizard == null) - config_wizard = new ConfigWizard (browser); - return; - } - - ConfigWizard (Browser browser) - { - tn = new ThreadNotify (new ReadyEvent (UpdateNotebookPage)); - Glade.XML ui = new Glade.XML (null, "browser.glade", "window_config_wizard", null); - ui.Autoconnect (this); - //notebook.ShowTabs = false; - parent = browser; - window_config_wizard.TransientFor = browser.window1; - - d = new Contributions (); - if (Environment.GetEnvironmentVariable ("MONODOCTESTING") == null) - d.Url = "http://www.go-mono.com/docs/server.asmx"; - notebook.Page = 8; - - war = (WebClientAsyncResult) d.BeginCheckVersion (1, new AsyncCallback (VersionChecked), null); - } - - void NetworkError () - { - new_page = 9; - tn.WakeupMain (); - } - - void VersionChecked (IAsyncResult iar) - { - int ver = -1; - - try { - if (notebook.Page != 8) - return; - - ver = d.EndCheckVersion (iar); - if (ver != 0) - new_page = 10; - else - new_page = 0; - tn.WakeupMain (); - } catch (Exception e){ - Console.WriteLine ("Error" + e); - NetworkError (); - } - } - - // - // Called on the Window delete icon clicked - // - void OnDelete (object sender, DeleteEventArgs a) - { - config_wizard = null; - } - - // - // called when the license is approved - // - void OnPage1_Clicked (object sender, EventArgs a) - { - button_email_ok.Sensitive = false; - notebook.Page = 1; - } - - // - // Request the user registration. - // - void OnPage2_Clicked (object sender, EventArgs a) - { - notebook.Page = 2; - SettingsHandler.Settings.Email = entry_email.Text; - war = (WebClientAsyncResult) d.BeginRegister (entry_email.Text, new AsyncCallback (RegisterDone), null); - } - - void UpdateNotebookPage () - { - notebook.Page = new_page; - } - - void RegisterDone (IAsyncResult iar) - { - int code; - - try { - Console.WriteLine ("Registration done"); - code = d.EndRegister (iar); - if (code != 0 && code != -2){ - NetworkError (); - return; - } - new_page = 4; - } catch { - new_page = 3; - } - tn.WakeupMain (); - } - - void PasswordContinue_Clicked (object sender, EventArgs a) - { - notebook.Page = 5; - SettingsHandler.Settings.Key = entry_password.Text; - war = (WebClientAsyncResult) d.BeginGetSerial (entry_email.Text, entry_password.Text, new AsyncCallback (GetSerialDone), null); - } - - void GetSerialDone (IAsyncResult iar) - { - try { - int last = d.EndGetSerial (iar); - if (last == -1){ - SettingsHandler.Settings.Key = ""; - new_page = 11; - tn.WakeupMain (); - return; - } - - SettingsHandler.Settings.SerialNumber = last; - new_page = 6; - tn.WakeupMain (); - } catch { - NetworkError (); - } - } - - void AccountRequestCancel_Clicked (object sender, EventArgs a) - { - war.Abort (); - notebook.Page = 7; - } - - void SerialRequestCancel_Clicked (object sender, EventArgs a) - { - war.Abort (); - notebook.Page = 7; - } - - void LoginRequestCancel_Clicked (object sender, EventArgs a) - { - war.Abort (); - notebook.Page = 7; - } - - // - // Called when the user clicks `ok' on a terminate page - // - void Terminate_Clicked (object sender, EventArgs a) - { - window_config_wizard.Destroy (); - config_wizard = null; - } - - // Called when the registration process has been successful - void Completed_Clicked (object sender, EventArgs a) - { - window_config_wizard.Destroy (); - config_wizard = null; - try { - Console.WriteLine ("Saving"); - SettingsHandler.Save (); - parent.DoUpload (); - } catch (Exception e) { - MessageDialog md = new MessageDialog (null, - DialogFlags.DestroyWithParent, - MessageType.Error, - ButtonsType.Close, "Error Saving settings\n" + - e.ToString ()); - } - } - - void OnEmail_Changed (object sender, EventArgs a) - { - string text = entry_email.Text; - - if (text.IndexOf ("@") != -1 && text.Length > 3) - button_email_ok.Sensitive = true; - } + // + // Invoked by New Tab menu entry. + // + void OnNewTab (object sender, EventArgs a) + { + AddTab(); } - void OnContributionStatistics (object sender, EventArgs a) + // + // Invoked by Close Tab menu entry. + // + public void OnCloseTab (object sender, EventArgs a) { - string email = SettingsHandler.Settings.Email; - string key = SettingsHandler.Settings.Key; - - if (key == null || key == "") { - MessageDialog md = new MessageDialog (null, - DialogFlags.DestroyWithParent, - MessageType.Info, - ButtonsType.Close, - "You have not obtained or used a contribution key yet."); - md.Title = "No contribution key"; - - md.Run(); - md.Destroy(); - } - else - ContributionStatus.GetStatus (email, key); + CloseTab(); } - - class ContributionStatus { - enum State { - GetStatusError, - NetworkError, - Done - } - - State state; - Status status; - string contributoremail; - - ThreadNotify tn; - WebClientAsyncResult war; - Contributions d; - - public static void GetStatus (string email, string key) - { - new ContributionStatus(email, key); - } - - ContributionStatus (string email, string key) - { - tn = new ThreadNotify (new ReadyEvent (Update)); - - d = new Contributions (); - if (Environment.GetEnvironmentVariable ("MONODOCTESTING") == null) - d.Url = "http://www.go-mono.com/docs/server.asmx"; - - war = (WebClientAsyncResult) d.BeginGetStatus (email, key, new AsyncCallback (GetStatusDone), null); - contributoremail = email; - } - - void Update () - { - MessageDialog md = null; - - switch (state) { - case State.GetStatusError: - md = new MessageDialog (null, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Close, - "Server returned error while requesting contributor statistics"); - md.Title = "Contribution Statistics Error Occurred"; - break; - case State.NetworkError: - md = new MessageDialog (null, - DialogFlags.DestroyWithParent, - MessageType.Error, ButtonsType.Close, - "Network error occurred while requesting contributor statistics"); - md.Title = "Contribution Statistics Error Occurred"; - break; - case State.Done: - md = new MessageDialog (null, - DialogFlags.DestroyWithParent, - MessageType.Info, ButtonsType.Close, - "Contribution statistics for " + contributoremail + - "\n\nTotal contributions: " + status.Contributions + - "\nContributions committed: " + status.Commited + - "\nContributions pending: " + status.Pending); - md.Title = "Contribution Statistics"; - break; - } - - md.Run(); - md.Destroy(); - } - - void GetStatusDone (IAsyncResult iar) - { - try { - status = d.EndGetStatus (iar); - war = null; - - if (status == null) - state = State.GetStatusError; - else - state = State.Done; - - } catch (Exception e) { - state = State.NetworkError; - Console.WriteLine ("Error getting status: " + e); - } - if (tn != null) - tn.WakeupMain (); - } - } - - class NewComment { - [Glade.Widget] Window newcomment; - [Glade.Widget] Entry entry; - static NewComment NewCommentBox; - Browser parent; - - NewComment (Browser browser) - { - Glade.XML ui = new Glade.XML (null, "browser.glade", "newcomment", null); - ui.Autoconnect (this); - parent = browser; - newcomment.TransientFor = browser.window1; - } - - void OnOkClicked (object sender, EventArgs a) - { - //CommentService service = new CommentService(); - // todo - newcomment.Hide (); - } - - void OnCancelClicked (object sender, EventArgs a) - { - newcomment.Hide (); - } - - // - // Called on the Window delete icon clicked - // - void OnDelete (object sender, DeleteEventArgs a) - { - NewCommentBox = null; - } - - static public void Show (Browser browser) - { - if (NewCommentBox == null) - NewCommentBox = new NewComment (browser); - NewCommentBox.newcomment.Show (); - } - } - - void OnNewComment (object sender, EventArgs a) - { - NewComment.Show (this); - } - - - - class Lookup { - [Glade.Widget] Window lookup; - [Glade.Widget] Entry entry; - static Lookup LookupBox; - Browser parent; - - Lookup (Browser browser) - { - Glade.XML ui = new Glade.XML (null, "browser.glade", "lookup", null); - ui.Autoconnect (this); - parent = browser; - lookup.TransientFor = browser.window1; - } - - void OnOkClicked (object sender, EventArgs a) - { - string text = entry.Text; - if (text != "") - parent.LoadUrl (entry.Text); - lookup.Hide (); - } - - // - // Called on the Window delete icon clicked - // - void OnDelete(object sender, DeleteEventArgs a) - { - LookupBox = null; - } - - static public void Show (Browser browser) - { - if (LookupBox == null) - LookupBox = new Lookup (browser); - LookupBox.lookup.Show (); - } - } - - // - // Invoked by File/LookupURL menu entry. - // - void OnLookupURL (object sender, EventArgs a) - { - Lookup.Show (this); - } - - // - // Invoked by Edit/Select All menu entry. - // - void OnSelectAllActivate (object sender, EventArgs a) - { - CurrentTab.html.SelectAll (); - } - - // - // Invoked by New Tab menu entry. - // - void OnNewTab (object sender, EventArgs a) - { - AddTab(); - } - - // - // Invoked by Close Tab menu entry. - // - public void OnCloseTab (object sender, EventArgs a) - { - CloseTab(); - } - -} - -// -// 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) - { - Gtk.TreeModel 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; - Gtk.TreeModel 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; - Gtk.TreeModel 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); - } - } -} - -// -// The index browser -// -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); - browser.index_vbox.PackEnd (browser.matches); - } - - // - // 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); - } - } -} - -public enum Mode { - Viewer, Editor - } - -// -// A Tab is a Notebok with two pages, one for editing and one for visualizing -// -public class Tab : Notebook { - - // Our HTML preview during editing. - public IHtmlRender html_preview; - - // Where we render the contents - public IHtmlRender html; - - public TextView text_editor; - public Mode Tab_mode; - public History history; - private Browser browser; - private Label titleLabel; - private Image EditImg; - public HBox TabLabel; - - public string Title { - get { return titleLabel.Text; } - set { titleLabel.Text = value; } - } - - public Node CurrentNode; - public System.Xml.XmlNode edit_node; - public string edit_url; - - void FocusOut (object sender, FocusOutEventArgs args) - { - if (TabMode == Mode.Editor) - text_editor.GrabFocus (); - } - - - 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; - } - -#if MACOS - public static IHtmlRender GetRenderer (string engine, Browser browser) - { - var renderer = new GtkHtmlHtmlRender (browser.help_tree); - renderer.Initialize (); - - return renderer; - } -#else - 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; - } -#endif - - 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); - html_preview = GetRenderer (browser.engine, browser); - if (html == null || html_preview == 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")); - - // - // Second Page: editing - // - VBox vbox1 = new VBox(false, 0); - - VBox MainPart = new VBox(false, 0); - - // - // TextView for XML code - // - ScrolledWindow sw = new ScrolledWindow(); - text_editor = new TextView(); - text_editor.Buffer.Changed += new EventHandler (EditedTextChanged); - text_editor.WrapMode = WrapMode.Word; - sw.Add(text_editor); - text_editor.FocusOutEvent += new FocusOutEventHandler (FocusOut); - - // - // XML editing buttons - // - HBox EdBots = new HBox(false, 2); - Button button1 = new Button(""); - EdBots.PackStart(button1); - Button button2 = new Button(""); - EdBots.PackStart(button2); - Button button3 = new Button("<_table>"); - EdBots.PackStart(button3); - Button button4 = new Button("<_see...>"); - EdBots.PackStart(button4); - Button button5 = new Button("<_para>"); - EdBots.PackStart(button5); - Button button6 = new Button("Add Note"); - EdBots.PackStart(button6); - - button1.Clicked += new EventHandler (OnInsertExampleClicked); - button2.Clicked += new EventHandler (OnInsertListClicked); - button3.Clicked += new EventHandler (OnInsertTableClicked); - button4.Clicked += new EventHandler (OnInsertType); - button5.Clicked += new EventHandler (OnInsertParaClicked); - button6.Clicked += new EventHandler (OnInsertNoteClicked); - - Frame html_preview_frame = new Frame("Preview"); - ScrolledWindow html_preview_container = new ScrolledWindow(); - // - // code preview panel - // - html_preview_container.Add (html_preview.HtmlPanel); - html_preview_frame.Add(html_preview_container); - - MainPart.PackStart(sw); - MainPart.PackStart(EdBots, false, false, 0); - MainPart.PackStart(html_preview_frame); - - // - // Close and Save buttons - // - HBox MainBots = new HBox(false, 3); - HBox Filling = new HBox(false, 0); - Button close = new Button("C_lose"); - Button save = new Button("S_ave"); - Button restore = new Button("_Restore"); - - close.Clicked += new EventHandler (OnCancelEdits); - save.Clicked += new EventHandler (OnSaveEdits); - restore.Clicked += new EventHandler (OnRestoreEdits); - - MainBots.PackStart(Filling); - MainBots.PackStart(close, false, false, 0); - MainBots.PackStart(save, false, false, 0); - MainBots.PackStart(restore, false, false, 0); - - vbox1.PackStart(MainPart); - vbox1.PackStart(MainBots, false, false, 0); - - AppendPage(vbox1, new Label("Edit XML")); - - // - //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); - - //Icon showed when the Tab is in Edit Mode - EditImg = new Image (Stock.Convert, IconSize.SmallToolbar); - - TabLabel.PackStart (EditImg, false, true, 2); - 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(); - EditImg.Visible = false; - - } - - public Mode TabMode { - get { return Tab_mode; } - set { Tab_mode = value; } - } - - - public void SetMode (Mode m) - { - if (Tab_mode == m) - return; - - if (m == Mode.Viewer) { - this.Page = 0; - browser.cut1.Sensitive = false; - browser.paste1.Sensitive = false; - browser.print.Sensitive = true; - EditImg.Visible = false; - } else { - this.Page = 1; - browser.cut1.Sensitive = true; - browser.paste1.Sensitive = true; - browser.print.Sensitive = false; - EditImg.Visible = true; - } - - Tab_mode = m; - } - - // Events for the Editor - - void OnInsertParaClicked (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor ("\n\n"); - } - - void OnInsertNoteClicked (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor ("\n\n \n \n"); - } - - void OnInsertExampleClicked (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor ("\n\n \n \n"); - } - - void OnInsertListClicked (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor ("\n\n \n First Item\n \n"); - - } - - void OnInsertTableClicked (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor ("\n\n \n Column\n" + - " Description\n" + - " \n" + - " \n" + - " Term\n" + - " Description\n" + - " \n" + - ""); - } - - void OnInsertType (object sender, EventArgs a) - { - text_editor.Buffer.InsertAtCursor (""); - } - void OnSaveEdits (object sender, EventArgs a) - { - try { - edit_node.InnerXml = text_editor.Buffer.Text; - } catch (Exception e) { - browser.statusbar.Pop (browser.context_id); - browser.statusbar.Push (browser.context_id, e.Message); - return; - } - string [] uSplit = EditingUtils.ParseEditUrl (edit_url); - - if (uSplit[0].StartsWith ("monodoc:")) - EditingUtils.SaveChange (edit_url, browser.help_tree, edit_node, GetNiceUrl (browser.CurrentTab.CurrentNode)); - else if (uSplit[0].StartsWith ("file:")) - EditingUtils.SaveChange (edit_url, browser.help_tree, edit_node, String.Empty); - else - Console.WriteLine ("Edit url wrong: {0}", edit_url); - SetMode (Mode.Viewer); - history.ActivateCurrent (); - } - - 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; - } - } - - void OnCancelEdits (object sender, EventArgs a) - { - SetMode (Mode.Viewer); - history.ActivateCurrent (); - } - - void OnRestoreEdits (object sender, EventArgs a) - { - EditingUtils.RemoveChange (edit_url, browser.help_tree); - SetMode (Mode.Viewer); - history.ActivateCurrent (); - } - - bool queued = false; - - void EditedTextChanged (object sender, EventArgs args) - { - if (queued) - return; - - queued = true; - GLib.Timeout.Add (500, delegate { - queued = false; - - StringWriter sw = new StringWriter (); - XmlWriter w = new XmlTextWriter (sw); - var converter = new Monodoc.Generators.Html.Ecma2Html (); - - try { - edit_node.InnerXml = text_editor.Buffer.Text; - EditingUtils.RenderEditPreview (edit_url, browser.help_tree, edit_node, w); - w.Flush (); - } catch (Exception e) { - browser.statusbar.Pop (browser.context_id); - browser.statusbar.Push (browser.context_id, e.Message); - - return false; - } - browser.statusbar.Pop (browser.context_id); - browser.statusbar.Push (browser.context_id, "XML OK"); - string s = converter.Export (sw.ToString (), new Dictionary ()); - html_preview.Render(s); - - return false; - }); - } - } } diff --git a/docbrowser/browser.glade b/docbrowser/browser.glade index 35079b401..7bb480a68 100644 --- a/docbrowser/browser.glade +++ b/docbrowser/browser.glade @@ -166,28 +166,6 @@ - - - True - _Cut - True - - - - - - True - gtk-cut - 1 - 0.5 - 0.5 - 0 - 0 - - - - - True @@ -210,28 +188,6 @@ - - - True - _Paste - True - - - - - - True - gtk-paste - 1 - 0.5 - 0.5 - 0 - 0 - - - - - True @@ -279,16 +235,6 @@ - - - - True - Show Comments - True - False - - - @@ -309,77 +255,6 @@
- - - True - _Contributing - True - - - - - - True - _Upload Contributions... - True - - - - - - True - gtk-network - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - _View Contribution Statistics... - True - - - - - True - gtk-find-and-replace - 1 - 0.5 - 0.5 - 0 - 0 - - - - - - - - True - - - - - - True - Edit Mode - True - False - - - - - - - - True @@ -1178,1810 +1053,6 @@ - - True - Login configuration - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_NORMAL - GDK_GRAVITY_NORTH_WEST - - - - - 7 - True - False - True - GTK_POS_TOP - False - False - - - - True - False - 0 - - - - True - You can edit the contents of the API documentation in MonoDoc and contribute -those back. To do this you must agree to relicense your updates under the terms -of the MIT X11 Open Source License and register your email address with the -documentation service. - -If you agree, click Continue - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - True - True - True - Continue - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - 0 - False - False - - - - - False - True - - - - - - True - 0 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - False - 0 - - - - True - _Email: - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 9 - 0 - entry_email - - - 0 - False - False - - - - - - True - True - True - True - True - 0 - - True - * - False - - - - 0 - True - True - - - - - - True - xx - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 7 - 0 - - - 0 - False - False - - - - - 0 - True - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - True - True - True - Continue - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - 0 - False - False - - - - - False - True - - - - - - True - 1 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - Monodoc is requesting an account for you. - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - True - True - True - True - Cancel - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - 0 - False - False - - - - - False - True - - - - - - True - 2 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Error:</b> Monodoc encountered a failure when requesting -a password for your e-mail address. Try again later. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - True - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 3 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - False - 0 - - - - True - Once you receive your password on the mail, please enter it -here: - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - Password: - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 9 - 0 - entry_password - - - 0 - False - False - - - - - - True - True - True - False - 0 - - True - * - False - - - 0 - True - True - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 7 - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - True - True - Continue - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 4 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - MonoDoc is logging into the server. - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - True - Cancel - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - False - False - - - - - False - True - - - - - - True - 5 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Congratulations!</b> - -You can now contribute your changes to MonoDoc by using -the File/Upload menu option. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 6 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Terminated</b> - -The request to the Monodoc server has been cancelled. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 7 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Please wait</b> - -MonoDoc is checking the server version. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - True - Cancel - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - - - - - 0 - False - False - - - - - False - True - - - - - - True - 8 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Communications Problem</b> - -There was a communications problem when communicating -with the Mono Documentation Server. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 9 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Version missmatch</b> - -This version of MonoDoc is not compatible with the current Monodoc -server, please upgrade your MonoDoc installation. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - False - 0 - - - - - - - - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 10 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - True - False - 0 - - - - True - <b>Password Problem</b> - -The passkey entered is incorrect. -Please try again. - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - True - False - - - - - - True - False - 0 - - - - - - - - True - True - Ok - True - GTK_RELIEF_NORMAL - True - - - - 0 - False - False - GTK_PACK_END - - - - - 0 - False - False - - - - - False - True - - - - - - True - 11 - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - tab - - - - - - - - True - Uploading Documentation Updates - MonoDoc - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - Cancel - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - 0 - False - True - GTK_PACK_END - - - - - - True - False - 0 - - - - True - Monodoc Documentation Updates Uploader. - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 10 - 11 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - <b>Status:</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - False - False - - - - - - - - True - New Comment - 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 - TODO: Some advise on posting here. - False - False - GTK_JUSTIFY_LEFT - True - False - 0.5 - 0.5 - 5 - 5 - - - 0 - False - False - - - - - - True - 5 - 2 - False - 0 - 0 - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - 5 - 5 - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - 5 - 5 - - - - - - - True - Title: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 2 - 3 - 5 - 5 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 2 - 3 - 5 - 5 - - - - - - - True - Comment - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 3 - 4 - 5 - 5 - fill - - - - - - - True - E-Mail: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - 5 - 5 - fill - - - - - - - True - Name: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - 5 - 5 - fill - - - - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_ALWAYS - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 1 - 2 - 3 - 4 - 5 - 5 - fill - fill - - - - - - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - - - - 1 - 2 - 4 - 5 - 5 - 5 - fill - - - - - - - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - - - - 0 - 1 - 4 - 5 - 5 - 5 - fill - - - - - - 0 - True - True - - - - - - True Manage Bookmarks diff --git a/docbrowser/editing.cs b/docbrowser/editing.cs deleted file mode 100644 index d7c1e3270..000000000 --- a/docbrowser/editing.cs +++ /dev/null @@ -1,519 +0,0 @@ -// -// editing.cs -// -// Author: -// Ben Maurer (bmaurer@users.sourceforge.net) -// -// (C) 2003 Ben Maurer -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Text; -using System.Xml; -using System.Xml.Serialization; -using System.Xml.XPath; -using System.Web; - -namespace Monodoc { - public class EditingUtils { - - public static string FormatEditUri (string document_identifier, string xpath) - { - return String.Format ("edit:{0}@{1}", HttpUtility.UrlEncode (document_identifier), - HttpUtility.UrlEncode (xpath)); - } - - public static string GetXPath (XPathNavigator n) - { - switch (n.NodeType) { - case XPathNodeType.Root: return "/"; - case XPathNodeType.Attribute: { - string ret = "@" + n.Name; - n.MoveToParent (); - string s = GetXPath (n); - return s + (s == "/" ? "" : "/") + ret; - } - - case XPathNodeType.Element: { - string ret = n.Name; - int i = 1; - while (n.MoveToPrevious ()) { - if (n.NodeType == XPathNodeType.Element && n.Name == ret) - i++; - } - ret += "[" + i + "]"; - if (n.MoveToParent ()) { - string s = GetXPath (n); - return s + (s == "/" ? "" : "/") + ret; - } - } - break; - } - throw new Exception ("node type not supported for editing"); - - } - - public static XmlNode GetNodeFromUrl (string url, RootTree tree) - { - Console.WriteLine ("Url is: {0}", url); - string [] uSplit = ParseEditUrl (url); - Console.WriteLine ("Results are: {0}\n{1}\n{2}", uSplit [0], uSplit [1], uSplit [2]); - - string xp = uSplit [2]; - string id = uSplit [1]; - - XmlDocument d; - - if (uSplit[0].StartsWith("monodoc:///")) { - int prov = int.Parse (uSplit [0].Substring("monodoc:///".Length)); - d = tree.GetHelpSourceFromId (prov).GetHelpXmlWithChanges (id); - } else if (uSplit[0].StartsWith("file:")) { - d = new XmlDocument(); - d.PreserveWhitespace = true; - d.Load(uSplit[0].Substring(5)); - } else { - throw new NotImplementedException("Don't know how to load " + url); - } - - return d.SelectSingleNode (xp); - - } - - public static void SaveChange (string url, RootTree tree, XmlNode node, string node_url) - { - /*string [] uSplit = ParseEditUrl (url); - - string xp = uSplit [2]; - string id = uSplit [1]; - - if (uSplit[0].StartsWith("monodoc:///")) { - int prov = int.Parse (uSplit [0].Substring("monodoc:///".Length)); - HelpSource hs = tree.GetHelpSourceFromId (prov); - - changes.AddChange (hs.Name, hs.GetRealPath (id), xp, node, node_url); - changes.Save (); - } else if (uSplit[0].StartsWith("file:")) { - uSplit[0] = uSplit[0].Substring(5); - - XmlDocument d = new XmlDocument(); - d.PreserveWhitespace = true; - d.Load(uSplit[0]); - - XmlNode original = d.SelectSingleNode(xp); - original.ParentNode.ReplaceChild(d.ImportNode(node, true), original); - - d.Save(uSplit[0]); - } else { - throw new NotImplementedException("Don't know how to save to " + url); - }*/ - } - - public static void RemoveChange (string url, RootTree tree) - { - /*string [] uSplit = ParseEditUrl (url); - - string xp = uSplit [2]; - string id = uSplit [1]; - - if (uSplit[0].StartsWith("monodoc:///")) { - int prov = int.Parse (uSplit [0].Substring("monodoc:///".Length)); - HelpSource hs = tree.GetHelpSourceFromId (prov); - - changes.RemoveChange (hs.Name, hs.GetRealPath (id), xp); - changes.Save (); - } else if (uSplit[0].StartsWith("file:")) { - //TODO: Not implemented - }*/ - } - - public static void RenderEditPreview (string url, RootTree tree, XmlNode new_node, XmlWriter w) - { - string [] uSplit = ParseEditUrl (url); - - if (uSplit[0].StartsWith("monodoc:///")) { - int prov = int.Parse (uSplit [0].Substring("monodoc:///".Length)); - HelpSource hs = tree.GetHelpSourceFromId (prov); - hs.RenderPreviewDocs (new_node, w); - } else { - foreach (HelpSource hs in tree.HelpSources) { - if (hs is Monodoc.Providers.EcmaUncompiledHelpSource) { - // It doesn't matter which EcmaHelpSource is chosen. - hs.RenderPreviewDocs (new_node, w); - break; - } - } - } - } - - public static string [] ParseEditUrl (string url) - { - if (!url.StartsWith ("edit:")) - throw new Exception ("wtf"); - - string [] parts = url.Split ('@'); - if (parts.Length != 2) - throw new Exception (String.Format ("invalid editing url {0}", parts.Length)); - - string xp = HttpUtility.UrlDecode (parts [1]); - parts = HttpUtility.UrlDecode (parts [0]).Substring ("edit:".Length).Split ('@'); - if (parts.Length == 1) { - string p = parts[0]; - parts = new string[2]; - parts[0] = p; - parts[1] = ""; - } - - return new string [] {parts [0], parts [1], xp}; - } - - public static void AccountForChanges (XmlDocument d, string doc_set, string real_file) - { - try { - FileChangeset fcs = changes.GetChangeset (doc_set, real_file); - if (fcs == null) - return; - - foreach (Change c in fcs.Changes) { - // Filter out old changes - if (c.FromVersion != RootTree.MonodocVersion) - continue; - - XmlNode old = d.SelectSingleNode (c.XPath); - if (old != null) - old.ParentNode.ReplaceChild (d.ImportNode (c.NewNode, true), old); - } - } catch { - return; - } - } - - public static GlobalChangeset changes = GlobalChangeset.Load (); - - static public GlobalChangeset GetChangesFrom (int starting_serial_id) - { - return changes.GetFrom (starting_serial_id); - } - } - -#region Data Model - public class GlobalChangeset { - - public static XmlSerializer serializer = new XmlSerializer (typeof (GlobalChangeset)); - static string changeset_file = Path.Combine (SettingsHandler.Path, "changeset.xml"); - static string changeset_backup_file = Path.Combine (SettingsHandler.Path, "changeset.xml~"); - - public static GlobalChangeset Load () - { - try { - if (File.Exists (changeset_file)) - return LoadFromFile (changeset_file); - } catch {} - - return new GlobalChangeset (); - } - - public static GlobalChangeset LoadFromFile (string fileName) - { - using (Stream s = File.OpenRead (fileName)) { - return (GlobalChangeset) serializer.Deserialize (s); - } - } - - public void Save () - { - SettingsHandler.EnsureSettingsDirectory (); - - try { - if (File.Exists(changeset_file)) // create backup copy - File.Copy (changeset_file, changeset_backup_file, true); - - using (FileStream fs = File.Create (changeset_file)){ - serializer.Serialize (fs, this); - } - } catch (Exception e) { - Console.WriteLine ("Error while saving changes. " + e); - if (File.Exists(changeset_backup_file)) // if saving fails then use backup if we have one - File.Copy (changeset_backup_file, changeset_file, true); - else - File.Delete (changeset_file); // if no backup, delete invalid changeset - } - } - - static void VerifyDirectoryExists (DirectoryInfo d) { - if (d.Exists) - return; - - VerifyDirectoryExists (d.Parent); - d.Create (); - } - - [XmlElement ("DocSetChangeset", typeof (DocSetChangeset))] - public ArrayList DocSetChangesets = new ArrayList (); - - public FileChangeset GetChangeset (string doc_set, string real_file) - { - foreach (DocSetChangeset dscs in DocSetChangesets) { - if (dscs.DocSet != doc_set) - continue; - - foreach (FileChangeset fcs in dscs.FileChangesets) { - if (fcs.RealFile == real_file) - return fcs; - } - } - - return null; - } - - public int Count { - get { - int count = 0; - - foreach (DocSetChangeset dscs in DocSetChangesets){ - foreach (FileChangeset fcs in dscs.FileChangesets){ - count += fcs.Changes.Count; - } - } - - return count; - } - } - - Change NewChange (string xpath, XmlNode new_node, string node_url) - { - Change new_change = new Change (); - new_change.XPath = xpath; - new_change.NewNode = new_node; - new_change.NodeUrl = node_url; - - Console.WriteLine ("New serial:" + SettingsHandler.Settings.SerialNumber); - new_change.Serial = SettingsHandler.Settings.SerialNumber; - - return new_change; - } - - public void AddChange (string doc_set, string real_file, string xpath, XmlNode new_node, string node_url) - { - FileChangeset new_file_change_set; - Change new_change = NewChange (xpath, new_node, node_url); - - if (real_file == null) - throw new Exception ("Could not find real_file. Please talk to Miguel or Ben about this"); - - foreach (DocSetChangeset dscs in DocSetChangesets) { - if (dscs.DocSet != doc_set) - continue; - - foreach (FileChangeset fcs in dscs.FileChangesets) { - if (fcs.RealFile != real_file) - continue; - - foreach (Change c in fcs.Changes) { - if (c.XPath == xpath) { - c.NewNode = new_node; - c.Serial = SettingsHandler.Settings.SerialNumber; - return; - } - } - - fcs.Changes.Add (new_change); - return; - - } - - new_file_change_set = new FileChangeset (); - new_file_change_set.RealFile = real_file; - new_file_change_set.Changes.Add (new_change); - dscs.FileChangesets.Add (new_file_change_set); - return; - - } - - DocSetChangeset new_dcs = new DocSetChangeset (); - new_dcs.DocSet = doc_set; - - new_file_change_set = new FileChangeset (); - new_file_change_set.RealFile = real_file; - - new_file_change_set.Changes.Add (new_change); - new_dcs.FileChangesets.Add (new_file_change_set); - DocSetChangesets.Add (new_dcs); - } - - public void RemoveChange (string doc_set, string real_file, string xpath) - { - if (real_file == null) - throw new Exception ("Could not find real_file. Please talk to Miguel or Ben about this"); - - for (int i = 0; i < DocSetChangesets.Count; i++) { - DocSetChangeset dscs = DocSetChangesets [i] as DocSetChangeset; - if (dscs.DocSet != doc_set) - continue; - - for (int j = 0; j < dscs.FileChangesets.Count; j++) { - FileChangeset fcs = dscs.FileChangesets [j] as FileChangeset; - if (fcs.RealFile != real_file) - continue; - - for (int k = 0; k < fcs.Changes.Count; k++) { - Change c = fcs.Changes [k] as Change; - if (c.XPath == xpath) { - fcs.Changes.Remove (c); - break; - } - } - if (fcs.Changes.Count == 0) - dscs.FileChangesets.Remove (fcs); - } - - if (dscs.FileChangesets.Count == 0) - DocSetChangesets.Remove (dscs); - } - } - - public GlobalChangeset GetFrom (int starting_serial_id) - { - GlobalChangeset s = null; - - foreach (DocSetChangeset dscs in DocSetChangesets){ - object o = dscs.GetFrom (starting_serial_id); - if (o == null) - continue; - if (s == null) - s = new GlobalChangeset (); - s.DocSetChangesets.Add (o); - } - return s; - } - } - - public class DocSetChangeset { - [XmlAttribute] public string DocSet; - - [XmlElement ("FileChangeset", typeof (FileChangeset))] - public ArrayList FileChangesets = new ArrayList (); - - public DocSetChangeset GetFrom (int starting_serial_id) - { - DocSetChangeset dsc = null; - - foreach (FileChangeset fcs in FileChangesets){ - object o = fcs.GetFrom (starting_serial_id); - if (o == null) - continue; - if (dsc == null){ - dsc = new DocSetChangeset (); - dsc.DocSet = DocSet; - } - dsc.FileChangesets.Add (o); - } - return dsc; - } - } - - public class FileChangeset { - [XmlAttribute] public string RealFile; - - [XmlElement ("Change", typeof (Change))] - public ArrayList Changes = new ArrayList (); - - public FileChangeset GetFrom (int starting_serial_id) - { - FileChangeset fcs = null; - - foreach (Change c in Changes){ - if (c.Serial < starting_serial_id) - continue; - if (fcs == null){ - fcs = new FileChangeset (); - fcs.RealFile = RealFile; - } - fcs.Changes.Add (c); - } - return fcs; - } - } - - public class Change { - [XmlAttribute] public string XPath; - [XmlAttribute] public int FromVersion = RootTree.MonodocVersion; - [XmlAttribute] public string NodeUrl; - - public XmlNode NewNode; - - public int Serial; - - bool applied = false; - - // - // These are not a property, because we dont want them serialized; - // Only used by the Admin Client. - // - public bool Applied () - { - return applied; - } - - public void SetApplied (bool value) - { - applied = value; - } - } -#endregion - - public class EditMerger { - GlobalChangeset changeset; - ArrayList targetDirs; - - public EditMerger (GlobalChangeset changeset, ArrayList targetDirs) - { - this.changeset = changeset; - this.targetDirs = targetDirs; - } - - public void Merge () - { - foreach (DocSetChangeset dsc in changeset.DocSetChangesets) { - bool merged = false; - foreach (string path in targetDirs) { - if (File.Exists (Path.Combine (path, dsc.DocSet + ".source"))) { - Merge (dsc, path); - merged = true; - break; - } - } - if (!merged) Console.WriteLine ("Could not merge docset {0}", dsc.DocSet); - } - } - - void Merge (DocSetChangeset dsc, string path) - { - Console.WriteLine ("Merging changes in {0} ({1})", dsc.DocSet, path); - - foreach (FileChangeset fcs in dsc.FileChangesets) { - if (File.Exists (Path.Combine (path, fcs.RealFile))) - Merge (fcs, path); - else - Console.WriteLine ("\tCould not find file {0}", Path.Combine (path, fcs.RealFile)); - } - } - - void Merge (FileChangeset fcs, string path) - { - XmlDocument d = new XmlDocument (); - d.Load (Path.Combine (path, fcs.RealFile)); - - foreach (Change c in fcs.Changes) { - XmlNode old = d.SelectSingleNode (c.XPath); - if (old != null) - old.ParentNode.ReplaceChild (d.ImportNode (c.NewNode, true), old); - } - - d.Save (Path.Combine (path, fcs.RealFile)); - } - } -} - diff --git a/docbrowser/gtkhtml-osx.patch b/docbrowser/gtkhtml-osx.patch deleted file mode 100644 index c5ad667c9..000000000 --- a/docbrowser/gtkhtml-osx.patch +++ /dev/null @@ -1,363 +0,0 @@ -diff --git a/Makefile.am b/Makefile.am -index db132b5..f1b5d92 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -1,11 +1,7 @@ - ACLOCAL_AMFLAGS=-I m4 - - SUBDIRS = \ -- a11y \ -- gtkhtml \ -- components \ -- art \ -- po -+ gtkhtml - - CLEANFILES = \ - po/.intltool-merge-cache -diff --git a/configure.ac b/configure.ac -index c3efa4a..3cc84e0 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -9,9 +9,8 @@ AC_CONFIG_SRCDIR(README) - PACKAGE=gtkhtml - - dnl Required Package Versions --m4_define([gtk_minimum_version], [2.18.0]) -+m4_define([gtk_minimum_version], [2.17.0]) - m4_define([gail_minimum_version], [1.1.0]) --m4_define([enchant_minimum_version], [1.1.7]) - m4_define([gnome_icon_theme_minimum_version], [2.22.0]) - - GTKHTML_API_VERSION=3.14 -@@ -41,31 +40,11 @@ AM_MAINTAINER_MODE - dnl ************ - dnl I18N stuff - dnl ************ --IT_PROG_INTLTOOL([0.36.3]) --AM_GLIB_GNU_GETTEXT - - dnl ********************************** - dnl Compiler Warning Flags - dnl ********************************** --AS_COMPILER_FLAGS(WARNING_FLAGS, -- "-DG_DISABLE_DEPRECATED -- -DPANGO_DISABLE_DEPRECATED -- -DGDK_DISABLE_DEPRECATED -- -DGDK_PIXBUF_DISABLE_DEPRECATED -- -DGTK_DISABLE_DEPRECATED -- -DGNOME_DISABLE_DEPRECATED -- -DG_DISABLE_SINGLE_INCLUDES -- -DGTK_DISABLE_SINGLE_INCLUDES -- -Wall -Wextra -- -Wno-missing-field-initializers -- -Wno-sign-compare -- -Wno-unused-parameter -- -Wdeclaration-after-statement -- -Werror-implicit-function-declaration -- -Wformat-nonliteral -Wformat-security -Winit-self -- -Wmissing-declarations -Wmissing-include-dirs -- -Wmissing-noreturn -Wnested-externs -Wpointer-arith -- -Wredundant-decls -Wundef -Wwrite-strings") -+WARNING_FLAGS="" - AC_SUBST(WARNING_FLAGS) - - dnl Other useful compiler warnings for test builds only. -@@ -119,15 +98,6 @@ AC_SUBST(CPPFLAGS) - AC_SUBST(LDFLAGS) - - dnl ********************************** --dnl GAIL modules --dnl ********************************** --GAIL_MODULES="gail >= gail_minimum_version" --PKG_CHECK_MODULES(GAIL, $GAIL_MODULES) --AC_SUBST(GAIL_CFLAGS) --AC_SUBST(GAIL_LIBS) --AC_SUBST(GAIL_MODULES) -- --dnl ********************************** - dnl GTHREAD modules - dnl ********************************** - GTHREAD_MODULES="gthread-2.0" -@@ -138,7 +108,7 @@ AC_SUBST(GTHREAD_LIBS) - dnl ********************************** - dnl GTKHTML modules - dnl ********************************** --GTKHTML_MODULES="gtk+-2.0 >= gtk_minimum_version enchant >= enchant_minimum_version gconf-2.0 iso-codes" -+GTKHTML_MODULES="gtk+-2.0 >= gtk_minimum_version " - PKG_CHECK_MODULES(GTKHTML, $GTKHTML_MODULES) - AC_SUBST(GTKHTML_CFLAGS) - AC_SUBST(GTKHTML_LIBS) -@@ -179,47 +149,6 @@ AM_CONDITIONAL(HAVE_SOUP, test x$have_soup != xno) - AM_CONDITIONAL(HAVE_NEWSOUP, test x$HAVE_NEWSOUP != xno) - - dnl ************************************************** --dnl Gnome Icon Theme --dnl ************************************************** --PKG_CHECK_MODULES(GIT, gnome-icon-theme >= gnome_icon_theme_minimum_version) -- --dnl ************************************************** --dnl iso-codes --dnl ************************************************** --AC_MSG_CHECKING([for iso-codes package]) --have_iso_codes=no --if $PKG_CONFIG --exists iso-codes; then -- if $PKG_CONFIG iso-codes --atleast-version=0.49; then -- have_iso_codes=yes -- AC_MSG_RESULT([$have_iso_codes]) -- else -- AC_MSG_WARN([iso-codes detected, but version 0.49 or later is required due to licensing]) -- fi --else -- AC_MSG_RESULT([$have_iso_codes]) --fi -- --if test "x$have_iso_codes" = "xyes"; then -- AC_MSG_CHECKING([whether iso-codes has iso-639 and iso-3166 domains]) -- if $PKG_CONFIG --variable=domains iso-codes | grep 639 && \ -- $PKG_CONFIG --variable=domains iso-codes | grep 3166 ; then -- result=yes -- else -- result=no -- have_iso_codes=no -- fi -- AC_MSG_RESULT([$result]) --fi -- --if test "x$have_iso_codes" = "xyes"; then -- AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX], -- ["`$PKG_CONFIG --variable=prefix iso-codes`"], -- [ISO codes prefix]) -- AC_DEFINE([HAVE_ISO_CODES], [1], -- [Define if you have the iso-codes package]) --fi -- --dnl ************************************************** - dnl regex library - dnl ************************************************** - AC_CHECK_FUNCS(regexec,,[AC_CHECK_LIB(regex,regexec,[REGEX_LIBS=-lregex],[AC_MSG_ERROR([No regex library found])])]) -@@ -280,7 +209,6 @@ components/editor/Makefile - components/editor/gtkhtml-editor.pc - gtkhtml/Makefile - gtkhtml/libgtkhtml.pc --po/Makefile.in - ]) - AC_OUTPUT - -diff --git a/gtkhtml/Makefile.am b/gtkhtml/Makefile.am -index 6ac2d02..ca9f08f 100644 ---- a/gtkhtml/Makefile.am -+++ b/gtkhtml/Makefile.am -@@ -203,8 +203,9 @@ libgtkhtml_3_14_la_SOURCES = \ - $(PLATFORM_DEP_SOURCES) \ - $(NULL) - --libgtkhtml_3_14_la_LDFLAGS = -version-info $(GTKHTML_CURRENT):$(GTKHTML_REVISION):$(GTKHTML_AGE) -no-undefined --libgtkhtml_3_14_la_LIBADD = $(GTKHTML_LIBS) ../a11y/libgtkhtml-a11y.la $(GAIL_LIBS) $(REGEX_LIBS) -+libgtkhtml_3_14_la_LDFLAGS = -version-info $(GTKHTML_CURRENT):$(GTKHTML_REVISION):$(GTKHTML_AGE) -undefined suppress -flat_namespace -+libgtkhtml_3_14_la_LIBADD = -+AM_LDFLAGS = - - dist-hook: - mkdir $(distdir)/tests -diff --git a/gtkhtml/gtkhtml-properties.h b/gtkhtml/gtkhtml-properties.h -index ac462a5..28d413b 100644 ---- a/gtkhtml/gtkhtml-properties.h -+++ b/gtkhtml/gtkhtml-properties.h -@@ -27,7 +27,6 @@ - #define GTK_HTML_GNOME_CONFIG_PREFIX "/gtkhtml/Settings/" - - #include --#include - - #include "gtkhtml-types.h" - #include "gtkhtml.h" -@@ -47,6 +46,9 @@ struct _GtkHTMLClassProperties { - gchar *language; /* unused */ - }; - -+typedef void *GConfClient; -+typedef void *GConfEntry; -+ - GtkHTMLClassProperties * gtk_html_class_properties_new (void); - void gtk_html_class_properties_destroy (GtkHTMLClassProperties *p); - void gtk_html_class_properties_copy (GtkHTMLClassProperties *p1, -diff --git a/gtkhtml/gtkhtml.c b/gtkhtml/gtkhtml.c -index ebb908b..cd9b7b1 100644 ---- a/gtkhtml/gtkhtml.c -+++ b/gtkhtml/gtkhtml.c -@@ -789,13 +789,6 @@ destroy (GtkObject *object) - html->priv->scroll_timeout_id = 0; - } - -- if (html->priv->notify_monospace_font_id) { -- gconf_client_notify_remove ( -- gconf_client_get_default (), -- html->priv->notify_monospace_font_id); -- html->priv->notify_monospace_font_id = 0; -- } -- - if (html->priv->resize_cursor) { - gdk_cursor_unref (html->priv->resize_cursor); - html->priv->resize_cursor = NULL; -@@ -833,61 +826,11 @@ gtk_html_get_top_html (GtkHTML *html) - static cairo_font_options_t * - get_font_options (void) - { -- gchar *antialiasing, *hinting, *subpixel_order; -- GConfClient *gconf = gconf_client_get_default (); - cairo_font_options_t *font_options = cairo_font_options_create (); -- -- /* Antialiasing */ -- antialiasing = gconf_client_get_string (gconf, -- "/desktop/gnome/font_rendering/antialiasing", NULL); -- if (antialiasing == NULL) { -+ - cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT); -- } else { -- if (strcmp (antialiasing, "grayscale") == 0) -- cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY); -- else if (strcmp (antialiasing, "rgba") == 0) -- cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); -- else if (strcmp (antialiasing, "none") == 0) -- cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_NONE); -- else -- cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_DEFAULT); -- } -- hinting = gconf_client_get_string (gconf, -- "/desktop/gnome/font_rendering/hinting", NULL); -- if (hinting == NULL) { - cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT); -- } else { -- if (strcmp (hinting, "full") == 0) -- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_FULL); -- else if (strcmp (hinting, "medium") == 0) -- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_MEDIUM); -- else if (strcmp (hinting, "slight") == 0) -- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT); -- else if (strcmp (hinting, "none") == 0) -- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE); -- else -- cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_DEFAULT); -- } -- subpixel_order = gconf_client_get_string (gconf, -- "/desktop/gnome/font_rendering/rgba_order", NULL); -- if (subpixel_order == NULL) { - cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); -- } else { -- if (strcmp (subpixel_order, "rgb") == 0) -- cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB); -- else if (strcmp (subpixel_order, "bgr") == 0) -- cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_BGR); -- else if (strcmp (subpixel_order, "vrgb") == 0) -- cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VRGB); -- else if (strcmp (subpixel_order, "vbgr") == 0) -- cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_VBGR); -- else -- cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_DEFAULT); -- } -- g_free (antialiasing); -- g_free (hinting); -- g_free (subpixel_order); -- g_object_unref (gconf); - return font_options; - } - -@@ -926,29 +869,8 @@ gtk_html_set_fonts (GtkHTML *html, HTMLPainter *painter) - } - } - -- if (!fixed_name) { -- GConfClient *gconf; -- -- gconf = gconf_client_get_default (); -- fixed_name = gconf_client_get_string (gconf, "/desktop/gnome/interface/monospace_font_name", NULL); -- if (fixed_name) { -- fixed_desc = pango_font_description_from_string (fixed_name); -- if (fixed_desc) { -- fixed_size = pango_font_description_get_size (fixed_desc); -- fixed_points = !pango_font_description_get_size_is_absolute (fixed_desc); -- fixed_family = pango_font_description_get_family (fixed_desc); -- } else { -- g_free (fixed_name); -- fixed_name = NULL; -- } -- } -- g_object_unref (gconf); -- } -- -- if (!fixed_name) { - fixed_family = "Monospace"; - fixed_size = font_var_size; -- } - - html_font_manager_set_default (&painter->font_manager, - (gchar *)font_var, (gchar *)fixed_family, -@@ -1807,7 +1729,7 @@ hierarchy_changed (GtkWidget *widget, - - toplevel = gtk_widget_get_toplevel (widget); - -- if (gtk_widget_is_toplevel (toplevel) && priv->toplevel_unmap_handler == 0) { -+ if (GTK_WIDGET_TOPLEVEL (toplevel) && priv->toplevel_unmap_handler == 0) { - priv->toplevel_unmap_handler = g_signal_connect (G_OBJECT (toplevel), "unmap-event", - G_CALLBACK (toplevel_unmap), widget); - } -@@ -2738,11 +2660,6 @@ drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint t - static void - read_key_theme (GtkHTMLClass *html_class) - { -- gchar *key_theme; -- -- key_theme = gconf_client_get_string (gconf_client_get_default (), "/desktop/gnome/interface/gtk_key_theme", NULL); -- html_class->use_emacs_bindings = key_theme && !strcmp (key_theme, "Emacs"); -- g_free (key_theme); - } - - static void -@@ -2765,10 +2682,6 @@ client_notify_monospace_font (GConfClient* client, guint cnxn_id, GConfEntry* en - static void - client_notify_cursor_blink (GConfClient* client, guint cnxn_id, GConfEntry* entry, gpointer data) - { -- if (gconf_client_get_bool (client, "/desktop/gnome/interface/cursor_blink", NULL)) -- html_engine_set_cursor_blink_timeout (gconf_client_get_int (client, "/desktop/gnome/interface/cursor_blink_time", NULL) / 2); -- else -- html_engine_set_cursor_blink_timeout (0); - } - - static void -@@ -3158,7 +3071,6 @@ gtk_html_class_init (GtkHTMLClass *klass) - html_class->properties = gtk_html_class_properties_new (); - - add_bindings (klass); -- gtk_html_accessibility_init (); - - filename = g_build_filename (PREFIX, "share", GTKHTML_RELEASE_STRING, "keybindingsrc.emacs", NULL); - gtk_rc_parse (filename); -@@ -3166,16 +3078,7 @@ gtk_html_class_init (GtkHTMLClass *klass) - html_class->emacs_bindings = gtk_binding_set_find ("gtkhtml-bindings-emacs"); - read_key_theme (html_class); - -- client = gconf_client_get_default (); -- -- gconf_client_notify_add (client, "/desktop/gnome/interface/gtk_key_theme", -- client_notify_key_theme, html_class, NULL, &gconf_error); -- -- gconf_client_notify_add (client, "/desktop/gnome/interface/cursor_blink", client_notify_cursor_blink, NULL, NULL, NULL); -- gconf_client_notify_add (client, "/desktop/gnome/interface/cursor_blink_time", client_notify_cursor_blink, NULL, NULL, NULL); - client_notify_cursor_blink (client, 0, NULL, NULL); -- -- g_object_unref (client); - } - - void -@@ -3462,10 +3365,6 @@ gtk_html_init (GtkHTML* html) - g_signal_connect (G_OBJECT (html->priv->im_context), "delete_surrounding", - G_CALLBACK (gtk_html_im_delete_surrounding_cb), html); - -- html->priv->notify_monospace_font_id = -- gconf_client_notify_add (gconf_client_get_default (), "/desktop/gnome/interface/monospace_font_name", -- client_notify_monospace_font, html, NULL, &gconf_error); -- - gtk_html_construct (html); - } - diff --git a/docbrowser/list.cs b/docbrowser/list.cs index 3b4d204e0..545fe7330 100644 --- a/docbrowser/list.cs +++ b/docbrowser/list.cs @@ -46,7 +46,7 @@ public BigList (IListModel provider) layout = new Pango.Layout (PangoContext); - ExposeEvent += new ExposeEventHandler (ExposeHandler); + Drawn += new DrawnHandler (DrawnHandler); ButtonPressEvent += new ButtonPressEventHandler (ButtonPressEventHandler); ButtonReleaseEvent += new ButtonReleaseEventHandler (ButtonReleaseEventHandler); KeyPressEvent += new KeyPressEventHandler (KeyHandler); @@ -113,7 +113,7 @@ void StyleHandler (object obj, StyleSetArgs args) my_style = style_widget.Style.Copy (); Style = my_style; - my_style.SetBackgroundGC (StateType.Normal, Style.BaseGC (StateType.Normal)); + // my_style.SetBackgroundGC (StateType.Normal, Style.BaseGC (StateType.Normal)); Refresh (); } @@ -298,8 +298,10 @@ public int Selected { public event ItemActivated ItemActivated; - void ExposeHandler (object obj, ExposeEventArgs args) + void DrawnHandler (object obj, DrawnArgs args) { + // TODO: Fix everything +/* Gdk.Window win = args.Event.Window; Gdk.Rectangle area = args.Event.Area; @@ -340,6 +342,7 @@ void ExposeHandler (object obj, ExposeEventArgs args) } args.RetVal = true; +*/ } public Gtk.Adjustment Adjustment { diff --git a/ilcontrast/Makefile.am b/ilcontrast/Makefile.am index bcfe65633..9860245eb 100644 --- a/ilcontrast/Makefile.am +++ b/ilcontrast/Makefile.am @@ -7,22 +7,22 @@ assemblydir = $(libdir)/ilcontrast desktopdir = $(datadir)/applications pixmapdir = $(datadir)/pixmaps -if ENABLE_WEBKIT -assembly_DATA = $(TARGET) -bin_SCRIPTS = ilcontrast -desktop_DATA = ilcontrast.desktop -pixmap_DATA = ilcontrast.png -else -if ENABLE_GECKO -assembly_DATA = $(TARGET) -bin_SCRIPTS = ilcontrast +#if ENABLE_WEBKIT +#assembly_DATA = $(TARGET) +#bin_SCRIPTS = ilcontrast +#desktop_DATA = ilcontrast.desktop +#pixmap_DATA = ilcontrast.png +#else +#if ENABLE_GECKO +#assembly_DATA = $(TARGET) +#bin_SCRIPTS = ilcontrast desktop_DATA = ilcontrast.desktop -pixmap_DATA = ilcontrast.png -else +#pixmap_DATA = ilcontrast.png +#else all: echo "Install webkit-sharp or gecko-sharp to build ilContrast" -endif -endif +#endif +#endif if ENABLE_WEBKIT references = $(GTK_SHARP_LIBS) $(WEBKIT_SHARP_LIBS) -r:ICSharpCode.SharpZipLib.dll @@ -38,7 +38,7 @@ resources = \ sources = \ Application.cs \ - ComparisonInfo.cs \ + #ComparisonInfo.cs \ Window.cs \ mono-api-diff.cs \ mono-api-info.cs \