Author: lluis
Date: 2006-05-30 14:09:47 -0400 (Tue, 30 May 2006)
New Revision: 61273

Added:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs
Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
   trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs
   
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
   trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
Log:
2006-05-30 Lluis Sanchez Gual  <[EMAIL PROTECTED]>

        * MonoDevelop.Ide.Commands/ViewCommands.cs:
        * MonoDevelop.Ide.addin.xml:
        * MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs:
        * MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs:
          Implemented OpenWith command for project files.
          
        * MonoDevelop.Ide.Gui/DisplayBindingService.cs:
        * MonoDevelop.Ide.Gui/Workbench.cs: Implemented GetFileViewers
          command, which returns all available viewers (internal or
          external) for a file.
          
        * MonoDevelop.Ide.Codons/IDisplayBinding.cs:
        * MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs:
          Added DisplayName property to IDisplayBinding.
        
        * MonoDevelop.Ide.mdp:
        * Makefile.am: Updated.
        


Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2006-05-30 
18:07:49 UTC (rev 61272)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/ChangeLog        2006-05-30 
18:09:47 UTC (rev 61273)
@@ -1,3 +1,23 @@
+2006-05-30 Lluis Sanchez Gual  <[EMAIL PROTECTED]>
+
+       * MonoDevelop.Ide.Commands/ViewCommands.cs:
+       * MonoDevelop.Ide.addin.xml:
+       * MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs:
+       * MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs:
+         Implemented OpenWith command for project files.
+         
+       * MonoDevelop.Ide.Gui/DisplayBindingService.cs:
+       * MonoDevelop.Ide.Gui/Workbench.cs: Implemented GetFileViewers
+         command, which returns all available viewers (internal or
+         external) for a file.
+         
+       * MonoDevelop.Ide.Codons/IDisplayBinding.cs:
+       * MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs:
+         Added DisplayName property to IDisplayBinding.
+       
+       * MonoDevelop.Ide.mdp:
+       * Makefile.am: Updated.
+       
 2006-05-29  David Makovský (Yakeen) <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Ide.Gui.Content/ICodeStyleOperations.cs: reverted 
interface changes

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am      2006-05-30 
18:07:49 UTC (rev 61272)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/Makefile.am      2006-05-30 
18:09:47 UTC (rev 61273)
@@ -76,6 +76,7 @@
 MonoDevelop.Ide.Gui/AbstractPadContent.cs \
 MonoDevelop.Ide.Gui/AbstractSecondaryViewContent.cs \
 MonoDevelop.Ide.Gui/AbstractViewContent.cs \
+MonoDevelop.Ide.Gui/FileViewer.cs \
 MonoDevelop.Ide.Gui/IBaseViewContent.cs \
 MonoDevelop.Ide.Gui/IPadContent.cs \
 MonoDevelop.Ide.Gui/ISecondaryViewContent.cs \

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
        2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Codons/IDisplayBinding.cs
        2006-05-30 18:09:47 UTC (rev 61273)
@@ -19,6 +19,10 @@
        /// </summary>
        public interface IDisplayBinding
        {
+               // Display name of the binding, to be shown when there are 
several
+               // options for opening a file.
+               string DisplayName { get; }
+               
                /// <remarks>
                /// This function determines, if this display binding is able 
to create
                /// an IViewContent for the file given by fileName.

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
 2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
 2006-05-30 18:09:47 UTC (rev 61273)
@@ -29,6 +29,7 @@
                DeleteCurrentLayout,
                FullScreen,
                Open,
+               OpenWithList,
                TreeDisplayOptionList,
                ResetTreeDisplayOptions
        }

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
     2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DisplayBindingService.cs
     2006-05-30 18:09:47 UTC (rev 61273)
@@ -52,6 +52,17 @@
                        return null;
                }
                
+               public IDisplayBinding[] GetBindingsForMimeType (string 
mimeType)
+               {
+                       ArrayList list = new ArrayList ();
+                       foreach (DisplayBindingCodon binding in bindings) {
+                               if (binding.DisplayBinding != null && 
binding.DisplayBinding.CanCreateContentForMimeType (mimeType)) {
+                                       list.Add (binding.DisplayBinding);
+                               }
+                       }
+                       return (IDisplayBinding[]) list.ToArray 
(typeof(IDisplayBinding));
+               }
+               
                internal DisplayBindingCodon GetCodonPerFileName(string 
filename)
                {
                        string vfsname = filename;

Added: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs    
    2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/FileViewer.cs    
    2006-05-30 18:09:47 UTC (rev 61273)
@@ -0,0 +1,82 @@
+//
+// Document.cs
+//
+// Author:
+//   Lluis Sanchez Gual
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// 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.
+//
+
+using System;
+using MonoDevelop.Ide.Codons;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Gui.Utils;
+
+namespace MonoDevelop.Ide.Gui
+{
+       public class FileViewer
+       {
+               IDisplayBinding binding;
+               DesktopApplication app;
+               
+               internal FileViewer (DesktopApplication app)
+               {
+                       this.app = app;
+               }
+               
+               internal FileViewer (IDisplayBinding binding)
+               {
+                       this.binding = binding;
+               }
+               
+               public string Title {
+                       get { return binding != null ? binding.DisplayName : 
app.DisplayName; }
+               }
+               
+               public bool IsExternal {
+                       get { return binding == null; }
+               }
+               
+               public override bool Equals (object ob)
+               {
+                       FileViewer fv = ob as FileViewer;
+                       if (fv == null) return false;
+                       return binding == fv.binding || app.Command == 
fv.app.Command;
+               }
+               
+               public override int GetHashCode ()
+               {
+                       if (binding != null)
+                               return binding.GetHashCode ();
+                       else
+                               return app.Command.GetHashCode ();
+               }
+               
+               public void OpenFile (string filePath)
+               {
+                       if (binding != null)
+                               IdeApp.Workbench.OpenDocument (filePath, -1, 
-1, true, binding);
+                       else
+                               app.Launch (filePath);
+               }
+       }
+}

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs 
2006-05-30 18:07:49 UTC (rev 61272)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Workbench.cs 
2006-05-30 18:09:47 UTC (rev 61273)
@@ -38,6 +38,7 @@
 using MonoDevelop.Core.Gui;
 using MonoDevelop.Ide.Codons;
 using MonoDevelop.Ide.Gui.Content;
+using MonoDevelop.Core.Gui.Utils;
 
 namespace MonoDevelop.Ide.Gui
 {
@@ -220,6 +221,23 @@
                        return WrapPad (content);
                }
                
+               public FileViewer[] GetFileViewers (string fileName)
+               {
+                       ArrayList list = new ArrayList ();
+                       
+                       string mimeType = Gnome.Vfs.MimeType.GetMimeTypeForUri 
(fileName);
+
+                       IDisplayBinding[] bindings = 
Services.DisplayBindings.GetBindingsForMimeType (mimeType);
+                       foreach (IDisplayBinding bin in bindings)
+                               list.Add (new FileViewer (bin));
+
+                       foreach (DesktopApplication app in 
DesktopApplication.GetApplications (mimeType))
+                               if (app.Command != "monodevelop")
+                                       list.Add (new FileViewer (app));
+                               
+                       return (FileViewer[]) list.ToArray (typeof(FileViewer));
+               }
+               
                public Document OpenDocument (string fileName)
                {
                        return OpenDocument (fileName, true);
@@ -232,6 +250,11 @@
                
                public Document OpenDocument (string fileName, int line, int 
column, bool bringToFront)
                {
+                       return OpenDocument (fileName, line, column, 
bringToFront, null);
+               }
+               
+               internal Document OpenDocument (string fileName, int line, int 
column, bool bringToFront, IDisplayBinding binding)
+               {
                        foreach (Document doc in Documents) {
                                if (doc.FileName == fileName) {
                                        if (bringToFront)
@@ -250,6 +273,7 @@
                        openFileInfo.BringToFront = bringToFront;
                        openFileInfo.Line = line;
                        openFileInfo.Column = column;
+                       openFileInfo.DisplayBinding = binding;
                        RealOpenFile (openFileInfo);
                        
                        if (!pm.AsyncOperation.Success)
@@ -431,7 +455,11 @@
                                        }
                                }
                                
-                               IDisplayBinding binding = 
Services.DisplayBindings.GetBindingPerFileName(fileName);
+                               IDisplayBinding binding;
+                               if (oFileInfo.DisplayBinding != null)
+                                       binding = oFileInfo.DisplayBinding;
+                               else
+                                       binding = 
Services.DisplayBindings.GetBindingPerFileName(fileName);
                                
                                if (binding != null) {
                                        Project project = null;
@@ -516,6 +544,7 @@
                public bool BringToFront;
                public int Line;
                public int Column;
+               public IDisplayBinding DisplayBinding;
                public IViewContent NewContent;
        }
        

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
       2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.BrowserDisplayBinding/BrowserDisplayBinding.cs
       2006-05-30 18:09:47 UTC (rev 61273)
@@ -18,6 +18,10 @@
 {
        public class BrowserDisplayBinding : IDisplayBinding, 
ISecondaryDisplayBinding
        {
+               public string DisplayName {
+                       get { return "Web Browser"; }
+               }
+               
 
                public bool CanCreateContentForFile(string fileName)
                {

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
    2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/ProjectFileNodeBuilder.cs
    2006-05-30 18:09:47 UTC (rev 61273)
@@ -36,6 +36,7 @@
 using MonoDevelop.Ide.Gui;
 using MonoDevelop.Components.Commands;
 using MonoDevelop.Core.Gui;
+using MonoDevelop.Ide.Codons;
 
 namespace MonoDevelop.Ide.Gui.Pads.ProjectPad
 {
@@ -192,5 +193,25 @@
                        }
                        IdeApp.ProjectOperations.SaveProject (finfo.Project);
                }
+               
+               [CommandHandler (ViewCommands.OpenWithList)]
+               public void OnOpenWith (object ob)
+               {
+                       ProjectFile finfo = CurrentNode.DataItem as ProjectFile;
+                       ((FileViewer)ob).OpenFile (finfo.Name);
+               }
+               
+               [CommandUpdateHandler (ViewCommands.OpenWithList)]
+               public void OnOpenWithUpdate (CommandArrayInfo info)
+               {
+                       ProjectFile finfo = CurrentNode.DataItem as ProjectFile;
+                       FileViewer prev = null; 
+                       foreach (FileViewer fv in 
IdeApp.Workbench.GetFileViewers (finfo.Name)) {
+                               if (prev != null && fv.IsExternal != 
prev.IsExternal)
+                                       info.AddSeparator ();
+                               info.Add (fv.Title, fv);
+                               prev = fv;
+                       }
+               }
        }
 }

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs
     2006-05-30 18:07:49 UTC (rev 61272)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ProjectPad/SystemFileNodeBuilder.cs
     2006-05-30 18:09:47 UTC (rev 61273)
@@ -147,5 +147,25 @@
                                project.Save (m);
                        }
                }
+               
+               [CommandHandler (ViewCommands.OpenWithList)]
+               public void OnOpenWith (object ob)
+               {
+                       SystemFile file = CurrentNode.DataItem as SystemFile;
+                       ((FileViewer)ob).OpenFile (file.Path);
+               }
+               
+               [CommandUpdateHandler (ViewCommands.OpenWithList)]
+               public void OnOpenWithUpdate (CommandArrayInfo info)
+               {
+                       SystemFile file = CurrentNode.DataItem as SystemFile;
+                       FileViewer prev = null; 
+                       foreach (FileViewer fv in 
IdeApp.Workbench.GetFileViewers (file.Path)) {
+                               if (prev != null && fv.IsExternal != 
prev.IsExternal)
+                                       info.AddSeparator ();
+                               info.Add (fv.Title, fv);
+                               prev = fv;
+                       }
+               }
        }
 }

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2006-05-30 18:07:49 UTC (rev 61272)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.addin.xml        
2006-05-30 18:09:47 UTC (rev 61273)
@@ -343,6 +343,9 @@
                                _label = "Display Options List" />
                <Command id = 
"MonoDevelop.Ide.Commands.ViewCommands.ResetTreeDisplayOptions"
                                _label = "Reset Options" />
+               <Command id = 
"MonoDevelop.Ide.Commands.ViewCommands.OpenWithList"
+                               type = "array"
+                               _label = "OpenWidthList" />
 
                <!-- ToolCommands -->
                
@@ -505,6 +508,9 @@
         
        <Extension path = 
"/SharpDevelop/Views/ProjectBrowser/ContextMenu/ProjectFileNode" 
extension-nodes="CommandItem, SeparatorItem, ItemSet, LinkItem, 
LocalCommandItem" description="Context menu for a project file in the solution 
pad.">
                <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.Open" 
/>
+               <ItemSet id = "OpenWith" _label = "Open With">
+                       <CommandItem id = 
"MonoDevelop.Ide.Commands.ViewCommands.OpenWithList" />
+               </ItemSet>
                <SeparatorItem id = "OpenSeparator" />
                <ItemSet id = "Add" _label = "Add">
                        <CommandItem id = 
"MonoDevelop.Ide.Commands.ProjectCommands.AddNewFiles" />
@@ -526,6 +532,9 @@
                
        <Extension path = 
"/SharpDevelop/Views/ProjectBrowser/ContextMenu/SystemFileNode"  
extension-nodes="CommandItem, SeparatorItem, ItemSet, LinkItem, 
LocalCommandItem" description="Context menu for a file (not belonging to a 
project) in the solution pad.">
                <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.Open" 
/>
+               <ItemSet id = "OpenWith" _label = "Open With">
+                       <CommandItem id = 
"MonoDevelop.Ide.Commands.ViewCommands.OpenWithList" />
+               </ItemSet>
                <CommandItem id = 
"MonoDevelop.Ide.Commands.ProjectCommands.IncludeToProject" />
                <SeparatorItem id = "IncludeToProjectSeparator" />
                <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Copy" 
/>

Modified: trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp      
2006-05-30 18:07:49 UTC (rev 61272)
+++ trunk/monodevelop/Core/src/MonoDevelop.Ide/MonoDevelop.Ide.mdp      
2006-05-30 18:09:47 UTC (rev 61273)
@@ -241,6 +241,7 @@
     <File name="./MonoDevelop.Ide.Gui.Search/ISearchProgressMonitor.cs" 
subtype="Code" buildaction="Compile" />
     <File name="./MonoDevelop.Ide.Gui.Search/SearchProgressMonitor.cs" 
subtype="Code" buildaction="Compile" />
     <File name="./MonoDevelop.Ide.Gui.Pads/SearchResultPad.cs" subtype="Code" 
buildaction="Compile" />
+    <File name="./MonoDevelop.Ide.Gui/FileViewer.cs" subtype="Code" 
buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, 
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to