[Monodevelop-patches-list] r1937 - in branches/MonoDevelop-plan-43: . src/Plugins/Content src/Plugins/Editor src/Plugins/Node
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Sat Aug 14 17:27:05 EDT 2004
Author: jzwart
Date: 2004-08-14 17:27:05 -0400 (Sat, 14 Aug 2004)
New Revision: 1937
Added:
branches/MonoDevelop-plan-43/src/Plugins/Content/AbstractNodeViewer.cs
branches/MonoDevelop-plan-43/src/Plugins/Content/Context.cs
Modified:
branches/MonoDevelop-plan-43/ChangeLog
branches/MonoDevelop-plan-43/default.build
branches/MonoDevelop-plan-43/src/Plugins/Content/ContentManager.cs
branches/MonoDevelop-plan-43/src/Plugins/Content/INodeViewerFactory.cs
branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewer.cs
branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewerFactory.cs
branches/MonoDevelop-plan-43/src/Plugins/Node/Buffer.cs
branches/MonoDevelop-plan-43/src/Plugins/Node/FileNode.cs
branches/MonoDevelop-plan-43/src/Plugins/Node/Node.cs
branches/MonoDevelop-plan-43/src/Plugins/Node/TextFileNode.cs
branches/MonoDevelop-plan-43/src/Plugins/Node/node.plugin.in
Log:
2004-08-15 Jeroen Zwartepoorte <jeroen at xs4all.nl>
* default.build: nant.project.basedir is obsolete; use
project::get-base-directory () function instead.
* src/Plugins/Node/node.plugin.in: register the TextFileNode from within
the TextFileNode class itself, not Node.
* src/Plugins/Node/Node.cs: Idem.
* src/Plugins/Node/Buffer.cs: implement some more basic bits.
* src/Plugins/Node/TextFileNode.cs: register text/plain mimetype here.
* src/Plugins/Editor/EditorNodeViewer.cs: get basic file loading
working. Use new AbstractNodeViewer class.
* src/Plugins/Editor/EditorNodeViewerFactory.cs: Use Context class.
* src/Plugins/Content/AbstractNodeViewer.cs: basic default impl of
INodeViewer interface.
* src/Plugins/Content/Context.cs: convenience class for coupling a
Workbench and a Node.
* src/Plugins/Content/ContentManager.cs: use Context API.
* src/Plugins/Content/INodeViewerFactory.cs: idem.
Modified: branches/MonoDevelop-plan-43/ChangeLog
===================================================================
--- branches/MonoDevelop-plan-43/ChangeLog 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/ChangeLog 2004-08-14 21:27:05 UTC (rev 1937)
@@ -1,3 +1,22 @@
+2004-08-15 Jeroen Zwartepoorte <jeroen at xs4all.nl>
+
+ * default.build: nant.project.basedir is obsolete; use
+ project::get-base-directory () function instead.
+ * src/Plugins/Node/node.plugin.in: register the TextFileNode from within
+ the TextFileNode class itself, not Node.
+ * src/Plugins/Node/Node.cs: Idem.
+ * src/Plugins/Node/Buffer.cs: implement some more basic bits.
+ * src/Plugins/Node/TextFileNode.cs: register text/plain mimetype here.
+ * src/Plugins/Editor/EditorNodeViewer.cs: get basic file loading
+ working. Use new AbstractNodeViewer class.
+ * src/Plugins/Editor/EditorNodeViewerFactory.cs: Use Context class.
+ * src/Plugins/Content/AbstractNodeViewer.cs: basic default impl of
+ INodeViewer interface.
+ * src/Plugins/Content/Context.cs: convenience class for coupling a
+ Workbench and a Node.
+ * src/Plugins/Content/ContentManager.cs: use Context API.
+ * src/Plugins/Content/INodeViewerFactory.cs: idem.
+
2004-08-13 Jeroen Zwartepoorte <jeroen at xs4all.nl>
* default.build: don't hardcode the version dependencies; use
Modified: branches/MonoDevelop-plan-43/default.build
===================================================================
--- branches/MonoDevelop-plan-43/default.build 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/default.build 2004-08-14 21:27:05 UTC (rev 1937)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project name="monodevelop" default="build">
<!-- global project settings -->
- <property name="basedir" value="${nant.project.basedir}"/>
+ <property name="basedir" value="${project::get-base-directory()}"/>
<property name="project.name" value="monodevelop"/>
<property name="project.version" value="0.1" overwrite="false"/>
<!-- global build settings -->
Added: branches/MonoDevelop-plan-43/src/Plugins/Content/AbstractNodeViewer.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Content/AbstractNodeViewer.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Content/AbstractNodeViewer.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -0,0 +1,55 @@
+//
+// AbstractNodeViewer: basic default implementation of INodeViewer interface.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using Gtk;
+using System;
+using MonoDevelop.Node;
+
+namespace MonoDevelop.Content {
+ abstract public class AbstractNodeViewer : INodeViewer {
+ private Context context;
+
+ public AbstractNodeViewer (Context context)
+ {
+ this.context = context;
+ }
+
+ public Context Context {
+ get {
+ return context;
+ }
+ }
+
+ abstract public Widget StructureWidget {
+ get;
+ }
+
+ abstract public Widget ViewerWidget {
+ get;
+ }
+
+ public string ViewerDescription {
+ get {
+ return null;
+ }
+ }
+
+ public string ViewerTitle {
+ get {
+ return null;
+ }
+ }
+
+ public Gdk.Pixbuf ViewerIcon {
+ get {
+ return null;
+ }
+ }
+ }
+}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Content/ContentManager.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Content/ContentManager.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Content/ContentManager.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -68,7 +68,10 @@
// Find a FileNode Type for the specified mimetype.
FileNodeEntry entry = FileNode.FindFileNodeType (mimetype);
+ // FIXME: if the mimetype is of type text/* and there's no specific node for it,
+ // fallback to text/plain and try to open that.
if (entry == null) {
+ // FIXME: popup a dialog saying there are no viewers for this mimetype.
log.Debug ("No matching FileNode found for mimetype \"" + mimetype + "\"");
return;
}
@@ -92,7 +95,8 @@
foreach (INodeViewerFactory factory in factories) {
if (factory.CanDisplayNode (fn)) {
log.Debug ("" + factory + " can display node " + fn);
- INodeViewer viewer = factory.CreateNodeViewer (fn);
+ Context ctx = new Context (Workbench.Workbench.ActiveWorkbench, fn);
+ INodeViewer viewer = factory.CreateNodeViewer (ctx);
AppendPage (viewer.ViewerWidget, new Label (fn.DisplayName));
viewer.ViewerWidget.ShowAll ();
break;
Added: branches/MonoDevelop-plan-43/src/Plugins/Content/Context.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Content/Context.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Content/Context.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -0,0 +1,37 @@
+//
+// Context.cs: convenience class for coupling a Workbench and a Node.
+//
+// Author:
+// Jeroen Zwartepoorte <jeroen at xs4all.nl>
+//
+// (C) Copyright Jeroen Zwartepoorte 2004
+//
+
+using System;
+using MonoDevelop.Node;
+using MonoDevelop.Workbench;
+
+namespace MonoDevelop.Content {
+ public class Context {
+ private Workbench workbench;
+ private Node node;
+
+ public Context (Workbench workbench, Node node)
+ {
+ this.workbench = workbench;
+ this.node = node;
+ }
+
+ public Workbench Workbench {
+ get {
+ return workbench;
+ }
+ }
+
+ public Node Node {
+ get {
+ return node;
+ }
+ }
+ }
+}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Content/INodeViewerFactory.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Content/INodeViewerFactory.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Content/INodeViewerFactory.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -18,6 +18,6 @@
public interface INodeViewerFactory {
bool CanDisplayNode (Node node);
- INodeViewer CreateNodeViewer (Node node);
+ INodeViewer CreateNodeViewer (Context context);
}
}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewer.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewer.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewer.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -8,20 +8,27 @@
//
using System;
+using System.IO;
+using System.Text;
using Gtk;
using MonoDevelop.Content;
+using MonoDevelop.Node;
+using log4net;
namespace MonoDevelop.Editor {
- public class EditorNodeViewer : INodeViewer {
+ public class EditorNodeViewer : AbstractNodeViewer {
+ static private readonly ILog log = LogManager.GetLogger (typeof (EditorNodeViewer));
+
private ScrolledWindow structure;
private TreeView tree;
private ScrolledWindow viewer;
+ private TextBuffer buffer;
private TextView editor;
private string description;
private string title;
private Gdk.Pixbuf icon;
- public EditorNodeViewer ()
+ public EditorNodeViewer (Context context) : base (context)
{
structure = new ScrolledWindow ();
structure.ShadowType = ShadowType.In;
@@ -31,39 +38,61 @@
viewer = new ScrolledWindow ();
viewer.ShadowType = ShadowType.In;
editor = new TextView ();
+ buffer = editor.Buffer;
viewer.Add (editor);
+
+ TextFileNode node = (TextFileNode)context.Node;
+ InsertText (node.Buffer.Reader);
}
- public Widget StructureWidget {
+ public override Widget StructureWidget {
get {
return structure;
}
}
- public Widget ViewerWidget {
+ public override Widget ViewerWidget {
get {
return viewer;
}
}
- public string ViewerDescription {
+ public new string ViewerDescription {
get {
return description;
}
}
- public string ViewerTitle {
+ public new string ViewerTitle {
get {
return title;
}
}
- public Gdk.Pixbuf ViewerIcon {
+ public new Gdk.Pixbuf ViewerIcon {
get {
return icon;
}
}
+ private void InsertText (Stream reader)
+ {
+ byte[] buf = new byte[2048];
+ int read = -1;
+ {
+ TextIter iter = buffer.GetIterAtMark (buffer.InsertMark);
+ buffer.Insert (iter, "blahdieblah\n");
+ }
+ do {
+ read = reader.Read (buf, 0, buf.Length);
+ log.Debug ("bytes read: " + read);
+ TextIter iter = buffer.GetIterAtMark (buffer.InsertMark);
+ string text = Encoding.UTF8.GetString (buf);
+ log.Debug (text);
+ buffer.Insert (iter, text);
+ } while (read == buf.Length);
+ }
+
public static void InitializePlugin (byte major, byte minor)
{
ContentManager.AddNodeViewerFactory (new EditorNodeViewerFactory ());
Modified: branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewerFactory.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewerFactory.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Editor/EditorNodeViewerFactory.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -19,12 +19,12 @@
public bool CanDisplayNode (Node node)
{
- return true;
+ return node is TextFileNode;
}
- public INodeViewer CreateNodeViewer (Node node)
+ public INodeViewer CreateNodeViewer (Context context)
{
- return new EditorNodeViewer ();
+ return new EditorNodeViewer (context);
}
}
}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Node/Buffer.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Node/Buffer.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Node/Buffer.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -20,14 +20,11 @@
private BufferContentCallback callback;
private long lastModified;
private long sourceLastModified;
- private string uri;
+ private Gnome.Vfs.Uri uri;
- internal Buffer (string uri)
- {
- }
-
internal Buffer (Gnome.Vfs.Uri uri)
{
+ this.uri = uri;
}
public BufferContentCallback BufferUpdater {
@@ -62,7 +59,6 @@
}
}
-
public long SourceLastModified {
get {
return sourceLastModified;
@@ -71,13 +67,13 @@
public string Uri {
get {
- return uri;
+ return uri.ToString ();
}
}
public Stream Reader {
get {
- return null;
+ return new VfsStream (uri.ToString (), FileMode.Open);
}
}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Node/FileNode.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Node/FileNode.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Node/FileNode.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -24,6 +24,7 @@
private Project project;
private Gnome.Vfs.Uri uri;
private Gnome.Vfs.FileInfo info;
+ private Buffer buffer = null;
public FileNode (Project project, Node parent, string uri)
{
@@ -32,6 +33,14 @@
this.uri = new Gnome.Vfs.Uri (uri);
}
+ public Buffer Buffer {
+ get {
+ if (buffer == null)
+ buffer = new Buffer (uri);
+ return buffer;
+ }
+ }
+
public override bool CanDelete {
get {
return uri.Exists &&
Modified: branches/MonoDevelop-plan-43/src/Plugins/Node/Node.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Node/Node.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Node/Node.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -90,17 +90,5 @@
abstract public void SaveAndDelete ();
abstract public void SaveAs ();
-
- public static void InitializePlugin (byte major, byte minor)
- {
- FileNode.RegisterFileNodeType ("text/x-csharp",
- "Text file",
- typeof (TextFileNode),
- null);
- }
-
- public static void FinalizePlugin ()
- {
- }
}
}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Node/TextFileNode.cs
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Node/TextFileNode.cs 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Node/TextFileNode.cs 2004-08-14 21:27:05 UTC (rev 1937)
@@ -18,5 +18,15 @@
{
log.Debug ("Created instance of TextFileNode");
}
+
+ public static void InitializePlugin (byte major, byte minor)
+ {
+ FileNode.RegisterFileNodeType ("text/plain", "Text file",
+ typeof (TextFileNode), null);
+ }
+
+ public static void FinalizePlugin ()
+ {
+ }
}
}
Modified: branches/MonoDevelop-plan-43/src/Plugins/Node/node.plugin.in
===================================================================
--- branches/MonoDevelop-plan-43/src/Plugins/Node/node.plugin.in 2004-08-13 15:54:15 UTC (rev 1936)
+++ branches/MonoDevelop-plan-43/src/Plugins/Node/node.plugin.in 2004-08-14 21:27:05 UTC (rev 1937)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin version="1.0">
<assembly>@assembly@</assembly>
- <class name="MonoDevelop.Node.Node"/>
+ <class name="MonoDevelop.Node.TextFileNode"/>
</plugin>
More information about the Monodevelop-patches-list
mailing list