[Mono-devel-list] A larger patch for the monodoc-browser
Philip Van Hoof
spamfrommailing at freax.org
Wed May 21 08:16:07 EDT 2003
On Tue, 2003-05-20 at 23:23, Miguel de Icaza wrote:
> So could you rework your patch a bit to cope with this?
I've attached a new patch. I removed the linear searching from the
previous patch.
--
Philip Van Hoof a.k.a. freax
me at freax dot org
http://www.freax.be -- http://www.freax.eu.org -- http://www.freax.org
-------------- next part --------------
? Makefile.in
? autom4te.cache
? file.zip
? mod
? browser/Makefile.in
? browser/browser.cs.freax
? browser/browser.gladep
? browser/tree.zip
? class/Makefile.in
? class/tmp
? extras/Makefile.in
? extras/filesource
? extras/filetree
? extras/filezip
Index: ChangeLog
===================================================================
RCS file: /mono/monodoc/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog 14 Apr 2003 22:34:48 -0000 1.3
+++ ChangeLog 21 May 2003 12:15:17 -0000
@@ -1,3 +1,8 @@
+2003-04-14 Philip Van Hoof <me at freax.org>
+ * Added some menus
+ * Finished the "Look For"-tabpage
+ * Cleanup
+
2003-04-14 Miguel de Icaza <miguel at ximian.com>
* Makefile.am (bin_SCRIPTS): Install a script `mod' that can be
Index: browser/Makefile.am
===================================================================
RCS file: /mono/monodoc/browser/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- browser/Makefile.am 19 Apr 2003 22:52:22 -0000 1.8
+++ browser/Makefile.am 21 May 2003 12:15:18 -0000
@@ -6,7 +6,7 @@
assembler_sources = $(srcdir)/assembler.cs $(shared_sources)
dump_sources = $(srcdir)/dump.cs $(shared_sources)
browser_sources = $(srcdir)/browser.cs $(srcdir)/history.cs $(shared_sources)
-browser_assemblies = -r:gtk-sharp.dll -r:glade-sharp.dll -r:glib-sharp.dll -r:ICSharpCode.SharpZipLib.dll
+browser_assemblies = -r:gtk-sharp.dll -r:gdk-sharp.dll -r:glade-sharp.dll -r:glib-sharp.dll -r:gnome-sharp.dll -r:ICSharpCode.SharpZipLib.dll
EXTRA_DIST = $(assembler_sources) $(dump_sources) $(browser_sources) browser.glade monodoc.xml mono-ecma.xsl
Index: browser/browser.cs
===================================================================
RCS file: /mono/monodoc/browser/browser.cs,v
retrieving revision 1.21
diff -u -r1.21 browser.cs
--- browser/browser.cs 15 Apr 2003 05:23:52 -0000 1.21
+++ browser/browser.cs 21 May 2003 12:15:18 -0000
@@ -14,10 +14,15 @@
//
using GLib;
using Gtk;
+using Gnome;
+using Gdk;
using GtkSharp;
using Glade;
using System;
+using System.IO;
using System.Collections;
+using System.Text.RegularExpressions;
+using System.Text;
class Browser {
Glade.XML ui;
@@ -67,6 +72,21 @@
TreeView reference_tree;
[Glade.Widget]
+ Label lookfor_label;
+
+ [Glade.Widget]
+ Label searchfor_label;
+
+ [Glade.Widget]
+ Gtk.Entry search_entry;
+
+ [Glade.Widget]
+ TreeView searchfor_tree;
+
+ [Glade.Widget]
+ TreeView lookfor_tree;
+
+ [Glade.Widget]
Box help_container;
[Glade.Widget]
@@ -81,6 +101,9 @@
[Glade.Widget]
Button forward_button;
+ [Glade.Widget]
+ Gtk.Entry index_entry;
+
public History history;
HTML html;
@@ -105,7 +128,7 @@
//html_container = (ScrolledWindow) ui ["html_container"];
help_tree = RootTree.LoadTree ();
- tree_browser = new TreeBrowser (help_tree, reference_tree, this);
+ tree_browser = new TreeBrowser (help_tree, reference_tree, lookfor_tree, searchfor_tree, this);
html = new HTML ();
html.Show ();
@@ -136,7 +159,7 @@
}
}
- void LinkClicked (object o, LinkClickedArgs args)
+ void LinkClicked (object o, LinkClickedArgs args)
{
LoadUrl (args.Url);
}
@@ -207,54 +230,121 @@
{
Application.Quit ();
}
+
+ public void on_quit_activate (object o, EventArgs e)
+ {
+ Application.Quit ();
+ }
+
+ public void on_copy_activate (object o, EventArgs e)
+ {
+ this.html.Copy ();
+ }
+
+ public void on_about_activate (object o, EventArgs e)
+ {
+ string[] authors = {
+ "Miguel De Icaza <miguel at ximian.com>",
+ "Duncan Mak <duncan at ximian.com>"
+ };
+ string[] documenters = {};
+ Pixbuf logo = new Pixbuf ("/usr/share/pixmaps/gnome-about-logo.png");
+ // Pixbuf logo = new Pixbuf ("pixmaps" + Path.DirectorySeparatorChar + "monodoc-logo.png");
+ About about = new About("MonoDoc-browser", "CVS", "Copyright (C) 2003",
+ "This tool displays documentation in the format used by the ECMA specification",
+ authors, documenters, "", logo);
+ about.Show ();
+ }
+
+ public void on_select_all_activate (object o, EventArgs e)
+ {
+ this.html.SelectAll ();
+ }
+
+ public void on_index_entry_activate (object o, EventArgs e)
+ {
+ tree_browser.LookFor(index_entry.Text);
+ }
+
+ public void on_search_entry_activate (object o, EventArgs e)
+ {
+ tree_browser.SearchFor(search_entry.Text);
+ }
}
-//
-// This class implements the tree browser
-//
-class TreeBrowser {
- Browser browser;
- TreeView tree_view;
-
- TreeStore store;
- RootTree help_tree;
- TreeIter root_iter;
- //
+// This class implements the tree browser
+class TreeBrowser {
+ private Browser browser;
+ private TreeView tree_view;
+ private TreeView lookfor_tree;
+ private TreeView searchfor_tree;
+ private TreeStore store;
+ private RootTree help_tree;
+ private TreeIter root_iter;
+ public bool all_expanded=false;
// This hashtable maps an iter to its node.
- //
- Hashtable iter_to_node;
+ private Hashtable iter_to_node;
- //
// This hashtable maps the node to its iter
- //
- Hashtable node_to_iter;
+ private Hashtable node_to_iter;
- //
// Maps a node to its TreeIter parent
- //
- Hashtable node_parent;
+ private Hashtable node_parent;
+
+ // This hashtable maps an iter to its node (for the lookfor-treeview).
+ private Hashtable iter_to_lookfornode;
+
+ // This hashtable maps an iter to its node (for the searchfor-treeview).
+ private Hashtable iter_to_searchfornode;
+
+ private Hashtable populated = new Hashtable ();
+ private bool IgnoreRowActivated = false;
- public TreeBrowser (RootTree help_tree, TreeView reference_tree, Browser browser)
+ public TreeBrowser (RootTree help_tree, TreeView reference_tree, TreeView lookfor_tree, TreeView searchfor_tree, Browser browser)
{
this.browser = browser;
- tree_view = reference_tree;
+ this.tree_view = reference_tree;
+ this.lookfor_tree = lookfor_tree;
+ this.searchfor_tree = searchfor_tree;
iter_to_node = new Hashtable ();
node_to_iter = new Hashtable ();
node_parent = new Hashtable ();
+ iter_to_lookfornode = new Hashtable ();
+ iter_to_searchfornode = new Hashtable ();
- // Setup the TreeView
+ // Setup the normal TreeView
TreeViewColumn name_col = new TreeViewColumn ();
CellRenderer name_render = new CellRendererText ();
name_col.PackStart (name_render, true);
name_col.AddAttribute (name_render, "text", 0);
tree_view.AppendColumn (name_col);
- // Bind events
+ // Setup the LookFor-TreeView
+ TreeViewColumn lname_col = new TreeViewColumn ();
+ CellRenderer lname_render = new CellRendererText ();
+ lname_col.PackStart (lname_render, true);
+ lname_col.AddAttribute (lname_render, "text", 0);
+ lookfor_tree.AppendColumn (lname_col);
+
+ // Setup the SearchFor-TreeView
+ TreeViewColumn sname_col = new TreeViewColumn ();
+ CellRenderer sname_render = new CellRendererText ();
+ sname_col.PackStart (sname_render, true);
+ sname_col.AddAttribute (sname_render, "text", 0);
+ searchfor_tree.AppendColumn (sname_col);
+
+ // Bind events for the normal TreeView
tree_view.RowExpanded += new GtkSharp.RowExpandedHandler (RowExpanded);
tree_view.Selection.Changed += new EventHandler (RowActivated);
+ // Bind events for the LookFor-TreeView
+ // This TreeView will be a simple ListBox, so a RowExpanded-handler is not needed
+ // lookfor_tree.RowExpanded += new GtkSharp.RowExpandedHandler (RowExpanded);
+ lookfor_tree.Selection.Changed += new EventHandler (LookForRowActivated);
+ searchfor_tree.Selection.Changed += new EventHandler (SearchForRowActivated);
+
// Setup the model
this.help_tree = help_tree;
store = new TreeStore ((int) TypeFundamentals.TypeString);
@@ -283,12 +373,9 @@
}
}
- Hashtable populated = new Hashtable ();
-
void RowExpanded (object o, GtkSharp.RowExpandedArgs args)
{
Node result = iter_to_node [args.Iter] as Node;
-
Open (result);
}
@@ -301,10 +388,8 @@
if (populated.Contains (node))
return;
-
- //
+
// We need to populate data on a second level
- //
if (node.Nodes == null)
return;
@@ -313,7 +398,7 @@
}
populated [node] = true;
}
-
+
void PopulateTreeFor (Node n)
{
if (populated [n] == null){
@@ -331,7 +416,7 @@
TreeIter iter = (TreeIter) node_to_iter [n];
TreePath path = store.GetPath (iter);
}
-
+
public void ShowNode (Node n)
{
if (node_to_iter [n] == null){
@@ -345,9 +430,7 @@
TreeIter iter = (TreeIter) node_to_iter [n];
TreePath path = store.GetPath (iter);
- //
// HACK until we upgrade Gtk# to Gtk 2.2
- //
int depth = path.Depth;
for (int i = 0; i < depth; i++){
TreePath p = store.GetPath (iter);
@@ -364,7 +447,8 @@
tree_view.ScrollToCell (path, null, true, 0.5f, 0.5f);
}
- class NodePageVisit : PageVisit {
+ class NodePageVisit : PageVisit
+ {
Browser browser;
Node n;
string url;
@@ -388,53 +472,93 @@
}
}
- 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)
+ void LoadNode (Node n)
+ {
+ Console.Error.WriteLine ("Loading url: " + n.URL);
+ if (n.tree.HelpSource == null)
+ return;
+
+ string url = n.URL;
+
+ // Try the tree-based urls first.
+ Node match;
+ string s = n.tree.HelpSource.GetText (url, out match);
+ if (s != null){
+ ((Browser)browser).Render (s, match, url);
+ browser.history.AppendHistory (new NodePageVisit (browser, n, url));
+ return;
+ }
+
+ // Try the url resolver next
+ s = help_tree.RenderUrl (url, out match);
+ if (s != null){
+ ((Browser)browser).Render (s, match, url);
+ browser.history.AppendHistory (new Browser.LinkPageVisit (browser, url));
+ return;
+ }
+
+ ((Browser)browser).Render ("<b>Unhandled URL</b> " + n.URL, null, url);
+ }
+
+ void RowActivated (object sender, EventArgs a)
{
if (IgnoreRowActivated)
return;
-
+
Gtk.TreeIter iter = new Gtk.TreeIter ();
Gtk.TreeModel model;
- if (tree_view.Selection.GetSelected (out model, ref iter)){
+ if (tree_view.Selection.GetSelected (out model, ref iter)) {
Node n = (Node) iter_to_node [iter];
+ if (n != null)
+ this.LoadNode(n);
+ }
+ }
- Console.Error.WriteLine ("Loading url: " + n.URL);
- if (n.tree.HelpSource == null)
- return;
+ void LookForRowActivated (object sender, EventArgs a)
+ {
+ if (IgnoreRowActivated)
+ return;
- string url = n.URL;
-
- //
- // Try the tree-based urls first.
- //
- Node match;
- string s = n.tree.HelpSource.GetText (url, out match);
- if (s != null){
- ((Browser)browser).Render (s, match, url);
- browser.history.AppendHistory (new NodePageVisit (browser, n, url));
- return;
- }
+ Gtk.TreeIter iter = new Gtk.TreeIter ();
+ Gtk.TreeModel model;
- //
- // Try the url resolver next
- //
- s = help_tree.RenderUrl (url, out match);
- if (s != null){
- ((Browser)browser).Render (s, match, url);
- browser.history.AppendHistory (new Browser.LinkPageVisit (browser, url));
- return;
- }
+ if (lookfor_tree.Selection.GetSelected (out model, ref iter)) {
+ Node n = (Node) iter_to_lookfornode [iter];
+ if (n != null)
+ this.LoadNode(n);
+ }
+ }
- ((Browser)browser).Render ("<b>Unhandled URL</b> " + n.URL, null, url);
+ void SearchForRowActivated (object sender, EventArgs a)
+ {
+ if (IgnoreRowActivated)
+ return;
+
+ Gtk.TreeIter iter = new Gtk.TreeIter ();
+ Gtk.TreeModel model;
+
+ if (searchfor_tree.Selection.GetSelected (out model, ref iter)) {
+ Node n = (Node) iter_to_searchfornode [iter];
+ if (n != null)
+ this.LoadNode(n);
}
}
+
+ public void SearchFor (string searchfor)
+ {
+ // Use the hastable iter_to_searchfornode[TreeIter] = Node
+ Console.WriteLine("Searching for: {0}", searchfor);
+ }
+
+ public void LookFor (string searchfor)
+ {
+ // Use the hashtable iter_to_lookfornode[TreeIter] = Node
+ Console.WriteLine("Looking for: {0}", searchfor);
+ }
+
}
Index: browser/browser.glade
===================================================================
RCS file: /mono/monodoc/browser/browser.glade,v
retrieving revision 1.9
diff -u -r1.9 browser.glade
--- browser/browser.glade 4 Apr 2003 23:49:39 -0000 1.9
+++ browser/browser.glade 21 May 2003 12:15:19 -0000
@@ -2,6 +2,7 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
+<requires lib="gnome"/>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
@@ -29,6 +30,19 @@
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="menuitem4_menu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="quit">
+ <property name="visible">True</property>
+ <property name="stock_item">GNOMEUIINFO_MENU_EXIT_ITEM</property>
+ <signal name="activate" handler="on_quit_activate" last_modification_time="Wed, 14 May 2003 11:12:29 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
</child>
@@ -37,6 +51,27 @@
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="menuitem5_menu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="copy">
+ <property name="visible">True</property>
+ <property name="stock_item">GNOMEUIINFO_MENU_COPY_ITEM</property>
+ <signal name="activate" handler="on_copy_activate" last_modification_time="Wed, 14 May 2003 11:12:29 GMT"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkMenuItem" id="select_all">
+ <property name="visible">True</property>
+ <property name="stock_item">GNOMEUIINFO_MENU_SELECT_ALL_ITEM</property>
+ <signal name="activate" handler="on_select_all_activate" last_modification_time="Wed, 14 May 2003 11:12:29 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
</child>
@@ -53,6 +88,19 @@
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
+
+ <child>
+ <widget class="GtkMenu" id="menuitem7_menu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="about">
+ <property name="visible">True</property>
+ <property name="stock_item">GNOMEUIINFO_MENU_ABOUT_ITEM</property>
+ <signal name="activate" handler="on_about_activate" last_modification_time="Wed, 14 May 2003 11:12:29 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
</widget>
</child>
</widget>
@@ -165,7 +213,7 @@
<property name="spacing">0</property>
<child>
- <widget class="GtkLabel" id="label">
+ <widget class="GtkLabel" id="lookfor_label">
<property name="visible">True</property>
<property name="label" translatable="yes">_Look for:</property>
<property name="use_underline">True</property>
@@ -197,6 +245,7 @@
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
+ <signal name="activate" handler="on_index_entry_activate" last_modification_time="Wed, 14 May 2003 16:16:12 GMT"/>
</widget>
<packing>
<property name="padding">4</property>
@@ -215,7 +264,7 @@
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
- <widget class="GtkTreeView" id="treeview1">
+ <widget class="GtkTreeView" id="lookfor_tree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
@@ -258,18 +307,79 @@
</child>
<child>
- <widget class="GtkLabel" id="label5">
+ <widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="label" translatable="yes">label5</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="searchfor_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Search for:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">index_entry</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="search_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char" translatable="yes">*</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="on_search_entry_activate" last_modification_time="Fri, 16 May 2003 01:27:20 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">4</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTreeView" id="searchfor_tree">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="rules_hint">False</property>
+ <property name="reorderable">False</property>
+ <property name="enable_search">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="tab_expand">False</property>
More information about the Mono-devel-list
mailing list