Author: lluis
Date: 2006-05-30 13:51:00 -0400 (Tue, 30 May 2006)
New Revision: 61268
Added:
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.Utils/DesktopApplication.cs
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/ChangeLog
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/Makefile.am
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.mdp
Log:
2006-05-30 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.Core.Gui.mdp:
* Makefile.am: Added DesktopApplication.cs.
* MonoDevelop.Core.Gui.Utils/DesktopApplication.cs: Wrapper for
MimeApplication. Implementes some missing properties.
Modified: trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/ChangeLog 2006-05-30
16:47:15 UTC (rev 61267)
+++ trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/ChangeLog 2006-05-30
17:51:00 UTC (rev 61268)
@@ -1,3 +1,10 @@
+2006-05-30 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Core.Gui.mdp:
+ * Makefile.am: Added DesktopApplication.cs.
+ * MonoDevelop.Core.Gui.Utils/DesktopApplication.cs: Wrapper for
+ MimeApplication. Implementes some missing properties.
+
2006-05-25 Mark Howard <[EMAIL PROTECTED]>
* Base.glade: Make error message text selectable (and hence copy-able)
Modified: trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/Makefile.am
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/Makefile.am 2006-05-30
16:47:15 UTC (rev 61267)
+++ trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/Makefile.am 2006-05-30
17:51:00 UTC (rev 61268)
@@ -18,6 +18,7 @@
MonoDevelop.Core.Gui/IMessageService.cs \
MonoDevelop.Core.Gui.Components/FileBrowser.cs \
MonoDevelop.Core.Gui.Utils/FileIconLoader.cs \
+MonoDevelop.Core.Gui.Utils/DesktopApplication.cs \
MonoDevelop.Core.Gui/MessageService.cs \
MonoDevelop.Core.Gui/ResourceNotFoundException.cs \
MonoDevelop.Core.Gui.Dialogs/ResourceService.cs \
Added:
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.Utils/DesktopApplication.cs
===================================================================
---
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.Utils/DesktopApplication.cs
2006-05-30 16:47:15 UTC (rev 61267)
+++
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.Utils/DesktopApplication.cs
2006-05-30 17:51:00 UTC (rev 61268)
@@ -0,0 +1,97 @@
+//
+// DesktopApplication.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 System.IO;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using MonoDevelop.Core;
+using Gnome.Vfs;
+
+namespace MonoDevelop.Core.Gui.Utils
+{
+ public struct DesktopApplication
+ {
+ string id;
+ string displayName;
+ string command;
+
+ public string DisplayName {
+ get { return displayName; }
+ }
+
+ public string Command {
+ get { return command; }
+ }
+
+ public void Launch (params string[] files)
+ {
+ // TODO: implement all other cases
+ if (command.IndexOf ("%f") != -1) {
+ foreach (string s in files) {
+ string cmd = command.Replace ("%f", s);
+ Process.Start (cmd);
+ }
+ }
+ else if (command.IndexOf ("%F") != -1) {
+ string[] fs = new string [files.Length];
+ for (int n=0; n<files.Length; n++) {
+ fs [n] = files [n].Replace (" ", "\\ ");
+ }
+ string cmd = command.Replace ("%F", string.Join
(" ", fs));
+ Process.Start (cmd);
+ } else {
+ foreach (string s in files) {
+ Process.Start (command + " " + s);
+ }
+ }
+ }
+
+ public static DesktopApplication GetDefaultApplication (string
mimeType)
+ {
+ MimeApplication app = Mime.GetDefaultApplication
(mimeType);
+ if (app != null)
+ return (DesktopApplication)
Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
+ else
+ return new DesktopApplication ();
+ }
+
+ public static DesktopApplication[] GetApplications (string
mimeType)
+ {
+ MimeApplication[] apps = Mime.GetAllApplications
(mimeType);
+ ArrayList list = new ArrayList ();
+ foreach (MimeApplication app in apps) {
+ DesktopApplication dap = (DesktopApplication)
Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
+ list.Add (dap);
+ }
+ return (DesktopApplication[]) list.ToArray
(typeof(DesktopApplication));
+ }
+ }
+}
Modified:
trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.mdp
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.mdp
2006-05-30 16:47:15 UTC (rev 61267)
+++ trunk/monodevelop/Core/src/MonoDevelop.Core.Gui/MonoDevelop.Core.Gui.mdp
2006-05-30 17:51:00 UTC (rev 61268)
@@ -193,6 +193,7 @@
<File name="./MonoDevelop.Core.Gui.Codons/LocalCommandItemCodon.cs"
subtype="Code" buildaction="Compile" />
<File
name="./MonoDevelop.Core.Gui.ProgressMonitoring/MessageDialogProgressMonitor.cs"
subtype="Code" buildaction="Compile" />
<File name="./MonoDevelop.Core.Gui.Codons/StockIconCodon.cs"
subtype="Code" buildaction="Compile" />
+ <File name="./MonoDevelop.Core.Gui.Utils/DesktopApplication.cs"
subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="MonoDevelop.Core"
/>
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches