[Monodevelop-patches-list] r1065 - in trunk/MonoDevelop/src: AddIns/DisplayBindings/SourceEditor/Gui Main/Base/Gui Main/Base/Gui/BrowserDisplayBinding Main/Base/Gui/Workbench/Layouts

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sun Feb 29 11:55:26 EST 2004


Author: tberman
Date: 2004-02-29 11:55:25 -0500 (Sun, 29 Feb 2004)
New Revision: 1065

Modified:
   trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
   trunk/MonoDevelop/src/Main/Base/Gui/AbstractBaseViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/AbstractSecondaryViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs
   trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/HtmlViewPane.cs
   trunk/MonoDevelop/src/Main/Base/Gui/IBaseViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/ISecondaryViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
   trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
Log:
side by side html editing/displaying. has a cpl bugs, works pretty well though.


Modified: trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/AddIns/DisplayBindings/SourceEditor/Gui/SourceEditorDisplayBinding.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -91,9 +91,9 @@
 			}
 		}
 		
-		public override string TabPageText {
+		public override string TabPageLabel {
 			get {
-				return "${res:FormsDesigner.DesignTabPages.SourceTabPage}";
+				return "Source Editor";
 			}
 		}
 		
@@ -228,6 +228,7 @@
 		{
 			// gedit also hooks this event, but do we need it?
 			UpdateLineCol ();
+			OnContentChanged (null);
 		}
 		
 		// WORKAROUND until we get this method returning char in gtk#

Modified: trunk/MonoDevelop/src/Main/Base/Gui/AbstractBaseViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/AbstractBaseViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/AbstractBaseViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -28,7 +28,7 @@
 			}
 		}
 		
-		public virtual string TabPageText {
+		public virtual string TabPageLabel {
 			get {
 				return "Abstract Content";
 			}

Modified: trunk/MonoDevelop/src/Main/Base/Gui/AbstractSecondaryViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/AbstractSecondaryViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/AbstractSecondaryViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -24,5 +24,9 @@
 		public virtual void NotifyBeforeSave()
 		{
 		}
+
+		public virtual void BaseContentChanged ()
+		{
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/AbstractViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -16,6 +16,10 @@
 		
 		bool   isDirty  = false;
 		bool   isViewOnly = false;
+
+		public override string TabPageLabel {
+			get { return "Change me"; }
+		}
 		
 		public virtual string UntitledName {
 			get {
@@ -100,9 +104,17 @@
 				BeforeSave(this, e);
 			}
 		}
+
+		protected virtual void OnContentChanged (EventArgs e)
+		{
+			if (ContentChanged != null) {
+				ContentChanged (this, e);
+			}
+		}
 		
 		public event EventHandler ContentNameChanged;
 		public event EventHandler DirtyChanged;
 		public event EventHandler BeforeSave;
+		public event EventHandler ContentChanged;
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -16,10 +16,13 @@
 using ICSharpCode.Core.AddIns.Codons;
 using ICSharpCode.SharpDevelop.Gui;
 
+using MonoDevelop.Gui.Utils;
+
 namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
 {
-	public class BrowserDisplayBinding : IDisplayBinding
+	public class BrowserDisplayBinding : IDisplayBinding, ISecondaryDisplayBinding
 	{
+
 		public bool CanCreateContentForFile(string fileName)
 		{
 			return fileName.StartsWith("http") || fileName.StartsWith("ftp");
@@ -57,5 +60,19 @@
 		{
 			return null;
 		}
+
+		public bool CanAttachTo (IViewContent parent)
+		{
+			string filename = parent.ContentName;
+			string mimetype = Vfs.GetMimeType (filename);
+			if (mimetype == "text/html")
+				return true;
+			return false;
+		}
+
+		public ISecondaryViewContent CreateSecondaryViewContent (IViewContent parent)
+		{
+			return new BrowserPane (false, parent);
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/HtmlViewPane.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/HtmlViewPane.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/BrowserDisplayBinding/HtmlViewPane.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -8,6 +8,7 @@
 using System;
 using Gtk;
 using GtkSharp;
+using GtkMozEmbed;
 
 using ICSharpCode.SharpDevelop.Internal.Undo;
 using System.Drawing.Printing;
@@ -20,11 +21,57 @@
 
 namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
 {
-	public class BrowserPane : AbstractViewContent
+	public class BrowserPane : AbstractViewContent, ISecondaryViewContent
 	{	
 		protected HtmlViewPane htmlViewPane;
+		protected IViewContent parent;
 		string title;
 
+		public void Selected ()
+		{
+		}
+
+		public void Deselected ()
+		{
+		}
+
+		public void NotifyBeforeSave ()
+		{
+		}
+
+		public override string TabPageLabel
+		{
+			get {
+				return "Web Browser";
+			}
+		}
+		
+		public void BaseContentChanged ()
+		{
+			//FIXME: This is a hack
+			if (parent.Control.GetType ().ToString () == "MonoDevelop.SourceEditor.Gui.SourceEditor")
+			{
+				try {
+					htmlViewPane.MozillaControl.OpenStream ("file://", "text/html");
+					htmlViewPane.MozillaControl.AppendData (((Gtk.TextView)((Gtk.ScrolledWindow)parent.Control).Children[0]).Buffer.Text);
+					htmlViewPane.MozillaControl.CloseStream ();
+					Gtk.Timeout.Add (50, new Gtk.Function (checkFocus));
+					
+				} catch {
+					Console.WriteLine ("gtkmozembed tossed an exception");
+				}
+			}
+		}
+
+		public bool checkFocus ()
+		{
+			if (((Gtk.ScrolledWindow)parent.Control).Children[0].HasFocus == false) {
+				((Gtk.ScrolledWindow)parent.Control).Children[0].GrabFocus ();
+				return false;
+			}
+			return true;
+		}
+
 		public override Widget Control {
 			get {
 				return htmlViewPane;
@@ -45,8 +92,18 @@
 			}
 		}
 		
-		protected BrowserPane(bool showNavigation) //: base (type)
+		public BrowserPane (bool showNavigation, IViewContent parent) : this (showNavigation)
 		{
+			this.parent = parent;
+		}
+
+		void onFocused (object o, EventArgs e)
+		{
+			Console.WriteLine ("aa");
+		}
+
+		public BrowserPane(bool showNavigation) //: base (type)
+		{
 			htmlViewPane = new HtmlViewPane(showNavigation);
 			htmlViewPane.MozillaControl.Title += new EventHandler (OnTitleChanged);
 		}
@@ -79,6 +136,7 @@
 	public class HtmlViewPane : Gtk.Frame
 	{
 		MozillaControl htmlControl = null;
+		public Gtk.EventBox catcher = null;
 		
 		VBox   topPanel   = new VBox (false, 2);
 		Toolbar toolBar    = new Toolbar ();
@@ -154,7 +212,9 @@
 			htmlControl.NetStop += new EventHandler (OnNetStop);
 			htmlControl.ShowAll ();
 
-			mainbox.PackStart (htmlControl);
+			catcher = new Gtk.EventBox ();
+			catcher.Add (htmlControl);
+			mainbox.PackStart (catcher);
 
 			status = new Statusbar ();
 			mainbox.PackStart (status, false, true, 0);

Modified: trunk/MonoDevelop/src/Main/Base/Gui/IBaseViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/IBaseViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/IBaseViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -34,9 +34,6 @@
 		/// The text on the tab page when more than one view content
 		/// is attached to a single window.
 		/// </summary>
-		string TabPageText {
-			get;
-		}
 		
 		/// <summary>
 		/// Reinitializes the content. (Re-initializes all add-in tree stuff)

Modified: trunk/MonoDevelop/src/Main/Base/Gui/ISecondaryViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/ISecondaryViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/ISecondaryViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -31,5 +31,11 @@
 		/// Is called before the save operation of the main IViewContent
 		/// </summary>
 		void NotifyBeforeSave();
+
+		void BaseContentChanged ();
+
+		string TabPageLabel {
+			get;
+		}
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/IViewContent.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -79,6 +79,9 @@
 		/// </summary>
 		void Load(string fileName);
 		
+		string TabPageLabel {
+			get;
+		}
 		/// <summary>
 		/// Is called each time the name for the content has changed.
 		/// </summary>
@@ -91,5 +94,7 @@
 		event EventHandler DirtyChanged;
 		
 		event EventHandler BeforeSave;
+
+		event EventHandler ContentChanged;
 	}
 }

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -317,14 +317,14 @@
 			TabLabel tabLabel = new TabLabel (new Label (), new Gtk.Image (""));
 			tabLabel.Button.Clicked += new EventHandler (closeClicked);
 			tabLabel.Button.StateChanged += new StateChangedHandler (stateChanged);
-			tabControl.AppendPage (content.Control, tabLabel);
-
 			SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow(content, tabControl, tabLabel);
 
 			sdiWorkspaceWindow.CloseEvent += new EventHandler(CloseWindowEvent);
-			sdiWorkspaceWindow.SwitchView(tabControl.Children.Length - 1);
+			//sdiWorkspaceWindow.SwitchView(tabControl.Children.Length - 1);
 			_windows.Add (sdiWorkspaceWindow);
-			
+		
+			tabControl.AppendPage (sdiWorkspaceWindow, tabLabel);
+		
 			if (tabControl.NPages > 1)
 				tabControl.ShowTabs = true;
 			tabControl.ShowAll();

Modified: trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
===================================================================
--- trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2004-02-29 15:48:01 UTC (rev 1064)
+++ trunk/MonoDevelop/src/Main/Base/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs	2004-02-29 16:55:25 UTC (rev 1065)
@@ -10,6 +10,8 @@
 using System.IO;
 using Gtk;
 
+using Gdl;
+
 using ICSharpCode.Core.Services;
 using ICSharpCode.SharpDevelop.Services;
 
@@ -18,11 +20,14 @@
 
 namespace ICSharpCode.SharpDevelop.Gui
 {
-	public class SdiWorkspaceWindow : IWorkbenchWindow
+	public class SdiWorkspaceWindow : Dock, IWorkbenchWindow
 	{
 		Notebook   viewTabControl = null;
 		IViewContent content;
 		ArrayList    subViewContents = null;
+
+		DockItem mainItem;
+		ArrayList    subDockItems = null;
 		
 		TabLabel tabLabel;
 		Widget    tabPage;
@@ -100,7 +105,7 @@
 			tabControl.CurrentPage = toSelect;
 		}
 		
-		public SdiWorkspaceWindow(IViewContent content, Notebook tabControl, TabLabel tabLabel)
+		public SdiWorkspaceWindow(IViewContent content, Notebook tabControl, TabLabel tabLabel) : base ()
 		{
 			this.tabControl = tabControl;
 			this.content = content;
@@ -112,6 +117,12 @@
 			content.ContentNameChanged += new EventHandler(SetTitleEvent);
 			content.DirtyChanged       += new EventHandler(SetTitleEvent);
 			content.BeforeSave         += new EventHandler(BeforeSave);
+			content.ContentChanged     += new EventHandler (OnContentChanged);
+
+			mainItem = new DockItem (content.TabPageLabel, content.TabPageLabel, DockItemBehavior.Locked | DockItemBehavior.CantClose | DockItemBehavior.CantIconify);
+			mainItem.Add (content.Control);
+			mainItem.ShowAll ();
+			AddItem (mainItem, DockPlacement.Center);
 			SetTitleEvent(null, null);
 		}
 		
@@ -142,11 +153,11 @@
 			if (content == null) {
 				return;
 			}
-			
+		
 			string newTitle = "";
 			if (content.ContentName == null) {
 				if (myUntitledTitle == null) {
-					string baseName  = Path.GetFileNameWithoutExtension(content.UntitledName);
+					string baseName  = System.IO.Path.GetFileNameWithoutExtension(content.UntitledName);
 					int    number    = 1;
 					bool   found     = true;
 					while (found) {
@@ -167,7 +178,7 @@
 				}
 				newTitle = myUntitledTitle;
 			} else {
-				newTitle = Path.GetFileName(content.ContentName);
+				newTitle = System.IO.Path.GetFileName(content.ContentName);
 			}
 			
 			if (content.IsDirty) {
@@ -186,7 +197,18 @@
 			content.ContentNameChanged -= new EventHandler(SetTitleEvent);
 			content.DirtyChanged       -= new EventHandler(SetTitleEvent);
 			content.BeforeSave         -= new EventHandler(BeforeSave);
+			content.ContentChanged     -= new EventHandler (OnContentChanged);
 		}
+
+		public void OnContentChanged (object o, EventArgs e)
+		{
+			if (subViewContents != null) {
+				foreach (ISecondaryViewContent subContent in subViewContents)
+				{
+					subContent.BaseContentChanged ();
+				}
+			}
+		}
 		
 		public void CloseWindow(bool force, bool fromMenu, int pageNum)
 		{
@@ -233,7 +255,20 @@
 		
 		public void AttachSecondaryViewContent(ISecondaryViewContent subViewContent)
 		{
-
+			if (subViewContents == null) {
+				subViewContents = new ArrayList ();
+				subDockItems = new ArrayList ();
+			}
+	
+			mainItem.Behavior = DockItemBehavior.CantClose | DockItemBehavior.CantIconify;
+			subViewContents.Add (subViewContent);
+			DockItem dockitem = new DockItem (subViewContent.TabPageLabel, subViewContent.TabPageLabel, DockItemBehavior.CantClose | DockItemBehavior.CantIconify);
+			dockitem.Add (subViewContent.Control);
+			subViewContent.Control.ShowAll ();
+			dockitem.ShowAll ();
+			subDockItems.Add (dockitem);
+			AddItem (dockitem, DockPlacement.Bottom);
+			OnContentChanged (null, null);
 		}
 		
 		int oldIndex = -1;




More information about the Monodevelop-patches-list mailing list